Class BasicPOJOClass

java.lang.Object
org.hibernate.tool.internal.export.java.BasicPOJOClass
All Implemented Interfaces:
ImportContext, MetaAttributeConstants, POJOClass
Direct Known Subclasses:
ComponentPOJOClass, EntityPOJOClass

public abstract class BasicPOJOClass extends Object implements POJOClass, MetaAttributeConstants
Abstract implementation of POJOClass. To be extended by ComponentPOJO and EntityPOJO
Author:
max, Amit Bhayani
  • Field Details

    • importContext

      protected ImportContext importContext
    • meta

      protected org.hibernate.mapping.MetaAttributable meta
    • c2j

      protected final Cfg2JavaTool c2j
  • Constructor Details

    • BasicPOJOClass

      public BasicPOJOClass(org.hibernate.mapping.MetaAttributable ma, Cfg2JavaTool c2j)
  • Method Details

    • init

      protected void init()
    • getPackageDeclaration

      protected String getPackageDeclaration(String pkgName)
    • getPackageDeclaration

      public String getPackageDeclaration()
      Description copied from interface: POJOClass
      Returns "package packagename;" where packagename is either the declared packagename, or the one provide via meta attribute "generated-class". Returns "// default package" if no package declarition available.
      Specified by:
      getPackageDeclaration in interface POJOClass
    • getPackageName

      public String getPackageName()
      Return package name. Note: Does not handle inner classes
      Specified by:
      getPackageName in interface POJOClass
    • getShortName

      public String getShortName()
      Specified by:
      getShortName in interface POJOClass
    • getQualifiedDeclarationName

      public String getQualifiedDeclarationName()
      Specified by:
      getQualifiedDeclarationName in interface POJOClass
    • getDeclarationName

      public String getDeclarationName()
      Specified by:
      getDeclarationName in interface POJOClass
      Returns:
      unqualified classname for this class (can be changed by meta attribute "generated-class")
    • getGeneratedClassName

      protected String getGeneratedClassName()
    • qualifyInnerClass

      protected String qualifyInnerClass(String className)
    • getMappedClassName

      protected abstract String getMappedClassName()
    • getMetaAsString

      public String getMetaAsString(String attribute)
    • hasMetaAttribute

      public boolean hasMetaAttribute(String attribute)
    • getMetaAsString

      public String getMetaAsString(String attribute, String seperator)
    • getMetaAsBool

      public boolean getMetaAsBool(String attribute)
    • getMetaAsBool

      public boolean getMetaAsBool(String attribute, boolean defaultValue)
    • getClassJavaDoc

      public String getClassJavaDoc(String fallback, int indent)
      Description copied from interface: POJOClass
      Returns the javadoc associated with the class.
      Specified by:
      getClassJavaDoc in interface POJOClass
      Parameters:
      fallback - the default text if nothing else is found
      indent - how many spaces should be added
      Returns:
    • getClassModifiers

      public String getClassModifiers()
      Specified by:
      getClassModifiers in interface POJOClass
    • getDeclarationType

      public String getDeclarationType()
      Specified by:
      getDeclarationType in interface POJOClass
      Returns:
      declaration type "interface" or "class"
    • isInterface

      public boolean isInterface()
      Specified by:
      isInterface in interface POJOClass
    • getExtendsDeclaration

      public String getExtendsDeclaration()
      Specified by:
      getExtendsDeclaration in interface POJOClass
    • getImplementsDeclaration

      public String getImplementsDeclaration()
      Specified by:
      getImplementsDeclaration in interface POJOClass
    • generateEquals

      public String generateEquals(String thisName, String otherName, boolean useGenerics)
      Specified by:
      generateEquals in interface POJOClass
    • getAllPropertiesIterator

      public abstract Iterator<org.hibernate.mapping.Property> getAllPropertiesIterator()
      returns the properties that would be visible on this entity as a pojo. This does not return *all* properties since hibernate has certain properties that are only relevant in context of persistence.
      Specified by:
      getAllPropertiesIterator in interface POJOClass
    • generateEquals

      protected String generateEquals(String thisName, String otherName, Iterator<org.hibernate.mapping.Property> allPropertiesIterator, boolean useGenerics)
    • getExtraClassCode

      public String getExtraClassCode()
      Specified by:
      getExtraClassCode in interface POJOClass
    • needsEqualsHashCode

      public boolean needsEqualsHashCode()
      Specified by:
      needsEqualsHashCode in interface POJOClass
    • getExtends

      public abstract String getExtends()
      Specified by:
      getExtends in interface POJOClass
    • getImplements

      public abstract String getImplements()
      Specified by:
      getImplements in interface POJOClass
    • importType

      public String importType(String fqcn)
      Description copied from interface: ImportContext
      Add fqcn to the import list. Returns fqcn as needed in source code. Attempts to handle fqcn with array and generics references. e.g. java.util.Collectioninvalid input: '<'org.marvel.Hulk> imports java.util.Collection and returns Collection org.marvel.Hulk[] imports org.marvel.Hulk and returns Hulk
      Specified by:
      importType in interface ImportContext
      Parameters:
      fqcn -
      Returns:
      import string
    • generateImports

      public String generateImports()
      Specified by:
      generateImports in interface ImportContext
    • staticImport

      public String staticImport(String fqcn, String member)
      Specified by:
      staticImport in interface ImportContext
    • generateBasicAnnotation

      public String generateBasicAnnotation(org.hibernate.mapping.Property property)
      Specified by:
      generateBasicAnnotation in interface POJOClass
    • generateAnnColumnAnnotation

      public String generateAnnColumnAnnotation(org.hibernate.mapping.Property property)
      Specified by:
      generateAnnColumnAnnotation in interface POJOClass
    • appendCommonColumnInfo

      protected void appendCommonColumnInfo(StringBuffer annotations, org.hibernate.mapping.Column column, boolean insertable, boolean updatable)
    • getToStringPropertiesIterator

      public Iterator<org.hibernate.mapping.Property> getToStringPropertiesIterator()
      Specified by:
      getToStringPropertiesIterator in interface POJOClass
    • getEqualsHashCodePropertiesIterator

      public Iterator<org.hibernate.mapping.Property> getEqualsHashCodePropertiesIterator()
      Specified by:
      getEqualsHashCodePropertiesIterator in interface POJOClass
    • needsToString

      public boolean needsToString()
      Specified by:
      needsToString in interface POJOClass
    • hasMetaAttribute

      public boolean hasMetaAttribute(org.hibernate.mapping.MetaAttributable pc, String attribute)
    • getMetaAttribAsBool

      public boolean getMetaAttribAsBool(org.hibernate.mapping.MetaAttributable pc, String attribute, boolean defaultValue)
    • hasFieldJavaDoc

      public boolean hasFieldJavaDoc(org.hibernate.mapping.Property property)
    • getFieldJavaDoc

      public String getFieldJavaDoc(org.hibernate.mapping.Property property, int indent)
      Specified by:
      getFieldJavaDoc in interface POJOClass
    • getFieldDescription

      public String getFieldDescription(org.hibernate.mapping.Property property)
      Specified by:
      getFieldDescription in interface POJOClass
    • getGetterSignature

      public String getGetterSignature(org.hibernate.mapping.Property p)
      Method getGetterSignature.
      Returns:
      String
    • getPropertyName

      public String getPropertyName(org.hibernate.mapping.Property p)
      Parameters:
      p -
      Returns:
      foo -> Foo, FOo -> FOo
    • getCollectionNameFor

      public String getCollectionNameFor(org.hibernate.mapping.Property property)
    • beanCapitalize

      public static String beanCapitalize(String fieldname)
      foo -> Foo FOo -> FOo
    • isComponent

      public boolean isComponent(org.hibernate.mapping.Property property)
    • generateHashCode

      public String generateHashCode(org.hibernate.mapping.Property property, String result, String thisName, boolean jdk5)
    • getFieldModifiers

      public String getFieldModifiers(org.hibernate.mapping.Property property)
    • getPropertyGetModifiers

      public String getPropertyGetModifiers(org.hibernate.mapping.Property property)
    • getPropertySetModifiers

      public String getPropertySetModifiers(org.hibernate.mapping.Property property)
    • isRequiredInConstructor

      protected boolean isRequiredInConstructor(org.hibernate.mapping.Property field)
    • needsMinimalConstructor

      public boolean needsMinimalConstructor()
      Specified by:
      needsMinimalConstructor in interface POJOClass
    • needsFullConstructor

      public boolean needsFullConstructor()
      Specified by:
      needsFullConstructor in interface POJOClass
    • getJavaTypeName

      public String getJavaTypeName(org.hibernate.mapping.Property p, boolean useGenerics)
      Specified by:
      getJavaTypeName in interface POJOClass
    • hasFieldInitializor

      public boolean hasFieldInitializor(org.hibernate.mapping.Property p, boolean useGenerics)
    • getFieldInitialization

      public String getFieldInitialization(org.hibernate.mapping.Property p, boolean useGenerics)
      Specified by:
      getFieldInitialization in interface POJOClass