com.anaptecs.jeaf.services.scheduling.ExecutionResult Maven / Gradle / Ivy
/*
* anaptecs GmbH, Ricarda-Huch-Str. 71, 72760 Reutlingen, Germany
*
* Copyright 2004 - 2019. All rights reserved.
*/
package com.anaptecs.jeaf.services.scheduling;
import java.util.Calendar;
import com.anaptecs.jeaf.core.api.AbstractObjectID;
import com.anaptecs.jeaf.core.api.Identifiable;
import com.anaptecs.jeaf.core.api.MessageConstants;
import com.anaptecs.jeaf.core.api.ServiceObject;
import com.anaptecs.jeaf.core.api.ServiceObjectID;
import com.anaptecs.jeaf.tools.api.Tools;
import com.anaptecs.jeaf.xfun.api.XFun;
import com.anaptecs.jeaf.xfun.api.checks.Check;
/**
* @author JEAF Generator
* @version JEAF Release 1.4.x
*/
public class ExecutionResult implements ServiceObject, Identifiable {
/**
* Default serial version uid.
*/
private static final long serialVersionUID = 1L;
/**
* Constant for the name of attribute "successful".
*/
public static final String SUCCESSFUL = "successful";
/**
* Constant for the name of attribute "executionTime".
*/
public static final String EXECUTIONTIME = "executionTime";
/**
* Constant for the name of attribute "errorMessage".
*/
public static final String ERRORMESSAGE = "errorMessage";
/**
* Constant for the name of attribute "trigger".
*/
public static final String TRIGGER = "trigger";
/**
* Constant for the name of attribute "exception".
*/
public static final String EXCEPTION = "exception";
/**
* Reference to the identifier of this object. The reference may be null since an id is not mandatory.
*/
private final ServiceObjectID objectID;
/**
* Attribute indicated whether the task was executed successful or not. True means successful.
*/
private Boolean successful;
/**
*
*/
private Calendar executionTime;
/**
*
*/
private String errorMessage;
/**
* The attribute describes the reason that caused the task to be executed. The reference is never null.
*/
private ExecutionTrigger trigger;
/**
* Exception which might be occurred during Task execution.
*/
private Exception exception;
/**
* Initialize object using the passed builder.
*
* @param pBuilder Builder that should be used to initialize this object. The parameter must not be null.
*/
protected ExecutionResult( Builder pBuilder ) {
// Ensure that builder is not null.
Check.checkInvalidParameterNull(pBuilder, "pBuilder");
// Read object ID.
AbstractObjectID> lObjectID = pBuilder.objectID;
if (lObjectID != null) {
objectID = new ServiceObjectID(pBuilder.objectID);
}
else {
objectID = null;
}
// Read attribute values from builder.
successful = pBuilder.successful;
executionTime = pBuilder.executionTime;
errorMessage = pBuilder.errorMessage;
trigger = pBuilder.trigger;
exception = pBuilder.exception;
}
/**
* Class implements builder to create a new instance of class ExecutionResult. As the class has readonly attributes or
* associations instances can not be created directly. Instead this builder class has to be used.
*/
public static class Builder {
/**
* Reference to the identifier of this object. The reference may be null since an id is not mandatory.
*/
private AbstractObjectID> objectID;
/**
* Attribute indicated whether the task was executed successful or not. True means successful.
*/
private Boolean successful;
/**
*
*/
private Calendar executionTime;
/**
*
*/
private String errorMessage;
/**
* The attribute describes the reason that caused the task to be executed. The reference is never null.
*/
private ExecutionTrigger trigger;
/**
* Exception which might be occurred during Task execution.
*/
private Exception exception;
/**
* Use {@link #newBuilder()} instead of private constructor to create new builder.
*/
protected Builder( ) {
}
/**
* Use {@link #newBuilder(ExecutionResult)} instead of private constructor to create new builder.
*/
protected Builder( ExecutionResult pObject ) {
if (pObject != null) {
// Read attribute values from passed object.
objectID = pObject.objectID;
successful = pObject.successful;
executionTime = pObject.executionTime;
errorMessage = pObject.errorMessage;
trigger = pObject.trigger;
exception = pObject.exception;
}
}
/**
* Method returns a new builder.
*
* @return {@link Builder} New builder that can be used to create new ImmutablePOJOParent objects.
*/
public static Builder newBuilder( ) {
return new Builder();
}
/**
* Method creates a new builder and initialize it with the data from the passed object.
*
* @param pObject Object that should be used to initialize the builder. The parameter may be null.
* @return {@link Builder} New builder that can be used to create new ExecutionResult objects. The method never
* returns null.
*/
public static Builder newBuilder( ExecutionResult pObject ) {
return new Builder(pObject);
}
/**
* Method sets the identifier for the object created using the builder. The reference may be null since an id is not
* mandatory.
*/
public Builder setID( AbstractObjectID> pObjectID ) {
objectID = pObjectID;
return this;
}
/**
* Method sets the attribute "successful". Attribute indicated whether the task was executed successful or not. True
* means successful.
*
* @param pSuccessful Value to which the attribute "successful" should be set.
*/
public Builder setSuccessful( Boolean pSuccessful ) {
// Assign value to attribute
successful = pSuccessful;
return this;
}
/**
* Method sets the attribute "executionTime".
*
* @param pExecutionTime Value to which the attribute "executionTime" should be set.
*/
public Builder setExecutionTime( Calendar pExecutionTime ) {
// Assign value to attribute
executionTime = pExecutionTime;
return this;
}
/**
* Method sets the attribute "errorMessage".
*
* @param pErrorMessage Value to which the attribute "errorMessage" should be set.
*/
public Builder setErrorMessage( String pErrorMessage ) {
// Assign value to attribute
errorMessage = pErrorMessage;
return this;
}
/**
* Method sets the association "trigger". The attribute describes the reason that caused the task to be executed.
* The reference is never null.
*
* @param pTrigger ExecutionTrigger to which the association "trigger" should be set.
*/
public Builder setTrigger( ExecutionTrigger pTrigger ) {
trigger = pTrigger;
return this;
}
/**
* Method sets the attribute "exception". Exception which might be occurred during Task execution.
*
* @param pException Value to which the attribute "exception" should be set.
*/
public Builder setException( Exception pException ) {
// Assign value to attribute
exception = pException;
return this;
}
/**
* Method creates a new instance of class ExecutionResult. The object will be initialized with the values of the
* builder.
*
* @return ExecutionResult Created object. The method never returns null.
*/
public ExecutionResult build( ) {
return new ExecutionResult(this);
}
/**
* Method creates a new instance of class ExecutionResult. The object will be initialized with the values of the
* builder.
*
* @param pValidate Parameter defines if the created POJO should be validated using Java Validation.
* @return ExecutionResult Created object. The method never returns null.
*/
public ExecutionResult build( boolean pValidate ) {
ExecutionResult lPOJO = this.build();
if (pValidate == true) {
Tools.getValidationTools().validateObject(lPOJO);
}
return lPOJO;
}
}
/**
* Method returns the id of this object.
*
* @return {@link ServiceObjectID} ID of this object. Since an object must not have an id the method may also return
* null.
*/
@Override
public final ServiceObjectID getID( ) {
return objectID;
}
/**
* Method returns the unversioned object id of this object.
*
* @return {@link ServiceObjectID} ID of this object. Since an object must not have an id the method may also return
* null.
*/
@Override
public final ServiceObjectID getUnversionedID( ) {
ServiceObjectID lUnversionedID;
if (objectID != null) {
lUnversionedID = objectID.getUnversionedObjectID();
}
else {
lUnversionedID = null;
}
return lUnversionedID;
}
/**
* Method returns the attribute "successful". Attribute indicated whether the task was executed successful or not.
* True means successful.
*
* @return Boolean Value to which the attribute "successful" is set.
*/
public Boolean getSuccessful( ) {
return successful;
}
/**
* Method sets the attribute "successful". Attribute indicated whether the task was executed successful or not. True
* means successful.
*
* @param pSuccessful Value to which the attribute "successful" should be set.
*/
public void setSuccessful( Boolean pSuccessful ) {
// Assign value to attribute
successful = pSuccessful;
}
/**
* Method returns the attribute "executionTime".
*
*
* @return Calendar Value to which the attribute "executionTime" is set.
*/
public Calendar getExecutionTime( ) {
return executionTime;
}
/**
* Method sets the attribute "executionTime".
*
*
* @param pExecutionTime Value to which the attribute "executionTime" should be set.
*/
public void setExecutionTime( Calendar pExecutionTime ) {
// Assign value to attribute
executionTime = pExecutionTime;
}
/**
* Method returns the attribute "errorMessage".
*
*
* @return String Value to which the attribute "errorMessage" is set.
*/
public String getErrorMessage( ) {
return errorMessage;
}
/**
* Method sets the attribute "errorMessage".
*
*
* @param pErrorMessage Value to which the attribute "errorMessage" should be set.
*/
public void setErrorMessage( String pErrorMessage ) {
// Assign value to attribute
errorMessage = pErrorMessage;
}
/**
* Method returns the association "trigger". The attribute describes the reason that caused the task to be executed.
* The reference is never null.
*
* @return ExecutionTrigger ExecutionTrigger to which the association "trigger" is set.
*/
public ExecutionTrigger getTrigger( ) {
return trigger;
}
/**
* Method sets the association "trigger". The attribute describes the reason that caused the task to be executed. The
* reference is never null.
*
* @param pTrigger ExecutionTrigger to which the association "trigger" should be set.
*/
public void setTrigger( ExecutionTrigger pTrigger ) {
// pTrigger must not be null. To unset an association the unset method has to be called.
Check.checkInvalidParameterNull(pTrigger, "pTrigger");
trigger = pTrigger;
}
/**
* Method unsets the association "trigger". The attribute describes the reason that caused the task to be executed.
* The reference is never null.
*/
public final void unsetTrigger( ) {
trigger = null;
}
/**
* Method returns the attribute "exception". Exception which might be occurred during Task execution.
*
* @return Exception Value to which the attribute "exception" is set.
*/
public Exception getException( ) {
return exception;
}
/**
* Method sets the attribute "exception". Exception which might be occurred during Task execution.
*
* @param pException Value to which the attribute "exception" should be set.
*/
public void setException( Exception pException ) {
// Assign value to attribute
exception = pException;
}
/**
* Method returns a StringBuilder that can be used to create a String representation of this object. the returned
* StringBuilder also takes care about attributes of super classes.
*
* @return {@link StringBuilder} StringBuilder representing this object. The method never returns null.
*/
protected StringBuilder toStringBuilder( ) {
StringBuilder lBuilder = new StringBuilder(256);
lBuilder.append(XFun.getMessageRepository().getMessage(MessageConstants.OBJECT_INFO, this.getClass().getName()));
lBuilder.append('\n');
lBuilder.append(XFun.getMessageRepository().getMessage(MessageConstants.OBJECT_ATTRIBUTES_SECTION));
lBuilder.append('\n');
lBuilder.append(
XFun.getMessageRepository().getMessage(MessageConstants.OBJECT_ATTRIBUTE, "successful", "" + successful));
lBuilder.append('\n');
lBuilder.append(
XFun.getMessageRepository().getMessage(MessageConstants.OBJECT_ATTRIBUTE, "executionTime", "" + executionTime));
lBuilder.append('\n');
lBuilder.append(
XFun.getMessageRepository().getMessage(MessageConstants.OBJECT_ATTRIBUTE, "errorMessage", "" + errorMessage));
lBuilder.append('\n');
lBuilder
.append(XFun.getMessageRepository().getMessage(MessageConstants.OBJECT_ATTRIBUTE, "exception", "" + exception));
lBuilder.append('\n');
return lBuilder;
}
/**
* Method creates a new String with the values of all attributes of this class. All references to other objects will
* be ignored.
*
* @return {@link String} String representation of this object. The method never returns null.
*/
@Override
public String toString( ) {
return this.toStringBuilder().toString();
}
}