예제 #1
0
 /**
  * Get string representation of the constraint
  *
  * @param constraint
  * @return
  */
 public static String getConstraintString(IConstraint constraint) {
   String type = constraint.getType();
   // only this two supported for the moment
   if (type.equals(IConstraint.REQUIRES) || type.equals(IConstraint.MUTUALLY_EXCLUDES)) {
     String text = validFeatureName(constraint.getBlock1().getName()) + " implies ";
     if (type.equals(IConstraint.MUTUALLY_EXCLUDES)) {
       text += "not ";
     }
     text += validFeatureName(constraint.getBlock2().getName());
     return text;
   }
   return constraint.getText();
 }
예제 #2
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;
 }
예제 #3
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;
 }
예제 #4
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;
 }
예제 #5
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;
 }