Package com.hedera.pbj.compiler.impl
Class ContextualLookupHelper
java.lang.Object
com.hedera.pbj.compiler.impl.ContextualLookupHelper
Wrapper around LookupHelper adding the context of which protobuf source file the lookup is happening within. This
makes it easy to carry the source files context for lookup so that the package and imports are correctly understood.
-
Constructor Summary
ConstructorsConstructorDescriptionContextualLookupHelper(LookupHelper lookupHelper, File srcProtoFileContext) Create a new ContextualLookupHelper delegating tolookupHelperwith the context ofsrcProtoFileContext. -
Method Summary
Modifier and TypeMethodDescriptionGet the set of fields that are comparable for a given message.getFullyQualifiedMessageClassname(FileType fileType, Protobuf3Parser.MessageDefContext message) Get the fully qualified class name for a msgDef with given fileType that would be generated by PBJ.getPackageFieldMessageType(FileType fileType, Protobuf3Parser.FieldContext fieldContext) Get the Java package a class should be generated into for a given fieldContext and file type.getPackageFieldMessageType(FileType fileType, Protobuf3Parser.Type_Context typeContext) Get the Java package a class should be generated into for a given typeContext and file type.getPackageForEnum(FileType fileType, Protobuf3Parser.EnumDefContext enumDef) Get the Java package a class should be generated into for a given enum and file type.getPackageForMessage(FileType fileType, Protobuf3Parser.MessageDefContext message) Get the Java package a class should be generated into for a given msgDef and file type.getPackageOneofFieldMessageType(FileType fileType, Protobuf3Parser.OneofFieldContext fieldContext) Get the PBJ Java package a class should be generated into for a given fieldContext and file type.getUnqualifiedClassForMessage(FileType fileType, Protobuf3Parser.MessageDefContext context) Get the unqualified Java class name for given message or enum.booleanisEnum(Protobuf3Parser.MessageTypeContext messageType) Check if the given messageType is a known enum
-
Constructor Details
-
ContextualLookupHelper
Create a new ContextualLookupHelper delegating tolookupHelperwith the context ofsrcProtoFileContext.- Parameters:
lookupHelper- Lookup helper that we are delegating tosrcProtoFileContext- The proto source file for context
-
-
Method Details
-
getUnqualifiedClassForMessage
public String getUnqualifiedClassForMessage(FileType fileType, Protobuf3Parser.MessageDefContext context) Get the unqualified Java class name for given message or enum.- Parameters:
fileType- The type of file we want the package forcontext- Parser Context, a message or enum- Returns:
- java package to put model class in
-
getFullyQualifiedMessageClassname
public String getFullyQualifiedMessageClassname(FileType fileType, Protobuf3Parser.MessageDefContext message) Get the fully qualified class name for a msgDef with given fileType that would be generated by PBJ.- Parameters:
fileType- The type of file we want the fully qualified class name formessage- The msgDef to get fully qualified class name for- Returns:
- fully qualified class name
-
getComparableFields
Get the set of fields that are comparable for a given message.- Parameters:
message- The message to get comparable fields for- Returns:
- set of field names that are comparable
-
getPackageForMessage
Get the Java package a class should be generated into for a given msgDef and file type.- Parameters:
fileType- The type of file we want the package formessage- The msgDef to get package for- Returns:
- java package to put model class in
-
getPackageForEnum
Get the Java package a class should be generated into for a given enum and file type.- Parameters:
fileType- The type of file we want the package forenumDef- The enum to get package for- Returns:
- java package to put model class in
-
getPackageFieldMessageType
public String getPackageFieldMessageType(FileType fileType, Protobuf3Parser.FieldContext fieldContext) Get the Java package a class should be generated into for a given fieldContext and file type.- Parameters:
fileType- The type of file we want the package forfieldContext- The field to get package for message type for- Returns:
- java package to put model class in
-
getPackageFieldMessageType
public String getPackageFieldMessageType(FileType fileType, Protobuf3Parser.Type_Context typeContext) Get the Java package a class should be generated into for a given typeContext and file type.- Parameters:
fileType- The type of file we want the package fortypeContext- The field to get package for message type for- Returns:
- java package to put model class in
-
getPackageOneofFieldMessageType
public String getPackageOneofFieldMessageType(FileType fileType, Protobuf3Parser.OneofFieldContext fieldContext) Get the PBJ Java package a class should be generated into for a given fieldContext and file type.- Parameters:
fileType- The type of file we want the package forfieldContext- The field to get package for message type for- Returns:
- java package to put model class in
-
isEnum
Check if the given messageType is a known enum- Parameters:
messageType- to check if enum- Returns:
- true if known as an enum, recorded by addEnum()
-