
org.sackfix.fix44.RelatedSymGroup.scala Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of sackfix-messages-fix44_2.13 Show documentation
Show all versions of sackfix-messages-fix44_2.13 Show documentation
All Fix 4.4 strongly typed messages, purely generated code, do not edit.
The newest version!
package org.sackfix.fix44
import org.sackfix.field._
import org.sackfix.common.validated.fields.{SfFixGroup, SfGroupDecoder, SfFixFieldsToAscii, SfFixRenderable}
import org.sackfix.common.message.SfRepeatingGroupCountException
import scala.annotation.tailrec
import scala.collection.immutable.HashSet
import scala.collection.mutable.ArrayBuffer
/**
* Generated by SackFix code generator on 20210314
* Source specification was read from:
* /quickfixj1.6.0/FIX44.xml
*/
case class RelatedSymGroup(instrumentComponent:Option[InstrumentComponent]=None,
currencyField:Option[CurrencyField]=None,
expirationCycleField:Option[ExpirationCycleField]=None,
instrumentExtensionComponent:Option[InstrumentExtensionComponent]=None,
noLegsField:Option[NoLegsField]=None,
legsGroups: Option[List[LegsGroup]]=None,
tradingSessionIDField:Option[TradingSessionIDField]=None,
tradingSessionSubIDField:Option[TradingSessionSubIDField]=None,
textField:Option[TextField]=None,
encodedTextLenField:Option[EncodedTextLenField]=None,
encodedTextField:Option[EncodedTextField]=None) extends SfFixGroup with SfFixRenderable with SfFixFieldsToAscii {
if (noLegsField.map(_.value).getOrElse(0) != legsGroups.map(_.size).getOrElse(0))
throw SfRepeatingGroupCountException(NoLegsField.TagId,noLegsField.map(_.value).getOrElse(0), legsGroups.map(_.size).getOrElse(0))
override lazy val fixStr : String = appendFixStr().toString
override def appendFixStr(b:StringBuilder = new StringBuilder): StringBuilder = format(formatForFix, b)
override def toString():String = appendStringBuilder().toString()
def appendStringBuilder(b:StringBuilder = new StringBuilder) : StringBuilder = format(formatForToString, b)
def format( fmt: ((StringBuilder,SfFixRenderable)=>Unit), b:StringBuilder = new StringBuilder()): StringBuilder = {
instrumentComponent.foreach(fmt(b,_))
currencyField.foreach(fmt(b,_))
expirationCycleField.foreach(fmt(b,_))
instrumentExtensionComponent.foreach(fmt(b,_))
noLegsField.foreach(fmt(b,_))
legsGroups.getOrElse(List.empty).foreach(fmt(b,_))
tradingSessionIDField.foreach(fmt(b,_))
tradingSessionSubIDField.foreach(fmt(b,_))
textField.foreach(fmt(b,_))
encodedTextLenField.foreach(fmt(b,_))
encodedTextField.foreach(fmt(b,_))
b
}
}
object RelatedSymGroup extends SfGroupDecoder {
override val MandatoryFields = HashSet[Int]()
override def isMandatoryField(tagId:Int) : Boolean = {
MandatoryFields.contains(tagId) ||
InstrumentComponent.isMandatoryField(tagId) || InstrumentExtensionComponent.isMandatoryField(tagId) || LegsGroup.isMandatoryField(tagId)
}
override val OptionalFields = HashSet[Int](
CurrencyField.TagId, ExpirationCycleField.TagId, NoLegsField.TagId, TradingSessionIDField.TagId, TradingSessionSubIDField.TagId,
TextField.TagId, EncodedTextLenField.TagId, EncodedTextField.TagId)
override def isOptionalField(tagId:Int) : Boolean = {
OptionalFields.contains(tagId) ||
InstrumentComponent.isOptionalField(tagId) || InstrumentExtensionComponent.isOptionalField(tagId) || LegsGroup.isOptionalField(tagId)
}
override def isFieldOf(tagId:Int) : Boolean = isMandatoryField(tagId) || isOptionalField(tagId) ||
InstrumentComponent.isFieldOf(tagId) || InstrumentExtensionComponent.isFieldOf(tagId) || LegsGroup.isFieldOf(tagId)
override lazy val RepeatingGroupsTags = HashSet[Int](
NoLegsField.TagId)
override def isFirstField(tagId:Int) : Boolean = InstrumentComponent.isFirstField(tagId)
// Group version, startPos is the index to the first element of the first repeating group
@tailrec
def decode(flds: Seq[Tuple2[Int, Any]], startPos:Int = 0, groups:ArrayBuffer[RelatedSymGroup]=ArrayBuffer.empty[RelatedSymGroup]):Option[List[RelatedSymGroup]] = {
decodeSingle(flds, startPos) match {
case (pos: Int, None) => if (groups.nonEmpty) Some(groups.toList) else None
case (pos: Int, grp: Some[RelatedSymGroup]) => decode(flds, pos, groups += grp.get)
}
}
/**
* @param flds For groups in Fix ordering is VITAL.
* @param startPos This index into the ordered fields. It HAS to contain the first field of the group
* @return A Tuple2 holding the next position to read from the fields, and the newly created group
*/
def decodeSingle(flds: Seq[Tuple2[Int, Any]], startPos:Int):Tuple2[Int,Option[RelatedSymGroup]] = {
if (!isFirstField(flds(startPos)._1)) (startPos, None)
else {
val (pos, myFields, nextTagPosLookup) = extractMyFieldsAndPopulatePositions(true, flds, startPos)
validateMandatoryFieldsPresent(myFields)
if (myFields.nonEmpty) {
(pos,Some(RelatedSymGroup(InstrumentComponent.decode(flds, startPos),
myFields.get(CurrencyField.TagId).flatMap(f=>CurrencyField.decode(f)),
myFields.get(ExpirationCycleField.TagId).flatMap(f=>ExpirationCycleField.decode(f)),
InstrumentExtensionComponent.decode(flds, startPos),
myFields.get(NoLegsField.TagId).flatMap(f=>NoLegsField.decode(f)),
if (nextTagPosLookup.contains(NoLegsField.TagId)) LegsGroup.decode(flds, nextTagPosLookup(NoLegsField.TagId)) else None,
myFields.get(TradingSessionIDField.TagId).flatMap(f=>TradingSessionIDField.decode(f)),
myFields.get(TradingSessionSubIDField.TagId).flatMap(f=>TradingSessionSubIDField.decode(f)),
myFields.get(TextField.TagId).flatMap(f=>TextField.decode(f)),
myFields.get(EncodedTextLenField.TagId).flatMap(f=>EncodedTextLenField.decode(f)),
myFields.get(EncodedTextField.TagId).flatMap(f=>EncodedTextField.decode(f)))))
} else (startPos, None)
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy