All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.sackfix.fix50sp2modified.TriggeringInstructionComponent.scala Maven / Gradle / Ivy

The newest version!
package org.sackfix.fix50sp2modified

import org.sackfix.field._
import org.sackfix.common.validated.fields.{SfFixComponent, SfFixDecoder, 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 20170404
  * Source specification was read from:
  *   /quickfixj1.6.0/FIX50SP2.modified.xml
  */
case class TriggeringInstructionComponent(triggerTypeField:Option[TriggerTypeField]=None,
                                          triggerActionField:Option[TriggerActionField]=None,
                                          triggerPriceField:Option[TriggerPriceField]=None,
                                          triggerSymbolField:Option[TriggerSymbolField]=None,
                                          triggerSecurityIDField:Option[TriggerSecurityIDField]=None,
                                          triggerSecurityIDSourceField:Option[TriggerSecurityIDSourceField]=None,
                                          triggerSecurityDescField:Option[TriggerSecurityDescField]=None,
                                          triggerPriceTypeField:Option[TriggerPriceTypeField]=None,
                                          triggerPriceTypeScopeField:Option[TriggerPriceTypeScopeField]=None,
                                          triggerPriceDirectionField:Option[TriggerPriceDirectionField]=None,
                                          triggerNewPriceField:Option[TriggerNewPriceField]=None,
                                          triggerOrderTypeField:Option[TriggerOrderTypeField]=None,
                                          triggerNewQtyField:Option[TriggerNewQtyField]=None,
                                          triggerTradingSessionIDField:Option[TriggerTradingSessionIDField]=None,
                                          triggerTradingSessionSubIDField:Option[TriggerTradingSessionSubIDField]=None) extends SfFixComponent  with SfFixRenderable with SfFixFieldsToAscii {

  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 = {
    triggerTypeField.foreach(fmt(b,_))
    triggerActionField.foreach(fmt(b,_))
    triggerPriceField.foreach(fmt(b,_))
    triggerSymbolField.foreach(fmt(b,_))
    triggerSecurityIDField.foreach(fmt(b,_))
    triggerSecurityIDSourceField.foreach(fmt(b,_))
    triggerSecurityDescField.foreach(fmt(b,_))
    triggerPriceTypeField.foreach(fmt(b,_))
    triggerPriceTypeScopeField.foreach(fmt(b,_))
    triggerPriceDirectionField.foreach(fmt(b,_))
    triggerNewPriceField.foreach(fmt(b,_))
    triggerOrderTypeField.foreach(fmt(b,_))
    triggerNewQtyField.foreach(fmt(b,_))
    triggerTradingSessionIDField.foreach(fmt(b,_))
    triggerTradingSessionSubIDField.foreach(fmt(b,_))
    b
  }

}
     
object TriggeringInstructionComponent extends SfFixDecoder {

  override val MandatoryFields = HashSet[Int]()

  override def isMandatoryField(tagId:Int) : Boolean = {
    MandatoryFields.contains(tagId) 
  }

  override val OptionalFields = HashSet[Int](
    TriggerTypeField.TagId, TriggerActionField.TagId, TriggerPriceField.TagId, TriggerSymbolField.TagId, TriggerSecurityIDField.TagId, 
    TriggerSecurityIDSourceField.TagId, TriggerSecurityDescField.TagId, TriggerPriceTypeField.TagId, TriggerPriceTypeScopeField.TagId, TriggerPriceDirectionField.TagId, 
    TriggerNewPriceField.TagId, TriggerOrderTypeField.TagId, TriggerNewQtyField.TagId, TriggerTradingSessionIDField.TagId, TriggerTradingSessionSubIDField.TagId)

  override def isOptionalField(tagId:Int) : Boolean = {
    OptionalFields.contains(tagId) 
  }

  override def isFieldOf(tagId:Int) : Boolean = isMandatoryField(tagId) || isOptionalField(tagId) 

   override lazy val RepeatingGroupsTags = HashSet[Int]()
  
      
  override def isFirstField(tagId:Int) : Boolean = tagId==TriggerTypeField.TagId 

  def decode(flds: Seq[Tuple2[Int, Any]], startPos:Int = 0):Option[TriggeringInstructionComponent] = {
    val (pos, myFields, nextTagPosLookup) = extractMyFieldsAndPopulatePositions(false, flds, startPos)
    validateMandatoryFieldsPresent(myFields)

    if (myFields.nonEmpty) {
      Some(TriggeringInstructionComponent(myFields.get(TriggerTypeField.TagId).flatMap(f=>TriggerTypeField.decode(f)),
        myFields.get(TriggerActionField.TagId).flatMap(f=>TriggerActionField.decode(f)),
        myFields.get(TriggerPriceField.TagId).flatMap(f=>TriggerPriceField.decode(f)),
        myFields.get(TriggerSymbolField.TagId).flatMap(f=>TriggerSymbolField.decode(f)),
        myFields.get(TriggerSecurityIDField.TagId).flatMap(f=>TriggerSecurityIDField.decode(f)),
        myFields.get(TriggerSecurityIDSourceField.TagId).flatMap(f=>TriggerSecurityIDSourceField.decode(f)),
        myFields.get(TriggerSecurityDescField.TagId).flatMap(f=>TriggerSecurityDescField.decode(f)),
        myFields.get(TriggerPriceTypeField.TagId).flatMap(f=>TriggerPriceTypeField.decode(f)),
        myFields.get(TriggerPriceTypeScopeField.TagId).flatMap(f=>TriggerPriceTypeScopeField.decode(f)),
        myFields.get(TriggerPriceDirectionField.TagId).flatMap(f=>TriggerPriceDirectionField.decode(f)),
        myFields.get(TriggerNewPriceField.TagId).flatMap(f=>TriggerNewPriceField.decode(f)),
        myFields.get(TriggerOrderTypeField.TagId).flatMap(f=>TriggerOrderTypeField.decode(f)),
        myFields.get(TriggerNewQtyField.TagId).flatMap(f=>TriggerNewQtyField.decode(f)),
        myFields.get(TriggerTradingSessionIDField.TagId).flatMap(f=>TriggerTradingSessionIDField.decode(f)),
        myFields.get(TriggerTradingSessionSubIDField.TagId).flatMap(f=>TriggerTradingSessionSubIDField.decode(f))))
    } else None
  }

    
}
     




© 2015 - 2025 Weber Informatics LLC | Privacy Policy