Interface MCRProcessable

All Superinterfaces:
MCRListenableProgressable, MCRProgressable
All Known Implementing Classes:
MCRAbstractProcessable, MCRJobThread, MCRProcessableSupplier, MCRProcessableTask, MCRUploadHandler, MCRUploadHandlerIFS

public interface MCRProcessable extends MCRListenableProgressable
Describes an object which can be processed. A processable has a name, a user id, a status, a create-, start- and end time and is MCRProgressable.
Author:
Matthas Eichner
  • Method Details

    • getName

      String getName()
      Returns a human readable name.
      Returns:
      name of this process
    • getUserId

      String getUserId()
      Returns the id of the user who created this processable.
      Returns:
      the user id responsible for the processable
    • getStatus

      The status of this process.
      Returns:
      the status
    • isCreated

      default boolean isCreated()
      Returns true if this task was created but not started yet.
      Returns:
      true if this task is just created.
    • isProcessing

      default boolean isProcessing()
      Returns true if this task is currently processing.
      Returns:
      true if this task is processing
    • isCanceled

      default boolean isCanceled()
      Returns true if this task was cancelled before it completed normally.
      Returns:
      true if this task is cancelled
    • isFailed

      default boolean isFailed()
      Returns true if this task failed before it completed normally. One can assume that getError() does not return null in such case.
      Returns:
      true if the process failed
    • isSuccessful

      default boolean isSuccessful()
      Returns true if this task was successful and completed normally.
      Returns:
      true if this task was successful
    • isDone

      default boolean isDone()
      Returns true if this processable completed. Completion may be due to normal termination, an exception, or cancellation -- in all of these cases, this method will return true.
      Returns:
      true if this processable completed
    • getError

      Throwable getError()
      Returns the error if the processable failed. This will return null if the status != failed.
      Returns:
      the error occurred while processing
    • getStartTime

      Instant getStartTime()
      Time (instant) the process was started. Returns null if the process was not started yet.
      Returns:
      the time the process was started
    • getCreateTime

      Instant getCreateTime()
      Time (instant) this processable was created.
      Returns:
      the time the processable was created
    • getEndTime

      Instant getEndTime()
      Time (instant) this processable finished. Either successfully, canceled or with an error. If the processable is not finished this will return null.
      Returns:
      the time the processable finished
    • took

      default Duration took()
      Calculates the duration between starting and finishing the processable.
      Returns:
      the duration or null if the processable is not finished yet
    • getProperties

      Map<String,Object> getProperties()
      Returns a map of properties assigned to this processable.
      Returns:
      the properties map
    • getProperty

      default Object getProperty(String name)
      A shortcut for getProperties().get(name).
      Parameters:
      name - the name of the property
      Returns:
      the property value or null
    • getPropertyAs

      default <T> T getPropertyAs(String name, Class<T> type)
      Returns the property for the given name. The property will be cast to the specified type. Be aware that a ClassCastException is thrown if the type does not match.
      Parameters:
      name - name of property
      type - object type of the property
      Returns:
      the property value or null
    • addStatusListener

      void addStatusListener(MCRProcessableStatusListener listener)
      Parameters:
      listener - the listener to add
    • removeStatusListener

      void removeStatusListener(MCRProcessableStatusListener listener)
      Parameters:
      listener - the listener to remove