polygene-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From nic...@apache.org
Subject [06/50] polygene-java git commit: POLYGENE-261 - Fixed the "duplicate should be allowed" for ManyAssociations.
Date Mon, 10 Jul 2017 06:53:08 GMT
POLYGENE-261 - Fixed the "duplicate should be allowed" for ManyAssociations.

Signed-off-by: niclas <niclas@hedhman.org>


Project: http://git-wip-us.apache.org/repos/asf/polygene-java/repo
Commit: http://git-wip-us.apache.org/repos/asf/polygene-java/commit/f5cb14aa
Tree: http://git-wip-us.apache.org/repos/asf/polygene-java/tree/f5cb14aa
Diff: http://git-wip-us.apache.org/repos/asf/polygene-java/diff/f5cb14aa

Branch: refs/heads/es-jooq
Commit: f5cb14aa9aa48786354e28111f2eb327c297640d
Parents: df5fd8a
Author: niclas <niclas@hedhman.org>
Authored: Thu Jun 15 16:30:43 2017 +0800
Committer: niclas <niclas@hedhman.org>
Committed: Thu Jun 15 16:30:43 2017 +0800

----------------------------------------------------------------------
 .../api/association/ManyAssociation.java        | 36 +++++++++++++-------
 .../helpers/DefaultManyAssociationState.java    |  5 ---
 2 files changed, 24 insertions(+), 17 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f5cb14aa/core/api/src/main/java/org/apache/polygene/api/association/ManyAssociation.java
----------------------------------------------------------------------
diff --git a/core/api/src/main/java/org/apache/polygene/api/association/ManyAssociation.java
b/core/api/src/main/java/org/apache/polygene/api/association/ManyAssociation.java
index b7b7f7f..2471b94 100644
--- a/core/api/src/main/java/org/apache/polygene/api/association/ManyAssociation.java
+++ b/core/api/src/main/java/org/apache/polygene/api/association/ManyAssociation.java
@@ -40,18 +40,23 @@ public interface ManyAssociation<T> extends Iterable<T>, AbstractAssociation
      */
     boolean contains( T entity );
 
-    /** Adds an entity reference representing the given entity to the {@code index} slot
of this collection.
+    /**
+     * Adds an entity reference representing the given entity to the {@code index} slot of
this collection.
      * <p>
-     *     {@code index=0} represents the beginning of the collection and if the {@code index}
is equal or larger
-     *     than the length of the collection, the entity reference will be added to the end.
+     * {@code index=0} represents the beginning of the collection and if the {@code index}
is equal or larger
+     * than the length of the collection, the entity reference will be added to the end.
      * </p>
+     *
      * @param entity The entity whose entity reference is to be added to this collection.
-     * @param index the position for the entity to be inserted at.
+     * @param index  the position for the entity to be inserted at, starting at 0. If index
is larger than number
+     *               of references present, then it will be added to the end. If index is
smaller than 0, then it
+     *               will be added at the beginning, position 0.
      * @return true if the entity reference has been added, false otherwise.
      */
     boolean add( int index, T entity );
 
-    /** Adds an entity reference representing the given entity to the end of this collection.
+    /**
+     * Adds an entity reference representing the given entity to the end of this collection.
      *
      * @param entity The entity whose entity reference is to be added to this collection.
      * @return true if the entity reference has been added, false otherwise.
@@ -61,8 +66,9 @@ public interface ManyAssociation<T> extends Iterable<T>, AbstractAssociation
     /**
      * Removes the given entity from this {@code ManyAssociation}.
      * <p>
-     *     The entity reference representing the given entity is removed from this collection.
+     * The entity reference representing the given entity is removed from this collection.
      * </p>
+     *
      * @param entity The entity reference to be removed.
      * @return true if an entity reference was removed, otherwise false
      */
@@ -71,13 +77,15 @@ public interface ManyAssociation<T> extends Iterable<T>, AbstractAssociation
     /**
      * Clear all entities from this {@code ManyAssociation}.
      * <p>
-     *     All entity references present is removed from this collection.
+     * All entity references present is removed from this collection.
      * </p>
+     *
      * @return true if any entity reference was removed, otherwise false
      */
     boolean clear();
 
-    /** Fetch the entity refrence at the given index and fetch the entity from the entity
store.
+    /**
+     * Fetch the entity refrence at the given index and fetch the entity from the entity
store.
      *
      * @param index The index location in the collection of the entity reference to be fetched.
      * @return The retrieved entity that the entity reference of this collection represents.
@@ -86,6 +94,7 @@ public interface ManyAssociation<T> extends Iterable<T>, AbstractAssociation
 
     /**
      * Returns the number of references in this association.
+     *
      * @return the number of references in this association.
      */
     int count();
@@ -94,9 +103,10 @@ public interface ManyAssociation<T> extends Iterable<T>, AbstractAssociation
      * Fetches all entities represented by entity references in this collection and returns
a List of such
      * entities.
      * <p>
-     *     Multiple references to the same entity will be present multiple times in the List,
unlike {@link #toSet()}.
-     *     The order in which the entities were added to this collection is preserved.
+     * Multiple references to the same entity will be present multiple times in the List,
unlike {@link #toSet()}.
+     * The order in which the entities were added to this collection is preserved.
      * </p>
+     *
      * @return a List of entities represented by the entity references in this collection.
      */
     List<T> toList();
@@ -105,15 +115,17 @@ public interface ManyAssociation<T> extends Iterable<T>,
AbstractAssociation
      * Fetches all entities represented by entity references in this collection and returns
a Set of such
      * entities.
      * <p>
-     *     Multiple references to the same entity will NOT be present, unlike {@link #toList()}.
Sets are defined
-     *     to only contain any particular object once. Order is not preserved.
+     * Multiple references to the same entity will NOT be present, unlike {@link #toList()}.
Sets are defined
+     * to only contain any particular object once. Order is not preserved.
      * </p>
+     *
      * @return a Set of entities represented by the entity references in this collection.
      */
     Set<T> toSet();
 
     /**
      * Returns a stream of the references to the associated entities.
+     *
      * @return the references to the associated entities.
      */
     Stream<EntityReference> references();

http://git-wip-us.apache.org/repos/asf/polygene-java/blob/f5cb14aa/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/DefaultManyAssociationState.java
----------------------------------------------------------------------
diff --git a/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/DefaultManyAssociationState.java
b/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/DefaultManyAssociationState.java
index 9e95188..83b883e 100644
--- a/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/DefaultManyAssociationState.java
+++ b/core/spi/src/main/java/org/apache/polygene/spi/entitystore/helpers/DefaultManyAssociationState.java
@@ -55,11 +55,6 @@ public final class DefaultManyAssociationState
     @Override
     public boolean add( int i, EntityReference entityReference )
     {
-        if( references.contains( entityReference ) )
-        {
-            return false;
-        }
-
         references.add( i, entityReference );
         entityState.markUpdated();
         return true;


Mime
View raw message