diff --git a/gcm4/src/main/java/plugins/groups/GroupsPluginData.java b/gcm4/src/main/java/plugins/groups/GroupsPluginData.java index f0dd469ca..b59679a1a 100644 --- a/gcm4/src/main/java/plugins/groups/GroupsPluginData.java +++ b/gcm4/src/main/java/plugins/groups/GroupsPluginData.java @@ -254,11 +254,15 @@ private Builder(Data data) { * */ public GroupsPluginData build() { + try { if (!data.locked) { validateData(); } ensureImmutability(); return new GroupsPluginData(data); + }finally { + data = new Data(); + } } /** diff --git a/gcm4/src/main/java/plugins/materials/MaterialsPluginData.java b/gcm4/src/main/java/plugins/materials/MaterialsPluginData.java index 69fef0113..81a010443 100644 --- a/gcm4/src/main/java/plugins/materials/MaterialsPluginData.java +++ b/gcm4/src/main/java/plugins/materials/MaterialsPluginData.java @@ -247,11 +247,15 @@ public Builder addStage(final StageId stageId, final boolean offered, final Mate */ public MaterialsPluginData build() { + try { if (!data.locked) { validateData(); } ensureImmutability(); return new MaterialsPluginData(data); + }finally { + data = new Data(); + } } diff --git a/gcm4/src/main/java/plugins/partitions/testsupport/attributes/AttributesPluginData.java b/gcm4/src/main/java/plugins/partitions/testsupport/attributes/AttributesPluginData.java index b5537cde6..922fea89b 100644 --- a/gcm4/src/main/java/plugins/partitions/testsupport/attributes/AttributesPluginData.java +++ b/gcm4/src/main/java/plugins/partitions/testsupport/attributes/AttributesPluginData.java @@ -56,8 +56,12 @@ private void ensureImmutability() { * Returns the {@linkplain AttributesPluginData} from the collected data */ public AttributesPluginData build() { - ensureImmutability(); - return new AttributesPluginData(data); + try { + ensureImmutability(); + return new AttributesPluginData(data); + } finally { + data = new Data(); + } } /** diff --git a/gcm4/src/main/java/plugins/people/PeoplePluginData.java b/gcm4/src/main/java/plugins/people/PeoplePluginData.java index a3e186f4f..dd942cc98 100644 --- a/gcm4/src/main/java/plugins/people/PeoplePluginData.java +++ b/gcm4/src/main/java/plugins/people/PeoplePluginData.java @@ -155,7 +155,7 @@ private void ensureImmutability() { a = low; b = high; } else { - if (low > b+1) { + if (low > b + 1) { count += (b - a + 1); list2.add(new PersonRange(a, b)); a = low; @@ -179,11 +179,11 @@ private void ensureImmutability() { data.personRanges = list2; data.personIds = new ArrayList<>(count); - - if(data.personCount<0) { + + if (data.personCount < 0) { data.personCount = 0; - if(!data.personRanges.isEmpty()) { - data.personCount = data.personRanges.get(data.personRanges.size()-1).getHighPersonId()+1; + if (!data.personRanges.isEmpty()) { + data.personCount = data.personRanges.get(data.personRanges.size() - 1).getHighPersonId() + 1; } } @@ -215,9 +215,13 @@ private Builder(Data data) { * */ public PeoplePluginData build() { - validate(); - ensureImmutability(); - return new PeoplePluginData(data); + try { + validate(); + ensureImmutability(); + return new PeoplePluginData(data); + } finally { + data = new Data(); + } } /** diff --git a/gcm4/src/main/java/plugins/personproperties/PersonPropertiesPluginData.java b/gcm4/src/main/java/plugins/personproperties/PersonPropertiesPluginData.java index bc307536f..1e1af1f78 100644 --- a/gcm4/src/main/java/plugins/personproperties/PersonPropertiesPluginData.java +++ b/gcm4/src/main/java/plugins/personproperties/PersonPropertiesPluginData.java @@ -135,11 +135,15 @@ private Builder(Data data) { * */ public PersonPropertiesPluginData build() { + try { if (!data.locked) { validateData(); } ensureImmutability(); return new PersonPropertiesPluginData(data); + }finally { + data = new Data(); + } } /** diff --git a/gcm4/src/main/java/plugins/regions/RegionsPluginData.java b/gcm4/src/main/java/plugins/regions/RegionsPluginData.java index 0fe3b27da..550281fdb 100644 --- a/gcm4/src/main/java/plugins/regions/RegionsPluginData.java +++ b/gcm4/src/main/java/plugins/regions/RegionsPluginData.java @@ -67,10 +67,14 @@ public Data(Data data) { @Override public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof Data)) return false; + if (this == o) + return true; + if (!(o instanceof Data)) + return false; Data data = (Data) o; - return locked == data.locked && regionPropertyDefinitions.equals(data.regionPropertyDefinitions) && regionIds.equals(data.regionIds) && regionArrivalTimeTrackingPolicy == data.regionArrivalTimeTrackingPolicy && regionPropertyValues.equals(data.regionPropertyValues) && emptyRegionPropertyMap.equals(data.emptyRegionPropertyMap) && personRegions.equals(data.personRegions); + return locked == data.locked && regionPropertyDefinitions.equals(data.regionPropertyDefinitions) && regionIds.equals(data.regionIds) + && regionArrivalTimeTrackingPolicy == data.regionArrivalTimeTrackingPolicy && regionPropertyValues.equals(data.regionPropertyValues) + && emptyRegionPropertyMap.equals(data.emptyRegionPropertyMap) && personRegions.equals(data.personRegions); } @Override @@ -171,11 +175,15 @@ private Builder(Data data) { * */ public RegionsPluginData build() { - if (!data.locked) { - validateData(); + try { + if (!data.locked) { + validateData(); + } + ensureImmutability(); + return new RegionsPluginData(data); + } finally { + data = new Data(); } - ensureImmutability(); - return new RegionsPluginData(data); } @@ -454,8 +462,10 @@ public PluginDataBuilder getEmptyBuilder() { @Override public boolean equals(Object o) { - if (this == o) return true; - if (!(o instanceof RegionsPluginData)) return false; + if (this == o) + return true; + if (!(o instanceof RegionsPluginData)) + return false; RegionsPluginData that = (RegionsPluginData) o; return data.equals(that.data); } diff --git a/gcm4/src/main/java/plugins/resources/ResourcesPluginData.java b/gcm4/src/main/java/plugins/resources/ResourcesPluginData.java index 6c75cba67..5fb16b5a4 100644 --- a/gcm4/src/main/java/plugins/resources/ResourcesPluginData.java +++ b/gcm4/src/main/java/plugins/resources/ResourcesPluginData.java @@ -252,11 +252,15 @@ private Builder(Data data) { * */ public ResourcesPluginData build() { - if (!data.locked) { - validateData(); + try { + if (!data.locked) { + validateData(); + } + ensureImmutability(); + return new ResourcesPluginData(data); + } finally { + data = new Data(); } - ensureImmutability(); - return new ResourcesPluginData(data); } /** diff --git a/gcm4/src/main/java/plugins/stochastics/StochasticsPluginData.java b/gcm4/src/main/java/plugins/stochastics/StochasticsPluginData.java index e1f732594..d955bb64b 100644 --- a/gcm4/src/main/java/plugins/stochastics/StochasticsPluginData.java +++ b/gcm4/src/main/java/plugins/stochastics/StochasticsPluginData.java @@ -152,11 +152,15 @@ private void validateData() { * */ public StochasticsPluginData build() { + try { if (!data.locked) { validateData(); } ensureImmutability(); return new StochasticsPluginData(data); + }finally { + data = new Data(); + } } /**