Gridarta Editor
ArchetypeAttributesDefinition.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;
27 import org.jetbrains.annotations.NotNull;
28 
34 public class ArchetypeAttributesDefinition implements Iterable<ArchetypeAttributeDefinition> {
35 
39  @NotNull
40  private final List<ArchetypeAttributeDefinition> archetypeAttributes = new ArrayList<>();
41 
46  public void add(@NotNull final ArchetypeAttributeDefinition archetypeAttribute) {
47  archetypeAttributes.add(archetypeAttribute); // XXX: check for duplicates
48  }
49 
56  public boolean matches(@NotNull final Attributes baseObject) {
57  for (final ArchetypeAttributeDefinition typeAttribute : archetypeAttributes) {
58  if (!typeAttribute.matches(baseObject)) {
59  return false;
60  }
61  }
62 
63  return true;
64  }
65 
66  @Override
67  public Iterator<ArchetypeAttributeDefinition> iterator() {
68  return Collections.unmodifiableList(archetypeAttributes).iterator();
69  }
70 
75  public boolean isEmpty() {
76  return archetypeAttributes.isEmpty();
77  }
78 
79  @NotNull
80  @Override
81  public String toString() {
82  return archetypeAttributes.toString();
83  }
84 
85 }
net.sf.gridarta
net.sf
net.sf.gridarta.model.baseobject.Attributes
Definition: Attributes.java:28
net
net.sf.gridarta.model.archetypetype.ArchetypeAttributesDefinition.matches
boolean matches(@NotNull final Attributes baseObject)
Definition: ArchetypeAttributesDefinition.java:56
net.sf.gridarta.model.archetypetype.ArchetypeAttributesDefinition
Definition: ArchetypeAttributesDefinition.java:34
net.sf.gridarta.model.archetypetype.ArchetypeAttributesDefinition.iterator
Iterator< ArchetypeAttributeDefinition > iterator()
Definition: ArchetypeAttributesDefinition.java:67
net.sf.gridarta.model.archetypetype.ArchetypeAttributesDefinition.add
void add(@NotNull final ArchetypeAttributeDefinition archetypeAttribute)
Definition: ArchetypeAttributesDefinition.java:46
net.sf.gridarta.model
net.sf.gridarta.model.baseobject
Definition: AbstractBaseObject.java:20
net.sf.gridarta.model.archetypetype.ArchetypeAttributesDefinition.archetypeAttributes
final List< ArchetypeAttributeDefinition > archetypeAttributes
Definition: ArchetypeAttributesDefinition.java:40
net.sf.gridarta.model.archetypetype.ArchetypeAttributesDefinition.isEmpty
boolean isEmpty()
Definition: ArchetypeAttributesDefinition.java:75
net.sf.gridarta.model.archetypetype.ArchetypeAttributesDefinition.toString
String toString()
Definition: ArchetypeAttributesDefinition.java:81
net.sf.gridarta.model.archetypetype.ArchetypeAttributeDefinition
Definition: ArchetypeAttributeDefinition.java:30