示例#1
0
 public StrategyCalculator(Set<Class<? extends ITransformationStep>> actualClasses) {
   super();
   this.actualClasses = actualClasses;
   for (Class<? extends ITransformationStep> c : this.actualClasses) {
     addRequiredStrategiesRecursively(c);
   }
   for (StrategyRequirementHolder h : holders.values()) {
     for (Class<?> replacedClass : h.getReplacedStrategyClasses()) {
       StrategyRequirementHolder holder = holders.get(replacedClass);
       if (holder != null) {
         // Replaced strategy may not have been selected in the transformation process
         h.addReplaces(holder);
       }
     }
   }
   this.strategies = new HashMap<Class<?>, StepDependency.StrategyRequirement>();
   for (Class<? extends ITransformationStep> c : this.actualClasses) {
     for (StrategyRequirement sr : c.getAnnotation(StepDependency.class).strategyRequirement()) {
       StrategyRequirement existing = strategies.get(sr.strategyContract());
       if (existing == null || overrides(sr, existing)) {
         strategies.put(sr.strategyContract(), sr);
       }
     }
   }
 }
示例#2
0
 private void addRequiredStrategiesRecursively(Class<? extends ITransformationStep> c) {
   StepDependency sd = c.getAnnotation(StepDependency.class);
   for (StrategyRequirement sr : sd.strategyRequirement()) {
     holders.put(sr.requires(), new StrategyRequirementHolder(sr));
   }
   for (Class<? extends ITransformationStep> replacedTransformation : sd.replaces()) {
     addRequiredStrategiesRecursively(replacedTransformation);
   }
 }
示例#3
0
 private boolean overrides(StrategyRequirement sr, StrategyRequirement existing) {
   return holders.get(sr.requires()).replaces(holders.get(existing.requires()));
 }