List of usage examples for com.badlogic.gdx.utils.reflect Method getDeclaringClass
public Class getDeclaringClass()
From source file:com.github.ykrasik.jaci.util.reflection.ReflectionUtils.java
License:Apache License
/** * Assert that the given method takes no parameters. * * @param method Method to assert./*from w w w .j av a 2 s. c o m*/ * @throws IllegalArgumentException If the method takes any parameters. */ public static void assertNoParameters(Method method) { final Class<?>[] parameterTypes = method.getParameterTypes(); if (parameterTypes.length > 0) { final String message = ("Class=\'" + method.getDeclaringClass() + "\', method=\'" + method.getName() + "\': Must take no parameters!"); throw new IllegalArgumentException(message); } }
From source file:com.github.ykrasik.jaci.util.reflection.ReflectionUtils.java
License:Apache License
/** * Assert that the given method returns the expected return type. * * @param method Method to assert./*from w w w. java 2 s . com*/ * @param expectedReturnType Expected return type of the method. * @throws IllegalArgumentException If the method's return type doesn't match the expected type. */ public static void assertReturnValue(Method method, Class<?> expectedReturnType) { final Class<?> returnType = method.getReturnType(); if (returnType != expectedReturnType) { final String message = ("Class=\'" + method.getDeclaringClass() + "\', method=\'" + method.getName() + "\': Must return a value of type \'" + expectedReturnType + "\'!"); throw new IllegalArgumentException(message); } }
From source file:com.github.ykrasik.jaci.reflection.method.ReflectionMethodProcessor.java
License:Apache License
/** * Process the method and create a {@link CommandDef} out of it, if it is accepted by one of the {@link MethodCommandFactory}s. * * @param instance Instance of a class to which this method belongs. * @param method Method to be processed. * @return A {@code present} {@link CommandDef} if any of the factories managed to process the method. *//*from ww w . jav a 2 s.co m*/ public Opt<CommandDef> process(Object instance, Method method) { try { return doCreateCommand(instance, method); } catch (Exception e) { final String message = ("Error creating command: class=" + method.getDeclaringClass() + ", method=" + method.getName()); throw new IllegalArgumentException(message, e); } }