Package com.hedera.pbj.compiler.impl
Interface Field
- All Known Implementing Classes:
MapField,OneOfField,SingleField
public interface Field
Interface for SingleFields and OneOfFields
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumField type enum for use in field classes -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final longThe default maximum size of a repeated or length-encoded field (Bytes, String, Message, etc.). -
Method Summary
Modifier and TypeMethodDescriptionvoidaddAllNeededImports(Set<String> imports, boolean modelImports, boolean codecImports, boolean testImports) Add all the needed imports for this field to the supplied set.comment()Get the java doc comment for this field, cleaned and ready to insert in outputbooleanGet if this field is deprecated or notstatic StringextractMessageTypeName(Protobuf3Parser.Type_Context typeContext) Extract the name of the Java model class for a message type, or null if the type is not a message.static StringextractMessageTypePackage(Protobuf3Parser.Type_Context typeContext, FileType fileType, ContextualLookupHelper lookupHelper) Extract the name of the Java package for a given FileType for a message type, or null if the type is not a message.intGet the field number, the number of the field in the parent messageGet the java code default value for this field, "null" for object typesGet the Java field type for this fieldGet the Java field type for this field.default longmaxSize()Returns the field's max size relevant to repeated or length-encoded fields.default StringGet the message type for this field if it is of type message otherwise nullGet the name for this type that is added to write/sizeof etc.name()Get this fields name in original case and formatdefault StringGet this fields name converted to camel case with the first letter lower casedefault StringGet this fields name converted to camel case with the first letter upper casedefault booleanGet if this field is an optional value type, optionals are handled in protobuf by value type objects for primitivesdefault OneOfFieldparent()Get the parent field for this field, null if there is no parent like in the case of a single field.Get the java code to parse the value for this field from inputGet the case statement for setting this method to go in parser set method codeGet the protobuf field type for this fieldbooleanrepeated()Is this field a repeated field.Get the field definitions line of code for schema file for this field.Get the schema case statement for getting the field definition by field numbertype()Get the field type for this field, the field type is independent of repeated
-
Field Details
-
DEFAULT_MAX_SIZE
static final long DEFAULT_MAX_SIZEThe default maximum size of a repeated or length-encoded field (Bytes, String, Message, etc.).- See Also:
-
-
Method Details
-
repeated
boolean repeated()Is this field a repeated field. Repeated fields are lists of values rather than a single value.- Returns:
- true if this field is a list and false if it is a single value
-
maxSize
default long maxSize()Returns the field's max size relevant to repeated or length-encoded fields. The returned value has no meaning for scalar fields (BOOL, INT, etc.). -
fieldNumber
int fieldNumber()Get the field number, the number of the field in the parent message- Returns:
- this fields number
-
name
String name()Get this fields name in original case and format- Returns:
- this fields name
-
nameCamelFirstUpper
Get this fields name converted to camel case with the first letter upper case- Returns:
- this fields name converted
-
nameCamelFirstLower
Get this fields name converted to camel case with the first letter lower case- Returns:
- this fields name converted
-
type
Field.FieldType type()Get the field type for this field, the field type is independent of repeated- Returns:
- this fields type
-
protobufFieldType
String protobufFieldType()Get the protobuf field type for this field- Returns:
- this fields type in protobuf format
-
javaFieldType
String javaFieldType()Get the Java field type for this field- Returns:
- this fields type in Java format
-
javaFieldTypeBase
String javaFieldTypeBase()Get the Java field type for this field. UnlikejavaFieldType(), this method returns the base type for repeated and oneOf fields.- Returns:
- this fields type in Java format
-
methodNameType
String methodNameType()Get the name for this type that is added to write/sizeof etc. methods.- Returns:
- Name for type used in method names
-
addAllNeededImports
void addAllNeededImports(Set<String> imports, boolean modelImports, boolean codecImports, boolean testImports) Add all the needed imports for this field to the supplied set.- Parameters:
imports- set of imports to add to, this contains packages not classes. They are always imported as ".*".modelImports- if imports for this field's generated model classes should be addedcodecImports- if imports for this field's generated codec classes should be addedtestImports- if imports for this field's generated test classes should be added
-
parseCode
String parseCode()Get the java code to parse the value for this field from input- Returns:
- java source code to parse
-
javaDefault
String javaDefault()Get the java code default value for this field, "null" for object types- Returns:
- code for default value
-
schemaFieldsDef
String schemaFieldsDef()Get the field definitions line of code for schema file for this field. One line for single fields and multiple for oneofs.- Returns:
- field definition lines of code
-
schemaGetFieldsDefCase
String schemaGetFieldsDefCase()Get the schema case statement for getting the field definition by field number- Returns:
- java source code for case statement to get field def for field number
-
parserFieldsSetMethodCase
String parserFieldsSetMethodCase()Get the case statement for setting this method to go in parser set method code- Returns:
- java source code for case statement setting this field
-
comment
String comment()Get the java doc comment for this field, cleaned and ready to insert in output- Returns:
- java doc comment
-
deprecated
boolean deprecated()Get if this field is deprecated or not- Returns:
- true if field is deprecated, otherwise false
-
messageType
Get the message type for this field if it is of type message otherwise null- Returns:
- message type or null if not a message type field
-
optionalValueType
default boolean optionalValueType()Get if this field is an optional value type, optionals are handled in protobuf by value type objects for primitives- Returns:
- true if this field is option by use of a protobuf value type, otherwise false
-
parent
Get the parent field for this field, null if there is no parent like in the case of a single field.- Returns:
- this fields parent field for oneof fields
-
extractMessageTypeName
Extract the name of the Java model class for a message type, or null if the type is not a message. -
extractMessageTypePackage
static String extractMessageTypePackage(Protobuf3Parser.Type_Context typeContext, FileType fileType, ContextualLookupHelper lookupHelper) Extract the name of the Java package for a given FileType for a message type, or null if the type is not a message.
-