Search in sources :

Example 6 with DefaultClassMetadata

use of org.terasology.reflection.metadata.DefaultClassMetadata in project Terasology by MovingBlocks.

the class MetadataBuilderTest method testInheritsFields.

@Test
public void testInheritsFields() throws Exception {
    DefaultClassMetadata<Inheriting> metadata = new DefaultClassMetadata<>(new SimpleUri(), Inheriting.class, factory, copyStrategyLibrary);
    assertNotNull(metadata);
    assertEquals(2, metadata.getFieldCount());
    assertNotNull(metadata.getField("name"));
    assertNotNull(metadata.getField("value"));
    assertNotNull(metadata.newInstance());
}
Also used : DefaultClassMetadata(org.terasology.reflection.metadata.DefaultClassMetadata) SimpleUri(org.terasology.engine.SimpleUri) Test(org.junit.Test)

Example 7 with DefaultClassMetadata

use of org.terasology.reflection.metadata.DefaultClassMetadata in project Terasology by MovingBlocks.

the class MetadataBuilderTest method testPrivateField.

@Test
public void testPrivateField() throws Exception {
    DefaultClassMetadata<PrivateField> metadata = new DefaultClassMetadata<>(new SimpleUri(), PrivateField.class, factory, copyStrategyLibrary);
    assertNotNull(metadata);
    assertEquals(1, metadata.getFieldCount());
    FieldMetadata fieldMetadata = metadata.getField("name");
    assertNotNull(fieldMetadata);
    assertEquals(String.class, fieldMetadata.getType());
    assertEquals("name", fieldMetadata.getName());
    assertNotNull(metadata.newInstance());
}
Also used : DefaultClassMetadata(org.terasology.reflection.metadata.DefaultClassMetadata) FieldMetadata(org.terasology.reflection.metadata.FieldMetadata) SimpleUri(org.terasology.engine.SimpleUri) Test(org.junit.Test)

Aggregations

SimpleUri (org.terasology.engine.SimpleUri)7 DefaultClassMetadata (org.terasology.reflection.metadata.DefaultClassMetadata)7 Test (org.junit.Test)4 Type (java.lang.reflect.Type)2 MappedContainer (org.terasology.reflection.MappedContainer)2 FieldMetadata (org.terasology.reflection.metadata.FieldMetadata)2 Annotation (java.lang.annotation.Annotation)1 Field (java.lang.reflect.Field)1 List (java.util.List)1 Map (java.util.Map)1 Set (java.util.Set)1 BooleanTypeHandler (org.terasology.persistence.typeHandling.coreTypes.BooleanTypeHandler)1 ByteTypeHandler (org.terasology.persistence.typeHandling.coreTypes.ByteTypeHandler)1 DoubleTypeHandler (org.terasology.persistence.typeHandling.coreTypes.DoubleTypeHandler)1 EnumTypeHandler (org.terasology.persistence.typeHandling.coreTypes.EnumTypeHandler)1 FloatTypeHandler (org.terasology.persistence.typeHandling.coreTypes.FloatTypeHandler)1 IntTypeHandler (org.terasology.persistence.typeHandling.coreTypes.IntTypeHandler)1 ListTypeHandler (org.terasology.persistence.typeHandling.coreTypes.ListTypeHandler)1 LongTypeHandler (org.terasology.persistence.typeHandling.coreTypes.LongTypeHandler)1 MappedContainerTypeHandler (org.terasology.persistence.typeHandling.coreTypes.MappedContainerTypeHandler)1