Class SerializerFactory<IO extends IOInterface,​D>

java.lang.Object
dev.quantumfusion.hyphen.SerializerFactory<IO,​D>
Type Parameters:
IO - IO Class
D - Data Class

public class SerializerFactory<IO extends IOInterface,​D> extends Object
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.

  • 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 preferred IOInterface and with your intended dataclass.
      Please note that the resulting serializer is static, and you cannot change anything after creation.
      Type Parameters:
      IO - IO
      D - DataClass
      Parameters:
      ioClass - The Data Handling Class
      dataClass - 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 preferred IOInterface and 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_NAMES and Options.SHORT_VARIABLE_NAMES turned off

      Type Parameters:
      IO - IO
      D - DataClass
      Parameters:
      ioClass - The Data Handling Class
      dataClass - The Data Class
      Returns:
      A SerializerFactory
    • setOption

      public void setOption(Options option, Boolean value)
      This sets an optional option for the created HyphenSerializer
      Anything you change here will be hardcoded into the serializer as it changes the bytecode
      Parameters:
      option - Any option from Options
      value - The option on state
    • setClassLoader

      public void setClassLoader(ClassLoader classLoader)
      This sets the classloader used to define a HyphenSerializer
      If this is not set the default classloader will be the thread classloader at factory creation.
      Parameters:
      classLoader - The intended classloader
    • setClassName

      public void setClassName(String name)
      Sets the class name of the output HyphenSerializer
    • setExportPath

      public void setExportPath(Path path)
      Sets the FILE location of the serializer. This will export the HyphenSerializer bytecode into the file.

      See Also:
      setExportDir(java.nio.file.Path)
    • setExportDir

      public void setExportDir(Path path)
      Sets the DIRECTION location of the serializer. This will export the HyphenSerializer bytecode into a file that matches the serializer name.

      See Also:
      setExportPath(java.nio.file.Path)
    • addStaticDef

      public void addStaticDef(Class<?> target, SerializerDef def)
      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 to
      def - The Serializer Definition
      See Also:
      addDynamicDef(Class, DynamicDefFactory)
    • addDynamicDef

      public void addDynamicDef(Class<?> target, SerializerFactory.DynamicDefFactory factory)
      This adds a dynamic definition that does depend on the field itself.

      Parameters:
      target - The Class Target to add a static definition to
      factory - The Factory that creates a SerializerDef
      See Also:
      (Class, DynamicDefFactory)
    • addGlobalAnnotation

      public void addGlobalAnnotation(String id, Class<? extends Annotation> annotation, Object value)
      This adds annotations to the global annotation id. If a DataGlobalAnnotation.value() contains this id it will apply this and the previous annotations that were added to this id
      Parameters:
      id - The DataGlobalAnnotation.value() that is targeted
      annotation - The Annotation you are adding to the applications
      value - The Annotation value. If the annotation does not contain a value this will be ignored. It may be null
    • addGlobalAnnotation

      public void addGlobalAnnotation(Class<?> clazz, Class<? extends Annotation> annotation, Object value)
      This adds annotations to the global annotation which targets a class. If a DataGlobalAnnotation is applied to a clazz field. it will apply this and the previous annotations that were added to this clazz
      Parameters:
      clazz - The DataGlobalAnnotation field class that is targeted
      annotation - The Annotation you are adding to the applications
      value - The Annotation value. If the annotation does not contain a value this will be ignored. It may be null
    • build

      public HyphenSerializer<IO,​D> build()
      Builds a HyphenSerializer. Any options that are set at this point will be applied to the final HyphenSerializer
      Returns:
      A Serializer Powered by Hyphen.