Search in sources :

Example 1 with EnumSerialization

use of org.eclipse.sapphire.modeling.annotations.EnumSerialization in project liferay-ide by liferay.

the class ScriptPropertyEditorInput method getScriptLanguage.

public String getScriptLanguage() {
    String retval = null;
    try {
        Scriptable scriptable = _modelElement.nearest(Scriptable.class);
        Value<ScriptLanguageType> languageType = scriptable.getScriptLanguage();
        ScriptLanguageType scriptType = languageType.content();
        Class<?> scriptTypeClass = scriptType.getClass();
        Field field = scriptTypeClass.getFields()[scriptType.ordinal()];
        EnumSerialization enumValue = field.getAnnotation(EnumSerialization.class);
        retval = enumValue.primary();
    } catch (Exception e) {
    }
    return retval;
}
Also used : Field(java.lang.reflect.Field) EnumSerialization(org.eclipse.sapphire.modeling.annotations.EnumSerialization) ScriptLanguageType(com.liferay.ide.kaleo.core.model.ScriptLanguageType) Scriptable(com.liferay.ide.kaleo.core.model.Scriptable)

Example 2 with EnumSerialization

use of org.eclipse.sapphire.modeling.annotations.EnumSerialization in project liferay-ide by liferay.

the class KaleoModelUtil method getEnumSerializationAnnotation.

public static String getEnumSerializationAnnotation(Enum<?> type) {
    try {
        Class<?> typeClass = type.getClass();
        Field field = typeClass.getField(type.name());
        EnumSerialization enumAnnotation = field.getAnnotation(EnumSerialization.class);
        return enumAnnotation.primary();
    } catch (Exception e) {
        return null;
    }
}
Also used : Field(java.lang.reflect.Field) EnumSerialization(org.eclipse.sapphire.modeling.annotations.EnumSerialization) CoreException(org.eclipse.core.runtime.CoreException)

Aggregations

Field (java.lang.reflect.Field)2 EnumSerialization (org.eclipse.sapphire.modeling.annotations.EnumSerialization)2 ScriptLanguageType (com.liferay.ide.kaleo.core.model.ScriptLanguageType)1 Scriptable (com.liferay.ide.kaleo.core.model.Scriptable)1 CoreException (org.eclipse.core.runtime.CoreException)1