diff --git a/src/main/java/org/rosi_project/model_sync/model_join/representation/grammar/CompoundKeepBuilder.java b/src/main/java/org/rosi_project/model_sync/model_join/representation/grammar/CompoundKeepBuilder.java new file mode 100644 index 0000000000000000000000000000000000000000..2315a3a13b082f0b2d61a8a145489e4b922f5a07 --- /dev/null +++ b/src/main/java/org/rosi_project/model_sync/model_join/representation/grammar/CompoundKeepBuilder.java @@ -0,0 +1,37 @@ +package org.rosi_project.model_sync.model_join.representation.grammar; + +import java.util.List; + +import javax.annotation.Nonnull; + +import org.rosi_project.model_sync.model_join.representation.core.ClassResource; + +public abstract class CompoundKeepBuilder { + + protected ClassResource target; + @Nonnull + protected List<KeepExpression> keeps; + + /** + * Specifies the name of the class that should be generated for the subtype instances. + */ + @Nonnull + public CompoundKeepBuilder as(@Nonnull ClassResource target) { + this.target = target; + return this; + } + + /** + * Adds a {@link KeepExpression keep statement} for the subtype-class. The described attribute + * will be initialized for each instantiated subtype element. + */ + @Nonnull + public CompoundKeepBuilder keep(@Nonnull KeepExpression keep) { + this.keeps.add(keep); + return this; + } + + @Nonnull + public abstract KeepExpression buildExpression(); + +} diff --git a/src/main/java/org/rosi_project/model_sync/model_join/representation/grammar/KeepReferenceExpression.java b/src/main/java/org/rosi_project/model_sync/model_join/representation/grammar/KeepReferenceExpression.java index 5d6f0f32924f2f495b21b9ab3107dcbf15c044b2..307be52e0fd959130a523989774d0b760d9067db 100644 --- a/src/main/java/org/rosi_project/model_sync/model_join/representation/grammar/KeepReferenceExpression.java +++ b/src/main/java/org/rosi_project/model_sync/model_join/representation/grammar/KeepReferenceExpression.java @@ -53,14 +53,10 @@ public class KeepReferenceExpression extends CompoundKeepExpression { * * @author Rico Bergmann */ - public static class KeepReferenceBuilder { + public static class KeepReferenceBuilder extends CompoundKeepBuilder { private ReferenceDirection referenceDirection; private AttributePath attribute; - private ClassResource target; - - @Nonnull - private List<KeepExpression> keeps; /** * Default constructor. @@ -89,24 +85,6 @@ public class KeepReferenceExpression extends CompoundKeepExpression { return this; } - /** - * Specifies the name of the attribute in the target join. - */ - @Nonnull - public KeepReferenceBuilder as(@Nonnull ClassResource target) { - this.target = target; - return this; - } - - /** - * Adds an attribute to the view for the referenced instances. - */ - @Nonnull - public KeepReferenceBuilder keep(@Nonnull KeepExpression keepExpression) { - this.keeps.add(keepExpression); - return this; - } - /** * Finishes the construction process. */ diff --git a/src/main/java/org/rosi_project/model_sync/model_join/representation/grammar/KeepSubTypeExpression.java b/src/main/java/org/rosi_project/model_sync/model_join/representation/grammar/KeepSubTypeExpression.java index 76e8d6027462a00d341906020ca57c638b1ed074..f3b82c38ec96c6dc3345c68ba93920a89a6d9ea6 100644 --- a/src/main/java/org/rosi_project/model_sync/model_join/representation/grammar/KeepSubTypeExpression.java +++ b/src/main/java/org/rosi_project/model_sync/model_join/representation/grammar/KeepSubTypeExpression.java @@ -25,11 +25,9 @@ public class KeepSubTypeExpression extends CompoundKeepExpression { * * @author Rico Bergmann */ - public static class KeepSubTypeBuilder { + public static class KeepSubTypeBuilder extends CompoundKeepBuilder { private ClassResource typeToKeep; - private ClassResource target; - private List<KeepExpression> keeps; /** * Default constructor. @@ -45,26 +43,7 @@ public class KeepSubTypeExpression extends CompoundKeepExpression { public KeepSubTypeBuilder subtype(@Nonnull ClassResource type) { this.typeToKeep = type; return this; - } - - /** - * Specifies the name of the class that should be generated for the subtype instances. - */ - @Nonnull - public KeepSubTypeBuilder as(@Nonnull ClassResource target) { - this.target = target; - return this; - } - - /** - * Adds a {@link KeepExpression keep statement} for the subtype-class. The described attribute - * will be initialized for each instantiated subtype element. - */ - @Nonnull - public KeepSubTypeBuilder keep(@Nonnull KeepExpression keep) { - this.keeps.add(keep); - return this; - } + } /** * Finishes the construction process. diff --git a/src/main/java/org/rosi_project/model_sync/model_join/representation/grammar/KeepSuperTypeExpression.java b/src/main/java/org/rosi_project/model_sync/model_join/representation/grammar/KeepSuperTypeExpression.java index 6c72a3d9a42fdef32eafe621ceba232af271b803..e4b1b816ce20b12ab24af04a07f6315c16c8ef45 100644 --- a/src/main/java/org/rosi_project/model_sync/model_join/representation/grammar/KeepSuperTypeExpression.java +++ b/src/main/java/org/rosi_project/model_sync/model_join/representation/grammar/KeepSuperTypeExpression.java @@ -24,11 +24,9 @@ public class KeepSuperTypeExpression extends CompoundKeepExpression { * * @author Rico Bergmann */ - public static class KeepSuperTypeBuilder { + public static class KeepSuperTypeBuilder extends CompoundKeepBuilder { private ClassResource typeToKeep; - private ClassResource target; - private List<KeepExpression> keeps; /** * Default constructor. @@ -46,25 +44,6 @@ public class KeepSuperTypeExpression extends CompoundKeepExpression { return this; } - /** - * Specifies the name of the class that should be generated for the subtype instances. - */ - @Nonnull - public KeepSuperTypeBuilder as(@Nonnull ClassResource target) { - this.target = target; - return this; - } - - /** - * Adds a {@link KeepExpression keep statement} for the subtype-class. The described attribute - * will be initialized for each instantiated subtype element. - */ - @Nonnull - public KeepSuperTypeBuilder keep(@Nonnull KeepExpression keep) { - this.keeps.add(keep); - return this; - } - /** * Finishes the construction process. */