Gridarta Editor
ArchetypeAttributeSection.java
Go to the documentation of this file.
1 /*
2  * Gridarta MMORPG map editor for Crossfire, Daimonin and similar games.
3  * Copyright (C) 2000-2015 The Gridarta Developers.
4  *
5  * This program is free software; you can redistribute it and/or modify
6  * it under the terms of the GNU General Public License as published by
7  * the Free Software Foundation; either version 2 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License along
16  * with this program; if not, write to the Free Software Foundation, Inc.,
17  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18  */
19 
20 package net.sf.gridarta.model.archetypetype;
21 
22 import java.util.ArrayList;
23 import java.util.Collections;
24 import java.util.Iterator;
25 import java.util.List;
26 import org.jetbrains.annotations.NotNull;
27 
32 public class ArchetypeAttributeSection implements Iterable<ArchetypeAttribute> {
33 
37  public static final String GENERAL_SECTION = "general";
38 
42  public static final String SPECIAL_SECTION = "special";
43 
47  @NotNull
48  private final List<ArchetypeAttribute> archetypeAttributes = new ArrayList<>();
49 
53  @NotNull
54  private final String sectionName;
55 
60  public ArchetypeAttributeSection(@NotNull final String sectionName) {
61  this.sectionName = sectionName;
62  }
63 
68  @NotNull
69  public String getSectionName() {
70  return sectionName;
71  }
72 
77  public void add(@NotNull final ArchetypeAttribute archetypeAttribute) {
78  archetypeAttributes.add(archetypeAttribute);
79  }
80 
86  public void addAll(@NotNull final ArchetypeAttributeSection archetypeAttributeSection) {
87  archetypeAttributes.addAll(archetypeAttributeSection.archetypeAttributes);
88  }
89 
90  @Override
91  public Iterator<ArchetypeAttribute> iterator() {
92  return Collections.unmodifiableList(archetypeAttributes).iterator();
93  }
94 
99  public boolean isEmpty() {
100  return archetypeAttributes.isEmpty();
101  }
102 
108  public boolean hasAttributeKey(@NotNull final Comparable<String> key) {
109  for (final ArchetypeAttribute attr : archetypeAttributes) {
110  if (attr.getArchetypeAttributeName().equals(key)) {
111  return true;
112  }
113  }
114 
115  return false;
116  }
117 
118  @NotNull
119  @Override
120  public String toString() {
121  return sectionName + "(" + archetypeAttributes.size() + ")";
122  }
123 
124 }
net.sf.gridarta.model.archetypetype.ArchetypeAttributeSection.isEmpty
boolean isEmpty()
Definition: ArchetypeAttributeSection.java:99
net.sf.gridarta.model.archetypetype.ArchetypeAttributeSection.getSectionName
String getSectionName()
Definition: ArchetypeAttributeSection.java:69
net.sf.gridarta.model.archetypetype.ArchetypeAttributeSection.iterator
Iterator< ArchetypeAttribute > iterator()
Definition: ArchetypeAttributeSection.java:91
net.sf.gridarta.model.archetypetype.ArchetypeAttributeSection.SPECIAL_SECTION
static final String SPECIAL_SECTION
Definition: ArchetypeAttributeSection.java:42
net.sf.gridarta.model.archetypetype.ArchetypeAttributeSection.GENERAL_SECTION
static final String GENERAL_SECTION
Definition: ArchetypeAttributeSection.java:37
net.sf.gridarta.model.archetypetype.ArchetypeAttribute
Definition: ArchetypeAttribute.java:28
net.sf.gridarta.model.archetypetype.ArchetypeAttributeSection.add
void add(@NotNull final ArchetypeAttribute archetypeAttribute)
Definition: ArchetypeAttributeSection.java:77
net.sf.gridarta.model.archetypetype.ArchetypeAttributeSection.ArchetypeAttributeSection
ArchetypeAttributeSection(@NotNull final String sectionName)
Definition: ArchetypeAttributeSection.java:60
net.sf.gridarta.model.archetypetype.ArchetypeAttributeSection.toString
String toString()
Definition: ArchetypeAttributeSection.java:120
net.sf.gridarta.model.archetypetype.ArchetypeAttributeSection.sectionName
final String sectionName
Definition: ArchetypeAttributeSection.java:54
net.sf.gridarta.model.archetypetype.ArchetypeAttributeSection
Definition: ArchetypeAttributeSection.java:32
net.sf.gridarta.model.archetypetype.ArchetypeAttributeSection.hasAttributeKey
boolean hasAttributeKey(@NotNull final Comparable< String > key)
Definition: ArchetypeAttributeSection.java:108
net.sf.gridarta.model.archetypetype.ArchetypeAttributeSection.addAll
void addAll(@NotNull final ArchetypeAttributeSection archetypeAttributeSection)
Definition: ArchetypeAttributeSection.java:86
net.sf.gridarta.model.archetypetype.ArchetypeAttributeSection.archetypeAttributes
final List< ArchetypeAttribute > archetypeAttributes
Definition: ArchetypeAttributeSection.java:48