Package com.hedera.pbj.compiler.impl
Record Class SingleField
java.lang.Object
java.lang.Record
com.hedera.pbj.compiler.impl.SingleField
- Record Components:
repeated- If this is a repeated field, ie protobuf equivalent of arraytype- The type of this single fieldfieldNumber- The protobuf field numbername- The name of this filedmessageType- The message type of this field is of type messagemessageTypeCodecPackage-
- All Implemented Interfaces:
Field
public record SingleField(boolean repeated, Field.FieldType type, int fieldNumber, String name, String messageType, String messageTypeModelPackage, String messageTypeCodecPackage, String messageTypeTestPackage, String comment, boolean deprecated, OneOfField parent)
extends Record
implements Field
Record for Field in Protobuf file. Contains all logic and special cases for fields
-
Nested Class Summary
Nested classes/interfaces inherited from interface com.hedera.pbj.compiler.impl.Field
Field.FieldType -
Field Summary
Fields inherited from interface com.hedera.pbj.compiler.impl.Field
DEFAULT_MAX_SIZE -
Constructor Summary
ConstructorsConstructorDescriptionSingleField(boolean repeated, Field.FieldType type, int fieldNumber, String name, String messageType, String messageTypeModelPackage, String messageTypeCodecPackage, String messageTypeTestPackage, String comment, boolean deprecated, OneOfField parent) Creates an instance of aSingleFieldrecord class.SingleField(Protobuf3Parser.FieldContext fieldContext, ContextualLookupHelper lookupHelper) Construct a SingleField from a parsed field contextSingleField(Protobuf3Parser.OneofFieldContext fieldContext, OneOfField parent, ContextualLookupHelper lookupHelper) Construct a SingleField from a parsed oneof subfield context -
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()Returns the value of thecommentrecord component.booleanReturns the value of thedeprecatedrecord component.final booleanIndicates whether some other object is "equal to" this one.intReturns the value of thefieldNumberrecord component.final inthashCode()Returns a hash code value for this object.Get 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.Returns the value of themessageTyperecord component.Returns the value of themessageTypeCodecPackagerecord component.Returns the value of themessageTypeModelPackagerecord component.Returns the value of themessageTypeTestPackagerecord component.Get the name for this type that is added to write/sizeof etc.name()Returns the value of thenamerecord component.booleanGet if this field is an optional value type, optionals are handled in protobuf by value type objects for primitivesparent()Returns the value of theparentrecord component.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()Returns the value of therepeatedrecord component.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 numberfinal StringtoString()Returns a string representation of this record class.type()Returns the value of thetyperecord component.Methods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.hedera.pbj.compiler.impl.Field
maxSize, nameCamelFirstLower, nameCamelFirstUpper
-
Constructor Details
-
SingleField
Construct a SingleField from a parsed field context- Parameters:
fieldContext- the field context to extra field data fromlookupHelper- lookup helper for finding packages and other global context data
-
SingleField
public SingleField(Protobuf3Parser.OneofFieldContext fieldContext, OneOfField parent, ContextualLookupHelper lookupHelper) Construct a SingleField from a parsed oneof subfield context- Parameters:
fieldContext- the field context to extra field data fromlookupHelper- lookup helper for finding packages and other global context data
-
SingleField
public SingleField(boolean repeated, Field.FieldType type, int fieldNumber, String name, String messageType, String messageTypeModelPackage, String messageTypeCodecPackage, String messageTypeTestPackage, String comment, boolean deprecated, OneOfField parent) Creates an instance of aSingleFieldrecord class.- Parameters:
repeated- the value for therepeatedrecord componenttype- the value for thetyperecord componentfieldNumber- the value for thefieldNumberrecord componentname- the value for thenamerecord componentmessageType- the value for themessageTyperecord componentmessageTypeModelPackage- the value for themessageTypeModelPackagerecord componentmessageTypeCodecPackage- the value for themessageTypeCodecPackagerecord componentmessageTypeTestPackage- the value for themessageTypeTestPackagerecord componentcomment- the value for thecommentrecord componentdeprecated- the value for thedeprecatedrecord componentparent- the value for theparentrecord component
-
-
Method Details
-
optionalValueType
public boolean optionalValueType()Get if this field is an optional value type, optionals are handled in protobuf by value type objects for primitives- Specified by:
optionalValueTypein interfaceField- Returns:
- true if this field is option by use of a protobuf value type, otherwise false
-
protobufFieldType
Get the protobuf field type for this field- Specified by:
protobufFieldTypein interfaceField- Returns:
- this fields type in protobuf format
-
javaFieldType
Get the Java field type for this field- Specified by:
javaFieldTypein interfaceField- Returns:
- this fields type in Java format
-
javaFieldTypeBase
Description copied from interface:FieldGet the Java field type for this field. UnlikeField.javaFieldType(), this method returns the base type for repeated and oneOf fields.- Specified by:
javaFieldTypeBasein interfaceField- Returns:
- this fields type in Java format
-
javaFieldTypeForTest
-
methodNameType
Get the name for this type that is added to write/sizeof etc. methods.- Specified by:
methodNameTypein interfaceField- Returns:
- Name for type used in method names
-
addAllNeededImports
public void addAllNeededImports(Set<String> imports, boolean modelImports, boolean codecImports, boolean testImports) Add all the needed imports for this field to the supplied set.- Specified by:
addAllNeededImportsin interfaceField- 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
Get the java code to parse the value for this field from input -
javaDefault
Get the java code default value for this field, "null" for object types- Specified by:
javaDefaultin interfaceField- Returns:
- code for default value
-
schemaFieldsDef
Get the field definitions line of code for schema file for this field. One line for single fields and multiple for oneofs.- Specified by:
schemaFieldsDefin interfaceField- Returns:
- field definition lines of code
-
schemaGetFieldsDefCase
Get the schema case statement for getting the field definition by field number- Specified by:
schemaGetFieldsDefCasein interfaceField- Returns:
- java source code for case statement to get field def for field number
-
parserFieldsSetMethodCase
Get the case statement for setting this method to go in parser set method code- Specified by:
parserFieldsSetMethodCasein interfaceField- Returns:
- java source code for case statement setting this field
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared withObjects::equals(Object,Object); primitive components are compared with '=='. -
repeated
public boolean repeated()Returns the value of therepeatedrecord component. -
type
Returns the value of thetyperecord component. -
fieldNumber
public int fieldNumber()Returns the value of thefieldNumberrecord component.- Specified by:
fieldNumberin interfaceField- Returns:
- the value of the
fieldNumberrecord component
-
name
Returns the value of thenamerecord component. -
messageType
Returns the value of themessageTyperecord component.- Specified by:
messageTypein interfaceField- Returns:
- the value of the
messageTyperecord component
-
messageTypeModelPackage
Returns the value of themessageTypeModelPackagerecord component.- Returns:
- the value of the
messageTypeModelPackagerecord component
-
messageTypeCodecPackage
Returns the value of themessageTypeCodecPackagerecord component.- Returns:
- the value of the
messageTypeCodecPackagerecord component
-
messageTypeTestPackage
Returns the value of themessageTypeTestPackagerecord component.- Returns:
- the value of the
messageTypeTestPackagerecord component
-
comment
Returns the value of thecommentrecord component. -
deprecated
public boolean deprecated()Returns the value of thedeprecatedrecord component.- Specified by:
deprecatedin interfaceField- Returns:
- the value of the
deprecatedrecord component
-
parent
Returns the value of theparentrecord component.
-