public static <T> boolean setFeature( Object iUserObject, String elementName, Feature<T> feature, T value) { SchemaFeatures features = getSchemaFeature(iUserObject, elementName, feature); if (features == null) return false; T oldValue = features.getFeature(feature); features.setFeature(feature, value); // BROADCAST CHANGES TO ALL REGISTERED LISTENERS List<SchemaFeaturesChangeListener> listeners = Controller.getInstance().getListeners(SchemaFeaturesChangeListener.class); if (listeners != null) switch (feature.getType()) { case ACTION: for (SchemaFeaturesChangeListener listener : listeners) { listener.signalChangeAction(iUserObject, elementName, feature, oldValue, value); } break; case FIELD: for (SchemaFeaturesChangeListener listener : listeners) { listener.signalChangeField(iUserObject, elementName, feature, oldValue, value); } break; case EVENT: break; case CLASS: for (SchemaFeaturesChangeListener listener : listeners) { listener.signalChangeClass(iUserObject, feature, oldValue, value); } default: break; } return true; }
@Override protected Object clone() throws CloneNotSupportedException { SchemaFeatures cloned = (SchemaFeatures) super.clone(); cloned.features = null; cloned.parent = this; return cloned; }
public <T> boolean isSettedFeature(Feature<T> feature) { if (getFeatureType() != feature.getType()) { throw new RuntimeException( "Try to check a feature of type:" + feature.getType() + " on a SchemaFeature of type:" + getFeatureType()); } if (hasFeature(feature)) return true; if (parent == null) return false; return parent.isSettedFeature(feature); }
@SuppressWarnings("unchecked") public <T> T getFeature(Feature<T> feature) { if (getFeatureType() != feature.getType()) { throw new RuntimeException( "Try to get a feature of type:" + feature.getType() + " on a SchemaFeature of type:" + getFeatureType()); } if (features != null) { Object[] aspectFeature = features[feature.getAspectId()]; if (aspectFeature != null) { Object value = aspectFeature[feature.getFeatureId()]; if (value != UNSETTED_VALUE) { return (T) value; } } } if (parent == null) return feature.getDefaultValue(); return (T) parent.getFeature(feature); }
public static <T> T getFeature(Object iUserObject, String elementName, Feature<T> feature) { SchemaFeatures features = getSchemaFeature(iUserObject, elementName, feature); if (features == null) return null; return features.getFeature(feature); }