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>cardinalitiesprotected java.util.HashMap<java.lang.String,T>contentsprivate static longserialVersionUID -
Constructor Summary
Constructors Constructor Description CardinalitySet() -
Method Summary
Modifier and Type Method Description voidadd(T o)adds an object with default cardinalityvoidadd(T o, Cardinality c)adds an object with a specific cardinalitybooleancontains(java.lang.String id)booleancontains(T o)Tget(java.lang.String id)java.util.Collection<T>getAll()CardinalitygetCardinality(T o)returns the cardinality for one object collect here, if not specified, returns the default cardinalitybooleanisEmpty()java.util.Iterator<T>iterator()booleanremove(T o)voidsetCardinality(T o, Cardinality c)sets the cardinality on an object already in the collection*intsize()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface java.lang.Iterable
forEach, spliterator
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
- Constant Field Values
-
contents
-
cardinalities
-
-
Constructor Details
-
CardinalitySet
public CardinalitySet()
-
-
Method Details
-
add
adds an object with default cardinality -
add
adds an object with a specific cardinality -
contains
-
contains
public boolean contains(java.lang.String id) -
get
-
getAll
-
remove
-
setCardinality
sets the cardinality on an object already in the collection* -
getCardinality
returns the cardinality for one object collect here, if not specified, returns the default cardinality -
isEmpty
public boolean isEmpty() -
size
public int size() -
iterator
- Specified by:
iteratorin interfacejava.lang.Iterable<T extends Identifiable>
-