Search in sources :

Example 1 with CatalogedBy

use of org.spongepowered.api.util.annotation.CatalogedBy in project SpongeCommon by SpongePowered.

the class RegistryTestUtil method generateCatalogContainerTestObjects.

static Iterable<Object[]> generateCatalogContainerTestObjects() {
    final SpongeGameRegistry registry = (SpongeGameRegistry) Sponge.getGame().getRegistry();
    final ArrayList<Object[]> objects = new ArrayList<>();
    for (Map.Entry<Class<? extends CatalogType>, CatalogRegistryModule<?>> entry : registry.catalogRegistryMap.entrySet()) {
        final Class<? extends CatalogType> key = entry.getKey();
        final CatalogedBy catalogedBy = key.getAnnotation(CatalogedBy.class);
        if (catalogedBy != null) {
            for (Class<?> containerClass : catalogedBy.value()) {
                for (Field field : containerClass.getFields()) {
                    if (Modifier.isStatic(field.getModifiers())) {
                        objects.add(new Object[] { field.getName(), entry.getKey(), containerClass, entry.getValue(), field });
                    }
                }
            }
        }
    }
    return objects;
}
Also used : Field(java.lang.reflect.Field) CatalogType(org.spongepowered.api.CatalogType) CatalogRegistryModule(org.spongepowered.api.registry.CatalogRegistryModule) CatalogedBy(org.spongepowered.api.util.annotation.CatalogedBy) ArrayList(java.util.ArrayList) Map(java.util.Map)

Aggregations

Field (java.lang.reflect.Field)1 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 CatalogType (org.spongepowered.api.CatalogType)1 CatalogRegistryModule (org.spongepowered.api.registry.CatalogRegistryModule)1 CatalogedBy (org.spongepowered.api.util.annotation.CatalogedBy)1