Module io.github.sugarcubes.cloner
Package io.github.sugarcubes.cloner.spi
Interface ContainerModel<T>
- Type Parameters:
T- container type
public interface ContainerModel<T>
Low-level model of a container: a collection or a map. Knows how to create an empty container of the same kind, to
list its elements, to fill a container with elements and to look up a key; what and how to copy is decided by the
caller.
-
Method Summary
Modifier and TypeMethodDescriptionvoidRemoves all the elements, keeping the configuration of the container.booleancontainsKey(T container, Object key) Tells whether the container finds the key (a set element or a map key).Creates an empty container of the same kind as the original: the same class and configuration, e.g.Object[]Lists the elements of the container in iteration order; for a map keys and values in pairs.voidFills the empty container with the elements, in the order ofelements(Object).booleanTells whether the container uses hash codes of its keys (set elements or map keys).booleanisMap()Tells whether the container is a map: its elements are keys and values in pairs.
-
Method Details
-
isMap
boolean isMap()Tells whether the container is a map: its elements are keys and values in pairs.- Returns:
truefor a map
-
hashesKeys
boolean hashesKeys()Tells whether the container uses hash codes of its keys (set elements or map keys). Hash codes of copied keys are final only when the whole object graph is copied.- Returns:
trueif keys are hashed
-
create
Creates an empty container of the same kind as the original: the same class and configuration, e.g. the key type of anEnumMap.- Parameters:
original- original container- Returns:
- empty container
-
elements
Lists the elements of the container in iteration order; for a map keys and values in pairs.- Parameters:
container- container- Returns:
- elements
-
fill
Fills the empty container with the elements, in the order ofelements(Object).- Parameters:
container- empty containerelements- elements
-
containsKey
Tells whether the container finds the key (a set element or a map key).- Parameters:
container- containerkey- key- Returns:
trueif the key is found
-
clear
Removes all the elements, keeping the configuration of the container.- Parameters:
container- container
-