aboutsummaryrefslogtreecommitdiffstats
path: root/tests/bugs154/pr176991/AspectJBugTestCase.java
blob: 9b9b27d783880ca3ad63f39a45d6e7836fe84bda (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
package com.ihg.dec.framework.commons.utils.cow;

import java.util.AbstractSet;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Set;
import java.util.Map.Entry;

public class AspectJBugTestCase {
	class Value<V> {
		private V value;
		public Value(V value) {
			this.value = value;
		}
		public V getValue() {
			return value;
		}
		public void setValue(V value) {
			this.value = value;
		}
	}

	class EntrySetEntry<K, V> implements Entry<K, V> {
		private Entry<K, Value<V>> wrapped;

		public EntrySetEntry(Entry<K, Value<V>> wrapped) {
			this.wrapped = wrapped;
		}

		public K getKey() {
			return wrapped.getKey();
		}

		public V getValue() {
			return wrapped.getValue().getValue();
		}

		public V setValue(V value) {
			Value<V> old = wrapped.setValue(new Value<V>(value));
			return old == null ? null : old.getValue();
		}

	}

	class EntrySetIterator<K, V> implements Iterator<Entry<K, V>> {
		private Iterator<Entry<K, Value<V>>> wrapped;

		public EntrySetIterator(Iterator<Entry<K, Value<V>>> wrapped) {
			this.wrapped = wrapped;
		}

		public boolean hasNext() {
			return wrapped.hasNext();
		}

		public Entry<K, V> next() {
			return new EntrySetEntry<K, V>(wrapped.next());
		}

		public void remove() {
			throw new UnsupportedOperationException("Not implemented.");
		}
	}

	class EntrySet<K, V> extends AbstractSet<Entry<K, V>> implements
			Set<Entry<K, V>> {
		private Set<Entry<K, Value<V>>> wrapped;

		public EntrySet(Set<Entry<K, Value<V>>> wrapped) {
			this.wrapped = wrapped;
		}

		@Override
		public Iterator<Entry<K, V>> iterator() {
			return new EntrySetIterator<K, V>(wrapped.iterator());
		}

		@Override
		public int size() {
			return wrapped.size();
		}
	}

	public void testIt() {
		new EntrySet<String, String>( new HashSet<Entry<String, Value<String>>>());
	}
}

aspect X {
  declare parents: *.Entry* implements java.io.Serializable;
}