T
- A class that extends AbstractSubjectInfo
. The parse(String)
method returns instances
of this class.public abstract class AbstractSubjectParser<T extends AbstractSubjectInfo> extends Object implements SubjectParser<T>
SubjectParser
with common functions
shared by the subclasses FXSubjectParser
and MetalSubjectParser
.Modifier and Type | Field and Description |
---|---|
protected Pattern |
subjectPattern |
Constructor and Description |
---|
AbstractSubjectParser(String subjectPrefix)
Creates a new AbstractSubjectParser with the specified prefix.
|
AbstractSubjectParser(String subjectPrefix,
String regexSuffix)
Creates a new AbstractSubjectParser with the specified prefix.
|
Modifier and Type | Method and Description |
---|---|
protected abstract T |
createSubjectInfo(String subject,
String subjectPrefix,
String baseCurrency,
String termCurrency,
String amountIn,
String tenor,
String amount,
String marginBand)
Creates an instance of the subclass of
AbstractSubjectInfo that this class has been genericised with. |
String |
getSubjectRegex()
Returns the regular expression used by this parser to parse a subject.
|
T |
parse(String subject)
Returns the domain object that represents the subject request.
|
protected void |
validate(T subjectInfo)
A method called by
parse(String) which contains shared validation logic applicable to all sub-classes
of AbstractSubjectParser. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getNamespace
protected final Pattern subjectPattern
public AbstractSubjectParser(String subjectPrefix)
subjectPrefix
- A string prefix such as "/FX".public AbstractSubjectParser(String subjectPrefix, String regexSuffix)
parse(String)
should be overwritten if a subject suffix is provided.
subjectPrefix
- A string prefix such as "/FX".regexSuffix
- a string suffix as a regex.protected abstract T createSubjectInfo(String subject, String subjectPrefix, String baseCurrency, String termCurrency, String amountIn, String tenor, String amount, String marginBand)
AbstractSubjectInfo
that this class has been genericised with.subject
- The full subject.subjectPrefix
- A string prefix, e.g "/FX".baseCurrency
- The first currency in the pair.termCurrency
- The second currency in the pair.amountIn
- The unit that the amount is specified in. This could be the dealt currency for an instance
of FXSubjectInfo
or a unit such as OZT or Kilos for MetalSubjectInfo
,
for example.tenor
- The tenor for the subject info.amount
- The amount for the subject info, specified in the unit defined by the amountIn
parameter.marginBand
- The margin band for the subject info, sometimes referred to as the price tier.AbstractSubjectInfo
that this class has been genericised with.public T parse(String subject) throws SubjectParserException
SubjectParser
parse
in interface SubjectParser<T extends AbstractSubjectInfo>
subject
- The subject to parse.SubjectParserException
- If the subject is not in the correct formatprotected void validate(T subjectInfo) throws SubjectParserException
parse(String)
which contains shared validation logic applicable to all sub-classes
of AbstractSubjectParser.subjectInfo
- The domain object representing the subscription request.SubjectParserException
- If the values on the subscription request are invalid, for example the base
currency and term currency are the same.public String getSubjectRegex()
SubjectParser
getSubjectRegex
in interface SubjectParser<T extends AbstractSubjectInfo>
Copyright © 2015 Caplin Systems.