Skip to content
Snippets Groups Projects
Commit 18311aa3 authored by Chrissi's avatar Chrissi
Browse files

Add new abstract builder that collects the attributes of the compound keep expressions

parent 4d64347b
No related branches found
No related tags found
No related merge requests found
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();
}
......@@ -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.
*/
......
......@@ -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.
......@@ -47,25 +45,6 @@ public class KeepSubTypeExpression extends CompoundKeepExpression {
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.
*/
......
......@@ -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.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment