java.lang.Object
esa.opensf.osfi.LoadResult.Builder<E>
- Type Parameters:
E- Concrete type of exceptions to be recorded, or Exception for general handling.
- Enclosing class:
- LoadResult<R>
Helper that processes events during a load operation to generate a
LoadResult.-
Field Summary
FieldsModifier and TypeFieldDescriptionfinal List<LoadResult.Event>Warnings and errors recorded during processing. -
Constructor Summary
ConstructorsConstructorDescriptionBuilder(Class<E> clsToken, int logMinSev, int throwMinSev, List<LoadResult.Event> evtsFromPriorPhases) Create a helper that processes events and may generate aLoadResult. -
Method Summary
Modifier and TypeMethodDescription<R> LoadResult<R>finishEmpty(Object source, Exception fatalErr) Complete the operation without a result object.<R> LoadResult<R>finishWithResult(Object source, R result) Complete the operation with a result object.protected StringformatEventData(int severity, E e) Custom formatter for an event to appear in the OSFI log.voidprocessEvent(int severity, E data) Method called by subclasses to ingest an event.
-
Field Details
-
events
Warnings and errors recorded during processing.
-
-
Constructor Details
-
Builder
public Builder(Class<E> clsToken, int logMinSev, int throwMinSev, List<LoadResult.Event> evtsFromPriorPhases) Create a helper that processes events and may generate aLoadResult.- Parameters:
clsToken- Class object for the main type of exceptions considered. Note that this does not mean that only this type of exception will be in the listlogMinSev- Events below this level will not be logged or recorded.throwMinSev- Any event at or above this level will be rethrown when processed.evtsFromPriorPhases- Optional, if non-null it will be used as the initial value for the events of this instance. Used for chainingLoadResult-based calls.
-
-
Method Details
-
finishWithResult
Complete the operation with a result object.- Type Parameters:
R- Type of the result- Parameters:
source- Stringified and passed toLoadResult.source, never null.result- Result of the load operation.- Returns:
- Built LoadResult object, with a non-null result.
-
finishEmpty
Complete the operation without a result object.- Type Parameters:
R- Type of the result, possibly explicit- Parameters:
source- Stringified and passed toLoadResult.source, never null.fatalErr- Optional final exception. If it is not null, and it has not already been processed as an event, it will be added with severityLoadResult.SEV_FATAL.- Returns:
- Built LoadResult object, with a
nullresult.
-
processEvent
Method called by subclasses to ingest an event. This function will:- Log the event to the OSFI logger and to the
eventsmember if the severity is ≥logMinSeverity. - Rethrow the event data if its severity is ≥
throwMinSeverity.
- Parameters:
severity- See theSEV_*constants inLoadResultdata- Exception object to be processed, may be rethrown.- Throws:
E- if the severity is at or above the threshold set on construction
- Log the event to the OSFI logger and to the
-
formatEventData
Custom formatter for an event to appear in the OSFI log. This function must not throw.- Parameters:
severity- Event severity, as given by the constants inLoadResulte- Event data to format, never null.- Returns:
- Single line of text that will be sent to the OSFI log.
-