Class JBBPToJavaConverter.Builder

java.lang.Object
com.igormaznitsa.jbbp.compiler.conversion.JBBPToJavaConverter.Builder
Enclosing class:
JBBPToJavaConverter

public static final class JBBPToJavaConverter.Builder extends Object
Builder to build instance of converter.
  • Method Details

    • setMapSubClassesInterfaces

      public JBBPToJavaConverter.Builder setMapSubClassesInterfaces(Map<String,String> mapClassNameToInterface)
      Map inside structures to mainClassImplements, a structure class will implement mapped interface and getter of the structure object will return interface object as result.
      Parameters:
      mapClassNameToInterface - map with structure path as the key and the interface name as value, it can be null. Names of structures should be in the lower case form amd dot separated for their hierarchy. (example: "a.b.c")
      Returns:
      the builder instance, must not be null
    • setMapSubClassesSuperclasses

      public JBBPToJavaConverter.Builder setMapSubClassesSuperclasses(Map<String,String> mapClassNameToSuperclasses)
      Add superclasses to classes generated for inside structures, a structure class will extend mapped class.
      Parameters:
      mapClassNameToSuperclasses - map with structure path as the key and the interface name as value, it can be null. Names of structures should be in the lower case form amd dot separated for their hierarchy. (example: "a.b.c")
      Returns:
      the builder instance, must not be null
      Since:
      1.4.0
    • setMainClassCustomText

      public JBBPToJavaConverter.Builder setMainClassCustomText(String value)
      Set custom text, the text will be added into the end of the result class.
      Parameters:
      value - text value, it can be null
      Returns:
      the builder instance, must not be null
    • setAddGettersSetters

      public JBBPToJavaConverter.Builder setAddGettersSetters(boolean value)
      Set flag to generate getters setters. NB! All fields will be private ones in the case.
      Parameters:
      value - flag, if true then generate getters setters, false otherwise
      Returns:
      the builder instance, must not be null
    • setParserFlags

      public JBBPToJavaConverter.Builder setParserFlags(int value)
      Set the parser flags for the generated class, by default the flags are imported from the base parser.
      Parameters:
      value - parser flags.
      Returns:
      the builder instance, must not be null
    • addBinAnnotations

      public JBBPToJavaConverter.Builder addBinAnnotations()
      Turn on adding of Bin annotations to generated fields.
      Returns:
      the builder instance, must not be null
      Since:
      2.0.0
    • addNewInstanceMethods

      public JBBPToJavaConverter.Builder addNewInstanceMethods()
      Turn on generate newInstance methods compatible with JBBPMapper.
      Returns:
      the builder instance, must not be null
      Since:
      2.0.0
    • setMainClassPackage

      public JBBPToJavaConverter.Builder setMainClassPackage(String value)
      Set the package for the generated class.
      Parameters:
      value - name of the package, it can be empty or null in the case the class will be in the default package
      Returns:
      the builder instance, must not be null
    • setDoMainClassAbstract

      public JBBPToJavaConverter.Builder setDoMainClassAbstract(boolean value)
      Set flag to force abstract modifier for the generated class, by default the class is abstract one only if it contains abstract methods.
      Parameters:
      value - true if to force the abstract modifier, false otherwise
      Returns:
      the builder instance, must not be null
    • setMainClassName

      public JBBPToJavaConverter.Builder setMainClassName(String value)
      The Name of the generated class. Must be provided.
      Parameters:
      value - the class name for the generated class, must not be null
      Returns:
      the builder instance, must not be null
    • doInternalClassesNonStatic

      public JBBPToJavaConverter.Builder doInternalClassesNonStatic()
      Don't make insternal generated classes as static ones
      Returns:
      the builder instance, must not be null
      Since:
      1.4.0
    • setSuperClass

      public JBBPToJavaConverter.Builder setSuperClass(String value)
      Set the superclass for the main generated class. NB! Also it affects read and write methods of the main class, the class will be used as the return type.
      Parameters:
      value - the superclass name, it can be null
      Returns:
      the builder instance, must not be null
    • setMainClassImplements

      public JBBPToJavaConverter.Builder setMainClassImplements(String... values)
      Set interfaces to be added into 'implements' for the generated class.
      Parameters:
      values - interface names
      Returns:
      the builder instance, must not be null
    • setHeadComment

      public JBBPToJavaConverter.Builder setHeadComment(String text)
      Set commentaries placed just before first package directive of the generated class.
      Parameters:
      text - text to be used as comment, it can be null
      Returns:
      the builder instance, must not be null
    • disableGenerateFields

      public JBBPToJavaConverter.Builder disableGenerateFields()
      Disable generate fields, useful if some super class extended and its fields should be used instead of generated ones. If disable then all code will be generated but without class fields. By default, field generate is enabled.
      Returns:
      the builder instance, must not be null
      Since:
      1.4.0
    • build

      public JBBPToJavaConverter build()
      Build converter with provided parameters. NB! It locks builder parameters, and they can't be changed in future.
      Returns:
      a converter instance.