Package velox.api.layer1.data
Class InstrumentCoreInfo.BuilderBase<T extends InstrumentCoreInfo.BuilderBase<T>>
java.lang.Object
velox.api.layer1.data.InstrumentCoreInfo.BuilderBase<T>
- Type Parameters:
T- concrete builder class
- Direct Known Subclasses:
InstrumentCoreInfo.Builder,InstrumentInfo.BuilderBase
- Enclosing class:
- InstrumentCoreInfo
public abstract static class InstrumentCoreInfo.BuilderBase<T extends InstrumentCoreInfo.BuilderBase<T>>
extends Object
Builder pattern for inheritance structures. It works like this:
-
-
-
InstrumentCoreInfo.BuilderBase <----- InstrumentCoreInfo.Builder
^
|
InstrumentInfo.BuilderBase <--------- InstrumentInfo.Builder
^
|
InstrumentInfoDxfeed.Builder
If you want to add another builder to inheritance after last child (for example after InstrumentInfoDxfeed.Builder)
you should split the exiting builder into concrete and abstract classes
(like InstrumentInfoDxfeed.BuilderBase and InstrumentInfoDxfeed.Builder), and extend your new concrete builder
from created abstract class, i.e. something like this:
...
InstrumentInfo.BuilderBase <--------- InstrumentInfo.Builder
^
|
InstrumentInfoDxfeed.BuilderBase <-- InstrumentInfoDxfeed.Builder
^
|
InstrumentInfoNew.Builder
Also, there are several methods that you should overwrite for everything to work correctly:-
self(), build() - in the concrete builder class-
setFieldsFrom(InstrumentCoreInfo) - in the child builder base class with correct InstrumentInfo type-
InstrumentCoreInfo.toBuilder() - in the InstrumentInfo subclasses to ensure the correct builder class is created,
otherwise you will lose some fields, and receive wrong InstrumentInfo subtype-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionabstract InstrumentCoreInfobuild()getType()protected abstract Tself()setExchange(String exchange)
-
Field Details
-
symbol
-
exchange
-
type
-
-
Constructor Details
-
BuilderBase
public BuilderBase()
-
-
Method Details
-
self
-
build
-
setFieldsFrom
-
getSymbol
-
setSymbol
-
getExchange
-
setExchange
-
getType
-
setType
-