/** * Create a new Query Property instance. * * @param <T> type of the Property * @param mixinClass mixin of the Property * @param fieldName name of the Property field * * @return a new Query Property instance for the given mixin and property name. */ @SuppressWarnings( "unchecked" ) public static <T> Property<T> property( Class<?> mixinClass, String fieldName ) { try { Field field = mixinClass.getField( fieldName ); if( !Property.class.isAssignableFrom( field.getType() ) ) { throw new IllegalArgumentException( "Field must be of type Property<?>" ); } return (Property<T>) Proxy.newProxyInstance( mixinClass.getClassLoader(), array( field.getType() ), new PropertyReferenceHandler<>( new PropertyFunction<T>( null, null, null, null, field ) ) ); } catch( NoSuchFieldException e ) { throw new IllegalArgumentException( "No such field '" + fieldName + "' in mixin " + mixinClass.getName() ); } }
/** * Create a new Query Property instance. * * @param <T> type of the Property * @param mixinClass mixin of the Property * @param fieldName name of the Property field * * @return a new Query Property instance for the given mixin and property name. */ @SuppressWarnings( "unchecked" ) public static <T> Property<T> property( Class<?> mixinClass, String fieldName ) { try { Field field = mixinClass.getField( fieldName ); if( !Property.class.isAssignableFrom( field.getType() ) ) { throw new IllegalArgumentException( "Field must be of type Property<?>" ); } return (Property<T>) Proxy.newProxyInstance( mixinClass.getClassLoader(), array( field.getType() ), new PropertyReferenceHandler<>( new PropertyFunction<T>( null, null, null, null, field ) ) ); } catch( NoSuchFieldException e ) { throw new IllegalArgumentException( "No such field '" + fieldName + "' in mixin " + mixinClass.getName() ); } }
/** * Create a new EQUALS specification for an Association. * * @param <T> Association type * @param association an Association * @param value its value * * @return a new EQUALS specification for an Association. */ public static <T> EqPredicate<Identity> eq( Association<T> association, T value ) { return new EqPredicate<>( new PropertyFunction<>( null, association(association), null, null, IDENTITY_METHOD), ((HasIdentity) value).identity().get()); }
/** * Create a new EQUALS specification for an Association. * * @param <T> Association type * @param association an Association * @param value its value * * @return a new EQUALS specification for an Association. */ public static <T> EqPredicate<Identity> eq( Association<T> association, T value ) { return new EqPredicate<>( new PropertyFunction<>( null, association(association), null, null, IDENTITY_METHOD), ((HasIdentity) value).identity().get()); }
method.getReturnType().getClassLoader(), array( method.getReturnType() ), new PropertyReferenceHandler<>( new PropertyFunction<T>( compositeProperty, compositeAssociation, compositeManyAssociation,
method.getReturnType().getClassLoader(), array( method.getReturnType() ), new PropertyReferenceHandler<>( new PropertyFunction<T>( compositeProperty, compositeAssociation, compositeManyAssociation,
Proxy.newProxyInstance( field.getType().getClassLoader(), array( field.getType() ), new PropertyReferenceHandler<>( new PropertyFunction<T>( null, null, null, null, field ) ) ) );
Proxy.newProxyInstance( field.getType().getClassLoader(), array( field.getType() ), new PropertyReferenceHandler<>( new PropertyFunction<T>( null, null, null, null, field ) ) ) );