Package moise.os
Class CardinalitySet<T extends Identifiable>
- java.lang.Object
-
- moise.os.CardinalitySet<T>
-
- All Implemented Interfaces:
java.io.Serializable
,java.lang.Iterable<T>
public class CardinalitySet<T extends Identifiable> extends java.lang.Object implements java.io.Serializable, java.lang.Iterable<T>
Represents a collection with cardinality (e.g. RoleA needs (1,50) players).- Author:
- Jomi Fred Hubner
- See Also:
- Serialized Form
-
-
Field Summary
Fields Modifier and Type Field Description protected java.util.HashMap<T,Cardinality>
cardinalities
protected java.util.HashMap<java.lang.String,T>
contents
private static long
serialVersionUID
-
Constructor Summary
Constructors Constructor Description CardinalitySet()
-
Method Summary
Modifier and Type Method Description void
add(T o)
adds an object with default cardinalityvoid
add(T o, Cardinality c)
adds an object with a specific cardinalityboolean
contains(java.lang.String id)
boolean
contains(T o)
T
get(java.lang.String id)
java.util.Collection<T>
getAll()
Cardinality
getCardinality(T o)
returns the cardinality for one object collect here, if not specified, returns the default cardinalityboolean
isEmpty()
java.util.Iterator<T>
iterator()
void
remove(T o)
void
setCardinality(T o, Cardinality c)
sets the cardinality on an object already in the collection*int
size()
-
-
-
Field Detail
-
serialVersionUID
private static final long serialVersionUID
- See Also:
- Constant Field Values
-
contents
protected java.util.HashMap<java.lang.String,T extends Identifiable> contents
-
cardinalities
protected java.util.HashMap<T extends Identifiable,Cardinality> cardinalities
-
-
Method Detail
-
add
public void add(T o)
adds an object with default cardinality
-
add
public void add(T o, Cardinality c)
adds an object with a specific cardinality
-
contains
public boolean contains(T o)
-
contains
public boolean contains(java.lang.String id)
-
get
public T get(java.lang.String id)
-
getAll
public java.util.Collection<T> getAll()
-
remove
public void remove(T o)
-
setCardinality
public void setCardinality(T o, Cardinality c)
sets the cardinality on an object already in the collection*
-
getCardinality
public Cardinality getCardinality(T o)
returns the cardinality for one object collect here, if not specified, returns the default cardinality
-
isEmpty
public boolean isEmpty()
-
size
public int size()
-
iterator
public java.util.Iterator<T> iterator()
- Specified by:
iterator
in interfacejava.lang.Iterable<T extends Identifiable>
-
-