本文整理了Java中net.vidageek.mirror.dsl.Mirror
类的一些代码示例,展示了Mirror
类的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Mirror
类的具体详情如下:
包路径:net.vidageek.mirror.dsl.Mirror
类名称:Mirror
[英]This is the basic class to use Mirror. All Reflection features can be accessed using this class. It will load configuration file [mirror.properties]. Full Mirror configuration is found at http://projetos.vidageek.net/mirror/extension/configuration/
[中]这是使用镜像的基本类。使用该类可以访问所有反射功能。它将加载配置文件[mirror.properties]。完整镜像配置位于http://projetos.vidageek.net/mirror/extension/configuration/
代码示例来源: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: vidageek/mirror
/**
* Convenience method for {@link Mirror#proxify(Class...)}
*
* @see {@link Mirror#on(Class)}
* @see {@link Mirror#proxify(Class...)}
* @see {@link Mirror#reflectClass(String)}
*/
public ProxyHandler<Object> proxify(final String... classNames) {
List<Class<?>> classes = new ArrayList<Class<?>>();
for (String className : classNames) {
classes.add(reflectClass(className));
}
return proxify(classes.toArray(new Class<?>[classNames.length]));
}
代码示例来源:origin: vidageek/mirror
/**
* Convenience method for {@link Mirror#on(Class)}.
*
* @see Mirror#on(Class)
* @see Mirror#reflectClass(String)
*/
public ClassController<?> on(final String className) {
return on(reflectClass(className));
}
代码示例来源:origin: br.eti.clairton/security
} else {
final String typeName = withoutProxy(type.getName());
final List<Method> methods = mirror.on(typeName).reflectAll().methods().matching(matcher);
if (methods.size() > 1) {
throw new IllegalArgumentException("The type " + type + " must be annoted twice with " + Resource.class);
String resource = (String) method.invoke(target);
if(resource == null || resource.isEmpty()){
final Object instance = mirror.on(typeName).invoke().constructor().withoutArgs();
resource = (String) method.invoke(instance);
代码示例来源:origin: vidageek/mirror
/**
* Convenience method for {@link Mirror#proxify(Class...)}
*
* @see {@link Mirror#on(Class)}
* @see {@link Mirror#proxify(Class...)}
*/
public ProxyHandler<Object> proxify(final String className) {
return proxify(new String[] { className });
}
代码示例来源:origin: vidageek/mirror
/**
* Convenience method for {@link Mirror#proxify(Class...)}
*
* @see {@link Mirror#on(Class)}
* @see {@link Mirror#proxify(Class...)}
*/
@SuppressWarnings("unchecked")
public <T> ProxyHandler<T> proxify(final Class<T> clazz) {
return (ProxyHandler<T>) proxify(new Class[] { clazz });
}
代码示例来源: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 List<Field> getChoiceItemAnnotatedFields(final Class<? extends Object> type) {
List<Field> result = new ArrayList<Field>();
for (Field field : new Mirror().on(type).reflectAll().fields()) {
if (new Mirror().on(field).reflect().annotation(ChoiceItem.class) != null) {
result.add(field);
}
}
return result;
}
代码示例来源:origin: caelum/caelum-stella
private boolean hasChoiceItens(final Object toValidate) {
for (Field f : new Mirror().on(toValidate.getClass()).reflectAll().fields()) {
if (new Mirror().on(f).reflect().annotation(ChoiceItem.class) != null) {
return true;
}
}
return false;
}
代码示例来源:origin: br.com.caelum.stella/caelum-stella-bean-validation
private boolean hasChoiceItens(final Object toValidate) {
for (Field f : new Mirror().on(toValidate.getClass()).reflectAll().fields()) {
if (new Mirror().on(f).reflect().annotation(ChoiceItem.class) != null) {
return true;
}
}
return false;
}
代码示例来源:origin: org.opensingular/singular-commons-test
private Object getMock(Class<?> clazz) {
Optional<Field> f = mockFields.stream().filter(f1 -> f1.getType().equals(clazz)).findFirst();
if (!f.isPresent()) {
f = mockFields.stream().filter(f1 -> f1.getType().isAssignableFrom(clazz)).findFirst();
}
if (f.isPresent()){
return new Mirror().on(target).get().field(f.get());
} else {
return Mockito.mock(clazz);
}
}
}
代码示例来源:origin: br.com.caelum.stella/caelum-stella-bean-validation
private List<Field> getChoiceItemAnnotatedFields(final Class<? extends Object> type) {
List<Field> result = new ArrayList<Field>();
for (Field field : new Mirror().on(type).reflectAll().fields()) {
if (new Mirror().on(field).reflect().annotation(ChoiceItem.class) != null) {
result.add(field);
}
}
return result;
}
代码示例来源:origin: br.com.caelum.stella/caelum-stella-bean-validation
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: br.com.caelum.vraptor/vraptor-simplemail
private void send(HtmlEmail email) {
logger.info("body => {}", new Mirror().on(email).get().field("html"));
}
代码示例来源:origin: br.com.caelum.vraptor/vraptor-simplemail
private void send(SimpleEmail email) {
logger.info("body => {}", new Mirror().on(email).get().field("content"));
}
代码示例来源: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: vidageek/mirror
public Constructor<T> withAnyArgs() {
List<Constructor<T>> constructors = new Mirror(provider).on(clazz).reflectAll().constructors();
if (constructors.size() != 1) {
throw new MirrorException("there is more than one constructor on class " + clazz.getName()
+ ". withAnyArgs must be called only on classes with a single constructor.");
}
return constructors.get(0);
}
}
代码示例来源:origin: vidageek/mirror
public Class<?> getParameterClass(int index) {
Class<?>[] types = new Mirror(provider).on(clazz).reflect().method(methodName).withAnyArgs().getParameterTypes();
try {
return (Class<?>) types[index];
} catch (ArrayIndexOutOfBoundsException e) {
throw new ArrayIndexOutOfBoundsException(format("No parameter declared at position %d.", index));
}
}
}
代码示例来源:origin: br.com.caelum/iogi
static List<Method> settersOf(Object object) {
return new Mirror().on(object.getClass()).reflectAll().methods().matching(new Matcher<Method>() {
public boolean accepts(final Method method) {
return method.getName().endsWith("_$eq");
}
});
}
}
代码示例来源:origin: caelum/vraptor
public void onEvent() {
for (Method method : destroys) {
new Mirror().on(instance).invoke().method(method).withoutArgs();
}
}
});
内容来源于网络,如有侵权,请联系作者删除!