Java implementation of Fractions using generics