de.otto.edison.togglz.controller.TogglzRepresentation Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of edison-togglz Show documentation
Show all versions of edison-togglz Show documentation
Status library of the edison-microservice project.
package de.otto.edison.togglz.controller;
import de.otto.edison.togglz.FeatureClassProvider;
import net.jcip.annotations.Immutable;
import org.togglz.core.Feature;
import java.util.Map;
import static java.util.Arrays.asList;
import static java.util.stream.Collectors.toMap;
import static org.togglz.core.context.FeatureContext.getFeatureManager;
@Immutable
public class TogglzRepresentation {
private final Map togglzState;
private TogglzRepresentation(final Class featureClass) {
this.togglzState = buildTogglzState(featureClass);
}
public static TogglzRepresentation togglzRepresentation(final FeatureClassProvider featureClassProvider) {
return new TogglzRepresentation((Class) featureClassProvider.getFeatureClass());
}
private Map buildTogglzState(final Class featureClass) {
return asList(featureClass.getEnumConstants()).stream()
.collect(toMap(this::toggleName, this::toggleState));
}
private boolean toggleState(Feature feature) {
return getFeatureManager().getFeatureState(feature).isEnabled();
}
private String toggleName(Feature features) {
return features.name();
}
public Map getTogglzState() {
return togglzState;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy