org.xins.client.AbstractCAPICallResult Maven / Gradle / Ivy
/*
* $Id: AbstractCAPICallResult.java,v 1.25 2012/04/16 19:40:39 agoubard Exp $
*
* See the COPYRIGHT file for redistribution and use restrictions.
*/
package org.xins.client;
import java.io.Serializable;
import java.util.List;
import org.xins.common.MandatoryArgumentChecker;
import org.xins.common.service.CallException;
import org.xins.common.service.TargetDescriptor;
/**
* Base class for generated CAPI function result classes.
*
* This class should not be subclassed manually. It is only intended to be
* subclassed by classes generated by XINS.
*
* @version $Revision: 1.25 $ $Date: 2012/04/16 19:40:39 $
* @author Ernst de Haan
*
* @since XINS 1.0.0
*/
public abstract class AbstractCAPICallResult implements Serializable {
/**
* The XINS call result. This field cannot be null
.
*/
private XINSCallResult _result;
/**
* Creates a new AbstractCAPICallResult
object, based on the
* specified XINSCallResult
.
*
* @param result
* the lower-level {@link XINSCallResult}, cannot be null
.
*
* @throws IllegalArgumentException
* if result == null
.
*/
protected AbstractCAPICallResult(XINSCallResult result)
throws IllegalArgumentException {
// Check preconditions
MandatoryArgumentChecker.check("result", result);
// Store field
_result = result;
// Check preconditions
if (result.getErrorCode() != null) {
throw new IllegalArgumentException("result.getErrorCode() != null");
}
}
/**
* Returns the underlying XINS call result.
*
* @return
* the underlying {@link XINSCallResult} object, never
* null
.
*/
XINSCallResult getXINSCallResult() {
return _result;
}
/**
* Returns the target for which the call succeeded.
*
* @return
* the {@link TargetDescriptor} for which the call succeeded, not
* null
.
*
* @since XINS 1.1.0
*/
public final TargetDescriptor succeededTarget() {
return _result.getSucceededTarget();
}
/**
* Returns the call duration, in milliseconds.
*
* @return
* the duration of the succeeded call, in milliseconds, guaranteed to
* be a non-negative number.
*
* @since XINS 1.1.0
*/
public final long duration() {
return _result.getDuration();
}
/**
* Returns the list of CallException
s.
*
* @return
* the {@link org.xins.common.service.CallException}s,
* collected in a {@link CallExceptionList} object,
* or null
if the first call attempt succeeded.
*
* @since XINS 1.1.0
*/
public final List exceptions() {
return _result.getExceptions();
}
}