package Ġcom . example . flow Ċ Ċ import Ġcom . google . common . collect . ImmutableList Ċ import Ġnet . cord a . core . contracts . State And Ref Ċ import Ġnet . cord a . core . contracts . Unique Identifier Ċ import Ġnet . cord a . core . identity . Abstract Party Ċ import Ġnet . cord a . core . identity . Party Ċ import Ġnet . cord a . core . node . services . Vault Ċ import Ġnet . cord a . core . node . services . query By Ċ import Ġnet . cord a . core . node . services . vault . Query Criteria Ċ import Ġnet . cord a . core . transactions . Signed Transaction Ċ import Ġcom . example . state . Record State Ċ import Ġnet . cord a . core . flows .* Ċ import Ġnet . cord a . core . internal . random OrNull ĊĊ Ċ /** Ċ Ġ* ĠAn Ġabstract ĠFlow Logic Ġclass Ġthat Ġis Ġsub cl assed Ġby Ġthe Ġrecord 0 Ġflows Ġto Ċ Ġ* Ġprovide Ġhelper Ġmethods Ġand Ġclasses . Ċ Ġ*/ Ċ abstract Ġclass ĠRecord Base Flow Ġ: ĠFlow Logic < Signed Transaction >() Ġ{ ĊĠĠĠ Ġval Ġrand Not ary Ġget () Ġ= Ġrandom Not ary () ĊĊĠĠĠ Ġfun Ġget Record State By Linear Id ( linear Id : ĠUnique Identifier ) Ġ: ĠState And Ref < Record State > Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġquery Criteria Ġ= ĠQuery Criteria . Linear State Query Criteria ( ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġnull , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠImmutableList . of ( linear Id ), ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ ĠVault . State Status . UN CON SU MED , ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġnull ĊĠĠĠĠĠĠĠ Ġ) ĊĊĠĠĠĠĠĠĠ Ġreturn Ġservice Hub . vault Service . query By < Record State >( query Criteria ). states . single OrNull () ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ?: Ġthrow ĠFlow Exception (" O bl igation Ġwith Ġid Ġ$ linear Id Ġnot Ġfound .") ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġfun Ġresolve Identity ( abstract Party : ĠAbstract Party ): ĠAbstract Party Ġ{ ĊĠĠĠĠĠĠĠ Ġreturn Ġservice Hub . identity Service . require Well Known Party From Anonymous ( abstract Party ) ĊĠĠĠ Ġ} ĊĊĠĠĠ Ġprivate Ġfun Ġrandom Not ary (): ĠParty Ġ{ ĊĠĠĠĠĠĠĠ Ġ// ĠTodo : ĠFuture Ġimprovement Ġ- ĠApply ĠOracle Ġto Ġreceive Ġa Ġlarge Ġprime Ġnumber ĊĠĠĠĠĠĠĠ Ġval Ġnot ary List Ġ= Ġservice Hub . network Map Cache . not ary Id entities ĊĠĠĠĠĠĠĠ Ġval ĠnumOf Not ary Ġ= Ġnot ary List . size ĊĊĠĠĠĠĠĠĠ Ġreturn Ġnot ary List . random OrNull () ?: Ġthrow ĠFlow Exception (" No Ġavailable Ġnot ary .") ĊĠĠĠ Ġ} Ċ Ċ } Ċ Ċ internal Ġclass ĠSign Tx Flow No Checking ( other Flow : ĠFlow Session ) Ġ: ĠSign Transaction Flow ( other Flow ) Ġ{ ĊĠĠĠ Ġoverride Ġfun Ġcheck Transaction ( st x : ĠSigned Transaction ) Ġ{ ĊĠĠĠĠĠĠĠ Ġ// ĠTODO : ĠAdd Ġchecking Ġhere . ĊĠĠĠ Ġ} Ċ } Ċ Ċ /** Ċ Ġ* ĠA Ġversion Ġof Ġcheck Ġthat Ġthrows Ġa ĠFlow Exception Ġrather Ġthan Ġan ĠIllegalArgumentException Ċ Ġ*/ Ċ inline Ġfun Ġflow Check ( value : ĠBoolean , Ġmsg : Ġ() Ġ-> ĠString ) Ġ{ ĊĠĠĠ Ġif Ġ(! value ) Ġ{ ĊĠĠĠĠĠĠĠ Ġthrow ĠFlow Exception ( msg ()) ĊĠĠĠ Ġ} Ċ } Ċ