Class MetisFieldSet<T extends MetisFieldItem>
java.lang.Object
io.github.tonywasher.joceanus.metis.field.MetisFieldSet<T>
- Type Parameters:
T- the data type
- All Implemented Interfaces:
MetisFieldItem.MetisFieldSetDef
- Direct Known Subclasses:
MetisFieldVersionedSet
public class MetisFieldSet<T extends MetisFieldItem>
extends Object
implements MetisFieldItem.MetisFieldSetDef
Metis Data FieldSet.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected static final IntegerNo Maximum Length.static final intHash Prime. -
Constructor Summary
ConstructorsConstructorDescriptionMetisFieldSet(Class<T> pClazz, MetisFieldItem.MetisFieldSetDef pParent, boolean pStatic) Constructor. -
Method Summary
Modifier and TypeMethodDescription<E extends Enum<E> & MetisDataItem.MetisDataFieldId>
Map<MetisDataItem.MetisDataFieldId, E> buildFieldMap(Class<E> pClass, BiFunction<T, MetisDataItem.MetisDataFieldId, Object> pValueLookup) Build field set for enum class.protected voidCheck uniqueness of Id.Declare field used for calculation.declareLocalField(MetisDataItem.MetisDataFieldId pId, BiFunction<T, MetisDataItem.MetisDataFieldId, Object> pValue) Declare local field not used for equality.declareLocalField(MetisDataItem.MetisDataFieldId pId, Function<T, Object> pValue) Declare local field not used for equality.declareLocalField(String pName, Function<T, Object> pValue) Declare local field not used for equality.<E extends Enum<E>>
Map<E, MetisFieldItem.MetisFieldDef> declareLocalFieldsForEnum(Class<E> pClazz, BiFunction<T, E, Object> pValue) Declare local non-equality fields one for each Enum.booleanObtain the iterator over the fields.Obtain the anchorId.Obtain field from fieldId.Obtain the field class.Obtain the itemType.getName()Obtain the name of the fieldSet.protected IntegerObtain next value index.Obtain the number of versioned fields.inthashCode()booleanDoes the item have versioned values?booleanisLocked()Is this fieldSet locked?booleanisStatic()Is this a static fieldSet?static <T extends MetisFieldItem>
MetisFieldSet<T> lookUpFieldSet(Class<T> pClazz) LookUp a static FieldSet.lookUpParentFieldSet(Class<?> pClazz) LookUp a Parent FieldSet.static <T extends MetisFieldItem>
MetisFieldSet<T> newFieldSet(Class<T> pClazz) Declare a static fieldSet.static <T extends MetisFieldItem>
MetisFieldSet<T> newFieldSet(T pObject) Declare a local fieldSet.protected voidregisterField(MetisField<T> pField) Register the field.protected static voidregisterFieldSet(Class<?> pClazz, MetisFieldSet<?> pFieldSet) Register a fieldSet.static <E extends Enum<E>>
Map<E, MetisDataItem.MetisDataFieldId> reverseFieldMap(Map<MetisDataItem.MetisDataFieldId, E> pSourceMap, Class<E> pClass) Reverse field set to enum map.voidsetItemType(MetisFieldItem.MetisFieldItemType pItemType) Set the itemType.voidLock the fieldSet.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.github.tonywasher.joceanus.metis.field.MetisFieldItem.MetisFieldSetDef
hasLinks, hasPairedLinks
-
Field Details
-
HASH_PRIME
public static final int HASH_PRIMEHash Prime.- See Also:
-
FIELD_NO_MAXLENGTH
No Maximum Length.
-
-
Constructor Details
-
MetisFieldSet
MetisFieldSet(Class<T> pClazz, MetisFieldItem.MetisFieldSetDef pParent, boolean pStatic) Constructor.- Parameters:
pClazz- the class of the itempParent- the parent fieldspStatic- is this a static fieldSet?
-
-
Method Details
-
newFieldSet
Declare a static fieldSet.- Type Parameters:
T- the itemType- Parameters:
pClazz- the class of the fieldSet- Returns:
- the fieldSet.
-
lookUpParentFieldSet
LookUp a Parent FieldSet.- Parameters:
pClazz- the class of the fieldSet- Returns:
- the fieldSet.
-
lookUpFieldSet
LookUp a static FieldSet.- Type Parameters:
T- the itemType- Parameters:
pClazz- the class of the fieldSet- Returns:
- the fieldSet.
-
registerFieldSet
Register a fieldSet.- Parameters:
pClazz- the class of the fieldSetpFieldSet- the fieldSet
-
newFieldSet
Declare a local fieldSet.- Type Parameters:
T- the itemType- Parameters:
pObject- the object- Returns:
- the fieldSet.
-
getAnchorId
Obtain the anchorId.- Returns:
- the id
-
getName
Description copied from interface:MetisFieldItem.MetisFieldSetDefObtain the name of the fieldSet.- Specified by:
getNamein interfaceMetisFieldItem.MetisFieldSetDef- Returns:
- the name of the fieldSet.
-
getFieldClass
Obtain the field class.- Returns:
- the field class
-
getNextIndex
Obtain next value index.- Returns:
- the next index
-
getNumVersioned
Description copied from interface:MetisFieldItem.MetisFieldSetDefObtain the number of versioned fields.- Specified by:
getNumVersionedin interfaceMetisFieldItem.MetisFieldSetDef- Returns:
- the number of fields.
-
hasVersions
public boolean hasVersions()Description copied from interface:MetisFieldItem.MetisFieldSetDefDoes the item have versioned values?- Specified by:
hasVersionsin interfaceMetisFieldItem.MetisFieldSetDef- Returns:
- true/false
-
isStatic
public boolean isStatic()Is this a static fieldSet?- Returns:
- true/false
-
isLocked
public boolean isLocked()Is this fieldSet locked?- Returns:
- true/false
-
setLocked
public void setLocked()Description copied from interface:MetisFieldItem.MetisFieldSetDefLock the fieldSet.- Specified by:
setLockedin interfaceMetisFieldItem.MetisFieldSetDef
-
getItemType
Description copied from interface:MetisFieldItem.MetisFieldSetDefObtain the itemType.- Specified by:
getItemTypein interfaceMetisFieldItem.MetisFieldSetDef- Returns:
- the itemType
-
setItemType
Set the itemType.- Parameters:
pItemType- the itemType
-
fieldIterator
Description copied from interface:MetisFieldItem.MetisFieldSetDefObtain the iterator over the fields.- Specified by:
fieldIteratorin interfaceMetisFieldItem.MetisFieldSetDef- Returns:
- the iterator
-
declareLocalField
public MetisField<T> declareLocalField(MetisDataItem.MetisDataFieldId pId, Function<T, Object> pValue) Declare local field not used for equality.- Parameters:
pId- the id of the fieldpValue- the value supplier- Returns:
- the field
-
declareLocalField
public MetisField<T> declareLocalField(MetisDataItem.MetisDataFieldId pId, BiFunction<T, MetisDataItem.MetisDataFieldId, Object> pValue) Declare local field not used for equality.- Parameters:
pId- the id of the fieldpValue- the value supplier- Returns:
- the field
-
declareLocalFieldsForEnum
public <E extends Enum<E>> Map<E,MetisFieldItem.MetisFieldDef> declareLocalFieldsForEnum(Class<E> pClazz, BiFunction<T, E, Object> pValue) Declare local non-equality fields one for each Enum.- Type Parameters:
E- the Enum- Parameters:
pClazz- the class of the EnumpValue- the value supplier- Returns:
- map of class to fields
-
declareCalculatedField
Declare field used for calculation.- Parameters:
pId- the fieldId- Returns:
- the field
-
declareLocalField
Declare local field not used for equality.- Parameters:
pName- the name of the fieldpValue- the value supplier- Returns:
- the field
-
registerField
Register the field.- Parameters:
pField- the field
-
checkUniqueName
Check uniqueness of Id.- Parameters:
pId- the id to check.- Throws:
IllegalArgumentException- if name is present
-
getField
Description copied from interface:MetisFieldItem.MetisFieldSetDefObtain field from fieldId.- Specified by:
getFieldin interfaceMetisFieldItem.MetisFieldSetDef- Parameters:
pId- the fieldId.- Returns:
- the corresponding field
-
equals
-
hashCode
public int hashCode() -
buildFieldMap
public <E extends Enum<E> & MetisDataItem.MetisDataFieldId> Map<MetisDataItem.MetisDataFieldId,E> buildFieldMap(Class<E> pClass, BiFunction<T, MetisDataItem.MetisDataFieldId, Object> pValueLookup) Build field set for enum class.- Type Parameters:
E- the enum type- Parameters:
pClass- the enum classpValueLookup- the Lookup Function- Returns:
- the map from field to enum.
-
reverseFieldMap
public static <E extends Enum<E>> Map<E,MetisDataItem.MetisDataFieldId> reverseFieldMap(Map<MetisDataItem.MetisDataFieldId, E> pSourceMap, Class<E> pClass) Reverse field set to enum map.- Type Parameters:
E- the enum type- Parameters:
pSourceMap- the source mappClass- the enum class- Returns:
- the map from field to enum.
-