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


Java Method.equals方法代码示例

本文整理汇总了Java中java.lang.reflect.Method.equals方法的典型用法代码示例。如果您正苦于以下问题:Java Method.equals方法的具体用法?Java Method.equals怎么用?Java Method.equals使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在java.lang.reflect.Method的用法示例。


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

示例1: run

import java.lang.reflect.Method; //导入方法依赖的package包/类
public Boolean run() {
    Method[] methods = immutableClass.getMethods();
    for (int i = 0; i < methods.length; i++) {
        Method method = methods[i];
        String methodName = method.getName();
        if (methodName.startsWith("get") &&
                method.getParameterTypes().length == 0 &&
                method.getReturnType().isArray()) {
            try {
                Method submethod =
                    subclass.getMethod(methodName);
                if (!submethod.equals(method))
                    return false;
            } catch (NoSuchMethodException e) {
                return false;
            }
        }
    }
    return true;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:21,代码来源:MBeanInfo.java

示例2: invoke

import java.lang.reflect.Method; //导入方法依赖的package包/类
public Object invoke(
        final Object proxy, final Method method, final Object[] args) throws Throwable {
    if (method.equals(CLOSE_METHOD)) {
        close();
        return null;
    } else {
        try {
            return method.invoke(this.original, args);
        } catch (final InvocationTargetException ex) {
            final Throwable cause = ex.getCause();
            if (cause != null) {
                throw cause;
            } else {
                throw ex;
            }
        }
    }
}
 
开发者ID:mozilla-mobile,项目名称:FirefoxData-android,代码行数:19,代码来源:ResponseProxyHandler.java

示例3: hasObjectMethod

import java.lang.reflect.Method; //导入方法依赖的package包/类
/**
 * This Method checks if an instance of an object has an asked method.
 *
 * @param ontologyObject the ontology object
 * @param methode2check the methode2check
 * @return true, if the method is available
 */
private boolean hasObjectMethod(Object ontologyObject, Method methode2check) {
	
	if (ontologyObject==null) return false;
	
	Method[] meths = ontologyObject.getClass().getMethods();
	for (int i = 0; i < meths.length; i++) {
		Method meth = meths[i];
		if (meth.equals(methode2check)) {
			return true;
		}
	}
	return false;
}
 
开发者ID:EnFlexIT,项目名称:AgentWorkbench,代码行数:21,代码来源:DynFormBase.java

示例4: matchInheritance

import java.lang.reflect.Method; //导入方法依赖的package包/类
public static boolean matchInheritance(final Method subclassMethod, final Method superclassMethod) {
	if (Modifier.isStatic(superclassMethod.getModifiers()) || subclassMethod.equals(superclassMethod)) {
		return false;
	}

	if (matchSignature(subclassMethod, superclassMethod)) {
		final Package subclassPackage = subclassMethod.getDeclaringClass().getPackage();
		final Package superclassPackage = superclassMethod.getDeclaringClass().getPackage();
		final int superMethodModifiers = superclassMethod.getModifiers();

		return isAccessable(subclassPackage, superclassPackage, superMethodModifiers);
	} else {
		return false;
	}
}
 
开发者ID:daima,项目名称:solo-spring,代码行数:16,代码来源:Reflections.java

示例5: main

import java.lang.reflect.Method; //导入方法依赖的package包/类
public static void main(String[] args) throws Exception {
    System.setSecurityManager(new SecurityManager());
    Derived bean = new Derived();
    Class<?> type = bean.getClass();
    Method method1 = test("reflection", bean, type.getMethod("isAllowed"));
    Method method2 = test("bean introspection", bean, BeanUtils.getPropertyDescriptor(type, "allowed").getReadMethod());
    if (!method1.equals(method2)) {
        throw new Error("first method is not equal to the second one");
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:11,代码来源:Test7084904.java

示例6: compare

import java.lang.reflect.Method; //导入方法依赖的package包/类
private static boolean compare(Method m1, Method m2) {
    if ((m1 == null) && (m2 == null)) {
        return true;
    }
    if ((m1 == null) || (m2 == null)) {
        return false;
    }
    return m1.equals(m2);
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:10,代码来源:Test4634390.java

示例7: GenericTypeAwarePropertyDescriptor

import java.lang.reflect.Method; //导入方法依赖的package包/类
public GenericTypeAwarePropertyDescriptor(Class<?> beanClass, String propertyName,
		Method readMethod, Method writeMethod, Class<?> propertyEditorClass)
		throws IntrospectionException {

	super(propertyName, null, null);
	this.beanClass = beanClass;
	this.propertyEditorClass = propertyEditorClass;

	Method readMethodToUse = BridgeMethodResolver.findBridgedMethod(readMethod);
	Method writeMethodToUse = BridgeMethodResolver.findBridgedMethod(writeMethod);
	if (writeMethodToUse == null && readMethodToUse != null) {
		// Fallback: Original JavaBeans introspection might not have found matching setter
		// method due to lack of bridge method resolution, in case of the getter using a
		// covariant return type whereas the setter is defined for the concrete property type.
		Method candidate = ClassUtils.getMethodIfAvailable(
				this.beanClass, "set" + StringUtils.capitalize(getName()), (Class<?>[]) null);
		if (candidate != null && candidate.getParameterTypes().length == 1) {
			writeMethodToUse = candidate;
		}
	}
	this.readMethod = readMethodToUse;
	this.writeMethod = writeMethodToUse;

	if (this.writeMethod != null && this.readMethod == null) {
		// Write method not matched against read method: potentially ambiguous through
		// several overloaded variants, in which case an arbitrary winner has been chosen
		// by the JDK's JavaBeans Introspector...
		Set<Method> ambiguousCandidates = new HashSet<Method>();
		for (Method method : beanClass.getMethods()) {
			if (method.getName().equals(writeMethodToUse.getName()) &&
					!method.equals(writeMethodToUse) && !method.isBridge()) {
				ambiguousCandidates.add(method);
			}
		}
		if (!ambiguousCandidates.isEmpty()) {
			this.ambiguousWriteMethods = ambiguousCandidates;
		}
	}
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:40,代码来源:GenericTypeAwarePropertyDescriptor.java

示例8: compareMethods

import java.lang.reflect.Method; //导入方法依赖的package包/类
public static boolean compareMethods(Method a, Method b) {
	if ((a == null) != (b == null)) {
		return false;
	}
	if (a != null) {
		if (!a.equals(b)) {
			return false;
		}
	}
	return true;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:12,代码来源:ExtendedBeanInfo.java

示例9: findPropertyForMethod

import java.lang.reflect.Method; //导入方法依赖的package包/类
/**
 * Find a JavaBeans {@code PropertyDescriptor} for the given method,
 * with the method either being the read method or the write method for
 * that bean property.
 * @param method the method to find a corresponding PropertyDescriptor for
 * @return the corresponding PropertyDescriptor, or {@code null} if none
 * @throws BeansException if PropertyDescriptor lookup fails
 */
public static PropertyDescriptor findPropertyForMethod(Method method) throws BeansException {
	Assert.notNull(method, "Method must not be null");
	PropertyDescriptor[] pds = getPropertyDescriptors(method.getDeclaringClass());
	for (PropertyDescriptor pd : pds) {
		if (method.equals(pd.getReadMethod()) || method.equals(pd.getWriteMethod())) {
			return pd;
		}
	}
	return null;
}
 
开发者ID:lamsfoundation,项目名称:lams,代码行数:19,代码来源:BeanUtils.java

示例10: testMultipleGivenRegex

import java.lang.reflect.Method; //导入方法依赖的package包/类
@Test
public void testMultipleGivenRegex() throws NoSuchMethodException {
	MultipleGivenBean source = new MultipleGivenBean();
	ClassPathXmlApplicationContext context = getContext(source);
	process(context, source);

	MultipleGivenBean steps = context.getBean(MultipleGivenBean.class);
	Class<?> wrapped = AopUtils.getTargetClass(steps);
	Method method = wrapped.getMethod("doSomething");

	Map<String, StepImplementation> givenBeanIndex = context.getBeansOfType(StepImplementation.class);
	Collection<StepImplementation> givens = givenBeanIndex.values();

	Set<String> matches = Sets.newHashSetWithExpectedSize(2);
	for (StepImplementation given : givens) {
		Method givenMethod = given.getMethod();
		if (givenMethod.equals(method)) {
			Pattern pattern = given.getPattern();
			String regex = pattern.pattern();
			matches.add(regex);
		}
	}

	int count = matches.size();
	assertEquals(count, 2, "wrong number of GivenStep objects registered for MultipleGivenBean.getMartinis()");

	Set<String> expected = Sets.newHashSet(
		"this is regular expression one", "this is regular expression two");
	assertEquals(matches, expected, "Steps contain wrong regex Pattern objects");
}
 
开发者ID:qas-guru,项目名称:martini-core,代码行数:31,代码来源:StepsAnnotationProcessorTest.java

示例11: invoke

import java.lang.reflect.Method; //导入方法依赖的package包/类
@SuppressWarnings({"unchecked"})
public Object invoke(Object proxy, Method method, Object[] args) {
    if (method.equals(this.completeMethod)) {
        int result = complete((String)args[0], ((Integer) args[1]).intValue(),
                (List<String>) args[2]);
        return Integer.valueOf(result);
    }
    throw new NoSuchMethodError(method.toString());
}
 
开发者ID:middle2tw,项目名称:whackpad,代码行数:10,代码来源:ShellLine.java

示例12: findMethod

import java.lang.reflect.Method; //导入方法依赖的package包/类
public static Method findMethod(Class<? extends Snippets> declaringClass, String methodName, Method except) {
    for (Method m : declaringClass.getDeclaredMethods()) {
        if (m.getName().equals(methodName) && !m.equals(except)) {
            return m;
        }
    }
    return null;
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:9,代码来源:SnippetTemplate.java

示例13: addIfNotPresent

import java.lang.reflect.Method; //导入方法依赖的package包/类
void addIfNotPresent(Method newMethod) {
    for (int i = 0; i < length; i++) {
        Method m = methods[i];
        if (m == newMethod || (m != null && m.equals(newMethod))) {
            return;
        }
    }
    add(newMethod);
}
 
开发者ID:SunburstApps,项目名称:OpenJSharp,代码行数:10,代码来源:Class.java

示例14: verifyOneInvocation

import java.lang.reflect.Method; //导入方法依赖的package包/类
private static void verifyOneInvocation(Method method, Object[] args,
                                        List invocationQueue)
{
    TestProvider.Invocation inv =
        (TestProvider.Invocation) invocationQueue.remove(0);

    if (!method.equals(inv.method)) {
        throw new RuntimeException(
            "unexpected provider method invoked: expected " + method +
            ", detected " + inv.method);
    }

    List expectedArgs = Arrays.asList(args);
    List detectedArgs = Arrays.asList(inv.args);
    if (!expectedArgs.equals(detectedArgs)) {
        throw new RuntimeException("TEST FAILED: " +
            "unexpected provider method invocation arguments: " +
            "expected " + expectedArgs + ", detected " + detectedArgs);
    }

    if (!invocationQueue.isEmpty()) {
        inv = (TestProvider.Invocation)
            invocationQueue.remove(0);
        throw new RuntimeException("TEST FAILED: " +
            "unexpected provider invocation: " + inv.method + " " +
            Arrays.asList(inv.args));
    }
}
 
开发者ID:AdoptOpenJDK,项目名称:openjdk-jdk10,代码行数:29,代码来源:TestProvider.java

示例15: newResultSet

import java.lang.reflect.Method; //导入方法依赖的package包/类
public static ResultSet newResultSet(final Object... defs) throws NoSuchMethodException, SecurityException {
	if (defs.length % 2 != 0) {
		throw new IllegalArgumentException();
	}

	Method wasNull = ResultSet.class.getMethod("wasNull");

	Map<Method, Object> values = new HashMap<>();
	for (int i = 0; i < defs.length; i += 2) {
		Method target = defs[i].equals("wasNull") ? wasNull : ResultSet.class.getMethod(defs[i].toString(), int.class);
		values.put(target, defs[i + 1]);
	}

	AtomicBoolean flg = new AtomicBoolean(false);

	InvocationHandler handler = new InvocationHandler() {

		@Override
		public Object invoke(final Object proxy, final Method method, final Object[] args) throws Throwable {
			if (values.containsKey(method)) {
				Object o = values.get(method);
				flg.set(o == null);
				return o;
			}
			if (wasNull.equals(method)) {
				return flg.get();
			}

			return null;
		}
	};
	return (ResultSet) Proxy.newProxyInstance(Helper.class.getClassLoader(), new Class[] { ResultSet.class }, handler);
}
 
开发者ID:future-architect,项目名称:uroborosql,代码行数:34,代码来源:Helper.java


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