FieldScanner { protected String toFieldName(Method method) { if (method.getParameterCount() > 0) { return null; } if (method.getName().startsWith("get")) { String field = method.getName().substring(3); return field.substring(0, 1).toLowerCase() + field.substring(1); } else if (method.getName().startsWith("is")) { String field = method.getName().substring(2); return field.substring(0, 1).toLowerCase() + field.substring(1); } else { return null; } }  FieldData scanAnnotations(Class modelClass);  }
@Test public void testToFieldName() throws Exception { FieldScanner scanner = new FieldScanner(); assertEquals("loginAt", scanner.toFieldName(TestModel.class.getDeclaredMethod("getLoginAt"))); assertNull(scanner.toFieldName(TestModel.class.getDeclaredMethod("getLoginAt", long.class))); }