Exemplo n.º 1
0
  /** Resolve to compare objects but do not modify list */
  @Override
  public boolean contains(Object object) {
    if (isEObject()) {
      if (size > 4) {
        if (!isInstance(object)) {
          return false;
        } else if (isContainment()) {
          InternalEObject eObject = (InternalEObject) object;
          EObject eContainer = eObject.eContainer();
          boolean result =
              eContainer == owner
                  && (hasNavigableInverse()
                      ? eObject.eBaseStructuralFeatureID(eObject.eContainerFeatureID(), dataClass)
                          == getInverseFeatureID()
                      : InternalEObject.EOPPOSITE_FEATURE_BASE - eObject.eContainerFeatureID()
                          == getFeatureID());
          if (hasProxies() && !result && eContainer == null && eObject.eDirectResource() != null) {
            for (int i = 0; i < size; ++i) {
              EObject containedEObject = resolveProxy((EObject) data[i]);
              if (containedEObject == object) {
                return true;
              }
            }
          }
          return result;
        }
        // We can also optimize single valued reverse.
        //
        else if (hasNavigableInverse() && !hasManyInverse()) {
          Object opposite = ((EObject) object).eGet(getInverseEReference());
          if (opposite == owner) {
            return true;
          } else if (opposite == null || !((EObject) opposite).eIsProxy()) {
            return false;
          }
        }
      }

      boolean result = super.contains(object);
      if (hasProxies() && !result) {
        for (int i = 0; i < size; ++i) {
          EObject eObject = resolveProxy((EObject) data[i]);
          if (eObject == object) {
            return true;
          }
        }
      }
      return result;
    } else {
      return super.contains(object);
    }
  }
 @Override
 public void apply() {
   InternalEObject object = (InternalEObject) CDOUtil.getEObject(this.object);
   store.setContainer(object, null, object.eInternalContainer(), object.eContainerFeatureID());
 }