Search in sources :

Example 6 with EnumValue

use of org.whole.lang.model.EnumValue in project whole by wholeplatform.

the class TestsDataTypePresentationParser method parseEnumValue.

public EnumValue parseEnumValue(EntityDescriptor<?> ed, String value) {
    if (TestsEntityDescriptorEnum.CommentKind_ord == ed.getOrdinal()) {
        EnumType<?> dataEnumType = ed.getDataEnumType();
        if (dataEnumType == null)
            throw new WholeIllegalArgumentException(WholeMessages.no_data_type);
        EnumValue result = dataEnumType.valueOf(value);
        if (result == null)
            throw new WholeIllegalArgumentException(WholeMessages.no_data_type);
        return result;
    } else
        return super.parseEnumValue(ed, value);
}
Also used : EnumValue(org.whole.lang.model.EnumValue) WholeIllegalArgumentException(org.whole.lang.exceptions.WholeIllegalArgumentException)

Example 7 with EnumValue

use of org.whole.lang.model.EnumValue in project whole by wholeplatform.

the class JavaBeanBindingManagerTest method testBindData.

@Test
public void testBindData() {
    bm.wDefValue("boolF", false);
    assertTrue(bm.wBooleanValue("boolF") == false);
    bm.wDefValue("byteF", (byte) 4);
    assertTrue(bm.wByteValue("byteF") == 4);
    bm.wDefValue("charF", 'c');
    assertTrue(bm.wCharValue("charF") == 'c');
    bm.wDefValue("doubleF", 3.5d);
    assertTrue(bm.wDoubleValue("doubleF") == 3.5d);
    bm.wDefValue("floatF", 1.25f);
    assertTrue(bm.wFloatValue("floatF") == 1.25f);
    bm.wDefValue("intF", 12);
    assertTrue(bm.wIntValue("intF") == 12);
    bm.wDefValue("longF", 324l);
    assertTrue(bm.wLongValue("longF") == 324l);
    bm.wDefValue("shortF", (short) 34);
    assertTrue(bm.wShortValue("shortF") == 34);
    bm.wDefValue("stringF", "abc");
    assertEquals("abc", bm.wStringValue("stringF"));
    Date d = new Date();
    bm.wDefValue("dateF", d);
    assertSame(d, bm.wDateValue("dateF"));
    EnumValue e = FeatureModifierEnum.optional;
    bm.wDefValue("enumF", e);
    assertEquals(e, bm.wEnumValue("enumF"));
    Object o = new Object();
    bm.wDefValue("objectF", o);
    assertSame(o, bm.wGetValue("objectF"));
}
Also used : EnumValue(org.whole.lang.model.EnumValue) Date(java.util.Date) Test(org.junit.Test)

Aggregations

EnumValue (org.whole.lang.model.EnumValue)7 WholeIllegalArgumentException (org.whole.lang.exceptions.WholeIllegalArgumentException)3 Date (java.util.Date)2 Test (org.junit.Test)2 IEntity (org.whole.lang.model.IEntity)2 ArrayList (java.util.ArrayList)1 Collection (java.util.Collection)1 HashMap (java.util.HashMap)1 Map (java.util.Map)1 IDataTypeParser (org.whole.lang.parsers.IDataTypeParser)1 ArrayType (org.whole.lang.pojo.model.ArrayType)1 CollectionType (org.whole.lang.pojo.model.CollectionType)1 MapType (org.whole.lang.pojo.model.MapType)1 PrimitiveType (org.whole.lang.pojo.model.PrimitiveType)1 ProductDeclaration (org.whole.lang.pojo.model.ProductDeclaration)1 ReferenceType (org.whole.lang.pojo.model.ReferenceType)1 Type (org.whole.lang.pojo.model.Type)1 PrimitiveType (org.whole.lang.pojo.reflect.PojoEntityDescriptorEnum.PrimitiveType)1 ReferenceType (org.whole.lang.pojo.reflect.PojoEntityDescriptorEnum.ReferenceType)1 DataKinds (org.whole.lang.reflect.DataKinds)1