Package net.vidageek.mirror.dsl

Examples of net.vidageek.mirror.dsl.Mirror


  private Set<Class<?>> getParentTypes(String name, Class<?> type) {
    String[] path = name.split("\\.");
   
    try {
      for (int i = 0; i < path.length - 1; i++) {
        Field field = checkNotNull(new Mirror().on(type).reflect().field(path[i]));
        type = getActualType(field.getGenericType());
      }
      checkNotNull(new Mirror().on(type).reflect().field(path[path.length -1]));
    } catch (NullPointerException e) {
      throw new IllegalArgumentException("Field path '" + name + "' doesn't exists in " + type, e);
    }
   
    Set<Class<?>> types = Sets.newHashSet();
View Full Code Here


              Method setter = ReflectionBasedNullHandler.findMethod(origin.getClass(),
                      "set" + Info.capitalize(fieldName), origin.getClass(), null);
              EmptyElementsRemoval removal = (EmptyElementsRemoval) context.get("removal");
              removal.add(newArray, setter, origin);

              new Mirror().on(origin).invoke().method(setter).withArgs(newArray);
            }
            array = newArray;
        }
        super.setProperty(context, array, key, value);
    }
View Full Code Here

    return routes;
    }

    private void parse(Class<?> type) {
        checkFields(type);
        for (Method method : new Mirror().on(type).reflectAll().methods()) {
            checkOutjections(type, method);
            checkLogic(type, method);
            checkValidate(type, method);
        }
    }
View Full Code Here

    }
  }

  private void checkFields(Class<?> type) {
    for (Class<? extends Annotation> annotation : new Class[] { Out.class, In.class, Parameter.class }) {
            for (Field field : new Mirror().on(type).reflectAll().fields()) {
                if (field.isAnnotationPresent(annotation)) {
                    logger.error("Field " + field.getName() + " from " + type.getName() + " is annotated with "
                            + annotation.getName() + " but is not supported by VRaptor3! Read the migration guide.");
                }
            }
View Full Code Here

            }
        }
  }

  private void registerRulesFor(Class<?> baseType, List<Route> routes) {
    List<Method> methods = new Mirror().on(baseType).reflectAll().methodsMatching(suitableMethod());
    for (Method javaMethod : methods) {
      String uri = getUriFor(javaMethod, baseType);
      RouteBuilder builder = router.builderFor(uri);
      for (HttpMethod m : HttpMethod.values()) {
        if (javaMethod.isAnnotationPresent(m.getAnnotation())) {
View Full Code Here

    for (String field : fields) {
      try {
        Set<Class<?>> parentTypes = getParentTypesFor(field);
        String fieldName = getNameFor(field);
        for (Class<?> parentType : parentTypes) {
          Type genericType = new Mirror().on(parentType).reflect().field(fieldName).getGenericType();
          Class<?> fieldType = getActualType(genericType);

          if (!excludes.containsKey(fieldType)) {
            excludeNonPrimitiveFields(fieldType);
          }
View Full Code Here

    }
    return this;
  }

  private void excludeNonPrimitiveFields(Class<?> type) {
    for (Field field : new Mirror().on(type).reflectAll().fields()) {
      if (!isPrimitive(field.getType())) {
        excludes.put(type, field.getName());
      }
    }
  }
View Full Code Here

  }

  private Class<?> getParentType(String name, Class<?> type) {
    String[] path = name.split("\\.");
    for (int i = 0; i < path.length - 1; i++) {
      type = getActualType(new Mirror().on(type).reflect().field(path[i]).getGenericType());
    }
    return type;
  }
View Full Code Here

  @SuppressWarnings("unchecked")
  Object instantiate(Object target, Object property, Type type) {

    Class typeToInstantiate = (Class) ((ParameterizedType) type).getActualTypeArguments()[0];
    Object instance = new Mirror().on(typeToInstantiate).invoke().constructor().withoutArgs();

    // setting the position
    int position = (Integer) property;
    List list = (List) target;
    while (list.size() <= position) {
View Full Code Here

            instance = instantiateArray(baseType);
        } else {
            instance = generic.instantiate(baseType);
        }
        Method setter = findMethod(target.getClass(), "set" + propertyCapitalized, target.getClass(), getter.getReturnType());
        new Mirror().on(target).invoke().method(setter).withArgs(instance);
        return instance;
    }
View Full Code Here

TOP

Related Classes of net.vidageek.mirror.dsl.Mirror

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.