[New] Cloning without getters and setters
This commit is contained in:
parent
09889b6e77
commit
2e2bf893b2
|
@ -109,9 +109,9 @@ public abstract class AbstractStrolchElement implements StrolchElement {
|
||||||
* @param clone
|
* @param clone
|
||||||
* the clone to fill
|
* the clone to fill
|
||||||
*/
|
*/
|
||||||
protected void fillClone(StrolchElement clone) {
|
protected void fillClone(AbstractStrolchElement clone) {
|
||||||
clone.setId(getId());
|
clone.id = this.id;
|
||||||
clone.setName(getName());
|
clone.name = this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -282,7 +282,7 @@ public abstract class GroupedParameterizedElement extends AbstractStrolchElement
|
||||||
*/
|
*/
|
||||||
protected void fillClone(GroupedParameterizedElement clone) {
|
protected void fillClone(GroupedParameterizedElement clone) {
|
||||||
super.fillClone(clone);
|
super.fillClone(clone);
|
||||||
clone.setType(getType());
|
clone.type = this.type;
|
||||||
|
|
||||||
if (this.parameterBagMap != null) {
|
if (this.parameterBagMap != null) {
|
||||||
for (ParameterBag bag : this.parameterBagMap.values())
|
for (ParameterBag bag : this.parameterBagMap.values())
|
||||||
|
|
|
@ -231,22 +231,15 @@ public class Order extends AbstractStrolchRootElement implements StrolchRootElem
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Order getClone(boolean withVersion) {
|
public Order getClone(boolean withVersion) {
|
||||||
|
|
||||||
Order clone = new Order();
|
Order clone = new Order();
|
||||||
|
|
||||||
super.fillClone(clone);
|
super.fillClone(clone);
|
||||||
|
clone.date = this.date;
|
||||||
clone.setDate(this.date);
|
clone.state = this.state;
|
||||||
clone.setState(this.state);
|
|
||||||
|
|
||||||
if (this.policyDefs != null)
|
|
||||||
clone.setPolicyDefs(this.policyDefs.getClone());
|
|
||||||
|
|
||||||
if (withVersion)
|
|
||||||
clone.setVersion(this.version);
|
|
||||||
|
|
||||||
clone.locator = this.locator;
|
clone.locator = this.locator;
|
||||||
|
if (this.policyDefs != null)
|
||||||
|
clone.policyDefs = this.policyDefs.getClone();
|
||||||
|
if (withVersion)
|
||||||
|
clone.version = this.version;
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -89,7 +89,7 @@ public abstract class ParameterizedElement extends AbstractStrolchElement {
|
||||||
throw new StrolchException(msg);
|
throw new StrolchException(msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
this.type = type;
|
this.type = type.intern();
|
||||||
}
|
}
|
||||||
|
|
||||||
///
|
///
|
||||||
|
@ -1193,14 +1193,12 @@ public abstract class ParameterizedElement extends AbstractStrolchElement {
|
||||||
return lb.build();
|
return lb.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
protected void fillClone(ParameterizedElement clone) {
|
||||||
protected void fillClone(StrolchElement clone) {
|
|
||||||
super.fillClone(clone);
|
super.fillClone(clone);
|
||||||
ParameterizedElement peClone = (ParameterizedElement) clone;
|
clone.type = this.type;
|
||||||
peClone.setType(this.type);
|
|
||||||
if (this.parameterMap != null) {
|
if (this.parameterMap != null) {
|
||||||
for (Parameter<?> param : this.parameterMap.values()) {
|
for (Parameter<?> param : this.parameterMap.values()) {
|
||||||
peClone.addParameter(param.getClone());
|
clone.addParameter(param.getClone());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -309,10 +309,9 @@ public class Resource extends AbstractStrolchRootElement implements StrolchRootE
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Resource getClone(boolean withVersion) {
|
public Resource getClone(boolean withVersion) {
|
||||||
|
|
||||||
Resource clone = new Resource();
|
Resource clone = new Resource();
|
||||||
|
|
||||||
super.fillClone(clone);
|
super.fillClone(clone);
|
||||||
|
clone.locator = this.locator;
|
||||||
|
|
||||||
if (this.timedStateMap != null) {
|
if (this.timedStateMap != null) {
|
||||||
for (StrolchTimedState<IValue<?>> timedState : this.timedStateMap.values()) {
|
for (StrolchTimedState<IValue<?>> timedState : this.timedStateMap.values()) {
|
||||||
|
@ -321,13 +320,9 @@ public class Resource extends AbstractStrolchRootElement implements StrolchRootE
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.policyDefs != null)
|
if (this.policyDefs != null)
|
||||||
clone.setPolicyDefs(this.policyDefs.getClone());
|
clone.policyDefs = this.policyDefs.getClone();
|
||||||
|
|
||||||
if (withVersion)
|
if (withVersion)
|
||||||
clone.setVersion(this.version);
|
clone.version = this.version;
|
||||||
|
|
||||||
clone.locator = this.locator;
|
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -43,6 +43,7 @@ import li.strolch.utils.dbc.DBC;
|
||||||
*/
|
*/
|
||||||
public class Action extends GroupedParameterizedElement implements IActivityElement, PolicyContainer {
|
public class Action extends GroupedParameterizedElement implements IActivityElement, PolicyContainer {
|
||||||
|
|
||||||
|
protected Locator locator;
|
||||||
protected Activity parent;
|
protected Activity parent;
|
||||||
protected String resourceId;
|
protected String resourceId;
|
||||||
protected String resourceType;
|
protected String resourceType;
|
||||||
|
@ -211,10 +212,10 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
|
||||||
public Action getClone() {
|
public Action getClone() {
|
||||||
Action clone = new Action();
|
Action clone = new Action();
|
||||||
super.fillClone(clone);
|
super.fillClone(clone);
|
||||||
|
clone.resourceId = this.resourceId;
|
||||||
clone.setResourceId(this.resourceId);
|
clone.resourceType = this.resourceType;
|
||||||
clone.setResourceType(this.resourceType);
|
clone.state = this.state;
|
||||||
clone.setState(this.state);
|
clone.locator = this.locator;
|
||||||
|
|
||||||
if (this.changes != null) {
|
if (this.changes != null) {
|
||||||
for (IValueChange<? extends IValue<?>> change : getChanges()) {
|
for (IValueChange<? extends IValue<?>> change : getChanges()) {
|
||||||
|
@ -223,8 +224,7 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.policyDefs != null)
|
if (this.policyDefs != null)
|
||||||
clone.setPolicyDefs(this.policyDefs.getClone());
|
clone.policyDefs = this.policyDefs.getClone();
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -306,11 +306,14 @@ public class Action extends GroupedParameterizedElement implements IActivityElem
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Locator getLocator() {
|
public Locator getLocator() {
|
||||||
LocatorBuilder lb = new LocatorBuilder();
|
if (this.locator == null) {
|
||||||
if (this.parent != null)
|
LocatorBuilder lb = new LocatorBuilder();
|
||||||
this.parent.fillLocator(lb);
|
if (this.parent != null)
|
||||||
fillLocator(lb);
|
this.parent.fillLocator(lb);
|
||||||
return lb.build();
|
fillLocator(lb);
|
||||||
|
this.locator = lb.build();
|
||||||
|
}
|
||||||
|
return this.locator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -696,27 +696,21 @@ public class Activity extends AbstractStrolchRootElement
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Activity getClone(boolean withVersion) {
|
public Activity getClone(boolean withVersion) {
|
||||||
|
|
||||||
Activity clone = new Activity();
|
Activity clone = new Activity();
|
||||||
clone.timeOrdering = this.timeOrdering;
|
|
||||||
|
|
||||||
super.fillClone(clone);
|
super.fillClone(clone);
|
||||||
|
clone.timeOrdering = this.timeOrdering;
|
||||||
|
clone.locator = this.locator;
|
||||||
|
|
||||||
if (this.elements == null)
|
if (this.elements != null) {
|
||||||
return clone;
|
for (IActivityElement element : this.elements.values()) {
|
||||||
|
clone.addElement(element.getClone());
|
||||||
for (IActivityElement element : this.elements.values()) {
|
}
|
||||||
clone.addElement(element.getClone());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (this.policyDefs != null)
|
if (this.policyDefs != null)
|
||||||
clone.setPolicyDefs(this.policyDefs.getClone());
|
clone.policyDefs = this.policyDefs.getClone();
|
||||||
|
|
||||||
if (withVersion)
|
if (withVersion)
|
||||||
clone.setVersion(this.version);
|
clone.version = this.version;
|
||||||
|
|
||||||
clone.locator = this.locator;
|
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -181,13 +181,13 @@ public abstract class AbstractParameter<T> extends AbstractStrolchElement implem
|
||||||
* @param clone
|
* @param clone
|
||||||
* the clone to fill
|
* the clone to fill
|
||||||
*/
|
*/
|
||||||
protected void fillClone(Parameter<?> clone) {
|
protected void fillClone(AbstractParameter<?> clone) {
|
||||||
super.fillClone(clone);
|
super.fillClone(clone);
|
||||||
|
|
||||||
clone.setHidden(this.hidden);
|
clone.hidden = this.hidden;
|
||||||
clone.setInterpretation(this.interpretation);
|
clone.interpretation = this.interpretation;
|
||||||
clone.setUom(this.uom);
|
clone.uom = this.uom;
|
||||||
clone.setIndex(this.index);
|
clone.index = this.index;
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("nls")
|
@SuppressWarnings("nls")
|
||||||
|
|
|
@ -126,11 +126,8 @@ public class BooleanParameter extends AbstractParameter<Boolean> {
|
||||||
@Override
|
@Override
|
||||||
public BooleanParameter getClone() {
|
public BooleanParameter getClone() {
|
||||||
BooleanParameter clone = new BooleanParameter();
|
BooleanParameter clone = new BooleanParameter();
|
||||||
|
|
||||||
super.fillClone(clone);
|
super.fillClone(clone);
|
||||||
|
clone.value = this.value;
|
||||||
clone.setValue(this.value);
|
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -180,11 +180,8 @@ public class DateParameter extends AbstractParameter<Date> {
|
||||||
@Override
|
@Override
|
||||||
public DateParameter getClone() {
|
public DateParameter getClone() {
|
||||||
DateParameter clone = new DateParameter();
|
DateParameter clone = new DateParameter();
|
||||||
|
|
||||||
super.fillClone(clone);
|
super.fillClone(clone);
|
||||||
|
clone.value = this.value;
|
||||||
clone.setValueFromZonedDateTime(this.value);
|
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -163,11 +163,8 @@ public class DurationParameter extends AbstractParameter<PeriodDuration> {
|
||||||
@Override
|
@Override
|
||||||
public DurationParameter getClone() {
|
public DurationParameter getClone() {
|
||||||
DurationParameter clone = new DurationParameter();
|
DurationParameter clone = new DurationParameter();
|
||||||
|
|
||||||
super.fillClone(clone);
|
super.fillClone(clone);
|
||||||
|
clone.value = this.value;
|
||||||
clone.setValue(this.value);
|
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,11 +74,8 @@ public class FloatListParameter extends AbstractListParameter<Double> {
|
||||||
@Override
|
@Override
|
||||||
public FloatListParameter getClone() {
|
public FloatListParameter getClone() {
|
||||||
FloatListParameter clone = new FloatListParameter();
|
FloatListParameter clone = new FloatListParameter();
|
||||||
|
|
||||||
super.fillClone(clone);
|
super.fillClone(clone);
|
||||||
|
clone.value = new ArrayList<>(this.value);
|
||||||
clone.setValue(this.value);
|
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -157,11 +157,8 @@ public class FloatParameter extends AbstractParameter<Double> {
|
||||||
@Override
|
@Override
|
||||||
public FloatParameter getClone() {
|
public FloatParameter getClone() {
|
||||||
FloatParameter clone = new FloatParameter();
|
FloatParameter clone = new FloatParameter();
|
||||||
|
|
||||||
super.fillClone(clone);
|
super.fillClone(clone);
|
||||||
|
clone.value = this.value;
|
||||||
clone.setValue(this.value);
|
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,11 +74,8 @@ public class IntegerListParameter extends AbstractListParameter<Integer> {
|
||||||
@Override
|
@Override
|
||||||
public IntegerListParameter getClone() {
|
public IntegerListParameter getClone() {
|
||||||
IntegerListParameter clone = new IntegerListParameter();
|
IntegerListParameter clone = new IntegerListParameter();
|
||||||
|
|
||||||
super.fillClone(clone);
|
super.fillClone(clone);
|
||||||
|
clone.value = new ArrayList<>(this.value);
|
||||||
clone.setValue(this.value);
|
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -150,11 +150,8 @@ public class IntegerParameter extends AbstractParameter<Integer> {
|
||||||
@Override
|
@Override
|
||||||
public IntegerParameter getClone() {
|
public IntegerParameter getClone() {
|
||||||
IntegerParameter clone = new IntegerParameter();
|
IntegerParameter clone = new IntegerParameter();
|
||||||
|
|
||||||
super.fillClone(clone);
|
super.fillClone(clone);
|
||||||
|
clone.value = this.value;
|
||||||
clone.setValue(this.value);
|
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,11 +74,8 @@ public class LongListParameter extends AbstractListParameter<Long> {
|
||||||
@Override
|
@Override
|
||||||
public LongListParameter getClone() {
|
public LongListParameter getClone() {
|
||||||
LongListParameter clone = new LongListParameter();
|
LongListParameter clone = new LongListParameter();
|
||||||
|
|
||||||
super.fillClone(clone);
|
super.fillClone(clone);
|
||||||
|
clone.value = new ArrayList<>(this.value);
|
||||||
clone.setValue(this.value);
|
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -150,11 +150,8 @@ public class LongParameter extends AbstractParameter<Long> {
|
||||||
@Override
|
@Override
|
||||||
public LongParameter getClone() {
|
public LongParameter getClone() {
|
||||||
LongParameter clone = new LongParameter();
|
LongParameter clone = new LongParameter();
|
||||||
|
|
||||||
super.fillClone(clone);
|
super.fillClone(clone);
|
||||||
|
clone.value = this.value;
|
||||||
clone.setValue(this.value);
|
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -74,11 +74,8 @@ public class StringListParameter extends AbstractListParameter<String> {
|
||||||
@Override
|
@Override
|
||||||
public StringListParameter getClone() {
|
public StringListParameter getClone() {
|
||||||
StringListParameter clone = new StringListParameter();
|
StringListParameter clone = new StringListParameter();
|
||||||
|
|
||||||
super.fillClone(clone);
|
super.fillClone(clone);
|
||||||
|
clone.value = new ArrayList<>(this.value);
|
||||||
clone.setValue(this.value);
|
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -149,11 +149,8 @@ public class StringParameter extends AbstractParameter<String> {
|
||||||
@Override
|
@Override
|
||||||
public StringParameter getClone() {
|
public StringParameter getClone() {
|
||||||
StringParameter clone = new StringParameter();
|
StringParameter clone = new StringParameter();
|
||||||
|
|
||||||
super.fillClone(clone);
|
super.fillClone(clone);
|
||||||
|
clone.value = this.value;
|
||||||
clone.setValue(this.value);
|
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -57,11 +57,8 @@ public class TextParameter extends StringParameter {
|
||||||
@Override
|
@Override
|
||||||
public TextParameter getClone() {
|
public TextParameter getClone() {
|
||||||
TextParameter clone = new TextParameter();
|
TextParameter clone = new TextParameter();
|
||||||
|
|
||||||
super.fillClone(clone);
|
super.fillClone(clone);
|
||||||
|
clone.value = this.value;
|
||||||
clone.setValue(this.value);
|
|
||||||
|
|
||||||
return clone;
|
return clone;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue