01: /*
02: * Copyright 2001-2007 Geert Bevin <gbevin[remove] at uwyn dot com> and
03: * JR Boyens <gnu-jrb[remove] at gmx dot net>
04: * Distributed under the terms of either:
05: * - the common development and distribution license (CDDL), v1.0; or
06: * - the GNU Lesser General Public License, v2.1 or later
07: * $Id: ManyToOneAssociationSet.java 3716 2007-04-11 06:21:18Z gbevin $
08: */
09: package com.uwyn.rife.database.querymanagers.generic;
10:
11: import java.util.Collection;
12: import java.util.HashSet;
13: import java.util.Iterator;
14: import java.util.Set;
15:
16: class ManyToOneAssociationSet<E> extends
17: AbstractManyToOneAssociationCollection<E> implements Set<E> {
18: private Set<E> mDelegate;
19:
20: ManyToOneAssociationSet(AbstractGenericQueryManager manager,
21: int objectId, ManyToOneAssociationDeclaration declaration) {
22: super (manager, objectId, declaration);
23: }
24:
25: protected void ensurePopulatedDelegate() {
26: if (null == mDelegate) {
27: mDelegate = new HashSet<E>(restoreManyToOneAssociations());
28: }
29: }
30:
31: public int size() {
32: ensurePopulatedDelegate();
33: return mDelegate.size();
34: }
35:
36: public boolean isEmpty() {
37: ensurePopulatedDelegate();
38: return mDelegate.isEmpty();
39: }
40:
41: public boolean contains(Object o) {
42: ensurePopulatedDelegate();
43: return mDelegate.contains(o);
44: }
45:
46: public Iterator<E> iterator() {
47: ensurePopulatedDelegate();
48: return mDelegate.iterator();
49: }
50:
51: public Object[] toArray() {
52: ensurePopulatedDelegate();
53: return mDelegate.toArray();
54: }
55:
56: public <T extends Object> T[] toArray(T[] a) {
57: ensurePopulatedDelegate();
58: return mDelegate.toArray(a);
59: }
60:
61: public boolean add(E o) {
62: ensurePopulatedDelegate();
63: return mDelegate.add(o);
64: }
65:
66: public boolean remove(Object o) {
67: ensurePopulatedDelegate();
68: return mDelegate.remove(o);
69: }
70:
71: public boolean containsAll(Collection<?> c) {
72: ensurePopulatedDelegate();
73: return mDelegate.containsAll(c);
74: }
75:
76: public boolean addAll(Collection<? extends E> c) {
77: ensurePopulatedDelegate();
78: return mDelegate.addAll(c);
79: }
80:
81: public boolean removeAll(Collection<?> c) {
82: ensurePopulatedDelegate();
83: return mDelegate.removeAll(c);
84: }
85:
86: public boolean retainAll(Collection<?> c) {
87: ensurePopulatedDelegate();
88: return mDelegate.retainAll(c);
89: }
90:
91: public void clear() {
92: ensurePopulatedDelegate();
93: mDelegate.clear();
94: }
95: }
|