Class RendererAdapter<T,S>
- java.lang.Object
-
- org.uncommons.watchmaker.framework.interactive.RendererAdapter<T,S>
-
- Type Parameters:
T
- The input type for the renderer.S
- The output type for the renderer.
- All Implemented Interfaces:
Renderer<T,S>
public class RendererAdapter<T,S> extends Object implements Renderer<T,S>
Adapter class for chaining together two renderers in series to provide flexibility. For example, if we have a Long -> Date renderer that turns a number of milliseconds since epoch into a Java date, and a Date -> String renderer that converts a Java date into its String representation in a particular locale, we can combine the two to create a Long -> String renderer without having to write a separate implementation of theRenderer
interface.
-
-
Constructor Summary
Constructors Constructor Description RendererAdapter(Renderer<T,? extends R> renderer1, Renderer<R,S> renderer2)
Creates an adapter that feeds the output of renderer1 into renderer2.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description S
render(T entity)
Renders an object of one type as an instance of another.
-
-
-
Constructor Detail
-
RendererAdapter
public RendererAdapter(Renderer<T,? extends R> renderer1, Renderer<R,S> renderer2)
Creates an adapter that feeds the output of renderer1 into renderer2.- Type Parameters:
R
- The intermediate type when transforming objects of type T to objects of type S.- Parameters:
renderer1
- A renderer that will translate an object of the input type (T) into an object of the intermediate type (R).renderer2
- A renderer that will translate an object of the intermediate type (R) into an object of the output type (S).
-
-