/** * Returns whether two objects are equal using the {@link #useEquals appropriate} comparison mechanism. * @return whether two objects are equal. */ protected boolean equalObjects(Object firstObject, Object secondObject) { return useEquals() && firstObject != null ? firstObject.equals(secondObject) : firstObject == secondObject; }
/** * Returns the collection of objects in the given collection that are also contained by this list. * @param collection the other collection. * @return the collection of objects in the given collection that are also contained by this list. */ protected Collection<E> getDuplicates(Collection<?> collection) { if (collection.isEmpty()) { return ECollections.emptyEList(); } else { Collection<E> filteredResult = useEquals() ? new BasicEList<E>(collection.size()) : new BasicEList.FastCompare<E>(collection.size()); for (E object : this) { if (collection.contains(object)) { filteredResult.add(object); } } return filteredResult; } }