Return-Path: X-Original-To: archive-asf-public-internal@cust-asf2.ponee.io Delivered-To: archive-asf-public-internal@cust-asf2.ponee.io Received: from cust-asf.ponee.io (cust-asf.ponee.io [163.172.22.183]) by cust-asf2.ponee.io (Postfix) with ESMTP id 15FDE200CC1 for ; Mon, 10 Jul 2017 08:53:07 +0200 (CEST) Received: by cust-asf.ponee.io (Postfix) id 14A9916716A; Mon, 10 Jul 2017 06:53:07 +0000 (UTC) Delivered-To: archive-asf-public@cust-asf.ponee.io Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by cust-asf.ponee.io (Postfix) with SMTP id 3E17116715B for ; Mon, 10 Jul 2017 08:53:06 +0200 (CEST) Received: (qmail 81788 invoked by uid 500); 10 Jul 2017 06:53:05 -0000 Mailing-List: contact commits-help@polygene.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@polygene.apache.org Delivered-To: mailing list commits@polygene.apache.org Received: (qmail 81625 invoked by uid 99); 10 Jul 2017 06:53:05 -0000 Received: from git1-us-west.apache.org (HELO git1-us-west.apache.org) (140.211.11.23) by apache.org (qpsmtpd/0.29) with ESMTP; Mon, 10 Jul 2017 06:53:05 +0000 Received: by git1-us-west.apache.org (ASF Mail Server at git1-us-west.apache.org, from userid 33) id E0B1AF3F24; Mon, 10 Jul 2017 06:53:03 +0000 (UTC) Content-Type: text/plain; charset="us-ascii" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit From: niclas@apache.org To: commits@polygene.apache.org Date: Mon, 10 Jul 2017 06:53:08 -0000 Message-Id: <8d8b73aac1cf48849a86355b1cde528c@git.apache.org> In-Reply-To: References: X-Mailer: ASF-Git Admin Mailer Subject: [06/50] polygene-java git commit: POLYGENE-261 - Fixed the "duplicate should be allowed" for ManyAssociations. archived-at: Mon, 10 Jul 2017 06:53:07 -0000 POLYGENE-261 - Fixed the "duplicate should be allowed" for ManyAssociations. Signed-off-by: niclas 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 Authored: Thu Jun 15 16:30:43 2017 +0800 Committer: niclas 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 extends Iterable, 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. *

- * {@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. *

+ * * @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 extends Iterable, AbstractAssociation /** * Removes the given entity from this {@code ManyAssociation}. *

- * The entity reference representing the given entity is removed from this collection. + * The entity reference representing the given entity is removed from this collection. *

+ * * @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 extends Iterable, AbstractAssociation /** * Clear all entities from this {@code ManyAssociation}. *

- * All entity references present is removed from this collection. + * All entity references present is removed from this collection. *

+ * * @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 extends Iterable, 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 extends Iterable, AbstractAssociation * Fetches all entities represented by entity references in this collection and returns a List of such * entities. *

- * 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. *

+ * * @return a List of entities represented by the entity references in this collection. */ List toList(); @@ -105,15 +115,17 @@ public interface ManyAssociation extends Iterable, AbstractAssociation * Fetches all entities represented by entity references in this collection and returns a Set of such * entities. *

- * 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. *

+ * * @return a Set of entities represented by the entity references in this collection. */ Set toSet(); /** * Returns a stream of the references to the associated entities. + * * @return the references to the associated entities. */ Stream 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;