Class JPAProperties


  • public class JPAProperties
    extends java.lang.Object
    Enumerates configuration property keys defined in JPA 2.0 Specification.
    Provides static utility functions to read their values from supplied map of properties.
    Provides static utility functions to convert them to values that are fit for OpenJPA implementation.
    Since:
    2.0.0
    Author:
    Pinaki Poddar
    • Constructor Summary

      Constructors 
      Constructor Description
      JPAProperties()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static <T> T convertToKernelValue​(java.lang.Class<T> resultType, java.lang.String key, java.lang.Object value)
      Convert the given user value to a value consumable by OpenJPA kernel constructs.
      static java.lang.Object convertToUserValue​(java.lang.String key, java.lang.Object value)
      Convert the given kernel value to a value visible to the user.
      static java.lang.String getBeanProperty​(java.lang.String key)
      Gets a bean-style property name from the given key.
      static <E extends java.lang.Enum<E>>
      E
      getEnumValue​(java.lang.Class<E> type, E[] values, java.lang.Object val)
      Gets a enum value of the given type from the given value.
      static <E extends java.lang.Enum<E>>
      E
      getEnumValue​(java.lang.Class<E> type, E[] values, java.lang.String key, java.util.Map<java.lang.String,​java.lang.Object> prop)
      Gets a enum value of the given type from the given properties looking up with the given key.
      static <E extends java.lang.Enum<E>>
      E
      getEnumValue​(java.lang.Class<E> type, java.lang.Object val)
      Gets a enum value of the given type from the given value.
      static <E extends java.lang.Enum<E>>
      E
      getEnumValue​(java.lang.Class<E> type, java.lang.String key, java.util.Map<java.lang.String,​java.lang.Object> prop)
      Get the value of the given key from the given properties after converting it to the given enumerated value.
      static boolean isValidKey​(java.lang.String key)
      Is the given key appears to be a valid JPA specification defined key?
      • Methods inherited from class java.lang.Object

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

      • JPAProperties

        public JPAProperties()
    • Method Detail

      • isValidKey

        public static boolean isValidKey​(java.lang.String key)
        Is the given key appears to be a valid JPA specification defined key?
        Returns:
        true if the given string merely prefixed with jakarta.persistence.. Does not really check all the keys defined in the specification.
      • getBeanProperty

        public static java.lang.String getBeanProperty​(java.lang.String key)
        Gets a bean-style property name from the given key.
        Parameters:
        key - must begin with JPA property prefix jakarta.persistence
        Returns:
        concatenates each part of the string leaving out jakarta.persistence. prefix. Part of string is what appears between DOT character.
      • convertToKernelValue

        public static <T> T convertToKernelValue​(java.lang.Class<T> resultType,
                                                 java.lang.String key,
                                                 java.lang.Object value)
        Convert the given user value to a value consumable by OpenJPA kernel constructs.
        Returns:
        the same value if the given key is not a valid JPA property key or the value is null.
      • convertToUserValue

        public static java.lang.Object convertToUserValue​(java.lang.String key,
                                                          java.lang.Object value)
        Convert the given kernel value to a value visible to the user.
        Returns:
        the same value if the given key is not a valid JPA property key or the value is null.
      • getEnumValue

        public static <E extends java.lang.Enum<E>> E getEnumValue​(java.lang.Class<E> type,
                                                                   java.lang.String key,
                                                                   java.util.Map<java.lang.String,​java.lang.Object> prop)
        Get the value of the given key from the given properties after converting it to the given enumerated value.
      • getEnumValue

        public static <E extends java.lang.Enum<E>> E getEnumValue​(java.lang.Class<E> type,
                                                                   E[] values,
                                                                   java.lang.String key,
                                                                   java.util.Map<java.lang.String,​java.lang.Object> prop)
        Gets a enum value of the given type from the given properties looking up with the given key. Converts the original value from a String or ordinal number, if necessary. Conversion from an integral number to enum value is only attempted if the allowed enum values are provided as non-null, non-empty array.
        Returns:
        null if the key does not exist in the given properties.
      • getEnumValue

        public static <E extends java.lang.Enum<E>> E getEnumValue​(java.lang.Class<E> type,
                                                                   java.lang.Object val)
        Gets a enum value of the given type from the given value. Converts the original value from a String, if necessary.
        Returns:
        null if the key does not exist in the given properties.
      • getEnumValue

        public static <E extends java.lang.Enum<E>> E getEnumValue​(java.lang.Class<E> type,
                                                                   E[] values,
                                                                   java.lang.Object val)
        Gets a enum value of the given type from the given value. Converts the original value from a String or ordinal number, if necessary. Conversion from an integral number to enum value is only attempted if the allowed enum values are provided as non-null, non-empty array.
        Returns:
        null if the key does not exist in the given properties.