Package dev.quantumfusion.hyphen
Class SerializerFactory<IO extends IOInterface,D>
java.lang.Object
dev.quantumfusion.hyphen.SerializerFactory<IO,D>
- Type Parameters:
IO- IO ClassD- Data Class
The Factory where you create a
HyphenSerializer
If you are looking at the code, this is mostly a wrapper around SerializerHandler
as this class requires a lot of documentation which takes up a lot of screen space.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfaceThis is a Dynamic Definition Factory that will create a Definition dependent on the Field itself. -
Method Summary
Modifier and TypeMethodDescriptionvoidaddDynamicDef(Class<?> target, SerializerFactory.DynamicDefFactory factory)This adds a dynamic definition that does depend on the field itself.voidaddGlobalAnnotation(Class<?> clazz, Class<? extends Annotation> annotation, Object value)This adds annotations to the global annotation which targets a class.voidaddGlobalAnnotation(String id, Class<? extends Annotation> annotation, Object value)This adds annotations to the global annotation id.voidaddStaticDef(Class<?> target, SerializerDef def)This adds a static definition that does not change dependent on types or any other variables.build()Builds aHyphenSerializer.static <IO extends IOInterface, D>
SerializerFactory<IO,D>Create a SerializerFactory which creates a HyphenSerializer with the preferredIOInterfaceand with your intended dataclass.
Please note that the resulting serializer is static, and you cannot change anything after creation.static <IO extends IOInterface, D>
SerializerFactory<IO,D>createDebug(Class<IO> ioClass, Class<D> dataClass)Create a SerializerFactory which creates a HyphenSerializer with the preferredIOInterfaceand with your intended dataclass.
Please note that the resulting serializer is static, and you cannot change anything after creation.voidsetClassLoader(ClassLoader classLoader)This sets the classloader used to define aHyphenSerializer
If this is not set the default classloader will be the thread classloader at factory creation.voidsetClassName(String name)Sets the class name of the outputHyphenSerializervoidsetExportDir(Path path)Sets the DIRECTION location of the serializer.voidsetExportPath(Path path)Sets the FILE location of the serializer.voidThis sets an optional option for the createdHyphenSerializer
Anything you change here will be hardcoded into the serializer as it changes the bytecode
-
Method Details
-
create
public static <IO extends IOInterface, D> SerializerFactory<IO,D> create(Class<IO> ioClass, Class<D> dataClass)Create a SerializerFactory which creates a HyphenSerializer with the preferredIOInterfaceand with your intended dataclass.
Please note that the resulting serializer is static, and you cannot change anything after creation.- Type Parameters:
IO- IOD- DataClass- Parameters:
ioClass- The Data Handling ClassdataClass- The Data Class- Returns:
- A SerializerFactory
-
createDebug
public static <IO extends IOInterface, D> SerializerFactory<IO,D> createDebug(Class<IO> ioClass, Class<D> dataClass)Create a SerializerFactory which creates a HyphenSerializer with the preferredIOInterfaceand with your intended dataclass.
Please note that the resulting serializer is static, and you cannot change anything after creation.
This is the debug type with
Options.SHORT_METHOD_NAMESandOptions.SHORT_VARIABLE_NAMESturned off- Type Parameters:
IO- IOD- DataClass- Parameters:
ioClass- The Data Handling ClassdataClass- The Data Class- Returns:
- A SerializerFactory
-
setOption
This sets an optional option for the createdHyphenSerializer
Anything you change here will be hardcoded into the serializer as it changes the bytecode- Parameters:
option- Any option fromOptionsvalue- The option on state
-
setClassLoader
This sets the classloader used to define aHyphenSerializer
If this is not set the default classloader will be the thread classloader at factory creation.- Parameters:
classLoader- The intended classloader
-
setClassName
Sets the class name of the outputHyphenSerializer -
setExportPath
Sets the FILE location of the serializer. This will export theHyphenSerializerbytecode into the file.
- See Also:
setExportDir(java.nio.file.Path)
-
setExportDir
Sets the DIRECTION location of the serializer. This will export theHyphenSerializerbytecode into a file that matches the serializer name.
- See Also:
setExportPath(java.nio.file.Path)
-
addStaticDef
This adds a static definition that does not change dependent on types or any other variables.
- Parameters:
target- The Class Target to add a static definition todef- The Serializer Definition- See Also:
addDynamicDef(Class, DynamicDefFactory)
-
addDynamicDef
This adds a dynamic definition that does depend on the field itself.
- Parameters:
target- The Class Target to add a static definition tofactory- The Factory that creates aSerializerDef- See Also:
(Class, DynamicDefFactory)
-
addGlobalAnnotation
This adds annotations to the global annotation id. If aDataGlobalAnnotation.value()contains thisidit will apply this and the previous annotations that were added to this id- Parameters:
id- TheDataGlobalAnnotation.value()that is targetedannotation- The Annotation you are adding to the applicationsvalue- The Annotation value. If the annotation does not contain a value this will be ignored. It may benull
-
addGlobalAnnotation
public void addGlobalAnnotation(Class<?> clazz, Class<? extends Annotation> annotation, Object value)This adds annotations to the global annotation which targets a class. If aDataGlobalAnnotationis applied to aclazzfield. it will apply this and the previous annotations that were added to thisclazz- Parameters:
clazz- TheDataGlobalAnnotationfield class that is targetedannotation- The Annotation you are adding to the applicationsvalue- The Annotation value. If the annotation does not contain a value this will be ignored. It may benull
-
build
Builds aHyphenSerializer. Any options that are set at this point will be applied to the finalHyphenSerializer- Returns:
- A Serializer Powered by Hyphen.
-