- Type Parameters:
T- type
public interface ValuesModel<T>
Low-level model of a type whose instances are created from the values of their components, e.g. a record or an
immutable collection. Knows how to read the values and to create an instance from them; what and how to copy is
decided by the caller.
-
Method Summary
Modifier and TypeMethodDescriptionCreates an instance from the values of the components.default FieldfieldOf(int index) Returns the field which holds the value of the component, so the field actions and values of the cloner apply to the component: e.g.getType()Returns the type.default booleanTells whether the values are hashed by the created instance (elements of a set, keys of a map).default booleanisMap()Tells whether the values are keys and values of a map in pairs.nameOf(int index) Returns the name of the component for messages.Object[]Reads the values of the components.
-
Method Details
-
getType
Returns the type.- Returns:
- type
-
nameOf
Returns the name of the component for messages.- Parameters:
index- index of the value- Returns:
- name of the component
-
fieldOf
Returns the field which holds the value of the component, so the field actions and values of the cloner apply to the component: e.g. the field of a record component.- Parameters:
index- index of the value- Returns:
- field or
nullif the component has no field, e.g. an element of a collection
-
hashesKeys
default boolean hashesKeys()Tells whether the values are hashed by the created instance (elements of a set, keys of a map). Hash codes of copied values may be final only when the whole object graph is copied.- Returns:
trueif values (or keys, seeisMap()) are hashed
-
isMap
default boolean isMap()Tells whether the values are keys and values of a map in pairs.- Returns:
truefor a map
-
read
Reads the values of the components.- Parameters:
object- object- Returns:
- values of the components
-
create
Creates an instance from the values of the components. If the constructor fails, throwsClonerExceptionwith the exception of the constructor as the cause.- Parameters:
values- values of the components- Returns:
- new instance
-