Class JPAProperties

java.lang.Object
org.apache.openjpa.persistence.JPAProperties

public class JPAProperties extends 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
  • Field Details

  • Constructor Details

    • JPAProperties

      public JPAProperties()
  • Method Details

    • isValidKey

      public static boolean isValidKey(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 String getBeanProperty(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(Class<T> resultType, String key, 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 Object convertToUserValue(String key, 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 Enum<E>> E getEnumValue(Class<E> type, String key, Map<String,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 Enum<E>> E getEnumValue(Class<E> type, E[] values, String key, Map<String,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 Enum<E>> E getEnumValue(Class<E> type, 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 Enum<E>> E getEnumValue(Class<E> type, E[] values, 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.