lundi 17 août 2015

Map different models as one response

I am trying to cast/map an API endpoint response to APIResponse.groovy. This can simply be done if I have an APIResponse model like

APIResponse.groovy

Integer age
String gender
Integer zip
Education education
String marital_status
Boolean magazine_buyer
Boolean outdoor_and_adventure

I want to group them as Demographics, Household and InterestPurchase. Like..

Demographics.groovy

Integer age
String gender
Integer zip
...

Household.groovy

Education education
Integer household_income
...

InterestPurchase.groovy

Boolean magazine_buyer
Boolean outdoor_and_adventure
...

I thought of something like

APIResponse.groovy

inteface APIResponse implements Household, Demographics, InterestPurchase{

}

but of course, this would not work since members of an interface is final and static..

Aucun commentaire:

Enregistrer un commentaire