Code example for Field

Methods: getAnnotation, getName, getType, isAnnotationPresent

0
	private String type;
	private String columnName;
	private boolean primaryKey = false;
 
	protected FieldDefinition(Field field){
		if (field.isAnnotationPresent(Column.class)) {
			Column columnAnnotation = field.getAnnotation(Column.class);
			boolean isPrimaryKey = field.isAnnotationPresent(PrimaryKey.class);
			 
			this.name = field.getName();
			this.columnName = columnAnnotation.name();
			this.type = field.getType().getSimpleName();
			this.primaryKey = isPrimaryKey;
		}else{ 
			throw new RuntimeException("Error: Field " + field.getName() + " does not contain @Column annotation");
		} 
 
	} 
 
	protected String getName() {
		return name;