Exemple #1
0
  public boolean isAssignableTo(Type type) {
    if (resolved != null) return type.isAssignableFrom(resolved);

    if (Type.OBJECT.equals(type)) return true;

    if (potentialClass != null && !type.isAssignableFrom(potentialClass)) potentialClass = null;

    Map map = mergeMultiAndSingle(this, type);

    if (map.size() == 1 && potentialClass == null) {
      // Update previous merge paths to the same resolved type
      resolved = Type.get((CtClass) map.values().iterator().next());
      propogateResolved();

      return true;
    }

    // Keep all previous merge paths up to date
    if (map.size() >= 1) {
      interfaces = map;
      propogateState();

      return true;
    }

    if (potentialClass != null) {
      resolved = potentialClass;
      propogateResolved();

      return true;
    }

    return false;
  }
 public void testGetType() {
   assertEquals("Ljava/lang/String;", Type.get(String.class).getName());
   assertEquals("[Ljava/lang/String;", Type.get(String[].class).getName());
   assertEquals("[[Ljava/lang/String;", Type.get(String[][].class).getName());
   assertEquals("I", Type.get(int.class).getName());
   assertEquals("[I", Type.get(int[].class).getName());
   assertEquals("[[I", Type.get(int[][].class).getName());
 }
 public SimpleRangePart(String rep, boolean hasLetters, boolean hasNumbers) {
   _rep = rep;
   _type = Type.get(hasLetters, hasNumbers);
 }
 public T get(ResultSet resultSet) throws SQLException {
   return type.get(resultSet, indexIn(resultSet));
 }
Exemple #5
0
  public Type merge(Type type) {
    if (this == type) return this;

    if (type == UNINIT) return this;

    if (type == BOGUS) return BOGUS;

    if (type == null) return this;

    if (resolved != null) return resolved.merge(type);

    if (potentialClass != null) {
      Type mergePotential = potentialClass.merge(type);
      if (!mergePotential.equals(potentialClass) || mergePotential.popChanged()) {
        potentialClass = Type.OBJECT.equals(mergePotential) ? null : mergePotential;
        changed = true;
      }
    }

    Map merged;

    if (type instanceof MultiType) {
      MultiType multi = (MultiType) type;

      if (multi.resolved != null) {
        merged = mergeMultiAndSingle(this, multi.resolved);
      } else {
        merged = mergeMultiInterfaces(multi, this);
        if (!inMergeSource(multi)) mergeSource = multi;
      }
    } else {
      merged = mergeMultiAndSingle(this, type);
    }

    // Keep all previous merge paths up to date
    if (merged.size() > 1 || (merged.size() == 1 && potentialClass != null)) {
      // Check for changes
      if (merged.size() != interfaces.size()) {
        changed = true;
      } else if (changed == false) {
        Iterator iter = merged.keySet().iterator();
        while (iter.hasNext()) if (!interfaces.containsKey(iter.next())) changed = true;
      }

      interfaces = merged;
      propogateState();

      return this;
    }

    if (merged.size() == 1) {
      resolved = Type.get((CtClass) merged.values().iterator().next());
    } else if (potentialClass != null) {
      resolved = potentialClass;
    } else {
      resolved = OBJECT;
    }

    propogateResolved();

    return resolved;
  }