com.github.fge.jsonschema.core.processing
Class CachingProcessor<IN extends MessageProvider,OUT extends MessageProvider>

java.lang.Object
  extended by com.github.fge.jsonschema.core.processing.CachingProcessor<IN,OUT>
Type Parameters:
IN - input type for that processor
OUT - output type for that processor
All Implemented Interfaces:
Processor<IN,OUT>

public final class CachingProcessor<IN extends MessageProvider,OUT extends MessageProvider>
extends Object
implements Processor<IN,OUT>

A class caching the result of a Processor

You can use this over whichever processor of your choice. Internally, it uses a LoadingCache to store results.

You can optionally pass an Equivalence as an argument for cache keys. By default, Equivalences.equals() will be used.


Constructor Summary
CachingProcessor(Processor<IN,OUT> processor)
          Constructor
CachingProcessor(Processor<IN,OUT> processor, Equivalence<IN> equivalence)
          Main constructor
 
Method Summary
 OUT process(ProcessingReport report, IN input)
          Process the input
 String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

CachingProcessor

public CachingProcessor(Processor<IN,OUT> processor)
Constructor

This is equivalent to calling CachingProcessor(Processor, Equivalence) with Equivalences.equals() as the second argument.

Parameters:
processor - the processor

CachingProcessor

public CachingProcessor(Processor<IN,OUT> processor,
                        Equivalence<IN> equivalence)
Main constructor

Parameters:
processor - the processor
equivalence - an equivalence to use for cache keys
Throws:
NullPointerException - processor or equivalence are null
Method Detail

process

public OUT process(ProcessingReport report,
                   IN input)
                                    throws ProcessingException
Description copied from interface: Processor
Process the input

Specified by:
process in interface Processor<IN extends MessageProvider,OUT extends MessageProvider>
Parameters:
report - the report to use while processing
input - the input for this processor
Returns:
the output
Throws:
ProcessingException - processing failed

toString

public String toString()
Overrides:
toString in class Object