Commit be235476 authored by Simon Barner's avatar Simon Barner
Browse files

GREEN

* Factorize commonalities between createExplorationObjective()
  and createExplorationConstraint()

Issue-Ref: 4072
Issue-Url: https://af3-developer.fortiss.org/issues/4072

Signed-off-by: Simon Barner's avatarSimon Barner <barner@fortiss.org>
parent 50cb0b10
...@@ -3,7 +3,7 @@ DSESolutionConversionUtils.java a6ccbba92864c653d1518a92455e87c17f7cc72b GREEN ...@@ -3,7 +3,7 @@ DSESolutionConversionUtils.java a6ccbba92864c653d1518a92455e87c17f7cc72b GREEN
DSMLModelElementFactory.java fa4a735ff40ab8f7d9898cecc0b04cfd8997572f GREEN DSMLModelElementFactory.java fa4a735ff40ab8f7d9898cecc0b04cfd8997572f GREEN
DSMLUtils.java 1113377031374cef7e29afcef458c4aeecad2b21 GREEN DSMLUtils.java 1113377031374cef7e29afcef458c4aeecad2b21 GREEN
ExplorationCLIUtils.java 32a4b2fc5f52e77c5e50b61912dcfe0f7f0c4cfd GREEN ExplorationCLIUtils.java 32a4b2fc5f52e77c5e50b61912dcfe0f7f0c4cfd GREEN
ExplorationModelElementFactory.java 1d3f5e3e930f6917cbed751057d6277a9a8f296e YELLOW ExplorationModelElementFactory.java e2faa562a5896c0a26919e42cb9e1e42a3ff6fd5 GREEN
ExplorationReflectionUtils.java 62731e1cef32fe93f2c2017f93f5ba1f054d5197 GREEN ExplorationReflectionUtils.java 62731e1cef32fe93f2c2017f93f5ba1f054d5197 GREEN
ExplorationScheduleUtils.java 95c9877ab2caa779a46fc20b8fdd63cd1cc392b1 GREEN ExplorationScheduleUtils.java 95c9877ab2caa779a46fc20b8fdd63cd1cc392b1 GREEN
ExplorationTimingConstraintUtils.java 44f83e7630b52f8213b96f162bf94a2de009eb3e GREEN ExplorationTimingConstraintUtils.java 44f83e7630b52f8213b96f162bf94a2de009eb3e GREEN
......
...@@ -61,6 +61,19 @@ public class ExplorationModelElementFactory { ...@@ -61,6 +61,19 @@ public class ExplorationModelElementFactory {
return ExplorationFactory.eINSTANCE.createExplorationSpecification(); return ExplorationFactory.eINSTANCE.createExplorationSpecification();
} }
/** Helper method to initialize an {@link IExplorationTarget}. */
private static <T> void initializeExplorationTarget(IExplorationTarget<T> explorationTarget,
Class<T> returnType, IProblemDimension probDim,
Collection<Class<? extends ISynthesisCategory>> synthCategory, IExpression expr,
String name) {
explorationTarget.setResultType(returnType);
explorationTarget.setExpression(expr);
explorationTarget.setProblemDimension(probDim);
explorationTarget.getSynthesisCategories().addAll(synthCategory);
explorationTarget.setName(name);
}
/** /**
* Creates an {@link ExplorationObjective} whose evaluation is of type {@code T}. * Creates an {@link ExplorationObjective} whose evaluation is of type {@code T}.
* *
...@@ -82,11 +95,8 @@ public class ExplorationModelElementFactory { ...@@ -82,11 +95,8 @@ public class ExplorationModelElementFactory {
String name) { String name) {
ExplorationObjective<T> objective = ExplorationObjective<T> objective =
ExplorationFactory.eINSTANCE.createExplorationObjective(); ExplorationFactory.eINSTANCE.createExplorationObjective();
objective.setResultType(returnType); initializeExplorationTarget(objective, returnType, probDim, synthCategory, expr, name);
objective.setExpression(expr);
objective.setProblemDimension(probDim);
objective.getSynthesisCategories().addAll(synthCategory);
objective.setName(name);
return objective; return objective;
} }
...@@ -114,11 +124,7 @@ public class ExplorationModelElementFactory { ...@@ -114,11 +124,7 @@ public class ExplorationModelElementFactory {
String name, boolean isImplicit) { String name, boolean isImplicit) {
ExplorationConstraint<T> constraint = ExplorationConstraint<T> constraint =
ExplorationFactory.eINSTANCE.createExplorationConstraint(); ExplorationFactory.eINSTANCE.createExplorationConstraint();
constraint.setResultType(returnType); initializeExplorationTarget(constraint, returnType, probDim, synthCategory, expr, name);
constraint.setExpression(expr);
constraint.setProblemDimension(probDim);
constraint.getSynthesisCategories().addAll(synthCategory);
constraint.setName(name);
constraint.setImplicit(isImplicit); constraint.setImplicit(isImplicit);
return constraint; return constraint;
} }
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment