Class JBBPToJavaConverter.Builder
java.lang.Object
com.igormaznitsa.jbbp.compiler.conversion.JBBPToJavaConverter.Builder
- Enclosing class:
JBBPToJavaConverter
Builder to build instance of converter.
-
Method Summary
Modifier and TypeMethodDescriptionTurn on adding of Bin annotations to generated fields.Turn on generate newInstance methods compatible with JBBPMapper.build()Build converter with provided parameters.Disable generate fields, useful if some super class extended and its fields should be used instead of generated ones.Don't make insternal generated classes as static onessetAddGettersSetters(boolean value) Set flag to generate getters setters.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.setHeadComment(String text) Set commentaries placed just before first package directive of the generated class.setMainClassCustomText(String value) Set custom text, the text will be added into the end of the result class.setMainClassImplements(String... values) Set interfaces to be added into 'implements' for the generated class.setMainClassName(String value) The Name of the generated class.setMainClassPackage(String value) Set the package for the generated class.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.setMapSubClassesSuperclasses(Map<String, String> mapClassNameToSuperclasses) Add superclasses to classes generated for inside structures, a structure class will extend mapped class.setParserFlags(int value) Set the parser flags for the generated class, by default the flags are imported from the base parser.setSuperClass(String value) Set the superclass for the main generated class.
-
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
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
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
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
Turn on adding of Bin annotations to generated fields.- Returns:
- the builder instance, must not be null
- Since:
- 2.0.0
-
addNewInstanceMethods
Turn on generate newInstance methods compatible with JBBPMapper.- Returns:
- the builder instance, must not be null
- Since:
- 2.0.0
-
setMainClassPackage
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
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
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
Don't make insternal generated classes as static ones- Returns:
- the builder instance, must not be null
- Since:
- 1.4.0
-
setSuperClass
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
Set interfaces to be added into 'implements' for the generated class.- Parameters:
values- interface names- Returns:
- the builder instance, must not be null
-
setHeadComment
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
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
Build converter with provided parameters. NB! It locks builder parameters, and they can't be changed in future.- Returns:
- a converter instance.
-