final Object returnValue; try { if ( ReflectHelper.isPublic( persistentClass, thisMethod ) ) { if ( !thisMethod.getDeclaringClass().isInstance( target ) ) { throw new ClassCastException(
final Object returnValue; try { if ( ReflectHelper.isPublic( persistentClass, thisMethod ) ) { if ( !thisMethod.getDeclaringClass().isInstance( target ) ) { throw new ClassCastException(
/** * Is this member publicly accessible. * <p/> * Short-hand for {@link #isPublic(Class, Member)} passing the member + {@link Member#getDeclaringClass()} * * @param member The member to check * @return True if the member is publicly accessible. */ public static boolean isPublic(Member member) { return isPublic( member.getDeclaringClass(), member ); }
/** * Is this member publicly accessible. * <p/> * Short-hand for {@link #isPublic(Class, Member)} passing the member + {@link Member#getDeclaringClass()} * * @param member The member to check * @return True if the member is publicly accessible. */ public static boolean isPublic(Member member) { return isPublic( member.getDeclaringClass(), member ); }
private Constructor<? extends ComponentTuplizer> getProperConstructor(Class<? extends ComponentTuplizer> clazz) { Constructor<? extends ComponentTuplizer> constructor = null; try { constructor = clazz.getDeclaredConstructor( COMPONENT_TUP_CTOR_SIG ); if ( ! ReflectHelper.isPublic( constructor ) ) { try { // found a constructor, but it was not publicly accessible so try to request accessibility constructor.setAccessible( true ); } catch ( SecurityException e ) { constructor = null; } } } catch ( NoSuchMethodException ignore ) { } return constructor; }
private Constructor<? extends ComponentTuplizer> getProperConstructor(Class<? extends ComponentTuplizer> clazz) { Constructor<? extends ComponentTuplizer> constructor = null; try { constructor = clazz.getDeclaredConstructor( COMPONENT_TUP_CTOR_SIG ); if ( ! ReflectHelper.isPublic( constructor ) ) { try { // found a constructor, but it was not publicly accessible so try to request accessibility constructor.setAccessible( true ); } catch ( SecurityException e ) { constructor = null; } } } catch ( NoSuchMethodException ignore ) { } return constructor; }
private Constructor<? extends EntityTuplizer> getProperConstructor( Class<? extends EntityTuplizer> clazz, Class[] constructorArgs) { Constructor<? extends EntityTuplizer> constructor = null; try { constructor = clazz.getDeclaredConstructor( constructorArgs ); if ( ! ReflectHelper.isPublic( constructor ) ) { try { // found a constructor, but it was not publicly accessible so try to request accessibility constructor.setAccessible( true ); } catch ( SecurityException e ) { constructor = null; } } } catch ( NoSuchMethodException ignore ) { } return constructor; }
private Constructor<? extends EntityTuplizer> getProperConstructor( Class<? extends EntityTuplizer> clazz, Class[] constructorArgs) { Constructor<? extends EntityTuplizer> constructor = null; try { constructor = clazz.getDeclaredConstructor( constructorArgs ); if ( ! ReflectHelper.isPublic( constructor ) ) { try { // found a constructor, but it was not publicly accessible so try to request accessibility constructor.setAccessible( true ); } catch ( SecurityException e ) { constructor = null; } } } catch ( NoSuchMethodException ignore ) { } return constructor; }
private static Field getField(Class root, Class clazz, String name) throws PropertyNotFoundException { if ( clazz==null || clazz==Object.class ) { throw new PropertyNotFoundException("field [" + name + "] not found on " + root.getName()); } Field field; try { field = clazz.getDeclaredField(name); } catch (NoSuchFieldException nsfe) { field = getField( root, clazz.getSuperclass(), name ); } if ( !ReflectHelper.isPublic(clazz, field) ) field.setAccessible(true); return field; }
private static Field getField(Class clazz, String name) throws PropertyNotFoundException { if ( clazz==null || clazz==Object.class ) { throw new PropertyNotFoundException("field not found: " + name); } Field field; try { field = clazz.getDeclaredField(name); } catch (NoSuchFieldException nsfe) { field = getField( clazz, clazz.getSuperclass(), name ); } if ( !ReflectHelper.isPublic(clazz, field) ) field.setAccessible(true); return field; }
private static Field getField(Class root, Class clazz, String name) throws PropertyNotFoundException { if ( clazz==null || clazz==Object.class ) { throw new PropertyNotFoundException("field [" + name + "] not found on " + root.getName()); } Field field; try { field = clazz.getDeclaredField(name); } catch (NoSuchFieldException nsfe) { field = getField( root, clazz.getSuperclass(), name ); } if ( !ReflectHelper.isPublic(clazz, field) ) field.setAccessible(true); return field; }
private static Field getField(Class clazz, String name) throws PropertyNotFoundException { if ( clazz==null || clazz==Object.class ) { throw new PropertyNotFoundException("field not found: " + name); } Field field; try { field = clazz.getDeclaredField(name); } catch (NoSuchFieldException nsfe) { field = getField( clazz, clazz.getSuperclass(), name ); } if ( !ReflectHelper.isPublic(clazz, field) ) field.setAccessible(true); return field; }
/** * Retrieve the default (no arg) constructor from the given class. * * @param clazz The class for which to retrieve the default ctor. * @return The default constructor. * @throws PropertyNotFoundException Indicates there was not publicly accessible, no-arg constructor (todo : why PropertyNotFoundException???) */ public static Constructor getDefaultConstructor(Class clazz) throws PropertyNotFoundException { if ( isAbstractClass( clazz ) ) { return null; } try { Constructor constructor = clazz.getDeclaredConstructor( NO_PARAM_SIGNATURE ); if ( !isPublic( clazz, constructor ) ) { constructor.setAccessible( true ); } return constructor; } catch ( NoSuchMethodException nme ) { throw new PropertyNotFoundException( "Object class [" + clazz.getName() + "] must declare a default (no-argument) constructor" ); } }
/** * Retrieve the default (no arg) constructor from the given class. * * @param clazz The class for which to retrieve the default ctor. * @return The default constructor. * @throws PropertyNotFoundException Indicates there was not publicly accessible, no-arg constructor (todo : why PropertyNotFoundException???) */ public static Constructor getDefaultConstructor(Class clazz) throws PropertyNotFoundException { if ( isAbstractClass( clazz ) ) { return null; } try { Constructor constructor = clazz.getDeclaredConstructor( NO_PARAM_SIGNATURE ); if ( !isPublic( clazz, constructor ) ) { constructor.setAccessible( true ); } return constructor; } catch ( NoSuchMethodException nme ) { throw new PropertyNotFoundException( "Object class [" + clazz.getName() + "] must declare a default (no-argument) constructor" ); } }
final Object returnValue; try { if ( ReflectHelper.isPublic( persistentClass, thisMethod ) ) { if ( !thisMethod.getDeclaringClass().isInstance( target ) ) { throw new ClassCastException(
private static BasicSetter getSetterOrNull(Class theClass, String propertyName) { if (theClass==Object.class || theClass==null) return null; Method method = setterMethod(theClass, propertyName); if (method!=null) { if ( !ReflectHelper.isPublic(theClass, method) ) method.setAccessible(true); return new BasicSetter(theClass, method, propertyName); } else { BasicSetter setter = getSetterOrNull( theClass.getSuperclass(), propertyName ); if (setter==null) { Class[] interfaces = theClass.getInterfaces(); for ( int i=0; setter==null && i<interfaces.length; i++ ) { setter=getSetterOrNull( interfaces[i], propertyName ); } } return setter; } }
private static BasicSetter getSetterOrNull(Class theClass, String propertyName) { if (theClass==Object.class || theClass==null) return null; Method method = setterMethod(theClass, propertyName); if (method!=null) { if ( !ReflectHelper.isPublic(theClass, method) ) method.setAccessible(true); return new BasicSetter(theClass, method, propertyName); } else { BasicSetter setter = getSetterOrNull( theClass.getSuperclass(), propertyName ); if (setter==null) { Class[] interfaces = theClass.getInterfaces(); for ( int i=0; setter==null && i<interfaces.length; i++ ) { setter=getSetterOrNull( interfaces[i], propertyName ); } } return setter; } }
if ( !isPublic( clazz, constructor ) ) { constructor.setAccessible( true );
private static BasicGetter getGetterOrNull(Class theClass, String propertyName) { if (theClass==Object.class || theClass==null) { return null; } Method method = getterMethod(theClass, propertyName); if (method!=null) { if ( !ReflectHelper.isPublic( theClass, method ) ) { method.setAccessible(true); } return new BasicGetter(theClass, method, propertyName); } else { BasicGetter getter = getGetterOrNull( theClass.getSuperclass(), propertyName ); if (getter==null) { Class[] interfaces = theClass.getInterfaces(); for ( int i=0; getter==null && i<interfaces.length; i++ ) { getter=getGetterOrNull( interfaces[i], propertyName ); } } return getter; } }
private static BasicGetter getGetterOrNull(Class theClass, String propertyName) { if (theClass==Object.class || theClass==null) { return null; } Method method = getterMethod(theClass, propertyName); if (method!=null) { if ( !ReflectHelper.isPublic( theClass, method ) ) { method.setAccessible(true); } return new BasicGetter(theClass, method, propertyName); } else { BasicGetter getter = getGetterOrNull( theClass.getSuperclass(), propertyName ); if (getter==null) { Class[] interfaces = theClass.getInterfaces(); for ( int i=0; getter==null && i<interfaces.length; i++ ) { getter=getGetterOrNull( interfaces[i], propertyName ); } } return getter; } }