Search in sources :

Example 1 with BooleanLiteral

use of com.robotoworks.mechanoid.sharedprefs.sharedPreferencesModel.BooleanLiteral in project mechanoid by robotoworks.

the class SharedPreferencesModelJavaValidator method checkDefaultValue.

@Check
public void checkDefaultValue(Preference preference) {
    PreferenceType type = preference.getType();
    Literal defaultValue = preference.getDefaultValue();
    if (defaultValue == null) {
        return;
    }
    switch(type) {
        case STRING:
            if (!(defaultValue instanceof StringLiteral)) {
                error("Type mismatch", SharedPreferencesModelPackage.Literals.PREFERENCE__DEFAULT_VALUE);
            }
            break;
        case BOOLEAN:
            if (!(defaultValue instanceof BooleanLiteral)) {
                error("Type mismatch", SharedPreferencesModelPackage.Literals.PREFERENCE__DEFAULT_VALUE);
            }
            break;
        case FLOAT:
        case INTEGER:
        case LONG:
            if (!(defaultValue instanceof NumericLiteral)) {
                error("Type mismatch", SharedPreferencesModelPackage.Literals.PREFERENCE__DEFAULT_VALUE);
            }
            break;
    }
}
Also used : StringLiteral(com.robotoworks.mechanoid.sharedprefs.sharedPreferencesModel.StringLiteral) NumericLiteral(com.robotoworks.mechanoid.sharedprefs.sharedPreferencesModel.NumericLiteral) BooleanLiteral(com.robotoworks.mechanoid.sharedprefs.sharedPreferencesModel.BooleanLiteral) BooleanLiteral(com.robotoworks.mechanoid.sharedprefs.sharedPreferencesModel.BooleanLiteral) StringLiteral(com.robotoworks.mechanoid.sharedprefs.sharedPreferencesModel.StringLiteral) Literal(com.robotoworks.mechanoid.sharedprefs.sharedPreferencesModel.Literal) NumericLiteral(com.robotoworks.mechanoid.sharedprefs.sharedPreferencesModel.NumericLiteral) PreferenceType(com.robotoworks.mechanoid.sharedprefs.sharedPreferencesModel.PreferenceType) Check(org.eclipse.xtext.validation.Check)

Aggregations

BooleanLiteral (com.robotoworks.mechanoid.sharedprefs.sharedPreferencesModel.BooleanLiteral)1 Literal (com.robotoworks.mechanoid.sharedprefs.sharedPreferencesModel.Literal)1 NumericLiteral (com.robotoworks.mechanoid.sharedprefs.sharedPreferencesModel.NumericLiteral)1 PreferenceType (com.robotoworks.mechanoid.sharedprefs.sharedPreferencesModel.PreferenceType)1 StringLiteral (com.robotoworks.mechanoid.sharedprefs.sharedPreferencesModel.StringLiteral)1 Check (org.eclipse.xtext.validation.Check)1