提交 e01074b2 编写于 作者: K kohsuke

added a mechanism to customize the conversion process.


git-svn-id: https://hudson.dev.java.net/svn/hudson/trunk/hudson/main@3042 71c3de6d-444a-0410-be80-ed276b4c234a
上级 5ca3f63f
package hudson.api;
/**
* Interface that an exposed bean can implement, to do the equivalent
* of <tt>writeReplace</tt> in Java serialization.
* @author Kohsuke Kawaguchi
*/
public interface CustomExposureBean {
/**
* The returned object will be introspected and written as JSON/XML.
*/
Object toExposedObject();
}
......@@ -58,6 +58,11 @@ abstract class Property implements Comparable<Property> {
return;
}
if(value instanceof CustomExposureBean) {
writeValue(((CustomExposureBean)value).toExposedObject(),depth,writer);
return;
}
Class c = value.getClass();
if(STRING_TYPES.contains(c)) {
......
......@@ -5,12 +5,14 @@ import com.thoughtworks.xstream.converters.basic.AbstractBasicConverter;
import java.io.Serializable;
import hudson.api.CustomExposureBean;
/**
* The build outcome.
*
* @author Kohsuke Kawaguchi
*/
public final class Result implements Serializable {
public final class Result implements Serializable, CustomExposureBean {
/**
* The build didn't have any fatal errors not errors.
*/
......@@ -75,6 +77,10 @@ public final class Result implements Serializable {
return FAILURE;
}
public Object toExposedObject() {
return name;
}
private static final long serialVersionUID = 1L;
private static final Result[] all = new Result[] {SUCCESS,UNSTABLE,FAILURE,ABORTED};
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册