Refine search
final Object[] args = toArray(arg); return invokeMethod(object, methodName, args); return invokeMethod(object, methodName, args, parameterTypes); final Method method = getMatchingAccessibleMethod( object.getClass(), methodName, final Object[] args = toArray(arg); return invokeExactMethod(object, methodName, args); return invokeExactMethod(object, methodName, args, parameterTypes); final Method method = getAccessibleMethod( object.getClass(), methodName, final Method method = getAccessibleMethod( objectClass, methodName, final Object[] args = toArray(arg); return invokeStaticMethod (objectClass, methodName, args); return invokeStaticMethod (objectClass, methodName, args, parameterTypes); final Method method = getMatchingAccessibleMethod( objectClass,
/** * Find a non primitive representation for given primitive class. * * @param clazz the class to find a representation for, not null * @return the original class if it not a primitive. Otherwise the wrapper class. Not null */ public static Class<?> toNonPrimitiveClass(final Class<?> clazz) { if (clazz.isPrimitive()) { final Class<?> primitiveClazz = MethodUtils.getPrimitiveWrapper(clazz); // the above method returns if (primitiveClazz != null) { return primitiveClazz; } else { return clazz; } } else { return clazz; } }
final MethodDescriptor md = new MethodDescriptor(clazz, methodName, parameterTypes, true); Method method = getCachedMethod(md); if (method != null) { return method; method = getAccessibleMethod (clazz, clazz.getMethod(methodName, parameterTypes)); cacheMethod(md, method); return method; } catch (final NoSuchMethodException e) {
while (srcClass != null && !destClass.equals(srcClass)) { if (destClass.isPrimitive()) { final Class<?> destClassWrapperClazz = getPrimitiveWrapper(destClass); if (destClassWrapperClazz != null && destClassWrapperClazz.equals(srcClass)) { cost += 0.25f; if (destClass.isInterface() && isAssignmentCompatible(destClass,srcClass)) {
MethodUtils.invokeExactMethod(parent, methodName, new Object[]{ child }, paramTypes); MethodUtils.invokeMethod(parent, methodName, new Object[]{ child }, paramTypes);
log.debug("Reflecting static {}, clazz={} args={}", method, klazz, Arrays.toString(args)); returnValue = MethodUtils.invokeStaticMethod(klazz, method.getName(), args, parameterTypes); } else { if ("<init>".equals(method.getName())) { returnValue = MethodUtils.invokeMethod(value, method.getName(), args, parameterTypes);
final PropertyDescriptor descriptor = getPropertyDescriptor(bean, name); if (descriptor == null) { throw new NoSuchMethodException("Unknown property '" + readMethod = MethodUtils.getAccessibleMethod(bean.getClass(), readMethod); if (readMethod != null) { final Object[] keyArray = new Object[1]; keyArray[0] = key; result = invokeMethod(readMethod, bean, keyArray); } else { throw new NoSuchMethodException("Property '" + name + final Method readMethod = getReadMethod(bean.getClass(), descriptor); if (readMethod != null) { final Object invokeResult = invokeMethod(readMethod, bean, EMPTY_OBJECT_ARRAY);
Object nestedBean = null; try { nestedBean = getProperty(bean, next); } catch (final IllegalAccessException e) { return false; try { final PropertyDescriptor desc = getPropertyDescriptor(bean, name); if (desc != null) { Method readMethod = getReadMethod(bean.getClass(), desc); if (readMethod == null) { if (desc instanceof IndexedPropertyDescriptor) { readMethod = ((MappedPropertyDescriptor) desc).getMappedReadMethod(); readMethod = MethodUtils.getAccessibleMethod(bean.getClass(), readMethod);
Object nestedBean = null; try { nestedBean = getProperty(bean, next); } catch (final IllegalAccessException e) { return false; try { final PropertyDescriptor desc = getPropertyDescriptor(bean, name); if (desc != null) { Method writeMethod = getWriteMethod(bean.getClass(), desc); if (writeMethod == null) { if (desc instanceof IndexedPropertyDescriptor) { writeMethod = ((MappedPropertyDescriptor) desc).getMappedWriteMethod(); writeMethod = MethodUtils.getAccessibleMethod(bean.getClass(), writeMethod);
@Override public Object invoke(Object proxy, Method method, Object[] args) throws Throwable { return MethodUtils.invokeMethod(getProductOptionValuesCollection(), method.getName(), args, method.getParameterTypes()); } });
private boolean customizeReaderInitialization(ImageReader reader, Hints hints) { // Special Management for NetCDF readers to set external Auxiliary File if (hints != null && (hints.containsKey(Utils.AUXILIARY_FILES_PATH) || hints.containsKey(Utils.AUXILIARY_DATASTORE_PATH))) { try { updateReaderWithAuxiliaryPath( hints, reader, Utils.AUXILIARY_FILES_PATH, "setAuxiliaryFilesPath"); updateReaderWithAuxiliaryPath( hints, reader, Utils.AUXILIARY_DATASTORE_PATH, "setAuxiliaryDatastorePath"); if (hints.get(Hints.REPOSITORY) != null && MethodUtils.getAccessibleMethod( reader.getClass(), "setRepository", new Class[] {Repository.class}) != null) { MethodUtils.invokeMethod(reader, "setRepository", hints.get(Hints.REPOSITORY)); } return true; } catch (NoSuchMethodException e) { throw new RuntimeException(e); } catch (IllegalAccessException e) { throw new RuntimeException(e); } catch (InvocationTargetException e) { throw new RuntimeException(e); } } return false; }
/** * Invokes an annotation method. * * @param annotationn the annotation has to be introspected. * @param method the method name to execute. * @return the annotation method value, null if any error occurs. */ private static Object invokeAnnotationMethod(Annotation annotation, String method) { try { return MethodUtils.invokeExactMethod(annotation, method, null); } catch (Throwable t) { return null; } }
/** * <p>Return an accessible method (that is, one that can be invoked via * reflection) with given name and a single parameter. If no such method * can be found, return <code>null</code>. * Basically, a convenience wrapper that constructs a <code>Class</code> * array for you.</p> * * @param clazz get method from this class * @param methodName get method with this name * @param parameterType taking this type of parameter * @return The accessible method */ public static Method getAccessibleMethod( final Class<?> clazz, final String methodName, final Class<?> parameterType) { final Class<?>[] parameterTypes = {parameterType}; return getAccessibleMethod(clazz, methodName, parameterTypes); }
/** * Returns a suitable handler method for an event. First, it searches for a method with a single * argument that assignment-compatible with the event. Failing that, it searches for a method * with no arguments. Failing that, it returns null. * * @param handlerName The name of the handler method (defaults to a method with the same name as * the event type). * @param instance The instance implementing the handler method. * @param event The event. * @return The handler method, or null if a suitable method could not be found. */ public static Method getHandler(String handlerName, Object instance, Event event) { handlerName = handlerName != null ? handlerName : event.getType(); Method method = MethodUtils.getMatchingAccessibleMethod(instance.getClass(), handlerName, new Class<?>[] { event.getClass() }); return method != null ? method : MethodUtils.getAccessibleMethod(instance.getClass(), handlerName, ArrayUtils.EMPTY_CLASS_ARRAY); }
/** * Find a method on a class with a specified parameter list. */ private static Method getMethod(final Class<?> clazz, final String methodName, final Class<?>[] parameterTypes) throws IntrospectionException { if (methodName == null) { return null; } final Method method = MethodUtils.getMatchingAccessibleMethod(clazz, methodName, parameterTypes); if (method != null) { return method; } final int parameterCount = (parameterTypes == null) ? 0 : parameterTypes.length; // No Method found throw new IntrospectionException("No method \"" + methodName + "\" with " + parameterCount + " parameter(s) of matching types."); }
/** * <p>Return an accessible property setter method for this property, * if there is one; otherwise return <code>null</code>.</p> * * <p><strong>FIXME</strong> - Does not work with DynaBeans.</p> * * @param clazz The class of the read method will be invoked on * @param descriptor Property descriptor to return a setter for * @return The write method * @since 1.9.1 */ public Method getWriteMethod(final Class<?> clazz, final PropertyDescriptor descriptor) { final BeanIntrospectionData data = getIntrospectionData(clazz); return (MethodUtils.getAccessibleMethod(clazz, data.getWriteMethod(clazz, descriptor))); }
public static List<ColumnFamilyDefinition> getCfDefs( Class<? extends CFEnum> cfEnum, List<ColumnFamilyDefinition> cf_defs, String keyspace ) { if ( cf_defs == null ) { cf_defs = new ArrayList<ColumnFamilyDefinition>(); } CFEnum[] values = null; try { values = ( CFEnum[] ) invokeStaticMethod( cfEnum, "values", null); } catch ( Exception e ) { logger.error( "Couldn't get CFEnum values", e ); } if ( values == null ) { return null; } for ( CFEnum cf : values ) { if ( !cf.create() ) { continue; } String defaultValidationClass = cf.getValidator(); List<ColumnDefinition> metadata = cf.getMetadata(); ColumnFamilyDefinition cf_def = HFactory.createColumnFamilyDefinition( keyspace, cf.getColumnFamily(), ComparatorType.getByClassName( cf.getComparator() ), metadata ); if ( defaultValidationClass != null ) { cf_def.setDefaultValidationClass( defaultValidationClass ); } cf_defs.add( cf_def ); } return cf_defs; }
@Override public void initialize() throws ContainerException { try { MethodUtils.invokeStaticMethod(busFactoryClass, "setThreadDefaultBus", new Object[] { bus }); MethodUtils.invokeMethod(jaxrsServerFactoryBean, "create", null); } catch (Exception e) { log.error("Failed to initialize jaxrs server.", e); } finally { try { MethodUtils.invokeStaticMethod(busFactoryClass, "setThreadDefaultBus", new Object[] { null }); } catch (Exception ignore) { } } }
getPropertyDescriptor(bean, name); if (descriptor == null) { throw new NoSuchMethodException("Unknown property '" + ((MappedPropertyDescriptor) descriptor). getMappedWriteMethod(); mappedWriteMethod = MethodUtils.getAccessibleMethod(bean.getClass(), mappedWriteMethod); if (mappedWriteMethod != null) { final Object[] params = new Object[2]; + " (class " + valueClassName +")"); invokeMethod(mappedWriteMethod, bean, params); } else { throw new NoSuchMethodException final Method readMethod = getReadMethod(bean.getClass(), descriptor); if (readMethod != null) { final Object invokeResult = invokeMethod(readMethod, bean, EMPTY_OBJECT_ARRAY);
MethodUtils.invokeExactMethod(parent, methodName, new Object[]{ child }, paramTypes); MethodUtils.invokeMethod(parent, methodName, new Object[]{ child }, paramTypes);