cayenne-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From aadamc...@apache.org
Subject [cayenne] branch master updated: tagging new ObjectId factory methods with their origin release - 4.2
Date Sat, 07 Sep 2019 07:02:20 GMT
This is an automated email from the ASF dual-hosted git repository.

aadamchik pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/cayenne.git


The following commit(s) were added to refs/heads/master by this push:
     new a5190fb  tagging new ObjectId factory methods with their origin release - 4.2
a5190fb is described below

commit a5190fb3e34ad8c7ac34a744c432099fc818304e
Author: Andrus Adamchik <andrus@objectstyle.com>
AuthorDate: Sat Sep 7 10:02:14 2019 +0300

    tagging new ObjectId factory methods with their origin release - 4.2
---
 .../src/main/java/org/apache/cayenne/ObjectId.java | 47 +++++++++++++++++-----
 1 file changed, 36 insertions(+), 11 deletions(-)

diff --git a/cayenne-server/src/main/java/org/apache/cayenne/ObjectId.java b/cayenne-server/src/main/java/org/apache/cayenne/ObjectId.java
index 88b4918..37d5ba8 100644
--- a/cayenne-server/src/main/java/org/apache/cayenne/ObjectId.java
+++ b/cayenne-server/src/main/java/org/apache/cayenne/ObjectId.java
@@ -24,50 +24,75 @@ import java.util.Map;
 
 /**
  * <p>
- * A portable global identifier for persistent objects. ObjectId can be
- * temporary (used for transient or new uncommitted objects) or permanent (used
- * for objects that have been already stored in DB).
+ * A portable global identifier for persistent objects. ObjectId can be temporary (used for
transient or new
+ * uncommitted objects) or permanent (used for objects that have been already stored in DB).
  * <p>
- * A temporary ObjectId stores object entity name and a pseudo-unique binary key;
- * permanent id stores a map of values from an external persistent store (aka "primary key").
+ * A temporary ObjectId stores object entity name and a pseudo-unique binary key; permanent
id stores a map of values
+ * from an external persistent store (aka "primary key").
  */
 public interface ObjectId extends Serializable {
 
+    /**
+     * Creates a temporary ObjectId for a given entity.
+     *
+     * @since 4.2
+     */
     static ObjectId of(String entityName) {
         return new ObjectIdTmp(entityName);
     }
 
+    /**
+     * Creates a temporary ObjectId for a given entity, using provided unique id key.
+     *
+     * @since 4.2
+     */
     static ObjectId of(String entityName, byte[] tmpKey) {
         return new ObjectIdTmp(entityName, tmpKey);
     }
 
+    /**
+     * Creates a single key/value permanent ObjectId.
+     *
+     * @since 4.2
+     */
     static ObjectId of(String entityName, String keyName, Object value) {
-        if(value instanceof Number) {
-            return new ObjectIdNumber(entityName, keyName, (Number)value);
+        if (value instanceof Number) {
+            return new ObjectIdNumber(entityName, keyName, (Number) value);
         }
         return new ObjectIdSingle(entityName, keyName, value);
     }
 
+    /**
+     * Creates an ObjectId using another id as a template, but for a different entity. Useful
inside the Cayenne stack
+     * when resolving inheritance hierarchies.
+     *
+     * @since 4.2
+     */
     static ObjectId of(String entityName, ObjectId objectId) {
-        if(objectId instanceof ObjectIdNumber) {
+        if (objectId instanceof ObjectIdNumber) {
             ObjectIdNumber id = (ObjectIdNumber) objectId;
             return new ObjectIdNumber(entityName, id.getKeyName(), id.getValue());
         }
 
-        if(objectId instanceof ObjectIdSingle) {
+        if (objectId instanceof ObjectIdSingle) {
             ObjectIdSingle id = (ObjectIdSingle) objectId;
             return new ObjectIdSingle(entityName, id.getKeyName(), id.getValue());
         }
 
-        if(objectId instanceof ObjectIdTmp) {
+        if (objectId instanceof ObjectIdTmp) {
             return of(entityName, objectId.getKey());
         }
 
         return of(entityName, objectId.getIdSnapshot());
     }
 
+    /**
+     * Creates an ObjectId, potentially mapped to multiple columns.
+     *
+     * @since 4.2
+     */
     static ObjectId of(String entityName, Map<String, ?> values) {
-        if(values.size() == 1) {
+        if (values.size() == 1) {
             Map.Entry<String, ?> entry = values.entrySet().iterator().next();
             return of(entityName, entry.getKey(), entry.getValue());
         }


Mime
View raw message