Ejemplo n.º 1
0
  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;
  }
Ejemplo n.º 2
0
 @Override
 protected Object clone() throws CloneNotSupportedException {
   SchemaFeatures cloned = (SchemaFeatures) super.clone();
   cloned.features = null;
   cloned.parent = this;
   return cloned;
 }
Ejemplo n.º 3
0
 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);
 }
Ejemplo n.º 4
0
 @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);
 }
Ejemplo n.º 5
0
 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);
 }