Class ClassTemplate

java.lang.Object
org.opendaylight.yangtools.binding.codegen.BaseTemplate
org.opendaylight.yangtools.binding.codegen.ClassTemplate
Direct Known Subclasses:
ListKeyTemplate, UnionTemplate

public class ClassTemplate extends BaseTemplate
Template for generating JAVA class.
  • Field Details

  • Constructor Details

    • ClassTemplate

      public ClassTemplate(GeneratedTransferObject genType)
      Creates instance of this class with concrete genType.
      Parameters:
      genType - generated transfer object which will be transformed to JAVA class source code
    • ClassTemplate

      public ClassTemplate(org.opendaylight.yangtools.binding.codegen.AbstractJavaGeneratedType javaType, GeneratedTransferObject genType)
      Creates instance of this class with concrete genType.
      Parameters:
      genType - generated transfer object which will be transformed to JAVA class source code
  • Method Details

    • generateAsInnerClass

      public CharSequence generateAsInnerClass()
      Generates JAVA class source code (class body only).
      Returns:
      string with JAVA class body source code
    • body

      protected CharSequence body()
    • generateBody

      protected CharSequence generateBody(boolean isInnerClass)
      Template method which generates class body.
      Parameters:
      isInnerClass - boolean value which specify if generated class is|isn't inner
      Returns:
      string with class source code in JAVA format
    • propertyMethods

      protected CharSequence propertyMethods()
    • innerClassesDeclarations

      protected CharSequence innerClassesDeclarations()
      Template method which generates inner classes inside this interface.
      Returns:
      string with the source code for inner classes in JAVA format
    • constructors

      protected CharSequence constructors()
    • allValuesConstructor

      public CharSequence allValuesConstructor()
    • genUnionConstructor

      protected CharSequence genUnionConstructor()
    • genConstructor

      protected CharSequence genConstructor(GeneratedProperty property, Iterable<GeneratedProperty> other)
    • generateRestrictions

      public CharSequence generateRestrictions(Type type, String paramName, Type returnType)
    • copyConstructor

      protected CharSequence copyConstructor()
    • parentConstructor

      protected CharSequence parentConstructor()
    • defaultInstance

      protected CharSequence defaultInstance()
    • bitsArgs

      protected CharSequence bitsArgs()
    • propsAsArgs

      protected CharSequence propsAsArgs(Iterable<GeneratedProperty> properties)
    • generateClassDeclaration

      protected CharSequence generateClassDeclaration(boolean isInnerClass)
      Template method which generates JAVA class declaration.
      Parameters:
      isInnerClass - boolean value which specify if generated class is|isn't inner
      Returns:
      string with class declaration in JAVA format
    • finalClass

      protected String finalClass()
    • enumDeclarations

      protected CharSequence enumDeclarations()
      Template method which generates JAVA enum type.
      Returns:
      string with inner enum source code in JAVA format
    • suidDeclaration

      protected CharSequence suidDeclaration()
    • annotationDeclaration

      protected CharSequence annotationDeclaration()
    • constantsDeclarations

      protected CharSequence constantsDeclarations()
      Template method which generates JAVA constants.
      Returns:
      string with constants in JAVA format
    • generateFields

      protected CharSequence generateFields()
      Template method which generates JAVA class attributes.
      Returns:
      string with the class attributes in JAVA format
    • isReadOnly

      protected boolean isReadOnly(GeneratedProperty field)
    • generateHashCode

      protected String generateHashCode()
      Template method which generates the method hashCode().
      Returns:
      string with the hashCode() method definition in JAVA format
    • getPropByName

      public GeneratedProperty getPropByName(String name)
    • getterByName

      protected static Optional<MethodSignature> getterByName(Iterable<MethodSignature> methods, String implMethodName)
    • propertyNameFromGetter

      protected static String propertyNameFromGetter(MethodSignature getter)
    • propertyNameFromGetter

      protected static String propertyNameFromGetter(String getterName)