当前位置: 首页>>代码示例>>Java>>正文


Java Method类代码示例

本文整理汇总了Java中com.badlogic.gdx.utils.reflect.Method的典型用法代码示例。如果您正苦于以下问题:Java Method类的具体用法?Java Method怎么用?Java Method使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Method类属于com.badlogic.gdx.utils.reflect包,在下文中一共展示了Method类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getNestedGenericTypeAnnotation

import com.badlogic.gdx.utils.reflect.Method; //导入依赖的package包/类
/**
 * Gets {@code NestedGenericType} annotation from object.
 * <p>
 * Looks at all object methods and returns first encountered annotation.
 *
 * @param object Object to deal with, not null
 * @return Annotation, may be null
 */
public static NestedGenericType getNestedGenericTypeAnnotation(Object object)
{
    NestedGenericType result = null;
    Method[] methods = ClassReflection.getMethods(object.getClass());
    // TODO - use type annotation, not method?
    for (Method m : methods) {
        Annotation[] annotations = m.getDeclaredAnnotations();
        Annotation a = m.getDeclaredAnnotation(NestedGenericType.class);
        if (a != null) {
            result = a.getAnnotation(NestedGenericType.class);
            break;
        }
    }
    return result;
}
 
开发者ID:mk-5,项目名称:gdx-fireapp,代码行数:24,代码来源:AnnotationProcessor.java

示例2: invoke

import com.badlogic.gdx.utils.reflect.Method; //导入依赖的package包/类
public void invoke(JGameObject clickTarget) {
	for (Component component : clickTarget.getAllComponents()) {
		if (component.getClass().getName().equals(invokeComponent)) {
			Object[] parameters = args.toArray(new Object[args.size()]);
			Class[] parametersType = new Class[args.size()];
			for (int x = 0; x < parameters.length; x++) {
				parametersType[x] = parameters[x].getClass();
			}

			try {
				Method method = ClassReflection.getDeclaredMethod(component.getClass(), invokeMethod,
						parametersType);
				method.invoke(component, parameters);
			} catch (ReflectionException e) {
				e.printStackTrace();
			}
		}
	}
}
 
开发者ID:Radomiej,项目名称:JavityEngine,代码行数:20,代码来源:RemoteInvoker.java

示例3: printCommands

import com.badlogic.gdx.utils.reflect.Method; //导入依赖的package包/类
@Override
public void printCommands () {
	for (Method m : getAllMethods()) {
		if (m.isPublic() && ConsoleUtils.canDisplayCommand(this, m)) {
			String s = "";
			s += m.getName();
			s += " : ";

			Class<?>[] params = m.getParameterTypes();
			for (int i = 0; i < params.length; i++) {
				s += params[i].getSimpleName();
				if (i < params.length - 1) {
					s += ", ";
				}
			}

			log(s);
		}
	}
}
 
开发者ID:StrongJoshua,项目名称:libgdx-inGameConsole,代码行数:21,代码来源:AbstractConsole.java

示例4: processMethods

import com.badlogic.gdx.utils.reflect.Method; //导入依赖的package包/类
/** Does the actual processing of found methods.
 *
 * @param component owner of the methods.
 * @param methods present in one of superclasses of the component.
 * @param context used to resolve dependencies.
 * @param contextDestroyer used to register destruction callbacks. */
@SuppressWarnings({ "rawtypes", "unchecked" }) // Using correct types, but wildcards fail to see that.
private void processMethods(final Object component, final Method[] methods, final Context context,
        final ContextDestroyer contextDestroyer) {
    for (final Method method : methods) {
        final com.badlogic.gdx.utils.reflect.Annotation[] annotations = getAnnotations(method);
        if (annotations == null || annotations.length == 0) {
            continue;
        }
        for (final com.badlogic.gdx.utils.reflect.Annotation annotation : annotations) {
            if (methodProcessors.containsKey(annotation.getAnnotationType())) {
                for (final AnnotationProcessor processor : methodProcessors.get(annotation.getAnnotationType())) {
                    processor.processMethod(method, annotation.getAnnotation(annotation.getAnnotationType()),
                            component, context, this, contextDestroyer);
                }
            }
        }
    }
}
 
开发者ID:gdx-libs,项目名称:gdx-autumn,代码行数:25,代码来源:ContextInitializer.java

示例5: extractActionFromContainer

import com.badlogic.gdx.utils.reflect.Method; //导入依赖的package包/类
/** @param actionContainer action container that might contain the referenced method.
 * @param actionId name of the requested action.
 * @param forActor will be used as potential action argument.
 * @return actor consumer constructed with container's method (or field) or null if action not found. */
protected ActorConsumer<?, ?> extractActionFromContainer(final ActionContainerWrapper actionContainer,
        final String actionId, final Object forActor) {
    Method method = actionContainer.getNamedMethod(actionId);
    if (method == null && Lml.EXTRACT_UNANNOTATED_METHODS) {
        method = findUnnamedMethod(actionContainer, actionId, forActor);
    }
    if (method != null) {
        return new MethodActorConsumer(method, actionContainer.getActionContainer());
    } else if (Lml.EXTRACT_FIELDS_AS_METHODS) {
        Field field = actionContainer.getNamedField(actionId);
        if (field == null && Lml.EXTRACT_UNANNOTATED_METHODS) {
            field = actionContainer.getField(actionId);
        }
        if (field != null) {
            return new FieldActorConsumer(field, actionContainer.getActionContainer());
        }
    }
    return null;
}
 
开发者ID:czyzby,项目名称:gdx-lml,代码行数:24,代码来源:AbstractLmlParser.java

示例6: getModifiers

import com.badlogic.gdx.utils.reflect.Method; //导入依赖的package包/类
/** @param method will be inspected.
 * @return modifiers representing the method state. */
public static int getModifiers(final Method method) {
    int modifiers = 0;
    if (method.isAbstract()) {
        modifiers |= ABSTRACT;
    }
    if (method.isFinal()) {
        modifiers |= FINAL;
    }
    if (method.isNative()) {
        modifiers |= NATIVE;
    }
    if (method.isPrivate()) {
        modifiers |= PRIVATE;
    }
    if (method.isProtected()) {
        modifiers |= PROTECTED;
    }
    if (method.isPublic()) {
        modifiers |= PUBLIC;
    }
    if (method.isStatic()) {
        modifiers |= STATIC;
    }
    return modifiers;
}
 
开发者ID:czyzby,项目名称:gdx-lml,代码行数:28,代码来源:Modifier.java

示例7: searchMethod

import com.badlogic.gdx.utils.reflect.Method; //导入依赖的package包/类
/**
 * Searches for the given method with the given class. If none is found, it looks for fitting methods
 * with the classe's interfaces and superclasses recursively.
 * @param methodName
 * @param clazz
 * @return
 */
private Method searchMethod(String methodName, Class<?> clazz, Class<?> source) {
    Method m = null;
    try {
        m = ClassReflection.getMethod(source, methodName, clazz);
    } catch (ReflectionException e) {
        try {
            if (methodName.contains("setCoordinates")) {
                // Special case
                m = ClassReflection.getMethod(source, methodName, IBodyCoordinates.class);
            }
        } catch (ReflectionException e1) {
            Logger.error(e1);
        }
    }
    return m;
}
 
开发者ID:langurmonkey,项目名称:gaiasky,代码行数:24,代码来源:JsonLoader.java

示例8: doneLoading

import com.badlogic.gdx.utils.reflect.Method; //导入依赖的package包/类
@Override
public void doneLoading(AssetManager manager) {
    super.doneLoading(manager);

    // Set static coordinates to position
    coordinates.getEquatorialCartesianCoordinates(null, pos);

    // Initialize transform
    if (transformName != null) {
        Class<Coordinates> c = Coordinates.class;
        try {
            Method m = ClassReflection.getMethod(c, transformName);
            Matrix4d trf = (Matrix4d) m.invoke(null);
            coordinateSystem = new Matrix4();
            trf.putIn(coordinateSystem);
        } catch (ReflectionException e) {
            Logger.error(this.getClass().getName(), "Error getting/invoking method Coordinates." + transformName + "()");
        }
    } else {
        // Equatorial, nothing
    }
    // Model
    mc.doneLoading(manager, localTransform, null);
}
 
开发者ID:langurmonkey,项目名称:gaiasky,代码行数:25,代码来源:MilkyWay.java

示例9: setTransformName

import com.badlogic.gdx.utils.reflect.Method; //导入依赖的package包/类
public void setTransformName(String transformName) {
    this.transformName = transformName;
    if (transformName != null) {
        Class<Coordinates> c = Coordinates.class;
        try {
            Method m = ClassReflection.getMethod(c, transformName);
            Matrix4d transform = (Matrix4d) m.invoke(null);

            trf = new Matrix4d(transform);

        } catch (ReflectionException e) {
            Logger.error(this.getClass().getName(), "Error getting/invoking method Coordinates." + transformName + "()");
        }
    } else {
        // Equatorial, nothing
    }
}
 
开发者ID:langurmonkey,项目名称:gaiasky,代码行数:18,代码来源:StaticCoordinates.java

示例10: setup

import com.badlogic.gdx.utils.reflect.Method; //导入依赖的package包/类
@SuppressWarnings("static-access")
@Before
public void setup() {

	Gdx.app = Mockito.mock(HeadlessApplication.class);

	when(Gdx.app.getPreferences(anyString())).thenReturn(new PreferencesStub());

	config = new TwitterConfig();

	PowerMockito.mockStatic(ClassReflection.class);
	classReflectionMock = Mockito.mock(ClassReflection.class);

	PowerMockito.mockStatic(Field.class);
	fieldMock = Mockito.mock(Field.class);

	PowerMockito.mockStatic(Constructor.class);
	constructorMock = Mockito.mock(Constructor.class);

	PowerMockito.mockStatic(Method.class);
	methodMock = Mockito.mock(Method.class);

	activityStub = new ActivityStub();
	twitterAPIStub = new TwitterAPIStub(config);
	gdxStub = new GdxStub();
	supportFragmentStub = new SupportFragmentStub();
	fragmentStub = new FragmentStub();
	gdxLifecycleListenerStub = new GdxLifecycleListenerStub();

	try {
		Mockito.when(classReflectionMock.forName("com.badlogic.gdx.Gdx")).thenReturn(gdxStub.getClass());
		Mockito.when(classReflectionMock.getField(gdxStub.getClass(), "app")).thenReturn(fieldMock);
		Mockito.when(fieldMock.get(null)).thenReturn(Gdx.app);

	} catch (ReflectionException e) {
	}
}
 
开发者ID:TomGrill,项目名称:gdx-twitter,代码行数:38,代码来源:TwitterSystemUnitTests.java

示例11: androidPremocking

import com.badlogic.gdx.utils.reflect.Method; //导入依赖的package包/类
private void androidPremocking() {

        Application mockApplication = mock(Application.class);
        when(mockApplication.getType()).thenReturn(Application.ApplicationType.Android);
        Gdx.app = mockApplication;

        try {
            mockConstructor = PowerMockito.mock(Constructor.class);
            mockFacebook = mock(AndroidGDXFacebook.class);
            mockField = mock(Field.class);
            mockObject = mock(Object.class);
            mockMethod = mock(Method.class);

            when(ClassReflection.forName(GDXFacebookVars.CLASSNAME_ANDROID)).thenReturn(AndroidGDXFacebook.class);
            when(ClassReflection.getConstructor(AndroidGDXFacebook.class, GDXFacebookConfig.class)).thenReturn(mockConstructor);
            when(mockConstructor.newInstance(anyObject())).thenReturn(mockFacebook);


            when(ClassReflection.forName("com.badlogic.gdx.Gdx")).thenReturn(Gdx.class);
            when(ClassReflection.getField(Gdx.class, "app")).thenReturn(mockField);
            when(mockField.get(null)).thenReturn(mockObject);


            when(ClassReflection.forName("com.badlogic.gdx.backends.android.AndroidEventListener")).thenReturn(AndroidEventListener.class);
            when(ClassReflection.forName("android.app.Activity")).thenReturn(Activity.class);

        } catch (ReflectionException e) {
            e.printStackTrace();
        }
    }
 
开发者ID:TomGrill,项目名称:gdx-facebook,代码行数:31,代码来源:GDXFacebookLoaderUnitTests.java

示例12: getAnnotation

import com.badlogic.gdx.utils.reflect.Method; //导入依赖的package包/类
/** Utility method that allows to extract actual annotation from method, bypassing LibGDX annotation wrapper.
 * Returns null if annotation is not present.
 *
 * @param method method that might be annotated.
 * @param annotationType class of the annotation.
 * @return an instance of the annotation if the method is annotated or null if not. */
public static <Type extends Annotation> Type getAnnotation(final Method method, final Class<Type> annotationType) {
    if (isAnnotationPresent(method, annotationType)) {
        return method.getDeclaredAnnotation(annotationType).getAnnotation(annotationType);
    }
    return null;
}
 
开发者ID:gdx-libs,项目名称:gdx-kiwi,代码行数:13,代码来源:Reflection.java

示例13: invokeMethod

import com.badlogic.gdx.utils.reflect.Method; //导入依赖的package包/类
/** @param method will be set accessible and invoked.
 * @param methodOwner will have the method invoked. Can be null (static methods).
 * @param resultType result will be casted to this type.
 * @param arguments method arguments.
 * @return result of method invocation.
 * @throws ReflectionException when unable to invoke the method. */
@SuppressWarnings("unchecked")
public static <ResultType> ResultType invokeMethod(final Method method, final Object methodOwner,
        final Class<ResultType> resultType, final Object... arguments) throws ReflectionException {
    method.setAccessible(true);
    return (ResultType) method.invoke(methodOwner, arguments);
}
 
开发者ID:gdx-libs,项目名称:gdx-kiwi,代码行数:13,代码来源:Reflection.java

示例14: getAllMethods

import com.badlogic.gdx.utils.reflect.Method; //导入依赖的package包/类
private ArrayList<Method> getAllMethods () {
	ArrayList<Method> methods = new ArrayList<Method>();
	Class c = exec.getClass();
	while (c != Object.class) {
		Collections.addAll(methods, ClassReflection.getDeclaredMethods(c));
		c = c.getSuperclass();
	}
	return methods;
}
 
开发者ID:StrongJoshua,项目名称:libgdx-inGameConsole,代码行数:10,代码来源:AbstractConsole.java

示例15: set

import com.badlogic.gdx.utils.reflect.Method; //导入依赖的package包/类
public void set (CommandExecutor ce, String s) {
	reset();
	setString = s.toLowerCase();
	Array<Method> methods = getAllMethods(ce);
	for (Method m : methods) {
		String name = m.getName();
		if (name.toLowerCase().startsWith(setString) && ConsoleUtils.canDisplayCommand(ce.console, m)) {
			possibleCommands.add(name);
		}
	}
	iterator = new ObjectSetIterator<>(possibleCommands);
}
 
开发者ID:StrongJoshua,项目名称:libgdx-inGameConsole,代码行数:13,代码来源:CommandCompleter.java


注:本文中的com.badlogic.gdx.utils.reflect.Method类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。