org.jjoost.collections
Interface UnitarySet<V>

All Superinterfaces:
AnyReadSet<V>, AnySet<V>, Function<V,java.lang.Boolean>, java.lang.Iterable<V>, java.io.Serializable

public interface UnitarySet<V>
extends AnySet<V>

This interface represents the rather dubious concept of a set that may contain at most one item. This set is primarily intended for use by the method values(key) on regular (scalar) maps.

Author:
b.elliottsmith

Method Summary
 UnitarySet<V> copy()
          Returns a copy of the set.
 V get()
          Returns the set's only value, if any
 V put(V value)
          Insert the parameter into the set, removing and returning the currently value that exists in the set, if any
 UnitarySet<V> unique()
          Returns this
 
Methods inherited from interface org.jjoost.collections.AnySet
add, clear, clearAndReturn, putAll, putIfAbsent, remove, remove, removeAndReturn, removeAndReturn, removeAndReturnFirst, removeAndReturnFirst, shrink
 
Methods inherited from interface org.jjoost.collections.AnyReadSet
all, contains, count, equality, first, isEmpty, list, permitsDuplicates, totalCount, uniqueCount
 
Methods inherited from interface java.lang.Iterable
iterator
 
Methods inherited from interface org.jjoost.util.Function
apply
 

Method Detail

put

V put(V value)
Insert the parameter into the set, removing and returning the currently value that exists in the set, if any

Specified by:
put in interface AnySet<V>
Parameters:
value - value to insert
Returns:
set's previous value, if any

get

V get()
Returns the set's only value, if any

Returns:
the set's value, or null if empty

copy

UnitarySet<V> copy()
Returns a copy of the set. This method may or may not return a set of the same class as the one it was called on, however will return a UnitarySet

Specified by:
copy in interface AnySet<V>

unique

UnitarySet<V> unique()
Returns this

Specified by:
unique in interface AnyReadSet<V>
Specified by:
unique in interface AnySet<V>
Returns:
this