From commits-return-6449-apmail-sis-commits-archive=sis.apache.org@sis.apache.org Wed Oct 7 19:37:11 2015 Return-Path: X-Original-To: apmail-sis-commits-archive@www.apache.org Delivered-To: apmail-sis-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 7482F18C31 for ; Wed, 7 Oct 2015 19:37:11 +0000 (UTC) Received: (qmail 28038 invoked by uid 500); 7 Oct 2015 19:37:11 -0000 Delivered-To: apmail-sis-commits-archive@sis.apache.org Received: (qmail 28010 invoked by uid 500); 7 Oct 2015 19:37:11 -0000 Mailing-List: contact commits-help@sis.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: sis-dev@sis.apache.org Delivered-To: mailing list commits@sis.apache.org Received: (qmail 27997 invoked by uid 99); 7 Oct 2015 19:37:11 -0000 Received: from Unknown (HELO spamd3-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Wed, 07 Oct 2015 19:37:11 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd3-us-west.apache.org (ASF Mail Server at spamd3-us-west.apache.org) with ESMTP id 75B47180E49 for ; Wed, 7 Oct 2015 19:37:10 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd3-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 1.79 X-Spam-Level: * X-Spam-Status: No, score=1.79 tagged_above=-999 required=6.31 tests=[KAM_ASCII_DIVIDERS=0.8, KAM_LAZY_DOMAIN_SECURITY=1, T_RP_MATCHES_RCVD=-0.01] autolearn=disabled Received: from mx1-us-west.apache.org ([10.40.0.8]) by localhost (spamd3-us-west.apache.org [10.40.0.10]) (amavisd-new, port 10024) with ESMTP id cCesbFKZEUki for ; Wed, 7 Oct 2015 19:37:09 +0000 (UTC) Received: from mailrelay1-us-west.apache.org (mailrelay1-us-west.apache.org [209.188.14.139]) by mx1-us-west.apache.org (ASF Mail Server at mx1-us-west.apache.org) with ESMTP id 30C0523032 for ; Wed, 7 Oct 2015 19:37:09 +0000 (UTC) Received: from svn01-us-west.apache.org (svn.apache.org [10.41.0.6]) by mailrelay1-us-west.apache.org (ASF Mail Server at mailrelay1-us-west.apache.org) with ESMTP id 9650CE0339 for ; Wed, 7 Oct 2015 19:37:08 +0000 (UTC) Received: from svn01-us-west.apache.org (localhost [127.0.0.1]) by svn01-us-west.apache.org (ASF Mail Server at svn01-us-west.apache.org) with ESMTP id 042B63A02E5 for ; Wed, 7 Oct 2015 19:37:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: svn commit: r1707365 - in /sis/branches/JDK8/core: sis-metadata/src/main/java/org/apache/sis/internal/metadata/ sis-metadata/src/main/java/org/apache/sis/metadata/iso/ sis-utility/src/main/java/org/apache/sis/internal/util/ Date: Wed, 07 Oct 2015 19:37:07 -0000 To: commits@sis.apache.org From: desruisseaux@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20151007193708.042B63A02E5@svn01-us-west.apache.org> Author: desruisseaux Date: Wed Oct 7 19:37:07 2015 New Revision: 1707365 URL: http://svn.apache.org/viewvc?rev=1707365&view=rev Log: Remove a OtherLocales method which was duplicated in CollectionsExt. Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/OtherLocales.java sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/OtherLocales.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/OtherLocales.java?rev=1707365&r1=1707364&r2=1707365&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/OtherLocales.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/internal/metadata/OtherLocales.java [UTF-8] Wed Oct 7 19:37:07 2015 @@ -147,28 +147,6 @@ public final class OtherLocales extends } /** - * Returns the first element of the given collection, or {@code null} if none. - * This method does not emit warning if more than one element is found. - * Consequently, this method should be used only when multi-occurrence is not ambiguous. - * - *

Note: while defined in {@code OtherLocales} because the primary use for this method is to - * get the default locale, this method is also opportunistically used for other legacy properties.

- * - * @param The type of elements in the collection. - * @param values The collection from which to get the first element, or {@code null}. - * @return The first element found in the given collection, or {@code null}. - */ - public static T getFirst(final Collection values) { - if (values != null) { - final Iterator it = values.iterator(); - if (it.hasNext()) { - return it.next(); - } - } - return null; - } - - /** * Sets the first element in the given collection to the given value. * Special cases: * @@ -185,6 +163,8 @@ public final class OtherLocales extends * @param values The collection where to add the new value, or {@code null}. * @param newValue The new value to set, or {@code null} for instead removing the first element. * @return The collection (may or may not be the given {@code values} collection). + * + * @see org.apache.sis.internal.util.CollectionsExt#first(Iterable) */ public static Collection setFirst(Collection values, final T newValue) { if (values == null) { Modified: sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java?rev=1707365&r1=1707364&r2=1707365&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-metadata/src/main/java/org/apache/sis/metadata/iso/DefaultMetadata.java [UTF-8] Wed Oct 7 19:37:07 2015 @@ -64,6 +64,7 @@ import org.apache.sis.metadata.iso.ident import org.apache.sis.metadata.iso.identification.DefaultDataIdentification; import org.apache.sis.internal.metadata.LegacyPropertyAdapter; import org.apache.sis.internal.metadata.OtherLocales; +import org.apache.sis.internal.util.CollectionsExt; import org.apache.sis.internal.jaxb.code.PT_Locale; import org.apache.sis.internal.jaxb.Context; import org.apache.sis.xml.Namespaces; @@ -455,7 +456,7 @@ public class DefaultMetadata extends ISO @Deprecated @XmlElement(name = "language") public Locale getLanguage() { - return OtherLocales.getFirst(getLanguages()); + return CollectionsExt.first(getLanguages()); // No warning if the collection contains more than one locale, because // this is allowed by the "getLanguage() + getLocales()" contract. } @@ -504,7 +505,7 @@ public class DefaultMetadata extends ISO @Deprecated public void setLocales(final Collection newValues) { checkWritePermission(); - setLanguages(OtherLocales.merge(OtherLocales.getFirst(languages), newValues)); // See "Note about deprecated methods implementation" + setLanguages(OtherLocales.merge(CollectionsExt.first(languages), newValues)); // See "Note about deprecated methods implementation" } /** @@ -1129,7 +1130,7 @@ public class DefaultMetadata extends ISO final URI uri = new URI(newValue); checkWritePermission(); Collection info = identificationInfo; // See "Note about deprecated methods implementation" - AbstractIdentification firstId = AbstractIdentification.castOrCopy(OtherLocales.getFirst(info)); + AbstractIdentification firstId = AbstractIdentification.castOrCopy(CollectionsExt.first(info)); if (firstId == null) { firstId = new DefaultDataIdentification(); } @@ -1138,7 +1139,7 @@ public class DefaultMetadata extends ISO citation = new DefaultCitation(); } Collection onlineResources = citation.getOnlineResources(); - DefaultOnlineResource firstOnline = DefaultOnlineResource.castOrCopy(OtherLocales.getFirst(onlineResources)); + DefaultOnlineResource firstOnline = DefaultOnlineResource.castOrCopy(CollectionsExt.first(onlineResources)); if (firstOnline == null) { firstOnline = new DefaultOnlineResource(); } @@ -1435,7 +1436,7 @@ public class DefaultMetadata extends ISO * This method sets the locale to be used for XML marshalling to the metadata language. */ private void beforeMarshal(final Marshaller marshaller) { - Context.push(OtherLocales.getFirst(languages)); + Context.push(CollectionsExt.first(languages)); } /** Modified: sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java URL: http://svn.apache.org/viewvc/sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java?rev=1707365&r1=1707364&r2=1707365&view=diff ============================================================================== --- sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java [UTF-8] (original) +++ sis/branches/JDK8/core/sis-utility/src/main/java/org/apache/sis/internal/util/CollectionsExt.java [UTF-8] Wed Oct 7 19:37:07 2015 @@ -63,7 +63,10 @@ public final class CollectionsExt extend /** * Returns the first element of the given iterable, or {@code null} if none. - * This method is null-safe. Note that the first element may be null. + * This method does not emit warning if more than one element is found. + * Consequently, this method should be used only when multi-occurrence is not ambiguous. + * + *

This method is null-safe. Note however that the first element may be null.

* * @param The type of elements contained in the iterable. * @param collection The iterable from which to get the first element, or {@code null}.