String fullFieldType;
try {
fullFieldType = pkgRegistry.getTypeResolver().resolveType( field.getPattern().getObjectType() ).getName();
FieldDefinition fieldDef = new FieldDefinition( field.getFieldName(),
fullFieldType );
// field is marked as PK
boolean isKey = field.getAnnotation( TypeDeclaration.ATTR_KEY ) != null;
fieldDef.setKey( isKey );
fieldDef.setIndex( field.getIndex() );
fieldDef.setInherited( field.isInherited() );
fieldDef.setInitExpr( field.getInitExpr() );
for ( String annotationName : field.getAnnotationNames() ) {
Class annotation = resolveAnnotation( annotationName,
pkgRegistry.getTypeResolver() );
if ( annotation != null ) {
try {
AnnotationDefinition annotationDefinition = AnnotationDefinition.build( annotation,
field.getAnnotations().get( annotationName ).getValueMap(),
pkgRegistry.getTypeResolver() );
fieldDef.addAnnotation( annotationDefinition );
} catch ( NoSuchMethodException nsme ) {
this.results.add( new TypeDeclarationError( "Annotated field " + field.getFieldName() + " - undefined property in @annotation " + annotationName + ": " + nsme.getMessage() + ";",
field.getLine() ) );
}
}