Class Utilities


  • public class Utilities
    extends java.lang.Object
    Author:
    Collin Alpert
    • Constructor Summary

      Constructors 
      Constructor Description
      Utilities()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.util.List<TableNameColumnReference> getAllFields​(java.lang.Class<? extends BaseEntity> instanceClass)
      Gets all the fields and the fields of foreign key objects in this entity.
      static java.util.List<TableNameColumnReference> getAllFields​(java.lang.Class<? extends BaseEntity> instanceClass, java.lang.String alias)
      Gets all the fields and the fields of foreign key objects in this entity.
      static java.lang.String getColumnName​(java.lang.reflect.Field field)
      Gets the corresponding table column name of a field.
      static java.util.List<java.lang.reflect.Field> getEntityFields​(java.lang.Class<? extends BaseEntity> instanceClass)  
      static java.util.List<java.lang.reflect.Field> getEntityFields​(java.lang.Class<? extends BaseEntity> instanceClass, boolean includeForeignKeys)  
      static java.util.List<java.lang.reflect.Field> getEntityFields​(java.lang.Class<? extends BaseEntity> instanceClass, java.lang.Class<?> delimiter)  
      static java.lang.String getTableName​(java.lang.Class<?> type)
      Gets the database table name from the TableName attribute on the class.
      static void log​(java.lang.Object text)
      Prints messages to the query, while considering the DBConnection.LOG_QUERIES constant.
      static void logf​(java.lang.String text, java.lang.Object... params)
      Prints formatted messages to the query, while considering the DBConnection.LOG_QUERIES constant.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Utilities

        public Utilities()
    • Method Detail

      • getEntityFields

        public static java.util.List<java.lang.reflect.Field> getEntityFields​(java.lang.Class<? extends BaseEntity> instanceClass)
      • getEntityFields

        public static java.util.List<java.lang.reflect.Field> getEntityFields​(java.lang.Class<? extends BaseEntity> instanceClass,
                                                                              boolean includeForeignKeys)
      • getEntityFields

        public static java.util.List<java.lang.reflect.Field> getEntityFields​(java.lang.Class<? extends BaseEntity> instanceClass,
                                                                              java.lang.Class<?> delimiter)
      • getAllFields

        public static java.util.List<TableNameColumnReference> getAllFields​(java.lang.Class<? extends BaseEntity> instanceClass)
        Gets all the fields and the fields of foreign key objects in this entity.
        Parameters:
        instanceClass - The class to get the fields from.
        Returns:
        A list of columns including references to their table.
      • getAllFields

        public static java.util.List<TableNameColumnReference> getAllFields​(java.lang.Class<? extends BaseEntity> instanceClass,
                                                                            java.lang.String alias)
        Gets all the fields and the fields of foreign key objects in this entity.
        Parameters:
        instanceClass - The class to get the fields from.
        alias - The alias that nested properties will use.
        Returns:
        A list of columns including references to their table.
      • log

        public static void log​(java.lang.Object text)
        Prints messages to the query, while considering the DBConnection.LOG_QUERIES constant.
        Parameters:
        text - The message to print.
      • logf

        public static void logf​(java.lang.String text,
                                java.lang.Object... params)
        Prints formatted messages to the query, while considering the DBConnection.LOG_QUERIES constant.
        Parameters:
        text - The formatted text.
        params - The parameters to be inserted into the string.
      • getTableName

        public static java.lang.String getTableName​(java.lang.Class<?> type)
        Gets the database table name from the TableName attribute on the class. If there is no attribute, the class name in lower case characters is returned.
        Parameters:
        type - The entity to get the table name of.
        Returns:
        The table name.
      • getColumnName

        public static java.lang.String getColumnName​(java.lang.reflect.Field field)
        Gets the corresponding table column name of a field.
        Parameters:
        field - The field representing the column in a table.
        Returns:
        The column name in the table.