提交 2b079a59 编写于 作者: K Kohsuke Kawaguchi

Adding another way to extract the value, this time into a "natural" Java object.

I came into this use case while working on the workflow, but I think it's useful in other context as well,
such as Scriptler plugin needing to define some parameters.
上级 6575f57a
......@@ -48,6 +48,11 @@ public class BooleanParameterValue extends ParameterValue {
this.value = value;
}
@Override
public Boolean getValue() {
return value;
}
/**
* Exposes the name/value as an environment variable.
*/
......
......@@ -96,6 +96,11 @@ public class FileParameterValue extends ParameterValue {
return location;
}
@Override
public Object getValue() {
return file;
}
/**
* Exposes the originalFileName as an environment variable.
*/
......
......@@ -37,6 +37,11 @@ public class JobParameterValue extends ParameterValue {
this.job = job;
}
@Override
public Job getValue() {
return job;
}
/**
* Exposes the name/value as an environment variable.
*/
......
......@@ -278,6 +278,16 @@ public abstract class ParameterValue implements Serializable {
return false;
}
/**
* Returns the most natural Java object that represents the actual value, like
* boolean, string, etc.
*
* If there's nothing that really fits the bill, the callee can return {@code this}.
*/
public Object getValue() {
return null;
}
/**
* Controls where the build (that this parameter is submitted to) will happen.
*
......
......@@ -66,7 +66,11 @@ public class RunParameterValue extends ParameterValue {
public String getNumber() {
return runId.split("#")[1];
}
@Override
public Run getValue() {
return getRun();
}
/**
* Exposes the name/value as an environment variable.
......
......@@ -65,9 +65,13 @@ public class StringParameterValue extends ParameterValue {
}
};
}
@Override
@Override
public Object getValue() {
return value;
}
@Override
public int hashCode() {
final int prime = 31;
int result = super.hashCode();
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册