You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

AspectJBugTestCase.java 1.9KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. package com.ihg.dec.framework.commons.utils.cow;
  2. import java.util.AbstractSet;
  3. import java.util.HashSet;
  4. import java.util.Iterator;
  5. import java.util.Set;
  6. import java.util.Map.Entry;
  7. public class AspectJBugTestCase {
  8. class Value<V> {
  9. private V value;
  10. public Value(V value) {
  11. this.value = value;
  12. }
  13. public V getValue() {
  14. return value;
  15. }
  16. public void setValue(V value) {
  17. this.value = value;
  18. }
  19. }
  20. class EntrySetEntry<K, V> implements Entry<K, V> {
  21. private Entry<K, Value<V>> wrapped;
  22. public EntrySetEntry(Entry<K, Value<V>> wrapped) {
  23. this.wrapped = wrapped;
  24. }
  25. public K getKey() {
  26. return wrapped.getKey();
  27. }
  28. public V getValue() {
  29. return wrapped.getValue().getValue();
  30. }
  31. public V setValue(V value) {
  32. Value<V> old = wrapped.setValue(new Value<V>(value));
  33. return old == null ? null : old.getValue();
  34. }
  35. }
  36. class EntrySetIterator<K, V> implements Iterator<Entry<K, V>> {
  37. private Iterator<Entry<K, Value<V>>> wrapped;
  38. public EntrySetIterator(Iterator<Entry<K, Value<V>>> wrapped) {
  39. this.wrapped = wrapped;
  40. }
  41. public boolean hasNext() {
  42. return wrapped.hasNext();
  43. }
  44. public Entry<K, V> next() {
  45. return new EntrySetEntry<K, V>(wrapped.next());
  46. }
  47. public void remove() {
  48. throw new UnsupportedOperationException("Not implemented.");
  49. }
  50. }
  51. class EntrySet<K, V> extends AbstractSet<Entry<K, V>> implements
  52. Set<Entry<K, V>> {
  53. private Set<Entry<K, Value<V>>> wrapped;
  54. public EntrySet(Set<Entry<K, Value<V>>> wrapped) {
  55. this.wrapped = wrapped;
  56. }
  57. @Override
  58. public Iterator<Entry<K, V>> iterator() {
  59. return new EntrySetIterator<K, V>(wrapped.iterator());
  60. }
  61. @Override
  62. public int size() {
  63. return wrapped.size();
  64. }
  65. }
  66. public void testIt() {
  67. new EntrySet<String, String>( new HashSet<Entry<String, Value<String>>>());
  68. }
  69. }
  70. aspect X {
  71. declare parents: *.Entry* implements java.io.Serializable;
  72. }