[[BackLinksMenu]] = Analysis = == Overview == Property Utilities are additions to the Properties Library that provide extra functionality. == Task requirements == Add utilites that: * Assign values to a property (except Auto Properties) * Clone objects with properties * Other - discuss with the team if something else is needed at this iteration == Task result == The task result should be source code (with unit tests included). == Implementation idea == Cloning should keep only those properties that are needed. == Related == [wiki:PRO_LIB_CORE_TUTORIAL] == How to demo == Present the utilities to the team and run unit tests to demonstrate them. = Design = * Assign - public static void assign(T dest, T source) 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. Implementation can just call a private assign() method that works for a particular property and can decide how to copy it. * Clone - public static T clone(T src) 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. 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. * Single property assign - private static void assign(!ProObject dest, !ProObject source, String propId) 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: ||property types||relation/annotation||value class||value action||comment|| ||!ValueProperty ||@own ||immutable ||error |||| || || ||pro-obj ||pro.clone |||| || || ||else ||error |||| || ||@shared||all ||copy ref |||| || ||none ||immutable ||copy ref ||This includes !FinalProperty obects|| || || ||else ||error |||| |||||||||||| ||!ParentProperty || ||all ||set null ||Better decide whether to keep the same parent in each case.|| |||||||||||| ||!FinalProperty || --> || --> || --> ||Same as !ValueProperty. Should the assign operation be possible? Probably not because it should be immutable|| |||||||||||| ||!ResourceProperty || --> || --> ||none ||do nothing|| ||!AutoProperty || --> || --> ||none ||do nothing|| |||||||||||| ||!ValueListProperty|| --> || --> || --> ||Create a new list and apply the rules for !ValueProperty to the elements of the list as if they are single values|| ||!AutoListProperty || --> || --> ||none ||do nothing|| * New annotation - @Shared 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. * Tests org.sophie2.core.prolib.util.!ProUtilTest = Implementation = ^(Implementation results should be described and linked here (from the wiki or the repository)^ = Testing = = Comments = = Log = [[Include(wiki:PRO_LIB_UTILS_R0_LOG)]]