Class AssertionErrorJobContext
- All Implemented Interfaces:
JobContext
JobContext where
all methods do fail with a
AssertionError.
You may want to subclass this class instead of
implementing JobContext directly
to make your subclass cope with new methods
in JobContext.-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidIndicates, that the job has proceeded.voidincrementProgress(int delta) Indicates, that the job has proceeded.Returns the duration the job has been requested to defer by its context.voidsetCompleteness(double completeness) Indicates the current completeness of the job.voidsetMessage(String message) Indicates a message describing the current status of the job.voidsleepAndStopIfRequested(Duration duration) Sleeps for the specified duration.voidChecks, whether the job has been requested to stop.booleanReturns whether this context can process information transferred byJobContext.setCompleteness(double).booleanReturns whether this context can process information transferred byJobContext.setMessage(String).booleanReturns whether this context can process information transferred byJobContext.incrementProgress()andJobContext.incrementProgress(int).
-
Constructor Details
-
AssertionErrorJobContext
public AssertionErrorJobContext()
-
-
Method Details
-
stopIfRequested
public void stopIfRequested()Description copied from interface:JobContextChecks, whether the job has been requested to stop. The job should call this method in reasonably short intervals. If throws aJobStop, the job should stop gracefully as soon as possible, but all resources held should be released.The job may call
JobContext.deferOrStopIfRequested(JobContext)instead.- Specified by:
stopIfRequestedin interfaceJobContext
-
requestsDeferral
Description copied from interface:JobContextReturns the duration the job has been requested to defer by its context. This method is considered bydeferOrStopIfRequested.In general the job should not call this method, but
deferOrStopIfRequested.The default implementation returns
zero.- Specified by:
requestsDeferralin interfaceJobContext
-
sleepAndStopIfRequested
Description copied from interface:JobContextSleeps for the specified duration. In contrast toJobContext.deferOrStopIfRequested(JobContext)this method actually waits for the specified amount of time. In contrast toThread.sleepit aborts prematurely by throwing aJobStop, if the the job has been requested to stop or becomes requested to stop while sleeping.In general the job should not call this method directly, but only
JobContext.sleepAndStopIfRequested(JobContext, Duration). Override this method for affecting (potentially long) sleeps. For instance the job might temporarily release resources.Calling this method with
durationzero or negative is equivalent to a call toJobContext.stopIfRequested().The default implementation polls
JobContext.stopIfRequested()every 100 milliseconds. Implementers are encouraged to provide a more efficient implementation. The default implementation fails fordurations too large forDuration.toNanos(), which is approximately 292 years.- Specified by:
sleepAndStopIfRequestedin interfaceJobContext
-
supportsMessage
public boolean supportsMessage()Description copied from interface:JobContextReturns whether this context can process information transferred byJobContext.setMessage(String).- Specified by:
supportsMessagein interfaceJobContext
-
setMessage
Description copied from interface:JobContextIndicates a message describing the current status of the job. Should be called only, ifJobContext.supportsMessage()returns true. Otherwise calls are ignored.- Specified by:
setMessagein interfaceJobContext
-
supportsProgress
public boolean supportsProgress()Description copied from interface:JobContextReturns whether this context can process information transferred byJobContext.incrementProgress()andJobContext.incrementProgress(int).- Specified by:
supportsProgressin interfaceJobContext
-
incrementProgress
public void incrementProgress()Description copied from interface:JobContextIndicates, that the job has proceeded. There is no information available, when the job will return. Calling this method is equivalent to callingincrementProgress(1). Should be called only, ifJobContext.supportsProgress()returns true. Otherwise calls are ignored.- Specified by:
incrementProgressin interfaceJobContext
-
incrementProgress
public void incrementProgress(int delta) Description copied from interface:JobContextIndicates, that the job has proceeded. There is no information available, when the job will return. Calling this method is equivalent to callingJobContext.incrementProgress()for the number of delta times. Parameter delta should be greater or equal 0. Values out of range are accepted as well, thus no exception is thrown in that case. Calling this method with delta of 0 is equivalent to not calling this method at all. Should be called only, ifJobContext.supportsProgress()returns true. Otherwise calls are ignored.- Specified by:
incrementProgressin interfaceJobContext
-
supportsCompleteness
public boolean supportsCompleteness()Description copied from interface:JobContextReturns whether this context can process information transferred byJobContext.setCompleteness(double).- Specified by:
supportsCompletenessin interfaceJobContext
-
setCompleteness
public void setCompleteness(double completeness) Description copied from interface:JobContextIndicates the current completeness of the job. Parameter completeness should be between 0 and 1. Values out of range are accepted as well, thus no exception is thrown in that case. Should be called only, ifJobContext.supportsCompleteness()returns true. Otherwise calls are ignored.- Specified by:
setCompletenessin interfaceJobContext
-