List of usage examples for org.apache.commons.lang3.reflect MethodUtils invokeExactStaticMethod
public static Object invokeExactStaticMethod(final Class<?> cls, final String methodName, Object... args) throws NoSuchMethodException, IllegalAccessException, InvocationTargetException
Invokes a static method whose parameter types match exactly the object types.
This uses reflection to invoke the method obtained from a call to #getAccessibleMethod(Class,String,Class[]) .
From source file:br.com.binarti.simplesearchexpr.converter.EnumSearchDataConverter.java
@Override protected Object asSingleObject(SimpleSearchExpressionField field, String value, Map<String, Object> params, Class<?> targetType) { try {/*from w w w . ja v a 2 s . c o m*/ return MethodUtils.invokeExactStaticMethod(targetType, "valueOf", value.trim()); } catch (Exception e) { throw new SimpleSearchDataConverterException("Error convert value to enum " + targetType, e); } }
From source file:com.feilong.commons.core.io.IOWriteUtilTest.java
/** * Unescape html2./*from ww w . j a va2 s. co m*/ * * @throws NoSuchMethodException * the no such method exception * @throws IllegalAccessException * the illegal access exception * @throws InvocationTargetException * the invocation target exception */ @Test public void unescapeHtml2() throws NoSuchMethodException, IllegalAccessException, InvocationTargetException { String a = "572 ??? *"; String result = (String) MethodUtils.invokeExactStaticMethod(IOWriteUtil.class, "getFormatFilePath", a); log.info(result); }
From source file:org.apache.servicecomb.it.ITUtils.java
@SuppressWarnings("unchecked") public static <T> T invokeExactStaticMethod(final Class<?> cls, final String methodName, Object... args) { try {//from ww w . j a va2 s . com return (T) MethodUtils.invokeExactStaticMethod(cls, methodName, args); } catch (Throwable e) { throw new IllegalStateException( String.format("Failed to invoke, class=%s, method=%s", cls.getName(), methodName), e); } }