Changes between Version 15 and Version 16 of PRO_LIB_UTILS_R0
- Timestamp:
- 12/11/08 13:07:27 (16 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
PRO_LIB_UTILS_R0
v15 v16 27 27 !ProUtil should provide functionality for "smart" copying of properties. "Smart" means that depending on specific objects a person can expect only the reference to the object to be copied or to change a little the copy to identify it as a copy or can expect a "deep" copy (means copy not only the object, but also objects used inside). So "smart" copy should follow some expected behaviour. What the common behavior is depends not only on object type but also on its connection to other objects and their mutability i.e. whether it is in a parent-child relation or whether points to an object that is mutable or immutable or automatic. 28 28 29 * Assign - public static <T extends !ProObject> void assign(T dest, T source) 29 * New annotation - @Shared 30 A new annotation should be created in org.sophie2.core.prolib.annot. This annotation is for the smart copying of objects. If a property is marked as @Shared, this means that the value it holds should be the same for all objects using this property. In other words, when copying such property the new property should hold a reference to the value, not a clone of the value. 31 32 * Assign - public static <T extends !ProObject> void assign(T dest, T source) in the !ProUtil class in org.sophie2.core.prolib.util package 30 33 The assign() method should copy the values of all properties of the source !ProObject to the destionation !ProObject. It should be a "smart" copy, so for each property should be decided how to be copied. 31 34 32 35 Implementation can just call a private assign() method that works for a particular property and can decide how to copy it. 33 36 34 * Clone - public static <T extends !ProObject> T clone(T src) 37 * Clone - public static <T extends !ProObject> T clone(T src) in the !ProUtil class in org.sophie2.core.prolib.util package 35 38 The clone() method should make a new !ProObject instance which is a copy of the original object. The properties in the new instance have their values assigned from the original object. 36 39 37 40 Implementation can just make a new !ProObject instance and then call the assign() method to copy all property values from the original to the new instance. 38 41 39 * Single property assign - private static <T extends !ProObject> void assign(!ProObject dest, !ProObject source, String propId) 42 * Single property assign - private static <T extends !ProObject> void assign(!ProObject dest, !ProObject source, String propId) in the !ProUtil class in org.sophie2.core.prolib.util package 40 43 The assign() method should take care about property types and annotations to decide what to do when trying to copy data. Here are all the cases: 41 44 ||property types||relation/annotation||value class||value action||comment|| … … 58 61 ||!AutoListProperty || --> || --> ||none ||do nothing|| 59 62 60 * New annotation - @Shared61 A new annotation should be created in org.sophie2.core.prolib.annot. This annotation is for the smart copying of objects. If a property is marked as @Shared, this means that the value it holds should be the same for all objects using this property. In other words, when copying such property the new property should hold a reference to the value, not a clone of the value.62 63 63 * Tests 64 64 [source:trunk/sophie2-platform/modules/org.sophie2.core/src/test/java/org/sophie2/core/prolib/util/ProUtilTest.java?rev=728]