Package net.vidageek.mirror.dsl

Examples of net.vidageek.mirror.dsl.Mirror


    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

  private Interceptor getAcceptor() {
    if (acceptor == null) {
      try {
        Constructor<?> constructor = type.getDeclaredConstructors()[0];
        int argsLength = constructor.getParameterTypes().length;
        acceptor = type.cast(new Mirror().on(type).invoke().constructor(constructor).withArgs(new Object[argsLength]));
      } catch (MirrorException e) {
        if (e.getCause() instanceof NullPointerException) {
          throw new InterceptionException("StaticInterceptors should not use constructor parameters inside the constructor", e);
        } else {
          throw new InterceptionException(e);
View Full Code Here

  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

      }
    }

    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

    @Override
    public String toString() {
      Method method = null;

      if (getMethodsAmountWithSameName() > 1) {
        method = new Mirror().on(controller).reflect().method(methodName).withArgs(getClasses(args));
        if (method == null && args.isEmpty()) {
          throw new IllegalArgumentException("Ambiguous method '" + methodName + "' on " + controller + ". Try to add some parameters to resolve ambiguity, or use different method names.");
        }
      } else {
        method = findMethodWithName(controller, methodName);
View Full Code Here

    return builder.toString();
  }


  public String getControllerAndMethodName() {
    Field resourceMethodField = new Mirror().on(FixedMethodStrategy.class).reflect().field("resourceMethod");
    resourceMethodField.setAccessible(true);
    try {
      ResourceMethod resourceMethod = (ResourceMethod) resourceMethodField.get(route);
      return resourceMethod.getMethod().toString();
    } catch (Exception e) {
View Full Code Here

    collectors.collect(result);
  }

  void includeMethodInvocationReturnInResult(String name, Object obj, String methodName) {
    try {
      Object toBeIncluded = new Mirror().on(obj).invoke().method(methodName).withoutArgs();
      result.include(name, toBeIncluded);
    } catch (Exception e) {
      result.include(name, "not found");
    }
  }
View Full Code Here

  }

  private List<Method> getMethods(Class<?> controller) {
    List<Method> methods = new ArrayList<>();
   
    for (Method method : new Mirror().on(controller).reflectAll().methods()) {
      if (!method.getDeclaringClass().equals(Object.class)) {
        methods.add(method);
      }
    }
   
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.