/** * Convert the given user value to a value consumable by OpenJPA kernel constructs. * * @return the same value if the given key is not a valid JPA property key or the value is null. */ public static <T> T convertToKernelValue(Class<T> resultType, String key, Object value) { if (value == null) return null; if (JPAProperties.isValidKey(key)) { // works because enum values are identical String if (value instanceof CacheRetrieveMode || (value instanceof String && CACHE_RETRIEVE_MODE.equals(key))) { return (T)DataCacheRetrieveMode.valueOf(value.toString().trim().toUpperCase()); } else if (value instanceof CacheStoreMode || (value instanceof String && CACHE_STORE_MODE.equals(key))) { return (T)DataCacheStoreMode.valueOf(value.toString().trim().toUpperCase()); } } return (T)value; }
/** * Convert the given user value to a value consumable by OpenJPA kernel constructs. * * @return the same value if the given key is not a valid JPA property key or the value is null. */ public static <T> T convertToKernelValue(Class<T> resultType, String key, Object value) { if (value == null) return null; if (JPAProperties.isValidKey(key)) { // works because enum values are identical String if (value instanceof CacheRetrieveMode || (value instanceof String && CACHE_RETRIEVE_MODE.equals(key))) { return (T)DataCacheRetrieveMode.valueOf(value.toString().trim().toUpperCase(Locale.ENGLISH)); } else if (value instanceof CacheStoreMode || (value instanceof String && CACHE_STORE_MODE.equals(key))) { return (T)DataCacheStoreMode.valueOf(value.toString().trim().toUpperCase(Locale.ENGLISH)); } } return (T)value; }
/** * Convert the given user value to a value consumable by OpenJPA kernel constructs. * * @return the same value if the given key is not a valid JPA property key or the value is null. */ public static <T> T convertToKernelValue(Class<T> resultType, String key, Object value) { if (value == null) return null; if (JPAProperties.isValidKey(key)) { // works because enum values are identical String if (value instanceof CacheRetrieveMode || (value instanceof String && CACHE_RETRIEVE_MODE.equals(key))) { return (T)DataCacheRetrieveMode.valueOf(value.toString().trim().toUpperCase(Locale.ENGLISH)); } else if (value instanceof CacheStoreMode || (value instanceof String && CACHE_STORE_MODE.equals(key))) { return (T)DataCacheStoreMode.valueOf(value.toString().trim().toUpperCase(Locale.ENGLISH)); } } return (T)value; }
/** * Convert the given user value to a value consumable by OpenJPA kernel constructs. * * @return the same value if the given key is not a valid JPA property key or the value is null. */ public static <T> T convertToKernelValue(Class<T> resultType, String key, Object value) { if (value == null) return null; if (JPAProperties.isValidKey(key)) { // works because enum values are identical String if (value instanceof CacheRetrieveMode || (value instanceof String && CACHE_RETRIEVE_MODE.equals(key))) { return (T)DataCacheRetrieveMode.valueOf(value.toString().trim().toUpperCase()); } else if (value instanceof CacheStoreMode || (value instanceof String && CACHE_STORE_MODE.equals(key))) { return (T)DataCacheStoreMode.valueOf(value.toString().trim().toUpperCase()); } } return (T)value; }