示例#1
0
  /**
   * @param newType
   * @param attributeId
   */
  public boolean hasAttributeChanged(DynamicTypeImpl newType, String attributeId) {
    Attribute oldAttribute = findAttributeForId(attributeId);
    Attribute newAttribute = newType.findAttributeForId(attributeId);
    if (oldAttribute == null && newAttribute == null) {
      return false;
    }
    if ((newAttribute == null) || (oldAttribute == null)) {
      return true;
    }
    String newKey = newAttribute.getKey();
    String oldKey = oldAttribute.getKey();
    if (!newKey.equals(oldKey)) {
      return true;
    }
    if (!newAttribute.getType().equals(oldAttribute.getType())) {
      return true;
    }
    {
      String[] keys = newAttribute.getConstraintKeys();
      String[] oldKeys = oldAttribute.getConstraintKeys();
      if (keys.length != oldKeys.length) {
        return true;
      }
      for (int i = 0; i < keys.length; i++) {
        if (!keys[i].equals(oldKeys[i])) return true;
        Object oldConstr = oldAttribute.getConstraint(keys[i]);
        Object newConstr = newAttribute.getConstraint(keys[i]);
        if (oldConstr == null && newConstr == null) continue;
        if (oldConstr == null || newConstr == null) return true;

        if (!oldConstr.equals(newConstr)) return true;
      }
    }
    return false;
  }