avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Yang <teddyyyy...@gmail.com>
Subject inheritance implementation?
Date Tue, 31 May 2011 18:33:32 GMT
I understand that avro does not have inheritance now, so I am wondering what
is the best way to achieve the following goal:

I define Apple, Orange, and Fruit. Apple and Orange should ideally derive
from Fruit, but since there is no built-in mechanism,
we create an internal member for aboth Apple and Orange, encapsulating the
contents of Orangle

Apple :{
Fruit: fruit_member

string: pattern_on_skin
}

Orange : {

Fruit: fruit_member

string: skin_thickness
}


Fruit: {
int : size,
string: color
int: weight
}



say I want to pass objects of both Apple and Orange to some scale to measure
the total weight,
I can pass them just as Objects,


int findTotalWeight(List<Object> l ) {

    int result=0;
    for(Object o : l ) {
       result += ???????  <============ somehow get access to the
fruit_member var ??
   }
}


so what is the best way to fill in the line above with "<====" ? doing a lot
of instanceof  is kind of cumbersome


Thanks
Yang

Mime
View raw message