Exemple #1
0
  @Override
  public int getTypeMatch(IType type) {
    if (this.field == null) {
      return 0;
    }

    IType type1 = this.getType();
    if (type.equals(type1)) {
      return 3;
    }
    if (type.isSuperTypeOf(type1)) {
      return 2;
    }
    return 0;
  }
  private void checkMethod(IMethod m) {
    Name name = m.getName();
    if (name == Name.equals) {
      if (m.parameterCount() == 1 && m.getParameter(0).getType().equals(Types.OBJECT)) {
        this.methods |= EQUALS;
      }
      return;
    }
    if (name == Name.hashCode) {
      if (m.parameterCount() == 0) {
        this.methods |= HASHCODE;
      }
      return;
    }
    if (name == Name.toString) {
      if (m.parameterCount() == 0) {
        this.methods |= TOSTRING;
      }
      return;
    }
    if (name == Name.apply) {
      if (m.parameterCount() == this.theClass.parameterCount()) {
        int len = this.theClass.parameterCount();
        for (int i = 0; i < len; i++) {
          IType t1 = m.getParameter(i).getType();
          IType t2 = m.getParameter(i).getType();
          if (!t1.equals(t2)) {
            return;
          }
        }

        this.methods |= APPLY;
      }
      return;
    }
  }