本文整理了Java中net.vidageek.mirror.dsl.Mirror.<init>()
方法的一些代码示例,展示了Mirror.<init>()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mirror.<init>()
方法的具体详情如下:
包路径:net.vidageek.mirror.dsl.Mirror
类名称:Mirror
方法名:<init>
暂无
代码示例来源:origin: caelum/vraptor
private <I> void extractLifecycleMethods(TypeLiteral<I> literal, final List<Method> constructs,
final List<Method> destroys) {
for (Method method : new Mirror().on(literal.getRawType()).reflectAll().methods()) {
if (method.isAnnotationPresent(PostConstruct.class)) {
constructs.add(method);
}
if (method.isAnnotationPresent(PreDestroy.class)) {
destroys.add(method);
}
}
}
代码示例来源:origin: caelum/caelum-stella
private boolean validateChoice(final Object toValidate, final List<Field> fields) {
int nonNullFields = 0;
for (Field field : fields) {
if (!field.getClass().isPrimitive()) {
Object object = new Mirror().on(toValidate).get().field(field);
if (object != null) {
nonNullFields++;
}
}
}
return nonNullFields == 1;
}
代码示例来源:origin: caelum/vraptor
private void excludeNonPrimitiveFields(Multimap<Class<?>, String> excludesMap, Class<?> type) {
for (Field field : new Mirror().on(type).reflectAll().fields()) {
if (!isPrimitive(field.getType())) {
excludesMap.put(field.getDeclaringClass(), field.getName());
}
}
}
代码示例来源:origin: caelum/vraptor
private void parseInclude(Multimap<Class<?>, String> excludesMap, Entry<String, Class<?>> include) {
Class<?> parentType = include.getValue();
String fieldName = getNameFor(include.getKey());
Field field = new Mirror().on(parentType).reflect().field(fieldName);
if (field == null) return;
Type genericType = field.getGenericType();
Class<?> fieldType = Serializee.getActualType(genericType);
if (!excludesMap.containsKey(fieldType)) {
excludeNonPrimitiveFields(excludesMap, fieldType);
}
excludesMap.remove(parentType, fieldName);
}
代码示例来源:origin: org.opensingular/singular-server-commons-test
private void registerMockBean(ApplicationContextMock applicationContext, Class<?> targetClass) {
new Mirror().on(targetClass).reflectAll().methods().matching(element -> element.isAnnotationPresent(Bean.class)).forEach(m -> {
if (m.getParameterCount() == 0) {
try {
applicationContext.putOrReplaceBean(m.invoke(Mockito.spy(targetClass)));
} catch (Exception e) {
getLogger().trace(e.getMessage(), e);
}
}
});
}
代码示例来源:origin: org.opensingular/flow-core
public IFlowRenderer getFlowRenderer() {
try {
Class<?> yfilesRendeder = Class.forName("com.opensingular.flow.extras.renderer");
return (IFlowRenderer) new Mirror().on(yfilesRendeder).invoke().method("getInstance").withoutArgs();
} catch (ClassNotFoundException e) {
getLogger().info(e.getMessage(), e);
}
return null;
}
代码示例来源:origin: caelum/vraptor
public void onEvent() {
for (Method method : destroys) {
new Mirror().on(instance).invoke().method(method).withoutArgs();
}
}
});
代码示例来源:origin: caelum/caelum-stella
private String getIEValue(final Object obj) {
return new Mirror().on(obj).invoke()
.method(camelCaseGetFieldName(ie.ieField())).withoutArgs()
.toString();
}
代码示例来源:origin: caelum/vraptor
public Object intercept(T proxy, Method method, Object[] args, SuperMethod superMethod) {
T instance = relation(method.getName()).uses(type);
new Mirror().on(instance).invoke().method(method).withArgs(args);
return null;
}
});
代码示例来源:origin: caelum/vraptor4
@Override
public List<Method> getMethodsFor(Class<?> clazz) {
try {
return new Mirror().on(clazz).reflectAll().methods();
} catch (MirrorException e) {
throw new ReflectionProviderException(e.getCause());
}
}
代码示例来源:origin: caelum/vraptor4
@Override
public List<Field> getFieldsFor(Class<?> clazz) {
try {
return new Mirror().on(clazz).reflectAll().fields();
} catch (MirrorException e) {
throw new ReflectionProviderException(e.getCause());
}
}
代码示例来源:origin: caelum/vraptor4
@Override
public Field getField(Class<?> clazz, String fieldName) {
try {
return new Mirror().on(clazz).reflect().field(fieldName);
} catch (MirrorException e) {
throw new ReflectionProviderException(e.getCause());
}
}
}
代码示例来源:origin: caelum/vraptor
@Before
@SuppressWarnings("unchecked")
public void setup() throws Exception {
MockitoAnnotations.initMocks(this);
when(localization.getBundle()).thenReturn(bundle);
when(request.getParameterNames()).thenReturn(Collections.enumeration(Collections.EMPTY_LIST));
this.instantiator = new ParametersInstantiatorInterceptor(parametersProvider, parameterNameProvider, params, validator, localization, request, flash);
this.errors = (List<Message>) new Mirror().on(instantiator).get().field("errors");
this.method = DefaultResourceMethod.instanceFor(Component.class, Component.class.getDeclaredMethod("method"));
this.otherMethod = DefaultResourceMethod.instanceFor(Component.class, Component.class.getDeclaredMethod("otherMethod", int.class));
}
代码示例来源:origin: caelum/vraptor4
@Override
public Method getMethod(Class<?> clazz, String methodName, Class<?>... parameterTypes) {
try {
return new Mirror().on(clazz).reflect().method(methodName).withArgs(parameterTypes);
} catch (MirrorException e) {
throw new ReflectionProviderException(e.getCause());
}
}
代码示例来源:origin: caelum/vraptor
@Test
public void shouldDeserializeFromGenericTypeOneParam() {
InputStream stream = new ByteArrayInputStream(
"{'entity':{'name':'Brutus','age':7,'birthday':'06/01/1987'}}".getBytes());
ResourceClass resourceClass = new DefaultResourceClass(ExtGenericController.class);
Method method = new Mirror().on(GenericController.class).reflect().method("method").withAnyArgs();
ResourceMethod resource = new DefaultResourceMethod(resourceClass, method);
when(provider.parameterNamesFor(resource.getMethod())).thenReturn(new String[] { "entity" });
Object[] deserialized = deserializer.deserialize(stream, resource);
Dog dog = (Dog) deserialized[0];
assertThat(dog.name, equalTo("Brutus"));
}
代码示例来源:origin: caelum/vraptor4
@Test
public void shouldNotProxifyJavaLangObjectMethods() throws Exception {
Object proxy = proxifier.proxify(JavassistProxifierTest.class, new MethodInvocation<Object>() {
@Override
public Object intercept(Object proxy, Method method, Object[] args, SuperMethod superMethod) {
fail("should not call this Method interceptor");
return null;
}
});
new Mirror().on(proxy).invoke().method("finalize").withoutArgs();
}
代码示例来源:origin: caelum/vraptor4
@Test
public void shouldGetTypesCorrectly() throws Exception {
final Method method = new Mirror().on(AController.class).reflect().method("aMethod").withArgs(Bean.class, String.class);
DefaultTypeFinder finder = new DefaultTypeFinder(provider, new DefaultReflectionProvider());
Map<String, Class<?>> types = finder.getParameterTypes(method, new String[] {"bean.bean2.id", "path"});
assertEquals(Integer.class, types.get("bean.bean2.id"));
assertEquals(String.class, types.get("path"));
}
@Test
代码示例来源:origin: caelum/vraptor4
@Test
public void shouldGetTypesCorrectlyOnInheritance() throws Exception {
final Method method = new Mirror().on(AController.class).reflect().method("otherMethod").withArgs(BeanExtended.class);
DefaultTypeFinder finder = new DefaultTypeFinder(provider, new DefaultReflectionProvider());
Map<String, Class<?>> types = finder.getParameterTypes(method, new String[] {"extended.id"});
assertEquals(Integer.class, types.get("extended.id"));
}
}
代码示例来源:origin: caelum/vraptor
@Test
public void shouldNotProxifyJavaLangObjectMethods() throws Exception {
Object proxy = proxifier.proxify(ReflectionInstanceCreatorTest.class, new MethodInvocation() {
public Object intercept(Object proxy, Method method, Object[] args, SuperMethod superMethod) {
Assert.fail("should not call this Method interceptor");
return null;
}
});
new Mirror().on(proxy).invoke().method("finalize").withoutArgs();
}
代码示例来源:origin: caelum/vraptor
@Test
public void shouldNotProxifyJavaLangObjectMethods() throws Exception {
Object proxy = proxifier.proxify(CglibProxifierTest.class, new MethodInvocation<Object>() {
public Object intercept(Object proxy, Method method, Object[] args, SuperMethod superMethod) {
fail("should not call this Method interceptor");
return null;
}
});
new Mirror().on(proxy).invoke().method("finalize").withoutArgs();
}
内容来源于网络,如有侵权,请联系作者删除!