package Ġcom . ec wid . apic lient . v 3 . util Ċ Ċ import Ġcom . google . common . base . Predicate Ċ import Ġcom . google . common . base . Pred icates Ċ import Ġorg . reflection s . Reflection Utils Ċ import Ġorg . reflection s . Reflection s Ċ import Ġuk . co . j emos . pod am . api . Abstract Random DataProvider Strategy Ċ import Ġuk . co . j emos . pod am . api . DataProvider Strategy Ċ import Ġuk . co . j emos . pod am . common . Pod am Constants Ċ import Ġjava . lang . reflect . Constructor Ċ import Ġjava . lang . reflect . Modifier Ċ import Ġjava . util .* Ċ Ċ internal Ġclass ĠDT OR andom DataProvider Strategy Ġ: ĠAbstract Random DataProvider Strategy () Ġ{ ĊĊ ĉ private Ġval Ġconcrete Sub classes Map Ġ= ĠHashMap < Class <* >, ĠConcrete Sub classes Provider <* >>() ĊĊ ĉ override Ġfun Ġsort ( construct ors : ĠArray < out ĠConstructor <* >>, Ġorder : ĠData Provider Strategy . Order ) Ġ{ Ċĉ ĉ // ĠWe Ġshould Ġnot Ġcall Ġsur rogate Ġdata Ġconstructor Ġwith Ġrandom Ġparameters Ċĉ ĉ // ĠInstead Ġwe Ġshould Ġcall Ġthe Ġsecond Ġmost Ġparameters Ġconstructor Ċĉ ĉ construct ors . sort With ( Ċĉĉ ĉ compare By Ġ{ Ġc : ĠConstructor < *> Ġ-> Ċĉĉĉ ĉ c . parameter Types . last OrNull ()?. simple Name Ġ== Ġ" Default Constructor Marker " Ċĉĉ ĉ }. then By Descending Ġ{ Ġc : ĠConstructor < *> Ġ-> Ċĉĉĉ ĉ c . parameter Types . size Ċĉĉ ĉ } Ċĉ ĉ ) Ċ ĉ } ĊĊ ĉ override Ġfun Ġ< T > Ġget Specific Class ( abstract Class : ĠClass < T >): ĠClass < out ĠT > Ġ{ Ċĉ ĉ return Ġget Concrete Sub classes Provider ( abstract Class ). next Ċ ĉ } ĊĊ ĉ override Ġfun Ġget NumberOf Collection Elements ( type : ĠClass < *> ): ĠInt Ġ{ Ċĉ ĉ return Ġwhen Ġ{ Ċĉĉ ĉ type . is Enum Ġ-> Ġtype . enum Constants . size Ċĉĉ ĉ type . is Interface Ġ|| ĠModifier . is Abstract ( type . modifiers ) Ġ-> Ġget Concrete Sub classes Provider ( type ). count Ċĉĉ ĉ else Ġ-> ĠPod am Constants . DEFAULT _ N BR _ COLLECTION _ ELEMENT S Ċĉ ĉ } Ċ ĉ } ĊĊ ĉ private Ġfun Ġ< T > Ġget Concrete Sub classes Provider ( abstract Class : ĠClass < T >): ĠConcrete Sub classes Provider < T > Ġ{ Ċĉ ĉ @ Suppress (" UN CHECK ED _ CAST ") Ċĉ ĉ return Ġconcrete Sub classes Map . get Or Put ( abstract Class ) Ġ{ ĠConcrete Sub classes Provider ( abstract Class ) Ġ} Ġas ĠConcrete Sub classes Provider < T > Ċ ĉ } ĊĊ ĉ private Ġclass ĠConcrete Sub classes Provider < out ĠT >( val Ġabstract Class : ĠClass < out ĠT >) Ġ{ ĊĊĉ ĉ private Ġval Ġsubclasses Ġ= ĠLinkedList < Class < out ĠT >>() Ċĉ ĉ private Ġvar Ġiterator : ĠIterator < Class < out ĠT >> ĊĊĉ ĉ val Ġnext : ĠClass < out ĠT > Ċĉĉ ĉ get () Ġ{ Ċĉĉĉ ĉ if Ġ( sub classes . isEmpty ()) Ġ{ Ċĉĉĉĉ ĉ return Ġabstract Class Ċĉĉĉ ĉ } Ċĉĉĉ ĉ if Ġ(! iterator . hasNext ()) Ġ{ Ċĉĉĉĉ ĉ iterator Ġ= Ġsubclasses . iterator () Ċĉĉĉ ĉ } Ċĉĉĉ ĉ return Ġiterator . next () Ċĉĉ ĉ } ĊĊĉ ĉ val Ġcount : ĠInt Ċĉĉ ĉ get () Ġ= Ġsubclasses . size ĊĊĉ ĉ init Ġ{ Ċĉĉ ĉ fill Concrete Sub classes ( abstract Class ) Ċĉĉ ĉ sort Classes ByName ( sub classes ) Ċĉĉ ĉ iterator Ġ= Ġsubclasses . iterator () Ċĉ ĉ } ĊĊĉ ĉ @ Suppress (" UN CHECK ED _ CAST ") Ċĉ ĉ private Ġfun Ġfill Concrete Sub classes ( abstract Class : ĠClass < out ĠT >) Ġ{ Ċĉĉ ĉ this . sub classes . addAll ( Ċĉĉĉ ĉ Reflection Utils . getAll ( Ċĉĉĉĉ ĉ reflection s . getSub Types Of ( abstract Class Ġas ĠClass < T >), Ċĉĉĉĉ ĉ Pred icates . not ( IS _ AB STR ACT ), Ċĉĉĉĉ ĉ Pred icates . not ( IS _ SUB CLASS _ OF _ ENUM ) Ċĉĉĉ ĉ ) Ċĉĉ ĉ ) Ċĉ ĉ } ĊĊĉ ĉ private Ġfun Ġsort Classes ByName ( classes : ĠMutable List < Class < out ĠT >>) Ġ{ Ċĉĉ ĉ classes . sort With Ġ{ Ġx , Ġy Ġ-> Ċĉĉĉ ĉ x . simple Name . compareTo ( y . simple Name ) Ċĉĉ ĉ } Ċĉ ĉ } ĊĊĉ ĉ comp anion Ġobject Ġ{ ĊĊĉĉ ĉ private Ġval Ġreflection s Ġ= ĠReflection s (" com . ec wid . apic lient . v 3 ") ĊĊĉĉ ĉ private Ġval ĠIS _ AB STR ACT Ġ= ĠPred icates . or ( Ċĉĉĉ ĉ Reflection Utils . with Class Modifier ( Modifier . AB STR ACT ), Ċĉĉĉ ĉ Reflection Utils . with Class Modifier ( Modifier . INTERFACE ) Ċĉĉ ĉ ) ĊĊĉĉ ĉ private Ġval ĠIS _ SUB CLASS _ OF _ ENUM Ġ= ĠPredicate < Class <* >> Ġ{ Ġclazz Ġ-> Ċĉĉĉ ĉ clazz ?. super class ?. is Enum Ġ== Ġtrue Ċĉĉ ĉ } Ċĉ ĉ } Ċ ĉ } Ċ } Ċ