Class FlyweightSet<E>
- java.lang.Object
-
- java.util.AbstractCollection<E>
-
- java.util.AbstractSet<E>
-
- com.macrofocus.molap.aggregates.cube.FlyweightSet<E>
-
- All Implemented Interfaces:
java.lang.Iterable<E>
,java.util.Collection<E>
,java.util.Set<E>
public class FlyweightSet<E> extends java.util.AbstractSet<E>
A thread-safe Set that manages flyweights: sharable objects that are usually immutable. Call theget
method for supplying the FlyweightSet with candidate flyweight instances.Objects that do not customize the hashCode and equals methods don't make sense to use as flyweights because each instance will be considered unique. The object returned from the
get
method will always be the same as the one passed in.
-
-
Constructor Summary
Constructors Constructor Description FlyweightSet()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
contains(java.lang.Object obj)
protected boolean
equals(E a, E b)
protected int
hashCode(E obj)
java.util.Iterator
iterator()
E
put(E obj)
Pass in a candidate flyweight object and get a unique instance from this set.int
size()
java.lang.String
toString()
-
Methods inherited from class java.util.AbstractCollection
add, addAll, clear, containsAll, isEmpty, remove, retainAll, toArray, toArray
-
-
-
-
Method Detail
-
put
public E put(E obj)
Pass in a candidate flyweight object and get a unique instance from this set. The returned object will always be of the same type as that passed in. If the object passed in does not equal any object currently in the set, it will be added to the set, becoming a flyweight.- Parameters:
obj
- candidate flyweight; null is also accepted
-
iterator
public java.util.Iterator iterator()
-
size
public int size()
-
contains
public boolean contains(java.lang.Object obj)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.util.AbstractCollection<E>
-
hashCode
protected int hashCode(E obj)
-
-