public If < ? , ? > [ ] generateIfConditions ( Class < ? extends If < ? , ? > > [ ] ifClasses , Field field ) { if ( ifClasses . length == 0 ) return ALWAYS ; If < ? , ? > [ ] result = new If < ? , ? > [ ifClasses . length ] ; for ( int i = 0 ; i < ifClasses . length ; i ++ ) { Class < ? extends If < ? , ? > > ifClass = ifClasses [ i ] ; result [ i ] = this . createIf ( ifClass , field ) ; // Sanity check the generic If class types to ensure that they match the actual types of the field & entity. Type valueType = GenericTypeReflector . getTypeParameter ( ifClass , If . class . getTypeParameters ( ) [ 0 ] ) ; Class < ? > valueClass = GenericTypeReflector . erase ( valueType ) ; Type pojoType = GenericTypeReflector . getTypeParameter ( ifClass , If . class . getTypeParameters ( ) [ 1 ] ) ; Class < ? > pojoClass = GenericTypeReflector . erase ( pojoType ) ; if ( ! TypeUtils . isAssignableFrom ( valueClass , field . getType ( ) ) ) throw new IllegalStateException ( "Cannot use If class " + ifClass . getName ( ) + " on " + field + " because you cannot assign " + field . getType ( ) . getName ( ) + " to " + valueClass . getName ( ) ) ; if ( ! TypeUtils . isAssignableFrom ( pojoClass , field . getDeclaringClass ( ) ) ) throw new IllegalStateException ( "Cannot use If class " + ifClass . getName ( ) + " on " + field + " because the containing class " + field . getDeclaringClass ( ) . getName ( ) + " is not compatible with " + pojoClass . getName ( ) ) ; } return result ; }
Clever enough to recognize that an empty set of conditions means Always .