public static final SerIterator array ( final Object [ ] array , final Class < ? > declaredType , final Class < ? > valueType ) { return new SerIterator ( ) { private int index = - 1 ; @ Override public String metaTypeName ( ) { return metaTypeNameBase ( valueType ) ; } private String metaTypeNameBase ( Class < ? > arrayType ) { if ( arrayType . isArray ( ) ) { return metaTypeNameBase ( arrayType . getComponentType ( ) ) + "[]" ; } if ( arrayType == Object . class ) { return "Object[]" ; } if ( arrayType == String . class ) { return "String[]" ; } return arrayType . getName ( ) + "[]" ; } @ Override public boolean metaTypeRequired ( ) { if ( valueType == Object . class ) { return Object [ ] . class . isAssignableFrom ( declaredType ) == false ; } if ( valueType == String . class ) { return String [ ] . class . isAssignableFrom ( declaredType ) == false ; } return true ; } @ Override public int size ( ) { return array . length ; } @ Override public boolean hasNext ( ) { return ( index + 1 ) < array . length ; } @ Override public void next ( ) { index ++ ; } @ Override public Class < ? > valueType ( ) { return valueType ; } @ Override public List < Class < ? > > valueTypeTypes ( ) { return Collections . emptyList ( ) ; } @ Override public Object value ( ) { return array [ index ] ; } } ; }
Gets an iterator wrapper for an object array .