Package net.vidageek.mirror.dsl

Examples of net.vidageek.mirror.dsl.Mirror


  private String[] getUris(Method javaMethod){
    Annotation method = find(Arrays.asList(javaMethod.getAnnotations()), instanceOfMethodAnnotation(), null);
    if (method == null) {
      return new String[0];
    }
    return (String[]) new Mirror().on(method).invoke().method("value").withoutArgs();
  }
View Full Code Here


    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

  }

  public void replay(Result result) {
    Object current = result;
    for (ExceptionRecorderParameter p : parameters) {
      current = new Mirror().on(current).invoke().method(p.getMethod()).withArgs(p.getArgs());
    }
  }
View Full Code Here

      types.addAll(getElementTypes());
    else
      types.add(getRootClass());

    for (Class<?> type : types) {
      for(Field field : new Mirror().on(type).reflectAll().fields()) {
        excludes.putAll(field.getName(), getParentTypes(field.getName(), type));
      }
    }
  }
View Full Code Here

  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


  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)) {
View Full Code Here

    String[] path = name.split("\\.");
    return path[path.length-1];
  }
 
  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());
      }
    }
  }
View Full Code Here

    }

    boolean skip = false;

    if (!serializee.isRecursive())
      skip = !isPrimitive(new Mirror().on(definedIn).reflect().field(fieldName).getType());

    return skip;
  }
View Full Code Here

      }
    }

    boolean should = super.shouldSerializeMember(definedIn, fieldName);
    if (!serializee.isRecursive())
      should = should && isPrimitive(new Mirror().on(definedIn).reflect().field(fieldName).getType());
    return should;
  }
View Full Code Here

      excludes.putAll(name, getParentTypesFor(name));
    }
  }
 
  public void excludeAll() {
    for(Field field : new Mirror().on(getRootClass()).reflectAll().fields()) {
      excludes.putAll(field.getName(), getParentTypes(field.getName(), getRootClass()));
    }
  }
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.