Returns a Method object corresponding to a setter that sets an instance of componentClass from target.

@param target         class that the setter should exist on
@param componentClass component to set
@return Method object, or null of one does not exist
495623
public static Method setterMethod(Class<?> target, Class<?> componentClass) {
      try {
         return target.getMethod(setterName(componentClass), componentClass);
      }
      catch (NoSuchMethodException e) {
         //if (log.isTraceEnabled()) log.trace("Unable to find method " + setterName(componentClass) + " in class " + target);
         return null;
      }
      catch (NullPointerException e) {
         return null;
      }
   }
19768
public static Method getMethod(Object target, String methodName, Class... parameterTypes) {
        try {
            return target.getClass().getMethod(methodName, parameterTypes);
        } catch (NoSuchMethodException e) {
            throw handleException(methodName, e);
        }
    }
1028798
public static function getComponentClassInstance(string $componentId)
    {
        if (!isset(self::$componentInstances[$componentId])) {
            $component = self::getComponentWithIdentifier($componentId);
            if (is_null($component)) {
                return null;
            }
            
            self::$componentInstances[$componentId] = $component->getInstance();
        }
        
        return @self::$componentInstances[$componentId];
    }
776025
public T get(String componentId) {
		for (T component : components) {
			if (component.getId().equals(componentId)) {
				return component;
			}
		}
		return null;
	}
634125
@SuppressWarnings("unchecked")
  public <T extends R> Converter<S, T> getConverter(Class<T> targetType) {
    return (Converter<S, T>) converters.get(targetType);
  }
1328739
public static Method findSetter(Class<?> onClass, Class<?> targetClass) {
        Method[] methods = onClass.getMethods();
        for (Method method : methods) {
            Class<?>[] ptypes = method.getParameterTypes();
            if (method.getName().startsWith("set") && ptypes.length == 1 && ptypes[0] == targetClass) { //$NON-NLS-1$
                return method;
            }
        }
        return null;
    }
113102
public Component getComponent(int componentIndex)
    {
        if (componentList != null)
            if (componentIndex < componentList.length)
                return componentList[componentIndex];
        return null;
    }
898009
public static void callSetter(Object target, PropertyDescriptor prop, Object value) {

        Method setter = prop.getWriteMethod();

        if (setter == null) {
            return;
        }

        try {

            setter.invoke(target, new Object[]{value});
        } catch (IllegalArgumentException e) {
            throw new RuntimeException(
                    "Cannot set " + prop.getName() + ": " + e.getMessage(), e);

        } catch (IllegalAccessException e) {
            throw new RuntimeException(
                    "Cannot set " + prop.getName() + ": " + e.getMessage(), e);

        } catch (InvocationTargetException e) {
            throw new RuntimeException(
                    "Cannot set " + prop.getName() + ": " + e.getMessage(), e);
        }
    }
696565
public static Optional<Method> extractSetter(final Class<?> targetClass, final String propertyName, final Class<?> propertyType) {
        
        final String methodName = "set" + Utils.capitalize(propertyName);
        
        Method method;
        try {
            method = targetClass.getMethod(methodName, propertyType);
        } catch (NoSuchMethodException | SecurityException e) {
            return Optional.empty();
        }
        
        method.setAccessible(true);
        
        return Optional.of(method);
    }
239065
@Deprecated
    public static <T> BiRecordGetter<T, RuntimeException> createBiRecordGetterByTargetClass(final Class<? extends T> targetClass) {
        if (Object[].class.isAssignableFrom(targetClass)) {
            return new BiRecordGetter<T, RuntimeException>() {
                @Override
                public T apply(ResultSet rs, List<String> columnLabelList) throws SQLException {
                    final int columnCount = columnLabelList.size();
                    final Object[] a = Array.newInstance(targetClass.getComponentType(), columnCount);

                    for (int i = 0; i < columnCount; i++) {
                        a[i] = JdbcUtil.getColumnValue(rs, i + 1);
                    }

                    return (T) a;
                }
            };
        } else if (List.class.isAssignableFrom(targetClass)) {
            return new BiRecordGetter<T, RuntimeException>() {

                private final boolean isListOrArrayList = targetClass.equals(List.class) || targetClass.equals(ArrayList.class);

                @Override
                public T apply(ResultSet rs, List<String> columnLabelList) throws SQLException {
                    final int columnCount = columnLabelList.size();
                    final List<Object> c = isListOrArrayList ? new ArrayList<Object>(columnCount) : (List<Object>) N.newInstance(targetClass);

                    for (int i = 0; i < columnCount; i++) {
                        c.add(JdbcUtil.getColumnValue(rs, i + 1));
                    }

                    return (T) c;
                }
            };
        } else if (Map.class.isAssignableFrom(targetClass)) {
            return new BiRecordGetter<T, RuntimeException>() {
                private final boolean isMapOrHashMap = targetClass.equals(Map.class) || targetClass.equals(HashMap.class);
                private final boolean isLinkedHashMap = targetClass.equals(LinkedHashMap.class);

                @Override
                public T apply(ResultSet rs, List<String> columnLabelList) throws SQLException {
                    final int columnCount = columnLabelList.size();
                    final Map<String, Object> m = isMapOrHashMap ? new HashMap<String, Object>(columnCount)
                            : (isLinkedHashMap ? new LinkedHashMap<String, Object>(columnCount) : (Map<String, Object>) N.newInstance(targetClass));

                    for (int i = 0; i < columnCount; i++) {
                        m.put(columnLabelList.get(i), JdbcUtil.getColumnValue(rs, i + 1));
                    }

                    return (T) m;
                }
            };
        } else if (N.isEntity(targetClass)) {
            return new BiRecordGetter<T, RuntimeException>() {
                private final boolean isDirtyMarker = N.isDirtyMarker(targetClass);
                private volatile String[] columnLabels = null;
                private volatile Method[] propSetters;
                private volatile Type<?>[] columnTypes = null;

                @Override
                public T apply(ResultSet rs, List<String> columnLabelList) throws SQLException {
                    final int columnCount = columnLabelList.size();

                    String[] columnLabels = this.columnLabels;
                    Method[] propSetters = this.propSetters;
                    Type<?>[] columnTypes = this.columnTypes;

                    if (columnLabels == null) {
                        columnLabels = columnLabelList.toArray(new String[columnLabelList.size()]);
                        this.columnLabels = columnLabels;
                    }

                    if (columnTypes == null || propSetters == null) {
                        final EntityInfo entityInfo = ParserUtil.getEntityInfo(targetClass);
                        final Map<String, String> column2FieldNameMap = getField2ColumnNameMap(targetClass);

                        propSetters = new Method[columnCount];
                        columnTypes = new Type[columnCount];

                        for (int i = 0; i < columnCount; i++) {
                            propSetters[i] = ClassUtil.getPropSetMethod(targetClass, columnLabels[i]);

                            if (propSetters[i] == null) {
                                String fieldName = column2FieldNameMap.get(columnLabels[i]);

                                if (N.isNullOrEmpty(fieldName)) {
                                    fieldName = column2FieldNameMap.get(columnLabels[i].toLowerCase());
                                }

                                if (N.notNullOrEmpty(fieldName)) {
                                    propSetters[i] = ClassUtil.getPropSetMethod(targetClass, fieldName);
                                }
                            }

                            if (propSetters[i] == null) {
                                columnLabels[i] = null;
                                throw new IllegalArgumentException(
                                        "No property in class: " + ClassUtil.getCanonicalClassName(targetClass) + " mapping to column: " + columnLabels[i]);
                            } else {
                                columnTypes[i] = entityInfo.getPropInfo(columnLabels[i]).type;
                            }
                        }

                        this.propSetters = propSetters;
                        this.columnTypes = columnTypes;
                    }

                    final Object entity = N.newInstance(targetClass);

                    for (int i = 0; i < columnCount; i++) {
                        if (columnLabels[i] == null) {
                            continue;
                        }

                        ClassUtil.setPropValue(entity, propSetters[i], columnTypes[i].get(rs, i + 1));
                    }

                    if (isDirtyMarker) {
                        ((DirtyMarker) entity).markDirty(false);
                    }

                    return (T) entity;
                }
            };
        } else {
            throw new IllegalArgumentException(targetClass.getCanonicalName() + " is not an Array/List/Map/Entity class");
        }
    }
232561
@Deprecated
    public <T> Class<T> getPropertyAsClass(String key, Class<T> targetType) {
        Optional<String> property = propertyResolver.getProperty(NameUtils.hyphenate(key), String.class);
        if (property.isPresent()) {
            Optional<Class> aClass = ClassUtils.forName(property.get(), Thread.currentThread().getContextClassLoader());
            if (aClass.isPresent()) {
                //noinspection unchecked
                return aClass.get();
            }
        }
        return null;
    }
679634
public BeanMappingObject getBeanMappingObject(Class src, Class target, boolean autoRegister) {
        BeanMappingObject object = autoRepository.getBeanMappingObject(src, target);
        if (object == null && autoRegister) {
            autoRepository.register(src, target);
            object = getFromRepository(src, target, this.autoRepository);
        }
        return object;
    }
158231
@SuppressWarnings("unchecked")
   public <T> T getComponent(Class<T> type) {
      String className = type.getName();
      return (T) getComponent(type, className);
   }
17578
public <T> T [] toArray(Class<T> componentClass) {
    final int size = size();
    final T[] array = (T[]) java.lang.reflect.Array.newInstance(componentClass, size);
    int i = 0;
    for (KTypeCursor<KType> c : this) {
      array[i++] = (T) c.value;
    }
    return array;
  }
667357
@SuppressWarnings("unchecked")
    private static <T> T createCustomComponent(Class<T> componentType, Class<?> componentClass,
            Map<String, String> configProperties) throws Exception {
        if (componentClass == null) {
            throw new IllegalArgumentException("Invalid component spec (class not found)."); //$NON-NLS-1$
        }
        try {
            Constructor<?> constructor = componentClass.getConstructor(Map.class);
            return (T) constructor.newInstance(configProperties);
        } catch (Exception e) {
        }
        return (T) componentClass.getConstructor().newInstance();
    }
1187041
public static boolean isTarget( Instance instance ) {
		return instance.getComponent() != null
				&& ComponentHelpers.isTarget( instance.getComponent());
	}
1339536
public List<ICalComponent> setComponent(ICalComponent component) {
		return components.replace(component.getClass(), component);
	}