aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorakozak2011-11-22 10:04:01 (EST)
committerWinston Prakash2011-12-01 20:47:02 (EST)
commita1422716b371382e16b7861030e963fb9133b0f1 (patch)
tree4ba4d443f23d8fb7afc118bca9639a9f2c9b648d
parent185241439b8c1c816718fffe717be46d4eea1504 (diff)
downloadorg.eclipse.hudson.core-a1422716b371382e16b7861030e963fb9133b0f1.zip
org.eclipse.hudson.core-a1422716b371382e16b7861030e963fb9133b0f1.tar.gz
org.eclipse.hudson.core-a1422716b371382e16b7861030e963fb9133b0f1.tar.bz2
Expose resetValue method to IProjectProperty interface. Make it possible to reset property value
Signed-off-by: Winston Prakash <winston.prakash@gmail.com>
-rw-r--r--hudson-core/src/main/java/hudson/model/BaseProjectProperty.java11
-rw-r--r--hudson-core/src/main/java/org/eclipse/hudson/api/model/IProjectProperty.java5
-rw-r--r--hudson-core/src/test/java/hudson/model/ProjectPropertyTest.java16
3 files changed, 30 insertions, 2 deletions
diff --git a/hudson-core/src/main/java/hudson/model/BaseProjectProperty.java b/hudson-core/src/main/java/hudson/model/BaseProjectProperty.java
index 9e8ad62..b89ba77 100644
--- a/hudson-core/src/main/java/hudson/model/BaseProjectProperty.java
+++ b/hudson-core/src/main/java/hudson/model/BaseProjectProperty.java
@@ -129,12 +129,19 @@ public class BaseProjectProperty<T> implements IProjectProperty<T> {
originalValue = value;
setPropertyOverridden(true);
} else {
- this.originalValue = null;
- setPropertyOverridden(false);
+ resetValue();
}
}
/**
+ * {@inheritDoc}
+ */
+ public void resetValue() {
+ this.originalValue = null;
+ setPropertyOverridden(false);
+ }
+
+ /**
* Returns true, if cascading value should be overridden by candidate value.
*
* @param cascadingValue value from cascading project if any.
diff --git a/hudson-core/src/main/java/org/eclipse/hudson/api/model/IProjectProperty.java b/hudson-core/src/main/java/org/eclipse/hudson/api/model/IProjectProperty.java
index bac6097..48fae06 100644
--- a/hudson-core/src/main/java/org/eclipse/hudson/api/model/IProjectProperty.java
+++ b/hudson-core/src/main/java/org/eclipse/hudson/api/model/IProjectProperty.java
@@ -80,4 +80,9 @@ public interface IProjectProperty<T> extends Serializable {
* @return value
*/
T getDefaultValue();
+
+ /**
+ * Resets value for given job. Default implementation sets Null value and resets propertyOverridden flag to false.
+ */
+ void resetValue();
}
diff --git a/hudson-core/src/test/java/hudson/model/ProjectPropertyTest.java b/hudson-core/src/test/java/hudson/model/ProjectPropertyTest.java
index 57744d7..27a259d 100644
--- a/hudson-core/src/test/java/hudson/model/ProjectPropertyTest.java
+++ b/hudson-core/src/test/java/hudson/model/ProjectPropertyTest.java
@@ -341,4 +341,20 @@ public class ProjectPropertyTest {
fail("PropertyKey is valid");
}
}
+
+ /**
+ * Resets project property value,
+ */
+ @Test
+ public void testResetValue() {
+ BaseProjectProperty property = new BaseProjectProperty(project);
+ property.setKey(propertyKey);
+ property.setValue(new Object());
+ property.setPropertyOverridden(true);
+ assertNotNull(property.getOriginalValue());
+ assertTrue(property.isPropertyOverridden());
+ property.resetValue();
+ assertNull(property.getOriginalValue());
+ assertFalse(property.isPropertyOverridden());
+ }
}