本文整理了Java中org.jboss.errai.codegen.meta.MetaClass.getMethod()
方法的一些代码示例,展示了MetaClass.getMethod()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。MetaClass.getMethod()
方法的具体详情如下:
包路径:org.jboss.errai.codegen.meta.MetaClass
类名称:MetaClass
方法名:getMethod
[英]Returns all declared and inherited public, protected, and package-private methods available on this class.
[中]返回该类上可用的所有已声明和继承的public、protected和package private方法。
代码示例来源:origin: errai/errai
public static boolean isMethodInInterface(final MetaClass iface, final MetaMethod member) {
if (iface.getMethod(member.getName(), Arrays.stream(member.getParameters()).map(p -> p.getType()).toArray(MetaClass[]::new)) != null)
return true;
return false;
}
代码示例来源:origin: errai/errai
@Override
public MetaClassMember getBindingMember() {
if (writingMember != null) {
return writingMember;
}
MetaMethod meth = toMap.getMethod(getterMethod, targetType);
final Method method = meth.asMethod();
if (method != null) {
method.setAccessible(true);
}
writingMember = meth;
if (writingMember == null) {
throw new RuntimeException("no such setter method: " + toMap.getFullyQualifiedName() + "." + getterMethod);
}
return writingMember;
}
代码示例来源:origin: errai/errai
@Override
public MetaClassMember getReadingMember() {
if (readingMember != null) {
return readingMember;
}
MetaMethod meth = toMap.getMethod(getterMethod, new MetaClass[0]);
final Method method = meth.asMethod();
if (method != null) {
method.setAccessible(true);
}
readingMember = meth;
if (readingMember == null) {
throw new RuntimeException("no such getter method: " + toMap.getFullyQualifiedName() + "." + getterMethod);
}
return readingMember;
}
代码示例来源:origin: errai/errai
@Override
public MetaClassMember getReadingMember() {
if (readingMember != null) {
return readingMember;
}
final MetaMethod meth = toMap.getMethod(getterMethod, new MetaClass[0]);
final Method method = meth.asMethod();
if (method != null) {
method.setAccessible(true);
}
readingMember = meth;
if (readingMember == null) {
throw new RuntimeException("no such getter method: " + toMap.getFullyQualifiedName() + "." + getterMethod);
}
return readingMember;
}
代码示例来源:origin: errai/errai
private MetaClass getValueType(final MetaClass type) {
if (type.isAssignableTo(TakesValue.class)) {
return type.getMethod("getValue", new Class[0]).getReturnType();
}
else {
return null;
}
}
代码示例来源:origin: errai/errai
@Override
public MetaClassMember getBindingMember() {
if (bindingMember != null) {
return bindingMember;
}
MetaMethod meth = toMap.getMethod(setterMethod, targetType);
final Method method = meth.asMethod();
if (method != null) {
method.setAccessible(true);
}
bindingMember = meth;
if (bindingMember == null) {
throw new RuntimeException("no such setter method: " + toMap.getFullyQualifiedName() + "." + setterMethod);
}
return bindingMember;
}
代码示例来源:origin: org.jboss.errai/errai-marshalling
@Override
public MetaClassMember getReadingMember() {
if (readingMember != null) {
return readingMember;
}
final MetaMethod meth = toMap.getMethod(getterMethod, new MetaClass[0]);
final Method method = meth.asMethod();
if (method != null) {
method.setAccessible(true);
}
readingMember = meth;
if (readingMember == null) {
throw new RuntimeException("no such getter method: " + toMap.getFullyQualifiedName() + "." + getterMethod);
}
return readingMember;
}
代码示例来源:origin: org.jboss.errai/errai-codegen
public static boolean isMethodInInterface(final MetaClass iface, final MetaMethod member) {
if (iface.getMethod(member.getName(), Arrays.stream(member.getParameters()).map(p -> p.getType()).toArray(MetaClass[]::new)) != null)
return true;
return false;
}
代码示例来源:origin: org.jboss.errai/errai-marshalling
@Override
public MetaClassMember getBindingMember() {
if (bindingMember != null) {
return bindingMember;
}
MetaMethod meth = toMap.getMethod(setterMethod, targetType);
final Method method = meth.asMethod();
if (method != null) {
method.setAccessible(true);
}
bindingMember = meth;
if (bindingMember == null) {
throw new RuntimeException("no such setter method: " + toMap.getFullyQualifiedName() + "." + setterMethod);
}
return bindingMember;
}
代码示例来源:origin: org.jboss.errai/errai-marshalling
@Override
public MetaClassMember getReadingMember() {
if (readingMember != null) {
return readingMember;
}
MetaMethod meth = toMap.getMethod(getterMethod, new MetaClass[0]);
final Method method = meth.asMethod();
if (method != null) {
method.setAccessible(true);
}
readingMember = meth;
if (readingMember == null) {
throw new RuntimeException("no such getter method: " + toMap.getFullyQualifiedName() + "." + getterMethod);
}
return readingMember;
}
代码示例来源:origin: org.jboss.errai/errai-marshalling
@Override
public MetaClassMember getBindingMember() {
if (writingMember != null) {
return writingMember;
}
MetaMethod meth = toMap.getMethod(getterMethod, targetType);
final Method method = meth.asMethod();
if (method != null) {
method.setAccessible(true);
}
writingMember = meth;
if (writingMember == null) {
throw new RuntimeException("no such setter method: " + toMap.getFullyQualifiedName() + "." + getterMethod);
}
return writingMember;
}
代码示例来源:origin: org.jboss.errai/errai-data-binding
private MetaClass getValueType(final MetaClass type) {
if (type.isAssignableTo(TakesValue.class)) {
return type.getMethod("getValue", new Class[0]).getReturnType();
}
else {
return null;
}
}
代码示例来源:origin: errai/errai
private void addContextualProviderInjectable(final Injectable providerInjectable,
final DependencyGraphBuilder builder, final boolean enabled) {
final MetaClass providerImpl = providerInjectable.getInjectedType();
final MetaMethod providerMethod = providerImpl.getMethod("provide", Class[].class, Annotation[].class);
// Do not get generic return type for contextual providers
final MetaClass providedType = providerMethod.getReturnType();
final InjectableType injectableType = (enabled ? InjectableType.ContextualProvider : InjectableType.Disabled);
final Injectable providedInjectable = builder.addInjectable(providedType,
qualFactory.forUniversallyQualified(), EXACT_TYPE, Dependent.class, injectableType,
WiringElementType.Provider, WiringElementType.DependentBean);
builder.addProducerMemberDependency(providedInjectable, providerImpl, providerInjectable.getQualifier(), providerMethod);
}
代码示例来源:origin: errai/errai
private void addProviderInjectable(final Injectable providerImplInjectable, final DependencyGraphBuilder builder,
final boolean enabled) {
final MetaClass providerImpl = providerImplInjectable.getInjectedType();
final MetaMethod providerMethod = providerImpl.getMethod("get", new Class[0]);
final MetaClass providedType = getMethodReturnType(providerMethod);
final InjectableType injectableType = (enabled ? InjectableType.Provider : InjectableType.Disabled);
final Injectable providedInjectable = builder.addInjectable(providedType, qualFactory.forSource(providerMethod),
EXACT_TYPE, Dependent.class, injectableType, WiringElementType.Provider, WiringElementType.DependentBean);
builder.addProducerMemberDependency(providedInjectable, providerImplInjectable.getInjectedType(), providerImplInjectable.getQualifier(), providerMethod);
}
代码示例来源:origin: errai/errai
@Test
public void parameterizedTypeIsAssignableToSameTypeWithWildcard() throws Exception {
final MetaClass parameterized = parameterizedAs(Collection.class, typeParametersOf(Integer.class));
final MetaClass wildcard = MetaClassFactory.get(WildcardMethod.class).getMethod("method", new Class[0]).getReturnType();
assertTrue(GraphUtil.hasAssignableTypeParameters(parameterized, wildcard));
}
代码示例来源:origin: errai/errai
@Test
public void testMethodObjectReturnType() {
final MetaClass c = getMetaClass(ClassWithGenericMethods.class);
final MetaMethod method = c.getMethod("methodReturningObject", new Class[] {});
assertEquals("java.lang.Object", method.getReturnType().getFullyQualifiedNameWithTypeParms());
assertEquals(getTypeOfMetaClassBeingTested(), method.getReturnType().getClass());
// the generic return type should be the same: plain old Object
assertEquals(getMetaClass(Object.class), method.getGenericReturnType());
}
代码示例来源:origin: errai/errai
private static Object createAccessorImpl(final MetaClass type, final String varName) {
final MetaClass propertyType = type.getMethod("getValue", new Class[0]).getReturnType();
return ObjectBuilder.newInstanceOf(NativeHasValueAccessors.Accessor.class)
.extend()
.publicMethod(Object.class, "get")
.append(loadVariable(varName).invoke("getValue").returnValue())
.finish()
.publicMethod(void.class, "set", finalOf(Object.class, "value"))
.append(loadVariable(varName).invoke("setValue", castTo(propertyType, loadVariable("value"))))
.finish()
.finish();
}
}
代码示例来源:origin: org.jboss.errai/errai-ui
private static Object createAccessorImpl(final MetaClass type, final String varName) {
final MetaClass propertyType = type.getMethod("getValue", new Class[0]).getReturnType();
return ObjectBuilder.newInstanceOf(NativeHasValueAccessors.Accessor.class)
.extend()
.publicMethod(Object.class, "get")
.append(loadVariable(varName).invoke("getValue").returnValue())
.finish()
.publicMethod(void.class, "set", finalOf(Object.class, "value"))
.append(loadVariable(varName).invoke("setValue", castTo(propertyType, loadVariable("value"))))
.finish()
.finish();
}
}
代码示例来源:origin: errai/errai
@Test
public void testMethodReturnTypeWithUpperBoundedWildcardParameter() {
final MetaClass c = getMetaClass(ClassWithGenericMethods.class);
final MetaMethod method = c.getMethod("methodReturningUpperBoundedWildcardCollection", new Class[] {});
// TODO (ERRAI-459) decide whether it's correct to have the type param present or not
// then adjust this assertion to strict equality rather than startsWith()
assertTrue(method.getReturnType().getFullyQualifiedNameWithTypeParms().startsWith("java.util.Collection"));
final MetaType genericReturnType = method.getGenericReturnType();
assertNotNull(genericReturnType);
assertTrue("Got unexpected return type type " + genericReturnType.getClass(),
genericReturnType instanceof MetaParameterizedType);
final MetaParameterizedType mpReturnType = (MetaParameterizedType) genericReturnType;
assertEquals(1, mpReturnType.getTypeParameters().length);
// Sole type parameter should be <? extends String>
assertTrue(mpReturnType.getTypeParameters()[0] instanceof MetaWildcardType);
final MetaWildcardType typeParam = (MetaWildcardType) mpReturnType.getTypeParameters()[0];
assertArrayEquals(new MetaType[] {}, typeParam.getLowerBounds());
assertArrayEquals(new MetaType[] { getMetaClass(String.class) }, typeParam.getUpperBounds());
}
代码示例来源:origin: errai/errai
@Test
public void testMethodReturnTypeWithLowerBoundedWildcardParameter() {
final MetaClass c = getMetaClass(ClassWithGenericMethods.class);
final MetaMethod method = c.getMethod("methodReturningLowerBoundedWildcardCollection", new Class[] {});
// TODO (ERRAI-459) decide whether it's correct to have the type param present or not
// then adjust this assertion to strict equality rather than startsWith()
assertTrue(method.getReturnType().getFullyQualifiedNameWithTypeParms().startsWith("java.util.Collection"));
final MetaType genericReturnType = method.getGenericReturnType();
assertNotNull(genericReturnType);
assertTrue("Got unexpected return type type " + genericReturnType.getClass(),
genericReturnType instanceof MetaParameterizedType);
final MetaParameterizedType mpReturnType = (MetaParameterizedType) genericReturnType;
assertEquals(1, mpReturnType.getTypeParameters().length);
// Sole type parameter should be <? extends String>
assertTrue(mpReturnType.getTypeParameters()[0] instanceof MetaWildcardType);
final MetaWildcardType typeParam = (MetaWildcardType) mpReturnType.getTypeParameters()[0];
assertArrayEquals(new MetaType[] { getMetaClass(String.class) }, typeParam.getLowerBounds());
assertArrayEquals(new MetaType[] { getMetaClass(Object.class)}, typeParam.getUpperBounds());
}
内容来源于网络,如有侵权,请联系作者删除!