提交 e6632898 编写于 作者: K kohsuke

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
上级 d2612725
......@@ -1240,10 +1240,6 @@ public final class Hudson extends Node implements ItemGroup<TopLevelItem>, Stapl
return nodeProperties;
}
public void setNodeProperties(Collection<NodeProperty<?>> nodeProperties) throws IOException {
this.nodeProperties.replaceBy(nodeProperties);
}
/**
* Resets all labels and remove invalid ones.
*/
......
......@@ -186,18 +186,13 @@ public abstract class Node extends AbstractModelObject implements Describable<No
return FileSystemProvisioner.DEFAULT;
}
// these are abstract because of possibly different owners for the nodeProperties list in subclasses
/**
* Gets the {@link NodeProperty} instances configured for this {@link Node}.
*/
public abstract DescribableList<NodeProperty<?>, NodePropertyDescriptor> getNodeProperties();
public abstract void setNodeProperties(Collection<NodeProperty<?>> nodeProperties) throws IOException;
public <N extends NodeProperty<?>> N getNodeProperty(Class<N> clazz) {
for (NodeProperty<?> p: getNodeProperties()) {
if (clazz.isInstance(p)) {
return clazz.cast(p);
}
}
return null;
return getNodeProperties().get(clazz);
}
public ACL getACL() {
......
......@@ -214,10 +214,6 @@ public abstract class Slave extends Node implements Serializable {
return nodeProperties;
}
public void setNodeProperties(Collection<NodeProperty<?>> nodeProperties) throws IOException {
this.nodeProperties.replaceBy(nodeProperties);
}
public RetentionStrategy getRetentionStrategy() {
return retentionStrategy == null ? RetentionStrategy.Always.INSTANCE : retentionStrategy;
}
......
......@@ -106,12 +106,6 @@ public class NodeListTest extends TestCase {
public DescribableList<NodeProperty<?>, NodePropertyDescriptor> getNodeProperties() {
throw new UnsupportedOperationException();
}
@Override
public void setNodeProperties(Collection<NodeProperty<?>> nodeProperties)
throws IOException {
throw new UnsupportedOperationException();
}
}
static class EphemeralNode extends DummyNode implements hudson.slaves.EphemeralNode {
public Cloud getCloud() {
......
......@@ -17,9 +17,8 @@ public class AbstractBuildTest extends HudsonTestCase {
public void testVariablesResolved() throws Exception {
FreeStyleProject project = createFreeStyleProject();
Hudson.getInstance().setNodeProperties(
Collections
.<NodeProperty<?>>singleton(new EnvironmentVariablesNodeProperty(
Hudson.getInstance().getNodeProperties().replaceBy(
Collections.singleton(new EnvironmentVariablesNodeProperty(
new Entry("KEY1", "value"), new Entry("KEY2",
"$KEY1"))));
CaptureEnvironmentBuilder builder = new CaptureEnvironmentBuilder();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册