Implementing field metrics in java