All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.anaptecs.jeaf.services.scheduling.OneTimeExecution Maven / Gradle / Ivy

There is a newer version: 1.8.0
Show newest version
/*
 * 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.MessageConstants;
import com.anaptecs.jeaf.tools.api.Tools;
import com.anaptecs.jeaf.xfun.api.XFun;

/**
 * Class describes the one time execution of a task. This means that the task will be executed only once at the defined
 * time.
 * 
 * @author JEAF Generator
 * @version JEAF Release 1.4.x
 */
public class OneTimeExecution extends ExecutionStrategy {
  /**
   * Default serial version uid.
   */
  private static final long serialVersionUID = 1L;

  /**
   * Constant for the name of attribute "executionTime".
   */
  public static final String EXECUTIONTIME = "executionTime";

  /**
   * Timestamp defining when the task should be executed.
   */
  private Calendar executionTime;

  /**
   * Initialize object using the passed builder.
   * 
   * @param pBuilder Builder that should be used to initialize this object. The parameter must not be null.
   */
  protected OneTimeExecution( Builder pBuilder ) {
    // Call constructor of super class.
    super(pBuilder);
    // Read attribute values from builder.
    executionTime = pBuilder.executionTime;
  }

  /**
   * Class implements builder to create a new instance of class OneTimeExecution. 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 extends ExecutionStrategy.Builder {
    /**
     * Timestamp defining when the task should be executed.
     */
    private Calendar executionTime;

    /**
     * Use {@link #newBuilder()} instead of private constructor to create new builder.
     */
    protected Builder( ) {
      super();
    }

    /**
     * Use {@link #newBuilder(OneTimeExecution)} instead of private constructor to create new builder.
     */
    protected Builder( OneTimeExecution pObject ) {
      super(pObject);
      if (pObject != null) {
        // Read attribute values from passed object.
        executionTime = pObject.executionTime;
      }
    }

    /**
     * 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 OneTimeExecution objects. The method never
     * returns null.
     */
    public static Builder newBuilder( OneTimeExecution 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.
     */
    @Override
    public Builder setID( AbstractObjectID pObjectID ) {
      super.setID(pObjectID);
      return this;
    }

    /**
     * Method sets the attribute "executionTime". Timestamp defining when the task should be executed.
     * 
     * @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 creates a new instance of class OneTimeExecution. The object will be initialized with the values of the
     * builder.
     * 
     * @return OneTimeExecution Created object. The method never returns null.
     */
    public OneTimeExecution build( ) {
      return new OneTimeExecution(this);
    }

    /**
     * Method creates a new instance of class OneTimeExecution. 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 OneTimeExecution Created object. The method never returns null.
     */
    public OneTimeExecution build( boolean pValidate ) {
      OneTimeExecution lPOJO = this.build();
      if (pValidate == true) {
        Tools.getValidationTools().validateObject(lPOJO);
      }
      return lPOJO;
    }
  }

  /**
   * Method returns the attribute "executionTime". Timestamp defining when the task should be executed.
   * 
   * @return Calendar Value to which the attribute "executionTime" is set.
   */
  public Calendar getExecutionTime( ) {
    return executionTime;
  }

  /**
   * Method sets the attribute "executionTime". Timestamp defining when the task should be executed.
   * 
   * @param pExecutionTime Value to which the attribute "executionTime" should be set.
   */
  public void setExecutionTime( Calendar pExecutionTime ) {
    // Assign value to attribute
    executionTime = pExecutionTime;
  }

  /**
   * 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 = super.toStringBuilder();
    lBuilder.append(
        XFun.getMessageRepository().getMessage(MessageConstants.OBJECT_ATTRIBUTE, "executionTime", "" + executionTime));
    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();
  }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy