Exemplo n.º 1
0
 public static int getNumberOfReasonsOfRequiresConstraint(
     List<IConstraint> constraints, Feature f1, Feature f2) {
   for (IConstraint constraint : constraints) {
     if (constraint.getType().equals(IConstraint.REQUIRES)) {
       if (f1.getName().equals(FeatureIDEUtils.validFeatureName(constraint.getBlock1().getName()))
           && f2.getName()
               .equals(FeatureIDEUtils.validFeatureName(constraint.getBlock2().getName()))) {
         return constraint.getNumberOfReasons();
       }
     }
   }
   return -1;
 }
Exemplo n.º 2
0
 public static boolean existsRequiresConstraint(
     List<IConstraint> constraints, Feature f1, Feature f2) {
   for (IConstraint constraint : constraints) {
     if (constraint.getType().equals(IConstraint.REQUIRES)) {
       if (f1.getName().equals(FeatureIDEUtils.validFeatureName(constraint.getBlock1().getName()))
           && f2.getName()
               .equals(FeatureIDEUtils.validFeatureName(constraint.getBlock2().getName()))) {
         return true;
       }
     }
   }
   return false;
 }
Exemplo n.º 3
0
 public static boolean existsExcludeConstraint(
     List<IConstraint> constraints, Feature f1, Feature f2) {
   for (IConstraint constraint : constraints) {
     if (constraint.getType().equals(IConstraint.MUTUALLY_EXCLUDES)) {
       // check f1 excludes f2 and viceversa
       if (f1.getName().equals(FeatureIDEUtils.validFeatureName(constraint.getBlock1().getName()))
           && f2.getName()
               .equals(FeatureIDEUtils.validFeatureName(constraint.getBlock2().getName()))) {
         return true;
       } else if (f2.getName()
               .equals(FeatureIDEUtils.validFeatureName(constraint.getBlock1().getName()))
           && f1.getName()
               .equals(FeatureIDEUtils.validFeatureName(constraint.getBlock2().getName()))) {
         return true;
       }
     }
   }
   return false;
 }
Exemplo n.º 4
0
 private Set<String> calculateAddedFeatures(FeatureModel oldModel, FeatureModel newModel) {
   Set<String> addedFeatures = new HashSet<String>();
   for (Feature feature : newModel.getFeatures())
     if (feature.isConcrete()) {
       String name = newModel.getRenamingsManager().getOldName(feature.getName());
       Feature associatedFeature =
           oldModel.getFeature(oldModel.getRenamingsManager().getNewName(name));
       if (associatedFeature == null || associatedFeature.isAbstract()) addedFeatures.add(name);
     }
   return addedFeatures;
 }
Exemplo n.º 5
0
 public static List<Feature> getFeatureRequiredFeatures(
     FeatureModel fm, List<IConstraint> constraints, Feature f1) {
   List<Feature> required = new ArrayList<Feature>();
   for (IConstraint constraint : constraints) {
     if (constraint.getType().equals(IConstraint.REQUIRES)) {
       if (f1.getName()
           .equals(FeatureIDEUtils.validFeatureName(constraint.getBlock1().getName()))) {
         required.add(
             fm.getFeature(FeatureIDEUtils.validFeatureName(constraint.getBlock2().getName())));
       }
     }
   }
   return required;
 }
Exemplo n.º 6
0
 private String createProductDefinition(Configuration configuration) {
   String ret =
       "product " + this.configName + " from " + this.featureModel.getRoot().getName() + " : {";
   int i = 0;
   for (Iterator<Feature> iter = configuration.getSelectedFeatures().iterator();
       iter.hasNext(); ) {
     Feature feature = iter.next();
     if (!feature.isAbstract()) {
       if (i++ != 0) ret += ", ";
       ret += feature.getName();
     }
   }
   return ret + "}";
 }