org.fudgemsg.mapping
Class FudgeBuilderFactoryAdapter

java.lang.Object
  extended by org.fudgemsg.mapping.FudgeBuilderFactoryAdapter
All Implemented Interfaces:
FudgeBuilderFactory

public class FudgeBuilderFactoryAdapter
extends Object
implements FudgeBuilderFactory

Implementation of a FudgeBuilderFactory that can delegate to another instance for unrecognized classes. This pattern is to allow factories to be chained together.


Constructor Summary
protected FudgeBuilderFactoryAdapter(FudgeBuilderFactory delegate)
          Creates a new FudgeBuilderFactoryAdapter.
 
Method Summary
<T> void
addGenericBuilder(Class<T> clazz, FudgeBuilder<T> builder)
          Registers a generic builder with the factory that may be returned as a FudgeObjectBuilder for the class, or as a FudgeMessageBuilder for any sub-classes of the class.
<T> FudgeMessageBuilder<T>
createMessageBuilder(Class<T> clazz)
          Creates a new FudgeMessageBuilder for encoding objects of the given class into Fudge messages.
<T> FudgeObjectBuilder<T>
createObjectBuilder(Class<T> clazz)
          Creates a new FudgeObjectBuilder for deserializing Fudge messages into the given class.
protected  FudgeBuilderFactory getDelegate()
          Returns the delegate instance to pass method calls to.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FudgeBuilderFactoryAdapter

protected FudgeBuilderFactoryAdapter(FudgeBuilderFactory delegate)
Creates a new FudgeBuilderFactoryAdapter.

Parameters:
delegate - instance to pass non-overridden method calls to
Method Detail

getDelegate

protected FudgeBuilderFactory getDelegate()
Returns the delegate instance to pass method calls to.

Returns:
the FudgeBuilderFactory delegate

addGenericBuilder

public <T> void addGenericBuilder(Class<T> clazz,
                                  FudgeBuilder<T> builder)
Registers a generic builder with the factory that may be returned as a FudgeObjectBuilder for the class, or as a FudgeMessageBuilder for any sub-classes of the class. After calling this, a factory may choose to return an alternative builder, but may not return null for a class which the generic builder has been registered for.

Specified by:
addGenericBuilder in interface FudgeBuilderFactory
Type Parameters:
T - the generic type (probably an interface) the builder is for
Parameters:
clazz - the generic type (probably an interface) the builder is for
builder - the builder to register

createMessageBuilder

public <T> FudgeMessageBuilder<T> createMessageBuilder(Class<T> clazz)
Creates a new FudgeMessageBuilder for encoding objects of the given class into Fudge messages.

Specified by:
createMessageBuilder in interface FudgeBuilderFactory
Type Parameters:
T - the class the builder should create messages from
Parameters:
clazz - the class the builder should create messages from
Returns:
the builder or null if none is available

createObjectBuilder

public <T> FudgeObjectBuilder<T> createObjectBuilder(Class<T> clazz)
Creates a new FudgeObjectBuilder for deserializing Fudge messages into the given class.

Specified by:
createObjectBuilder in interface FudgeBuilderFactory
Type Parameters:
T - the class the builder should create objects of
Parameters:
clazz - the class the builder should create objects of
Returns:
the builder or null if none is available


Copyright 2009-Present by OpenGamma Inc. and individual contributors
Released under the Apache License, Version 2.0