public static class RecursiveChain.Builder
extends java.lang.Object
RecursiveChain
objects. RecursiveChain
s
are built as if they were immutable objects. This means that you can't
directly change their fields once they are built (there is no setter).
However, RecursiveChain
s cannot be considered as pure
immutable objects as their state changes when they receive data from EMA.
FlatChain
for the
Equity Markets chain and set the two functions (lambda expressions in this
case) to be called when the chain is complete and when an error occurs:
OmmConsumer ommConsumer = ...; . . . RecursiveChain theChain = new RecursiveChain.Builder() .withOmmConsumer(ommConsumer) .withChainName("0#EQUITYMARKETS") .onComplete( (chain) -> chain.getElements().forEach( (position, name) -> System.out.println("\t" + chain.getName() + position + " = " + name) ) ) .onError( (errorMessage, chain) -> System.out.println("\tError received for <" + chain.getName() + ">: " + errorMessage) ) .build(); theChain.open();
withChainName(String)
and withOmmConsumer(OmmConsumer)
).Constructor and Description |
---|
Builder()
Default constructor
|
Modifier and Type | Method and Description |
---|---|
RecursiveChain |
build()
Builds the
RecursiveChain |
RecursiveChain.Builder |
onComplete(RecursiveChain.OnCompleteFunction function)
Sets the function to be called when the chain is complete.
|
RecursiveChain.Builder |
onElementAdded(RecursiveChain.OnElementAddedFunction function)
Sets the function to be called when the chain decodes a new element.
|
RecursiveChain.Builder |
onError(RecursiveChain.OnErrorFunction function)
Sets the function to be called when an error occurs.
|
RecursiveChain.Builder |
withChainName(java.lang.String chainName)
Sets the name of the chain.
|
RecursiveChain.Builder |
withMaxDepth(int maxDepth)
Sets the maximum depth to go when recursively opening this chain.
|
RecursiveChain.Builder |
withNameGuessingOptimization(int guessesCount)
Activates the "Name Guessing Optimization" and sets the number of
names to guess when the chain subscribes to a new
Chain
Record . |
RecursiveChain.Builder |
withOmmConsumer(com.thomsonreuters.ema.access.OmmConsumer ommConsumer)
Sets the EMA OmmConsumer used by the chain to subscribe to the
underlying
Chain Records . |
RecursiveChain.Builder |
withServiceName(java.lang.String serviceName)
Sets the name of the service the chain is published on.
|
RecursiveChain.Builder |
withSummaryLinksToSkip(SummaryLinksToSkipByDisplayTemplate summaryLinksToSkipByDisplayTemplate)
Sets the number of summary links to skip when opening the chain.
|
public RecursiveChain build()
RecursiveChain
public RecursiveChain.Builder withOmmConsumer(com.thomsonreuters.ema.access.OmmConsumer ommConsumer)
Chain Records
. This OmmConsumer must have
been properly initialized and connected to a Thomson Reuters real-time
infrastructure.ommConsumer
- the OmmConsumer that will be used by the chain to
subscribe to the underlying Chain Records
.public RecursiveChain.Builder withChainName(java.lang.String chainName)
chainName
- the name of the chain.public RecursiveChain.Builder withServiceName(java.lang.String serviceName)
Chain
Record
. If the service name is not set the default "ELEKTRON_DD"
service name will be used.serviceName
- the name of the service the chain is published on.public RecursiveChain.Builder withSummaryLinksToSkip(SummaryLinksToSkipByDisplayTemplate summaryLinksToSkipByDisplayTemplate)
summaryLinksToSkipByDisplayTemplate
- the number of summary links to skip per
display template.public RecursiveChain.Builder withNameGuessingOptimization(int guessesCount)
Chain
Record
. Checkout this Thomson Reuters article
to learn more about the name guessing optimization. If this method
is not called, the "Name Guessing Optimization" is not activated.guessesCount
- the number of names to guess. A reasonable value
would be between 5 and 50.public RecursiveChain.Builder withMaxDepth(int maxDepth)
maxDepth
- the maximum depth. Sub chains at this depth are
not recursively opened and considered as leaves.public RecursiveChain.Builder onElementAdded(RecursiveChain.OnElementAddedFunction function)
function
- function to be called on new elements.public RecursiveChain.Builder onComplete(RecursiveChain.OnCompleteFunction function)
RecursiveChain theChain = new RecursiveChain.Builder() .onComplete( (chain) -> chain.getElements().forEach( (position, name) -> System.out.println("\t" + chain.getName() + position + " = " + name) ) ) . . .
function
- function to be called when the chain is complete.public RecursiveChain.Builder onError(RecursiveChain.OnErrorFunction function)
RecursiveChain theChain = new RecursiveChain.Builder() .onError( (errorMessage, chain) -> System.out.println("\tError received for <" + chain.getName() + ">: " + errorMessage) ) . . .
function
- function to be called on errors.