01: /*
02: *
03: * JMoney - A Personal Finance Manager
04: * Copyright (c) 2004 Nigel Westbury <westbury@users.sourceforge.net>
05: *
06: *
07: * This program is free software; you can redistribute it and/or modify
08: * it under the terms of the GNU General Public License as published by
09: * the Free Software Foundation; either version 2 of the License, or
10: * (at your option) any later version.
11: *
12: * This program is distributed in the hope that it will be useful,
13: * but WITHOUT ANY WARRANTY; without even the implied warranty of
14: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15: * GNU General Public License for more details.
16: *
17: * You should have received a copy of the GNU General Public License
18: * along with this program; if not, write to the Free Software
19: * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
20: *
21: */
22:
23: package net.sf.jmoney.model2;
24:
25: import java.util.Collection;
26:
27: /**
28: * This interface is the interface to all objects that manage
29: * the sets of values that are the values of a multi-valued
30: * property. For example, the set of all accounts in a session
31: * are managed by an object that implements this interface.
32: */
33: public interface IListManager<E extends ExtendableObject> extends
34: Collection<E> {
35:
36: /**
37: * This method creates a new object in this collection
38: * in the datastore. The new object will be initialized
39: * with default values.
40: *
41: * @param propertySet the property set of the object to create
42: * (this parameter is required because some lists
43: * contain objects of a derivable type, in which case
44: * the exact type of the object to create must be given).
45: * @return the newly created object.
46: */
47: <F extends E> F createNewElement(
48: ExtendablePropertySet<F> propertySet);
49:
50: /**
51: * This method creates a new object in this collection
52: * in the datastore. The new object will be initialized
53: * with property values taken from the given interface.
54: *
55: * @param values values to be set in the properties of the new object
56: * @return the newly created object.
57: */
58: <F extends E> F createNewElement(
59: ExtendablePropertySet<F> propertySet, IValues values);
60:
61: /**
62: * Deletes the given object from this list. Because objects are 'owned' by the
63: * lists, removing it from the list means deleting the object altogether from
64: * the datastore.
65: *
66: * This method should fail if there are references to the object. However,
67: * this is expensive to enforce, so it may not fail. If the underlying datastore
68: * is a relational database and foreign key constraints have been defined
69: * then the database will cause a failure.
70: *
71: * @param extendableObject
72: * @return true if the element was deleted, false if it could not be deleted because
73: * there were references to it
74: */
75: boolean deleteElement(E extendableObject);
76:
77: /**
78: * Moves the given object into this list, removing it from its
79: * original list.
80: *
81: * @param extendableObject
82: * @param originalList
83: */
84: void moveElement(E extendableObject, IListManager originalList);
85: }
|