aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakozak2011-11-24 08:12:53 (EST)
committerWinston Prakash2011-12-01 20:47:25 (EST)
commitee7b09e6c6e309695eaf532f3baa0056e05c6a13 (patch)
tree4c5e1bb42349abdafdd6c4308bd5912ce24ac014
parenta1f5f4144d3063fe89df8aab280fdf2772e218a1 (diff)
downloadorg.eclipse.hudson.core-ee7b09e6c6e309695eaf532f3baa0056e05c6a13.zip
org.eclipse.hudson.core-ee7b09e6c6e309695eaf532f3baa0056e05c6a13.tar.gz
org.eclipse.hudson.core-ee7b09e6c6e309695eaf532f3baa0056e05c6a13.tar.bz2
Refine BasePP class in order to provide better flexibility in resetting original value for subclasses
Signed-off-by: Winston Prakash <winston.prakash@gmail.com>
-rw-r--r--hudson-core/src/main/java/org/eclipse/hudson/api/model/project/property/BaseProjectProperty.java16
-rw-r--r--hudson-core/src/main/java/org/eclipse/hudson/api/model/project/property/TriggerProjectProperty.java13
2 files changed, 18 insertions, 11 deletions
diff --git a/hudson-core/src/main/java/org/eclipse/hudson/api/model/project/property/BaseProjectProperty.java b/hudson-core/src/main/java/org/eclipse/hudson/api/model/project/property/BaseProjectProperty.java
index 43e5fca..a37f49a 100644
--- a/hudson-core/src/main/java/org/eclipse/hudson/api/model/project/property/BaseProjectProperty.java
+++ b/hudson-core/src/main/java/org/eclipse/hudson/api/model/project/property/BaseProjectProperty.java
@@ -139,8 +139,8 @@ public class BaseProjectProperty<T> implements IProjectProperty<T> {
/**
* Update value for cascading property. Before setting new value it will be checked for equality with cascading
- * value. If two values are equals - current value will be reset and will retrieved from parent. If not - value will
- * be set directly.
+ * value. If two values are equals - current value will be cleared via {@link #clearOriginalValue(Object)}
+ * and will retrieved from parent. If not - value will be set directly.
*
* @param value new value to be set.
* @param cascadingValue current cascading value.
@@ -151,7 +151,7 @@ public class BaseProjectProperty<T> implements IProjectProperty<T> {
if (allowOverrideValue(cascadingValue, candidateValue)) {
setOriginalValue(value, true);
} else {
- resetValue();
+ clearOriginalValue(value);
}
return true;
}
@@ -169,6 +169,16 @@ public class BaseProjectProperty<T> implements IProjectProperty<T> {
}
/**
+ * Method that clears original value and marks it as overridden if needed.
+ * Default implementation uses {@link #resetValue()}. Subclasses can override this method.
+ *
+ * @param originalValue value to set.
+ */
+ protected void clearOriginalValue(T originalValue) {
+ resetValue();
+ }
+
+ /**
* {@inheritDoc}
*/
public void resetValue() {
diff --git a/hudson-core/src/main/java/org/eclipse/hudson/api/model/project/property/TriggerProjectProperty.java b/hudson-core/src/main/java/org/eclipse/hudson/api/model/project/property/TriggerProjectProperty.java
index 42774b9..8fab530 100644
--- a/hudson-core/src/main/java/org/eclipse/hudson/api/model/project/property/TriggerProjectProperty.java
+++ b/hudson-core/src/main/java/org/eclipse/hudson/api/model/project/property/TriggerProjectProperty.java
@@ -26,14 +26,11 @@ public class TriggerProjectProperty<T> extends ExternalProjectProperty<T> {
super(job);
}
+ /**
+ * {@inheritDoc}
+ */
@Override
- protected boolean updateOriginalValue(T value, T cascadingValue) {
- T candidateValue = null == value ? getDefaultValue() : value;
- if (allowOverrideValue(cascadingValue, candidateValue)) {
- setOriginalValue(value, true);
- } else {
- setOriginalValue(value, false);
- }
- return true;
+ protected void clearOriginalValue(T originalValue) {
+ setOriginalValue(originalValue, false);
}
}