private static LinkedList < Field > initializeNonRequiredFields ( final Class < ? > aClass ) { final LinkedList < Field > result = new LinkedList ( ) ; final Field [ ] fields = aClass . getDeclaredFields ( ) ; for ( final Field f : fields ) { if ( f . getType ( ) . isArray ( ) ) { final XmlElementWrapper xmlElementWrapper = f . getAnnotation ( XmlElementWrapper . class ) ; if ( xmlElementWrapper != null ) { if ( ! xmlElementWrapper . required ( ) ) { result . add ( f ) ; } } else { final XmlElement xmlElement = f . getAnnotation ( XmlElement . class ) ; if ( xmlElement != null && ! xmlElement . required ( ) ) { result . add ( f ) ; } } } else if ( ! f . getType ( ) . isPrimitive ( ) ) { if ( f . getType ( ) . isEnum ( ) ) { if ( FixedType . class . equals ( f . getType ( ) ) ) { result . add ( f ) ; } else if ( BlockType . class . equals ( f . getType ( ) ) ) { result . add ( f ) ; } else if ( TierBlockPolicy . class . equals ( f . getType ( ) ) ) { result . add ( f ) ; } } else if ( Integer . class . equals ( f . getType ( ) ) ) { result . add ( f ) ; } else if ( Double . class . equals ( f . getType ( ) ) ) { result . add ( f ) ; } } } return result ; }
For each type of catalog object we keep the Field associated to non required attribute fields