Package de.gsi.dataset.serializer.spi
Class ClassFieldDescription
- java.lang.Object
-
- de.gsi.dataset.serializer.spi.ClassFieldDescription
-
- All Implemented Interfaces:
java.lang.Iterable<ClassFieldDescription>
public class ClassFieldDescription extends java.lang.Object implements java.lang.Iterable<ClassFieldDescription>
- Author:
- rstein
-
-
Field Summary
Fields Modifier and Type Field Description static intmaxRecursionLevelmaximum recursion depth that is being explored default is 10: anything beyond that is typically an indication if infinite recursion
-
Constructor Summary
Constructors Modifier Constructor Description ClassFieldDescription(java.lang.Class<?> referenceClass, boolean fullScan)This should be called only once with the root class as an argumentprotectedClassFieldDescription(java.lang.Class<?> referenceClass, java.lang.reflect.Field field, ClassFieldDescription parent, int recursionLevel)ClassFieldDescription(java.lang.reflect.Field field, ClassFieldDescription parent, int recursionLevel, boolean fullScan)This should be called for individual class field members
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected java.lang.ObjectallocateMemberClassField(java.lang.Object fieldParent, ClassFieldDescription localParent)protected static DataTypedataTypeFomClassType(java.lang.Class<?> classType)Returns the data type matching the given java class type, if any.protected static voidexploreClass(java.lang.Class<? extends java.lang.Object> classType, ClassFieldDescription parent, int recursionLevel, boolean fullScan)java.util.List<java.lang.String>getActualTypeArgumentNames()java.util.List<java.lang.Class<?>>getActualTypeArguments()java.util.List<ClassFieldDescription>getChildren()DataTypegetDataType()java.lang.reflect.FieldgetField()java.util.Map<java.lang.String,ClassFieldDescription>getFieldMap()java.lang.StringgetFieldName()java.lang.StringgetFieldNameRelative()java.lang.StringgetGenericFieldTypeString()java.lang.reflect.TypegetGenericType()intgetHierarchyDepth()java.lang.ObjectgetMemberClassObject(java.lang.Object rootObject)intgetModifierID()java.lang.StringgetModifierString()java.util.Optional<ClassFieldDescription>getParent()ClassFieldDescriptiongetParent(ClassFieldDescription field, int hierarchyLevel)java.lang.Class<?>getType()java.lang.StringgetTypeName()booleanisAbstract()booleanisClass()booleanisEnum()booleanisFinal()booleanisInterface()booleanisNative()booleanisPrimitive()booleanisPrivate()booleanisProtected()booleanisPublic()booleanisRoot()booleanisSerializable()booleanisStatic()booleanisStrict()booleanisSynchronized()booleanisTransient()booleanisVolatile()java.util.Iterator<ClassFieldDescription>iterator()java.util.concurrent.atomic.AtomicIntegerreadCount()voidreset()resets read and write countvoidresetReadCount()resets the read countervoidresetWriteCount()resets the write counterjava.lang.StringtoString()java.util.concurrent.atomic.AtomicIntegerwriteCount()
-
-
-
Constructor Detail
-
ClassFieldDescription
public ClassFieldDescription(java.lang.Class<?> referenceClass, boolean fullScan)This should be called only once with the root class as an argument- Parameters:
referenceClass- the root node containing further Field childrenfullScan-trueif the class field should be serialised according toSerializable(ie. object's non-static and non-transient fields);falseotherwise.
-
ClassFieldDescription
protected ClassFieldDescription(java.lang.Class<?> referenceClass, java.lang.reflect.Field field, ClassFieldDescription parent, int recursionLevel)
-
ClassFieldDescription
public ClassFieldDescription(java.lang.reflect.Field field, ClassFieldDescription parent, int recursionLevel, boolean fullScan)This should be called for individual class field members- Parameters:
field- Field reference for the given class memberparent- pointer to the root/parent reference class field descriptionrecursionLevel- hierarchy level (i.e. '0' being the root class, '1' the sub-class etc.fullScan-trueif the class field should be serialised according toSerializable(ie. object's non-static and non-transient fields);falseotherwise.
-
-
Method Detail
-
allocateMemberClassField
protected java.lang.Object allocateMemberClassField(java.lang.Object fieldParent, ClassFieldDescription localParent) throws java.lang.IllegalAccessException- Throws:
java.lang.IllegalAccessException
-
getActualTypeArgumentNames
public java.util.List<java.lang.String> getActualTypeArgumentNames()
- Returns:
- generic type argument name of the class (e.g. for List<String> this would return 'java.lang.String')
-
getActualTypeArguments
public java.util.List<java.lang.Class<?>> getActualTypeArguments()
- Returns:
- generic type argument objects of the class (e.g. for List<String> this would return 'String.class')
-
getChildren
public java.util.List<ClassFieldDescription> getChildren()
- Returns:
- the children (if any) from the super classes
-
getDataType
public DataType getDataType()
- Returns:
- the DataType (if known) for the detected Field,
DataType.OTHERin all other cases
-
getField
public java.lang.reflect.Field getField()
- Returns:
- the underlying Field type or
nullif it's a root node
-
getFieldMap
public java.util.Map<java.lang.String,ClassFieldDescription> getFieldMap()
- Returns:
- the hashMap containing the child references by field name
-
getFieldName
public java.lang.String getFieldName()
- Returns:
- the underlying field name
-
getFieldNameRelative
public java.lang.String getFieldNameRelative()
- Returns:
- relative field name within class hierarchy (ie. field_level0.field_level1.variable_0)
-
getGenericFieldTypeString
public java.lang.String getGenericFieldTypeString()
- Returns:
- field type strings (e.g. for the class Map<Integer,String> this returns '<java.lang.Integer,java.lang.String>'
-
getGenericType
public java.lang.reflect.Type getGenericType()
-
getHierarchyDepth
public int getHierarchyDepth()
- Returns:
- hierarchy level depth w.r.t. root object (ie. '0' being a variable in the root object)
-
getMemberClassObject
public java.lang.Object getMemberClassObject(java.lang.Object rootObject)
- Parameters:
rootObject- reference to the root object- Returns:
- the specific object link corresponding to this field
-
getModifierID
public int getModifierID()
- Returns:
- the modifierID
-
getModifierString
public java.lang.String getModifierString()
- Returns:
- the full modifier string (cached)
-
getParent
public java.util.Optional<ClassFieldDescription> getParent()
- Returns:
- the parent
-
getParent
public ClassFieldDescription getParent(ClassFieldDescription field, int hierarchyLevel)
- Parameters:
field- class Field description for whichhierarchyLevel- the recursion level of the parent (e.g. '1' yields the immediate parent, '2' the parent of the parent etc.)- Returns:
- the parent field reference description for the provided field
-
getType
public java.lang.Class<?> getType()
- Returns:
- field class type
-
getTypeName
public java.lang.String getTypeName()
- Returns:
- field class type name
-
isAbstract
public boolean isAbstract()
- Returns:
- the isAbstract
-
isClass
public boolean isClass()
- Returns:
- the isClass
-
isEnum
public boolean isEnum()
- Returns:
- whether class is an Enum type
-
isFinal
public boolean isFinal()
- Returns:
trueif the class field includes thefinalmodifier;falseotherwise.
-
isInterface
public boolean isInterface()
- Returns:
trueif the class field is an interface
-
isNative
public boolean isNative()
- Returns:
- the isNative
-
isPrimitive
public boolean isPrimitive()
- Returns:
trueif the class field is a primitive type (ie. boolean, byte, ..., int, float, double)
-
isPrivate
public boolean isPrivate()
- Returns:
trueif the class field includes theprivatemodifier;falseotherwise.
-
isProtected
public boolean isProtected()
- Returns:
- the isProtected
-
isPublic
public boolean isPublic()
- Returns:
trueif the class field includes thepublicmodifier;falseotherwise.
-
isRoot
public boolean isRoot()
- Returns:
- the isRoot
-
isSerializable
public boolean isSerializable()
- Returns:
trueif the class field should be serialised according toSerializable(ie. object's non-static and non-transient fields);falseotherwise.
-
isStatic
public boolean isStatic()
- Returns:
trueif the class field includes thestaticmodifier;falseotherwise.
-
isStrict
public boolean isStrict()
- Returns:
trueif the class field includes thestrictfpmodifier;falseotherwise.
-
isSynchronized
public boolean isSynchronized()
- Returns:
trueif the class field includes thesynchronizedmodifier;falseotherwise.
-
isTransient
public boolean isTransient()
- Returns:
trueif the class field includes thetransientmodifier;falseotherwise.
-
isVolatile
public boolean isVolatile()
- Returns:
trueif the class field includes thevolatilemodifier;falseotherwise.
-
iterator
public java.util.Iterator<ClassFieldDescription> iterator()
- Specified by:
iteratorin interfacejava.lang.Iterable<ClassFieldDescription>
-
readCount
public java.util.concurrent.atomic.AtomicInteger readCount()
- Returns:
- the readCount
-
reset
public void reset()
resets read and write count
-
resetReadCount
public void resetReadCount()
resets the read counter
-
resetWriteCount
public void resetWriteCount()
resets the write counter
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
writeCount
public java.util.concurrent.atomic.AtomicInteger writeCount()
- Returns:
- the writeCount
-
dataTypeFomClassType
protected static DataType dataTypeFomClassType(java.lang.Class<?> classType)
Returns the data type matching the given java class type, if any.- Parameters:
classType- the value to be searched- Returns:
- the matching data type
-
exploreClass
protected static void exploreClass(java.lang.Class<? extends java.lang.Object> classType, ClassFieldDescription parent, int recursionLevel, boolean fullScan)
-
-