CPD Results

The following document contains the results of PMD's CPD 5.3.2.

Duplications

File Line
de/fhdw/wtf/context/model/collections/PersistentListWithLinks.java 190
de/fhdw/wtf/context/model/collections/TransientList.java 127
		if (obj instanceof MutableCollection<?>) {
			try {
				@SuppressWarnings("unchecked")
				final MutableCollection<T> other = (MutableCollection<T>) obj;
				final Iterator<T> thisIterator = this.iterator();
				while (thisIterator.hasNext()) {
					final T current = thisIterator.next();
					if (!other.contains(current)) {
						return false;
					}
				}
				final Iterator<T> otherIterator = other.iterator();
				while (otherIterator.hasNext()) {
					final T current = otherIterator.next();
					if (!this.contains(current)) {
						return false;
					}
				}
				return true;
			} catch (final ClassCastException e) {
				return false;
			}
		}
		return false;
	}
	
	@Override
	public int hashCode() {
		return this.copy().hashCode();
File Line
de/fhdw/wtf/context/model/collections/PersistentMapWithKeyValueLinks.java 97
de/fhdw/wtf/context/model/collections/PersistentMapWithKeyValueLinks.java 126
			final BigInteger castedKeyObject = ((Int) key).getVal();
			if (value instanceof Str) {
				final Str castedValue = (Str) value;
				returnedLink =
						TransactionManager.getContext().put(
								this.owner,
								this.associationName,
								castedValue.toString(),
								castedKeyObject);
			} else if (value instanceof Int) {
				final Int castedValue = (Int) value;
				returnedLink =
						TransactionManager.getContext().put(
								this.owner,
								this.associationName,
								castedValue.getVal(),
								castedKeyObject);
			} else if (value instanceof AnyType) {
				final AnyType castedValue = (AnyType) value;
				returnedLink =
						TransactionManager.getContext().put(
								this.owner,
								this.associationName,
								castedValue.getObject(),
								castedKeyObject);
			} else {
				throw new FrameworkException("Type to insert is not known");
			}
		} else if (key instanceof AnyType) {
File Line
de/fhdw/wtf/context/model/collections/PersistentListWithLinks.java 134
de/fhdw/wtf/context/model/collections/TransientList.java 83
	}
	
	@Override
	public void apply(final Procedure<T> procedure) {
		final Iterator<T> iterator = this.iterator();
		while (iterator.hasNext()) {
			final T current = iterator.next();
			procedure.op(current);
		}
	}
	
	@Override
	public void remove(final Predicate<T> predicate) {
		final Iterator<T> iterator = this.iterator();
		while (iterator.hasNext()) {
			final T current = iterator.next();
			if (predicate.p(current)) {
				iterator.remove();
			}
		}
	}
	
	@Override
	public Iterator<T> iterator() {
File Line
de/fhdw/wtf/context/model/collections/ImmutableList.java 55
de/fhdw/wtf/context/model/collections/TransientList.java 55
		final Iterator<? extends T> iterator = ((MutableCollection<? extends T>) otherCollection).iterator();
		while (iterator.hasNext()) {
			final T current = iterator.next();
			this.elements.add(current);
		}
	}
	
	/**
	 * Adds the elements of an ImmutableCollection to this list.
	 * 
	 * @param otherCollection
	 *            The ImmutableCollection.
	 */
	private void addImmutableCollection(final ImmutableCollection<? extends T> otherCollection) {
		if (!otherCollection.isEmpty()) {
			this.elements.add(otherCollection.front());
			this.addImmutableCollection(otherCollection.tail());
		}
	}
	
	@Override
	public boolean contains(final T element) {
		return this.elements.contains(element);
	}
	
	@Override
	public ImmutableCollection<T> add(final T element) {