Class SerializationContext<T>
java.lang.Object
com.mrivanplays.annotationconfig.core.serialization.SerializationContext<T>
- Type Parameters:
T
- generic type of information that's being (de)serialized
Represents a serialization context. This holds information about the
Field
that's being
(de)serialized, but since AnnotationConfig can not always get a Field
instance, this
context class will hold information.- Since:
- 3.0.0
- Author:
- MrIvanPlays
-
Method Summary
Modifier and TypeMethodDescriptionstatic <T> SerializationContext<T>
Creates a newSerializationContext
from aField
Returns the annotated config this context originated from.Class<?>
Returns theClass
type of the (de)serialized object.Returns anOptional
which may or may not be fulfilled with a default value.Returns the genericType
of the (de)serialized object.getName()
Returns anOptional
which may or may not be fulfilled with a name.static <T> SerializationContext<T>
Creates a newSerializationContext
static <T> SerializationContext<T>
Creates a newSerializationContext
static <T> SerializationContext<T>
Creates a newSerializationContext
-
Method Details
-
fromField
public static <T> SerializationContext<T> fromField(Field field, Object annotatedConfig) throws IllegalAccessException Creates a newSerializationContext
from aField
- Type Parameters:
T
- type- Parameters:
field
- field to create context fromannotatedConfig
- annotated config- Returns:
- new serialization context
- Throws:
IllegalAccessException
- seeField.get(Object)
-
of
public static <T> SerializationContext<T> of(Class<?> classType, Type genericType, Object annotatedConfig) Creates a newSerializationContext
- Type Parameters:
T
- type- Parameters:
classType
- class typegenericType
- generic class typeannotatedConfig
- annotatedConfig- Returns:
- new serialization context
-
of
public static <T> SerializationContext<T> of(T def, Class<?> classType, Type genericType, Object annotatedConfig) Creates a newSerializationContext
- Type Parameters:
T
- type- Parameters:
def
- default value. can be nullclassType
- class typegenericType
- generic class typeannotatedConfig
- annotatedConfig- Returns:
- new serialization context
-
of
public static <T> SerializationContext<T> of(String name, T def, Class<?> classType, Type genericType, Object annotatedConfig) Creates a newSerializationContext
- Type Parameters:
T
- type- Parameters:
name
- name of field. can be nulldef
- default value. can be nullclassType
- class typegenericType
- generic class typeannotatedConfig
- annotatedConfig- Returns:
- new serialization context
-
getName
Returns anOptional
which may or may not be fulfilled with a name. In most of the cases, this is a field name.- Returns:
- name or empty optional
-
getDefaultValue
Returns anOptional
which may or may not be fulfilled with a default value. In most of the cases, this is fulfilled.- Returns:
- default value or empty optional
-
getClassType
Returns theClass
type of the (de)serialized object.- Returns:
- class type
-
getGenericType
Returns the genericType
of the (de)serialized object.- Returns:
- generic type
-
getAnnotatedConfig
Returns the annotated config this context originated from.- Returns:
- annotated config
-