You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@turbine.apache.org by gk...@apache.org on 2022/01/10 14:04:33 UTC

[turbine-fulcrum-localization] 02/03: Update: Use Java 8 streams and Method refs, update .gitignore

This is an automated email from the ASF dual-hosted git repository.

gk pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/turbine-fulcrum-localization.git

commit 57a4c9d9d1268cb9e1d2d83192accad7f7c9fad8
Author: Georg Kallidis <gk...@apache.org>
AuthorDate: Tue Dec 14 12:06:39 2021 +0100

    Update:  Use Java 8 streams and Method refs, update .gitignore
---
 .gitignore                                         |  3 ++-
 pom.xml                                            | 10 ++--------
 .../fulcrum/localization/LocaleTokenizer.java      | 23 ++++++++++++++++++----
 3 files changed, 23 insertions(+), 13 deletions(-)

diff --git a/.gitignore b/.gitignore
index 4dd87bc..b294244 100644
--- a/.gitignore
+++ b/.gitignore
@@ -1,4 +1,5 @@
-target
+target/
+.settings/
 *.log
 .classpath
 .project
diff --git a/pom.xml b/pom.xml
index 707774e..064dd38 100644
--- a/pom.xml
+++ b/pom.xml
@@ -32,18 +32,13 @@
   <description>Fulcrum Localization Service</description>
   <url>http://turbine.apache.org/fulcrum/fulcrum-localization</url>
 
-  <!-- Required for staging to work -->
-    <!-- distributionManagement id and url defined in parent -->
-    <distributionManagement>
-      <site>
-          <name>Fulcrum Localization Website</name>
-        </site>
-   </distributionManagement>
 
   <scm>
     <connection>scm:git:https://gitbox.apache.org/repos/asf/turbine-fulcrum-localization.git</connection>
     <developerConnection>scm:git:https://gitbox.apache.org/repos/asf/turbine-fulcrum-localization.git</developerConnection>
     <url>https://gitbox.apache.org/repos/asf/turbine-fulcrum-localization.git</url>
+    <url>https://github.com/apache/turbine-fulcrum-localization/tree/${project.scm.tag}</url>
+    <tag>HEAD</tag>
   </scm>
 
   <developers>
@@ -124,7 +119,6 @@
     <turbine.site.path>turbine-fulcrum-localization</turbine.site.path>
     <turbine.scmPubCheckoutDirectory>${turbine.site.cache}/fulcrum/localization</turbine.scmPubCheckoutDirectory>
     <turbine.site.cache>${project.build.directory}/turbine-sites</turbine.site.cache>
-    <siteContent.path>${project.build.directory}/staging</siteContent.path><!-- default stagingSiteURL -->
   </properties>  
 	
 </project>
diff --git a/src/java/org/apache/fulcrum/localization/LocaleTokenizer.java b/src/java/org/apache/fulcrum/localization/LocaleTokenizer.java
index 7176f25..760dcf7 100644
--- a/src/java/org/apache/fulcrum/localization/LocaleTokenizer.java
+++ b/src/java/org/apache/fulcrum/localization/LocaleTokenizer.java
@@ -25,6 +25,7 @@ import java.util.Collections;
 import java.util.Iterator;
 import java.util.Locale;
 import java.util.NoSuchElementException;
+import java.util.Objects;
 import java.util.StringTokenizer;
 
 /**
@@ -52,12 +53,12 @@ public class LocaleTokenizer
      * The default quality value for an <code>AcceptLanguage</code>
      * object.
      */
-    protected static final Float DEFAULT_QUALITY = new Float(1.0f);
+    protected static final Float DEFAULT_QUALITY = 1.0f;
 
     /**
      * The parsed locales.
      */
-    private ArrayList<AcceptLanguage> locales = new ArrayList<AcceptLanguage>(3);
+    private ArrayList<AcceptLanguage> locales = new ArrayList<>(3);
 
     /**
      * Parses the <code>Accept-Language</code> header.
@@ -113,7 +114,7 @@ public class LocaleTokenizer
         }
 
         // Sort by quality in descending order.
-        Collections.sort(locales, Collections.reverseOrder());
+        locales.sort(Collections.reverseOrder());
     }
 
     /**
@@ -137,12 +138,13 @@ public class LocaleTokenizer
         {
             throw new NoSuchElementException();
         }
-        return ((AcceptLanguage) locales.remove(0)).locale;
+        return (locales.remove(0)).locale;
     }
 
     /**
      * Not implemented.
      */
+    @Override
     public final void remove()
     {
         throw new UnsupportedOperationException(getClass().getName() +
@@ -181,5 +183,18 @@ public class LocaleTokenizer
 			}
 				
         }
+
+        @Override
+        public boolean equals(Object o) {
+            if (this == o) return true;
+            if (!(o instanceof AcceptLanguage)) return false;
+            AcceptLanguage that = (AcceptLanguage) o;
+            return quality.equals(that.quality);
+        }
+
+        @Override
+        public int hashCode() {
+            return Objects.hash(locale, quality);
+        }
     }
 }