avro-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Doug Cutting <cutt...@apache.org>
Subject Re: How to add custom code to avro generated Java objects?
Date Mon, 14 Mar 2011 18:45:24 GMT
The best practice is not to modify the generated classes directly, but
rather to author classes that wrap instances of generated classes,
adding methods that enforce such constraints to those.  The wrapper
classes can then also maintain back-compatible APIs.  Does that make sense?

Doug

On 03/14/2011 10:06 AM, Aleksey Maslov wrote:
> Hi,
> 
> Is there a way to specify inter dependencies between object methods in IDL?
> For example, if object tracks 2 symmetrical properties that have perfect
> -1/+1 correlation; when one is updated, the other needs to be updated (in
> opposite direction in case of -1 corr); Ex:
> 
> record CredtiCardStatement {
> double balance;
> double payed;
> }
> 
> so paying 100 units should decrease the balance by 100 units; 
> 
> any way to specify such dependencies in the IDL? 
> Or if I add this code to the generated Java file, is there a way to merge
> future re-generations of the record from IDL -> avro protocol -> java, not
> override it;
> 
> I am trying to smarten-up my java representations of avro data objects i get
> from generating from IDL but how can i preserve my changes, as i modify the
> IDL and re-generate the java object definitions?
> 
> Thank you,
> Aleksey
> 
> 
> --
> View this message in context: http://apache-avro.679487.n3.nabble.com/How-to-add-custom-code-to-avro-generated-Java-objects-tp2676654p2676654.html
> Sent from the Avro - Users mailing list archive at Nabble.com.

Mime
View raw message