com.github.fge.jsonschema.core.processing
Class ProcessingResult<R extends MessageProvider>

java.lang.Object
  extended by com.github.fge.jsonschema.core.processing.ProcessingResult<R>
Type Parameters:
R - type of the processing output

public final class ProcessingResult<R extends MessageProvider>
extends Object

Wrapper class over a processing result

This class is useful when you write your own wrappers over processors and want to be able to customize the output for said classes. It offers two static factory methods and offers the ability to grab the processing result, the processing report and the success status.

It also offers a wrapper which swallows ProcessingExceptions and wraps them in a report instead (which will always be a ListProcessingReport: in this case, the exception message will always be the first message in the report.


Method Summary
 ProcessingReport getReport()
          Get the report out of this result
 R getResult()
          Get the result of the computation
 boolean isSuccess()
          Tell whether the result is a success
static
<IN extends MessageProvider,OUT extends MessageProvider>
ProcessingResult<OUT>
of(Processor<IN,OUT> processor, ProcessingReport report, IN input)
          Build a result out of a processor, a report and an input
static
<IN extends MessageProvider,OUT extends MessageProvider>
ProcessingResult<OUT>
uncheckedResult(Processor<IN,OUT> processor, ProcessingReport report, IN input)
          Build a result out of a computation and wrap any processing exception
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

of

public static <IN extends MessageProvider,OUT extends MessageProvider> ProcessingResult<OUT> of(Processor<IN,OUT> processor,
                                                                                                ProcessingReport report,
                                                                                                IN input)
                                                        throws ProcessingException
Build a result out of a processor, a report and an input

Type Parameters:
IN - type of the input
OUT - type of the output
Parameters:
processor - the processor
report - the report
input - the input
Returns:
a processing result
Throws:
ProcessingException - processing failed
NullPointerException - the processor or report are null

uncheckedResult

public static <IN extends MessageProvider,OUT extends MessageProvider> ProcessingResult<OUT> uncheckedResult(Processor<IN,OUT> processor,
                                                                                                             ProcessingReport report,
                                                                                                             IN input)
Build a result out of a computation and wrap any processing exception

Type Parameters:
IN - type of the input
OUT - type of the output
Parameters:
processor - the processor to use
report - the report to use
input - the input
Returns:
a processing result
Throws:
NullPointerException - the processor or report are null

getReport

public ProcessingReport getReport()
Get the report out of this result

Returns:
the report

getResult

public R getResult()
Get the result of the computation

Note that in the event of a processing failure, the return value of this method is undefined.

Returns:
the result

isSuccess

public boolean isSuccess()
Tell whether the result is a success

Returns:
true if the computation occurred without a problem
See Also:
ProcessingReport.isSuccess()