Package net.vidageek.mirror.dsl

Examples of net.vidageek.mirror.dsl.Mirror


                throw new IllegalArgumentException("Vraptor does not support this interface or abstract type: "
                        + typeToInstantiate.getName());
            }
            typeToInstantiate = CONCRETE_TYPES.get(baseType);
        }
        Object instance = new Mirror().on(typeToInstantiate).invoke().constructor().withoutArgs();

        if(Collection.class.isAssignableFrom(typeToInstantiate)) {
          removal.add((Collection)instance);
        }
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

    }
    return set;
  }

  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

    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

    }
    List<Message> convertionErrors = new ArrayList<Message>();
    Object[] parameters = provider.getParametersFor(method, convertionErrors, localization.getBundle());
    BasicValidationErrors newErrors = new BasicValidationErrors();
    Object[] validationParameters = createValidatonParameters(newErrors, parameters);
    new Mirror().on(resourceInstance).invoke().method(validationMethod).withArgs(validationParameters);
    addConvertionErrors(convertionErrors);
    convertErrors(newErrors);
  }
View Full Code Here

                logger
                        .error("A get method was found at " + type
                                + " but was not used because it returns void. Fix it.");
                continue;
            }
            Object result = new Mirror().on(resourceInstance).invoke().method(outject).withoutArgs();
            String name = helper.nameForGetter(outject);
            logger.debug("Outjecting {} as {}", name, result);
            outjecter.include(name, result);
        }
    }
View Full Code Here

    int position = -1;
    if (index != -1) {
      position = Integer.parseInt(path.substring(index + 1));
      path = path.substring(0, index);
    }
    Object instance = new Mirror().on(current).invoke().getterFor(path);
    if (index != -1) {
      instance = access(instance, position);
    }
    return instance;
  }
View Full Code Here

        return lastValue;
    }
   
    public static <T> void invokeSetter(Object bean, String attribute, Object value, boolean fail){
        try {
            new Mirror().on(bean).set().field(attribute).withValue(value);
        } catch (Exception ex){
            if(fail) {
                throw new IllegalArgumentException(String.format(NO_SUCH_ATTRIBUTE_MESSAGE, bean.getClass().getName(), attribute, value.getClass().getName()));
            }
        }  
View Full Code Here

        return (T) newInstance(clazz, Collections.emptyList());
    }
   
    public static <T> T newInstance(Class<T> target, List<? extends Object> parameters) {
    if (parameters.size() > 0) {
      return new Mirror().on(target).invoke().constructor().withArgs(parameters.toArray());     
    } else {
      return new Mirror().on(target).invoke().constructor().withoutArgs();
    }
  }
View Full Code Here

   
    public static <T> List<String> filterConstructorParameterNames(Class<T> target, Collection<String> names) {
    List<String> result = Collections.emptyList();
    Paranamer paranamer = new AdaptiveParanamer();
   
    for (Constructor<T> constructor : new Mirror().on(target).reflectAll().constructors()) {
      List<String> constructorParameterNames = Arrays.asList(paranamer.lookupParameterNames(constructor, false));
      if (result.size() < constructorParameterNames.size() && names.containsAll(constructorParameterNames)) {
        result = constructorParameterNames;
      }
    }
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.