public DataConverter(Class<T> clazz) throws TooManyPrimaryKeys, NotAnnotatedAsTableClassException, PrimaryKeyIsNotColumnException, NoPrimaryKeyException { if (clazz.getAnnotation(Table.class) == null) { throw new NotAnnotatedAsTableClassException(); } else { if (!clazz.getDeclaredAnnotation(Table.class).name().equals("")) { tableName = clazz.getDeclaredAnnotation(Table.class).name(); } else { tableName = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, clazz.getSimpleName()); } } fields = new ArrayList<FieldConverter>(); for (Field field : clazz.getDeclaredFields()) { Class<?> type = field.getType(); Annotation primaryKeyAnnotation = field.getDeclaredAnnotation(PrimaryKey.class), columnAnnotation = field.getDeclaredAnnotation(Column.class); if (primaryKeyAnnotation != null) { if (columnAnnotation == null) { throw new PrimaryKeyIsNotColumnException(); } if (primaryKeyField != null) { throw new TooManyPrimaryKeys(); } primaryKeyField = field; } if (columnAnnotation != null) { String name = null; if (!field.getDeclaredAnnotation(Column.class).name().equals("")) { name = field.getDeclaredAnnotation(Column.class).name(); } else { name = CaseFormat.UPPER_CAMEL.to(CaseFormat.LOWER_UNDERSCORE, field.getName()); } FieldConverter currentFieldConverter = new FieldConverter(name, field); fields.add(currentFieldConverter); if (field.equals(primaryKeyField)) { primaryKeyFieldConverter = currentFieldConverter; } } Annotation[] annotations = field.getDeclaredAnnotations(); for (Annotation annotation : annotations) { annotation.getClass(); } } if (primaryKeyField == null) { throw new NoPrimaryKeyException(); } }