Package com.hedera.pbj.compiler.impl
Record Class OneOfField
java.lang.Object
java.lang.Record
com.hedera.pbj.compiler.impl.OneOfField
- All Implemented Interfaces:
Field
public record OneOfField(String parentMessageName, String name, String comment, List<Field> fields, boolean repeated, boolean deprecated, boolean comparable)
extends Record
implements Field
An implementation of Field for OneOf 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
ConstructorsConstructorDescriptionOneOfField(Protobuf3Parser.OneofContext oneOfContext, String parentMessageName, ContextualLookupHelper lookupHelper) Create a OneOf field from parser contextOneOfField(String parentMessageName, String name, String comment, List<Field> fields, boolean repeated, boolean deprecated, boolean comparable) Creates an instance of aOneOfFieldrecord class. -
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 thecomparablerecord component.booleanReturns the value of thedeprecatedrecord component.final booleanIndicates whether some other object is "equal to" this one.intGet the field number, the number of the field in the parent messagefields()Returns the value of thefieldsrecord component.Get reference to enum class in Java codefinal 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.Get the name for this type that is added to write/sizeof etc.name()Returns the value of thenamerecord component.Returns the value of theparentMessageNamerecord component.N/A for OneOfFieldGet 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 numbertoString()Helpful debug toStringtype()Get the field type for this field, the field type is independent of repeatedMethods inherited from class java.lang.Object
clone, finalize, getClass, notify, notifyAll, wait, wait, waitMethods inherited from interface com.hedera.pbj.compiler.impl.Field
maxSize, messageType, nameCamelFirstLower, nameCamelFirstUpper, optionalValueType, parent
-
Constructor Details
-
OneOfField
public OneOfField(Protobuf3Parser.OneofContext oneOfContext, String parentMessageName, ContextualLookupHelper lookupHelper) Create a OneOf field from parser context- Parameters:
oneOfContext- the parsed one of fieldparentMessageName- the name of the parent messagelookupHelper- helper for accessing global context
-
OneOfField
public OneOfField(String parentMessageName, String name, String comment, List<Field> fields, boolean repeated, boolean deprecated, boolean comparable) Creates an instance of aOneOfFieldrecord class.- Parameters:
parentMessageName- the value for theparentMessageNamerecord componentname- the value for thenamerecord componentcomment- the value for thecommentrecord componentfields- the value for thefieldsrecord componentrepeated- the value for therepeatedrecord componentdeprecated- the value for thedeprecatedrecord componentcomparable- the value for thecomparablerecord component
-
-
Method Details
-
type
Get the field type for this field, the field type is independent of repeated -
fieldNumber
public int fieldNumber()Get the field number, the number of the field in the parent message- Specified by:
fieldNumberin interfaceField- Returns:
- this fields number
-
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
-
className
-
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
-
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
N/A for OneOfField -
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
-
getEnumClassRef
Get reference to enum class in Java code- Returns:
- enum class reference
-
toString
Helpful debug toString -
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 '=='. -
parentMessageName
Returns the value of theparentMessageNamerecord component.- Returns:
- the value of the
parentMessageNamerecord component
-
name
Returns the value of thenamerecord component. -
comment
Returns the value of thecommentrecord component. -
fields
Returns the value of thefieldsrecord component.- Returns:
- the value of the
fieldsrecord component
-
repeated
public boolean repeated()Returns the value of therepeatedrecord component. -
deprecated
public boolean deprecated()Returns the value of thedeprecatedrecord component.- Specified by:
deprecatedin interfaceField- Returns:
- the value of the
deprecatedrecord component
-
comparable
public boolean comparable()Returns the value of thecomparablerecord component.- Returns:
- the value of the
comparablerecord component
-