Class ContextualLookupHelper

java.lang.Object
com.hedera.pbj.compiler.impl.ContextualLookupHelper

public class ContextualLookupHelper extends Object
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 Details

    • ContextualLookupHelper

      public ContextualLookupHelper(LookupHelper lookupHelper, File srcProtoFileContext)
      Create a new ContextualLookupHelper delegating to lookupHelper with the context of srcProtoFileContext.
      Parameters:
      lookupHelper - Lookup helper that we are delegating to
      srcProtoFileContext - 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 for
      context - 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 for
      message - The msgDef to get fully qualified class name for
      Returns:
      fully qualified class name
    • getComparableFields

      public List<String> getComparableFields(Protobuf3Parser.MessageDefContext message)
      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

      public String getPackageForMessage(FileType fileType, Protobuf3Parser.MessageDefContext message)
      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 for
      message - The msgDef to get package for
      Returns:
      java package to put model class in
    • getPackageForEnum

      public String getPackageForEnum(FileType fileType, Protobuf3Parser.EnumDefContext enumDef)
      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 for
      enumDef - 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 for
      fieldContext - 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 for
      typeContext - 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 for
      fieldContext - The field to get package for message type for
      Returns:
      java package to put model class in
    • isEnum

      public boolean isEnum(Protobuf3Parser.MessageTypeContext messageType)
      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()