com.dooapp.gaedo.blueprints.transformers.LiteralHelper Maven / Gradle / Ivy
package com.dooapp.gaedo.blueprints.transformers;
import com.dooapp.gaedo.blueprints.ObjectCache;
import com.dooapp.gaedo.properties.Property;
/**
* Some utility methods allowing one to store class-full data into class-less fields (Object and Serializable, as an example)
* @author ndx
*
*/
public class LiteralHelper {
public static final char CLASS_VALUE_SEPARATOR = ':';
/**
* Get type prefix of the given literal transformer for later loading it
* @param propertyValue a value in which we want to extract type prefix
* @return the value before ":"
*/
public static String getTypePrefix(String propertyValue) {
return propertyValue.substring(0, propertyValue.indexOf(CLASS_VALUE_SEPARATOR));
}
public static String getValueIn(String propertyValue) {
return propertyValue.substring(propertyValue.indexOf(CLASS_VALUE_SEPARATOR)+1);
}
public static String toString(Class> valueClass, String string) {
return valueClass.getCanonicalName()+CLASS_VALUE_SEPARATOR+string;
}
/**
* Get the property text for the given literal value, considered as a value of given property type
* @param propertyClass supposed class of property. If it is not a literal (Object or Serializable, as an example),
* then type is infered dynamically and set as prefix
* @param propertyValue
* @return
*/
public static String getLiteralTextFor(Class propertyClass, Object propertyValue) {
String text = null;
if(Literals.containsKey(propertyClass)) {
LiteralTransformer
© 2015 - 2025 Weber Informatics LLC | Privacy Policy