Пример #1
0
 public <T> void setFeature(Feature<T> feature, T iFeatureValue) {
   if (getFeatureType() != feature.getType()) {
     throw new RuntimeException(
         "Try to set a feature of type:"
             + feature.getType()
             + " on a SchemaFeature of type:"
             + getFeatureType());
   }
   if (features == null) {
     features = new Object[FeatureRegistry.aspectTotal()][];
   }
   Object[] aspectFeature = features[feature.getAspectId()];
   if (aspectFeature == null) {
     aspectFeature =
         new Object[FeatureRegistry.featureCount(feature.getAspectName(), feature.getType())];
     for (int i = 0; i < aspectFeature.length; i++) aspectFeature[i] = UNSETTED_VALUE;
     features[feature.getAspectId()] = aspectFeature;
   }
   aspectFeature[feature.getFeatureId()] = iFeatureValue;
 }
Пример #2
0
 protected <T> boolean hasFeature(Feature<T> feature) {
   if (features != null) {
     Object[] aspectFeature = features[feature.getAspectId()];
     if (aspectFeature != null) {
       Object value = aspectFeature[feature.getFeatureId()];
       if (value != UNSETTED_VALUE) {
         return true;
       }
     }
   }
   return false;
 }
Пример #3
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);
 }