InstrumentCoreInfo.BuilderBase
Package: velox.api.layer1.data
Type: Class
Inheritance: java.lang.Object → InstrumentCoreInfo.BuilderBase
Type Parameters:
T- concrete builder class
Direct Known Subclasses: InstrumentCoreInfo.Builder, InstrumentInfo.BuilderBase
Enclosing class: InstrumentCoreInfo
Description​
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 classsetFieldsFrom(InstrumentCoreInfo)- in the child builder base class with correct InstrumentInfo typeInstrumentCoreInfo.toBuilder()- in the InstrumentInfo subclasses to ensure the correct builder class is created, otherwise you will lose some fields, and receive wrong InstrumentInfo subtype
Fields​
symbol​
protected String symbol
exchange​
protected String exchange
type​
protected String type
Constructors​
BuilderBase​
public BuilderBase()
Methods​
self​
protected abstract T self()
build​
public abstract InstrumentCoreInfo build()
setFieldsFrom​
public T setFieldsFrom(InstrumentCoreInfo info)
getSymbol​
public String getSymbol()
setSymbol​
public T setSymbol(String symbol)
getExchange​
public String getExchange()
setExchange​
public T setExchange(String exchange)
getType​
public String getType()
setType​
public T setType(String type)