private Field getUnitField(Set<Field> fields) throws NoUnitException, TooManyUnitsException {
Field unitField = null;
for (Field field : fields) {
for (Annotation anno : field.getAnnotations()) {
if (Unit.class.isAssignableFrom(anno.annotationType())) {
if (unitField != null) throw new TooManyUnitsException("Already had field " + unitField + " when I found field " + field);
unitField = field;
}
}
}
if (unitField == null) throw new NoUnitException();