Class PrimaryKeyGenerator


  • public class PrimaryKeyGenerator
    extends Object
    Class to handle the generation of a PK class for a persistable class. The primary key class is generated as its own class, rather than as an inner class of the original class. NOTE: This will only currently handle persistable fields. If you require persistable properties then get the code and extend this.
    • Constructor Detail

      • PrimaryKeyGenerator

        public PrimaryKeyGenerator​(AbstractClassMetaData cmd,
                                   ClassEnhancer enhancer)
        Constructor for a PK generator for the specified class.
        Parameters:
        cmd - Metadata for the class that needs a primary key class
        enhancer - The enhancer being used
    • Method Detail

      • generate

        public byte[] generate()
        Method to generate the primary key class.
        Returns:
        The bytes for this pk class
      • addFields

        protected void addFields​(ClassWriter cw)
        Method to add fields to match the PK fields of the persistable class
        Parameters:
        cw - The ClassWriter to use
      • addDefaultConstructor

        protected void addDefaultConstructor​(ClassWriter cw)
        Method to add an empty default constructor.
        Parameters:
        cw - The ClassWriter to use
      • addStringConstructor

        protected void addStringConstructor​(ClassWriter cw)
        Method to add a constructor taking in a String.
        Parameters:
        cw - The ClassWriter to use
      • addMethodToString

        protected void addMethodToString​(ClassWriter cw)
        Method to add a toString() method.
        Parameters:
        cw - The ClassWriter to use
      • addMethodEquals

        protected void addMethodEquals​(ClassWriter cw)
        Method to add an equals() method.
        Parameters:
        cw - The ClassWriter to use
      • addMethodHashCode

        protected void addMethodHashCode​(ClassWriter cw)
        Method to add a hashCode() method.
        Parameters:
        cw - The ClassWriter to use