Package com.fasterxml.classmate

Examples of com.fasterxml.classmate.TypeBindings


  static List<ResolvedType> collectReplaceables(ResolvedType replacingType, ResolvedType wildcardType) {
    return breadthFirstSearch(replacingType, wildcardType);
  }

  private static List<ResolvedType> breadthFirstSearch(ResolvedType replacingType, ResolvedType wildcardType) {
    TypeBindings wildcardTypeBindings = wildcardType.getTypeBindings();
    TypeBindings bindingsToMatch = replacingType.getTypeBindings();
    Preconditions.checkArgument(typeBindingsAreOfSameSize(wildcardType, replacingType));
    List<ResolvedType> bindings = newArrayList();
    for (int index = 0; index < bindingsToMatch.size(); index++) {
      if (WildcardType.class.equals(wildcardTypeBindings.getBoundType(index).getErasedType())) {
        bindings.add(bindingsToMatch.getBoundType(index));
      } else {
        bindings.addAll(breadthFirstSearch(bindingsToMatch.getBoundType(index),
                wildcardTypeBindings.getBoundType(index)));
      }
    }
    return bindings;
  }
View Full Code Here


      return false;
    }
    if (!typeBindingsAreOfSameSize(wildcardType, toMatch)) {
      return false;
    }
    TypeBindings wildcardTypeBindings = wildcardType.getTypeBindings();
    TypeBindings bindingsToMatch = toMatch.getTypeBindings();
    for (int index = 0; index < bindingsToMatch.size(); index++) {
      ResolvedType wildcardTypeBindingsBoundType = wildcardTypeBindings.getBoundType(index);
      ResolvedType bindingsToMatchBoundType = bindingsToMatch.getBoundType(index);

      if (!wildcardTypeBindingsBoundType.getErasedType().equals(WildcardType.class)
              && !wildcardMatch(bindingsToMatchBoundType, wildcardTypeBindingsBoundType)) {
        return false;
      }
View Full Code Here

    }
    return true;
  }

  private static boolean typeBindingsAreOfSameSize(ResolvedType toMatch, ResolvedType wildcardType) {
    TypeBindings wildcardTypeBindings = wildcardType.getTypeBindings();
    TypeBindings bindingsToMatch = toMatch.getTypeBindings();
    return bindingsToMatch.size() == wildcardTypeBindings.size();
  }
View Full Code Here

      } else {
        throw new IllegalStateException("Expecting the same number of wildcard types as the replaceables");
      }

    }
    TypeBindings wildcardTypeBindings = wildcardType.getTypeBindings();
    List<Type> bindings = newArrayList();
    for (int index = 0; index < wildcardTypeBindings.size(); index++) {
      if (WildcardType.class.equals(wildcardTypeBindings.getBoundType(index).getErasedType())) {
        if (replaceableIterator.hasNext()) {
          bindings.add(replaceableIterator.next());
        } else {
          throw new IllegalStateException("Count of wildcards to candidates do not match");
        }
      } else {
        bindings.add(breadthFirstReplace(replaceableIterator, wildcardTypeBindings.getBoundType(index)));
      }
    }
    return new TypeResolver().resolve(wildcardType.getErasedType(), toArray(bindings, Type.class));
  }
View Full Code Here

TOP

Related Classes of com.fasterxml.classmate.TypeBindings

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.