package Ġcom . ben ny hu o . tie gu any in . compiler . basic . builder Ċ Ċ import Ġcom . ben ny hu o . tie gu any in . compiler . basic . Basic Class Ċ import Ġcom . ben ny hu o . tie gu any in . compiler . basic . types . B UNDLE Ċ import Ġcom . ben ny hu o . tie gu any in . compiler . basic . types . INT ENT Ċ import Ġcom . squareup . jav ap o et . Method Spec Ċ import Ġcom . squareup . jav ap o et . TypeName Ċ import Ġcom . squareup . jav ap o et . Type Spec Ċ import Ġjavax . lang . model . element . Modifier Ċ Ċ abstract Ġclass ĠBasic Save State Method Builder ( val Ġbasic Class : ĠBasic Class ) Ġ{ ĊĊĠĠĠ Ġabstract Ġval Ġinstance Type : ĠType Name ĊĊĠĠĠ Ġfun Ġbuild ( type Builder : ĠType Spec . Builder ) Ġ{ ĊĠĠĠĠĠĠĠ Ġval Ġmethod Builder Ġ= ĠMethod Spec . method Builder (" save State ") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Modifiers ( Modifier . PUBLIC , ĠModifier . STATIC ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. returns ( TypeName . VOID ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Parameter ( instance Type , Ġ" instance ") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Parameter ( B UNDLE . java , Ġ" out State ") ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. begin Control Flow (" if ( instance Ġinstanceof Ġ\$ T )", Ġbasic Class . type Element ) ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġ. add Statement ("\ $ T Ġtyped Instance Ġ= Ġ(\ $ T ) Ġinstance ", Ġbasic Class . type Element , Ġbasic Class . type Element ) ĊĊĠĠĠĠĠĠĠ Ġmethod Builder . add Statement ("\ $ T Ġintent Ġ= Ġnew Ġ\$ T ()", ĠINTENT . java , ĠINTENT . java ) ĊĊĠĠĠĠĠĠĠ Ġfor Ġ( required Field Ġin Ġbasic Class . fields ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠ Ġval Ġname Ġ= Ġrequired Field . name ĊĠĠĠĠĠĠĠĠĠĠĠ Ġif Ġ( required Field . is Private ) Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmethod Builder . add Statement (" intent . putExtra (\ $ S , Ġtyped Instance . get \$ L ()) ", Ġname , Ġname . capitalize ()) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} Ġelse Ġ{ ĊĠĠĠĠĠĠĠĠĠĠĠĠĠĠĠ Ġmethod Builder . add Statement (" intent . putExtra (\ $ S , Ġtyped Instance .\ $ L )", Ġname , Ġname ) ĊĠĠĠĠĠĠĠĠĠĠĠ Ġ} ĊĠĠĠĠĠĠĠ Ġ} ĊĊĠĠĠĠĠĠĠ Ġmethod Builder . add Statement (" out State . put All ( intent . get Extras ()) "). end Control Flow () ĊĊĠĠĠĠĠĠĠ Ġtype Builder . add Method ( method Builder . build ()) ĊĠĠĠ Ġ} Ċ Ċ }