From e66328986437e65f5306f16fb9a37b7784cb6af4 Mon Sep 17 00:00:00 2001 From: kohsuke Date: Wed, 25 Feb 2009 01:30:59 +0000 Subject: [PATCH] DescribableList is designed not to require the set method. git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@15706 71c3de6d-444a-0410-be80-ed276b4c234a --- core/src/main/java/hudson/model/Hudson.java | 4 ---- core/src/main/java/hudson/model/Node.java | 13 ++++--------- core/src/main/java/hudson/model/Slave.java | 4 ---- core/src/test/java/hudson/slaves/NodeListTest.java | 6 ------ .../test/java/hudson/model/AbstractBuildTest.java | 5 ++--- 5 files changed, 6 insertions(+), 26 deletions(-) diff --git a/core/src/main/java/hudson/model/Hudson.java b/core/src/main/java/hudson/model/Hudson.java index fbd44d29a3..fa671576a8 100644 --- a/core/src/main/java/hudson/model/Hudson.java +++ b/core/src/main/java/hudson/model/Hudson.java @@ -1240,10 +1240,6 @@ public final class Hudson extends Node implements ItemGroup, Stapl return nodeProperties; } - public void setNodeProperties(Collection> nodeProperties) throws IOException { - this.nodeProperties.replaceBy(nodeProperties); - } - /** * Resets all labels and remove invalid ones. */ diff --git a/core/src/main/java/hudson/model/Node.java b/core/src/main/java/hudson/model/Node.java index cb900209a1..8b5af18c73 100644 --- a/core/src/main/java/hudson/model/Node.java +++ b/core/src/main/java/hudson/model/Node.java @@ -186,18 +186,13 @@ public abstract class Node extends AbstractModelObject implements Describable, NodePropertyDescriptor> getNodeProperties(); - - public abstract void setNodeProperties(Collection> nodeProperties) throws IOException; public > N getNodeProperty(Class clazz) { - for (NodeProperty p: getNodeProperties()) { - if (clazz.isInstance(p)) { - return clazz.cast(p); - } - } - return null; + return getNodeProperties().get(clazz); } public ACL getACL() { diff --git a/core/src/main/java/hudson/model/Slave.java b/core/src/main/java/hudson/model/Slave.java index a3795649fa..163ca5b0b0 100644 --- a/core/src/main/java/hudson/model/Slave.java +++ b/core/src/main/java/hudson/model/Slave.java @@ -214,10 +214,6 @@ public abstract class Slave extends Node implements Serializable { return nodeProperties; } - public void setNodeProperties(Collection> nodeProperties) throws IOException { - this.nodeProperties.replaceBy(nodeProperties); - } - public RetentionStrategy getRetentionStrategy() { return retentionStrategy == null ? RetentionStrategy.Always.INSTANCE : retentionStrategy; } diff --git a/core/src/test/java/hudson/slaves/NodeListTest.java b/core/src/test/java/hudson/slaves/NodeListTest.java index cad3fabd4b..0f792c755f 100644 --- a/core/src/test/java/hudson/slaves/NodeListTest.java +++ b/core/src/test/java/hudson/slaves/NodeListTest.java @@ -106,12 +106,6 @@ public class NodeListTest extends TestCase { public DescribableList, NodePropertyDescriptor> getNodeProperties() { throw new UnsupportedOperationException(); } - - @Override - public void setNodeProperties(Collection> nodeProperties) - throws IOException { - throw new UnsupportedOperationException(); - } } static class EphemeralNode extends DummyNode implements hudson.slaves.EphemeralNode { public Cloud getCloud() { diff --git a/test/src/test/java/hudson/model/AbstractBuildTest.java b/test/src/test/java/hudson/model/AbstractBuildTest.java index 5d2bb5b893..b7dded42c0 100644 --- a/test/src/test/java/hudson/model/AbstractBuildTest.java +++ b/test/src/test/java/hudson/model/AbstractBuildTest.java @@ -17,9 +17,8 @@ public class AbstractBuildTest extends HudsonTestCase { public void testVariablesResolved() throws Exception { FreeStyleProject project = createFreeStyleProject(); - Hudson.getInstance().setNodeProperties( - Collections - .>singleton(new EnvironmentVariablesNodeProperty( + Hudson.getInstance().getNodeProperties().replaceBy( + Collections.singleton(new EnvironmentVariablesNodeProperty( new Entry("KEY1", "value"), new Entry("KEY2", "$KEY1")))); CaptureEnvironmentBuilder builder = new CaptureEnvironmentBuilder(); -- GitLab