java aggregation code