use of java.lang.reflect.Member in project guice by google.
the class ShortNameFactoryTest method testGetSourceName_method.
/**
* Tests the case where a provider method is the source of the
*
* @throws Exception
*/
public void testGetSourceName_method() throws Exception {
Member method = Obj.class.getDeclaredMethod("method", String.class);
assertEquals("Method should be identified by its file name and line number", "ShortNameFactoryTest.java:52", nameFactory.getSourceName(method));
}
use of java.lang.reflect.Member in project guice by google.
the class ShortNameFactoryTest method testGetMemberName_constructor.
public void testGetMemberName_constructor() throws Exception {
Member constructor = Obj.class.getDeclaredConstructor();
assertEquals("<init>", nameFactory.getMemberName(constructor));
}
use of java.lang.reflect.Member in project flink by apache.
the class CheckForbiddenMethodsUsage method testNoDefaultEncoding.
@Test
public void testNoDefaultEncoding() throws Exception {
final Reflections reflections = new Reflections(new ConfigurationBuilder().useParallelExecutor(Runtime.getRuntime().availableProcessors()).addUrls(ClasspathHelper.forPackage("org.apache.flink")).addScanners(new MemberUsageScanner()));
for (ForbiddenCall forbiddenCall : forbiddenCalls) {
final Set<Member> methodUsages = forbiddenCall.getUsages(reflections);
methodUsages.removeAll(forbiddenCall.getExclusions());
assertEquals("Unexpected calls: " + methodUsages, 0, methodUsages.size());
}
}
use of java.lang.reflect.Member in project qi4j-sdk by Qi4j.
the class MetaInfoDeclaration method metaInfoFor.
@Override
public MetaInfo metaInfoFor(AccessibleObject accessor) {
for (Map.Entry<Class<?>, InfoHolder<?>> entry : mixinPropertyDeclarations.entrySet()) {
InfoHolder<?> holder = entry.getValue();
MetaInfo metaInfo = holder.metaInfoFor(accessor);
if (metaInfo != null) {
Class<?> mixinType = entry.getKey();
return metaInfo.withAnnotations(mixinType).withAnnotations(accessor).withAnnotations(accessor instanceof Method ? ((Method) accessor).getReturnType() : ((Field) accessor).getType());
}
}
// TODO is this code reached at all??
Class<?> declaringType = ((Member) accessor).getDeclaringClass();
return new MetaInfo().withAnnotations(declaringType).withAnnotations(accessor).withAnnotations(accessor instanceof Method ? ((Method) accessor).getReturnType() : ((Field) accessor).getType());
}
use of java.lang.reflect.Member in project qi4j-sdk by Qi4j.
the class AssociationModel method bind.
@Override
public void bind(Resolution resolution) throws BindingException {
builderInfo = new AssociationInfo() {
@Override
public boolean isImmutable() {
return false;
}
@Override
public QualifiedName qualifiedName() {
return qualifiedName;
}
@Override
public Type type() {
return type;
}
@Override
public void checkConstraints(Object value) throws ConstraintViolationException {
AssociationModel.this.checkConstraints(value);
}
};
if (type instanceof TypeVariable) {
Class mainType = first(resolution.model().types());
type = Classes.resolveTypeVariable((TypeVariable) type, ((Member) accessor).getDeclaringClass(), mainType);
}
}
Aggregations