Search in sources :

Example 1 with AdminList

use of com.eden.orchid.api.server.admin.AdminList in project Orchid by JavaEden.

the class OrchidModule method bindKnownSet.

private void bindKnownSet(final Class<?> setClass) {
    Provider<OrchidContext> contextProvider = getProvider(OrchidContext.class);
    if (!knownSets.contains(setClass)) {
        Multibinder<AdminList> binder = Multibinder.newSetBinder(binder(), AdminList.class);
        binder.addBinding().toInstance(new AdminList() {

            @Override
            public Class<?> getListClass() {
                return setClass;
            }

            @Override
            public String getKey() {
                return setClass.getSimpleName();
            }

            @Override
            public Collection<Class<?>> getItems() {
                return contextProvider.get().resolveSet(setClass).stream().map(Object::getClass).collect(Collectors.toList());
            }

            @Override
            public boolean isImportantType() {
                return setClass.isAnnotationPresent(ImportantModularType.class);
            }
        });
        knownSets.add(setClass);
    }
}
Also used : AdminList(com.eden.orchid.api.server.admin.AdminList) OrchidContext(com.eden.orchid.api.OrchidContext) Collection(java.util.Collection) ImportantModularType(com.eden.orchid.api.server.annotations.ImportantModularType)

Aggregations

OrchidContext (com.eden.orchid.api.OrchidContext)1 AdminList (com.eden.orchid.api.server.admin.AdminList)1 ImportantModularType (com.eden.orchid.api.server.annotations.ImportantModularType)1 Collection (java.util.Collection)1