/** * Returns an <tt>ObservableFeatureToggle</tt> for the given feature name. * * @param featureName Name of the feature * @return toggle for the given feature name */ public ObservableFeatureToggle getFeatureToggle(String featureName) { return getFeatureToggle(getFeatureByName(featureName)); }
/** * Activates the feature with the given name * * @param featureName unique name of the feature that should be activated */ public void activate(String featureName) { activate(getFeatureByName(featureName)); }
/** * Deactivates the feature with the given name * * @param featureName unique name of the feature that should be deactivated */ public void deactivate(String featureName) { deactivate(getFeatureByName(featureName)); } }
/** * Checks if the feature with the given unique name is active * * @param featureName unique name of the feature * @return true if the feature with the given unique name is active */ public boolean isActive(String featureName) { return isActive(getFeatureByName(featureName)); }
public FeatureProperty<?> createFeatureProperty(String featureName) { return new FeatureProperty<>(getManager().getFeatureToggle(featureName)); }
private ObservableToggleManager createManagerFromConfig() { try { List<Element> elements = DataFXConfiguration.getInstance().getElements("features"); if (elements == null) { throw new RuntimeException("Can't load config. Features section not specified!"); } if (elements.isEmpty()) { throw new RuntimeException("Can't load config. Features section not specified!"); } if (elements.size() > 1) { throw new RuntimeException("Can't load config. Features section must only be specified once!"); } Class<? extends Feature> featureClass = (Class<? extends Feature>) Class.forName(elements.get(0).getElementsByTagName("featureEnum").item(0).getTextContent()); return new ObservableToggleManager(featureClass); } catch (Exception e) { throw new RuntimeException("Can't generate Feature Manager", e); } }
/** * Returns an <tt>ObservableFeatureToggle</tt> for the given Togglz feature. * * @param feature a Togglz feature * @return toggle for the given feature */ public ObservableFeatureToggle getFeatureToggle(Feature feature) { DefaultFeatureToggle toggle = new DefaultFeatureToggle(feature, (t) -> isActive(t)); weakFeatureStateListeners.add(new WeakReference<FeatureStateListener>(toggle)); return toggle; }
/** * Returns the registered feature with the given name * * @param featureName unique name of the feature * @return feature with the given name */ public Feature getFeatureByName(String featureName) { for (Feature feature : getManager().getFeatures()) { if (feature.name().equals(featureName)) { return feature; } } return null; }
public FeatureProperty<?> createFeatureProperty(String featureName) { return new FeatureProperty<>(getManager().getFeatureToggle(featureName)); }
private ObservableToggleManager createManagerFromConfig() { try { List<Element> elements = DataFXConfiguration.getInstance().getElements("features"); if (elements == null) { throw new RuntimeException("Can't load config. Features section not specified!"); } if (elements.isEmpty()) { throw new RuntimeException("Can't load config. Features section not specified!"); } if (elements.size() > 1) { throw new RuntimeException("Can't load config. Features section must only be specified once!"); } Class<? extends Feature> featureClass = (Class<? extends Feature>) Class.forName(elements.get(0).getElementsByTagName("featureEnum").item(0).getTextContent()); return new ObservableToggleManager(featureClass); } catch (Exception e) { throw new RuntimeException("Can't generate Feature Manager", e); } }