From 6ef494b6f4e5bfc17bf4fa2fd8f69dbc129378e8 Mon Sep 17 00:00:00 2001 From: Henri Yandell Date: Fri, 23 Oct 2009 06:44:45 +0000 Subject: [PATCH] Making private fields final per Sebb's patch to LANG-540 git-svn-id: https://svn.apache.org/repos/asf/commons/proper/lang/trunk@828943 13f79535-47bb-0310-9956-ffa450edef68 --- .../lang/text/translate/LookupTranslator.java | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/src/java/org/apache/commons/lang/text/translate/LookupTranslator.java b/src/java/org/apache/commons/lang/text/translate/LookupTranslator.java index 6eb379225..22fcfa609 100644 --- a/src/java/org/apache/commons/lang/text/translate/LookupTranslator.java +++ b/src/java/org/apache/commons/lang/text/translate/LookupTranslator.java @@ -27,9 +27,9 @@ import java.util.HashMap; // TODO: Replace with a RegexLookup? Performance test. public class LookupTranslator extends CharSequenceTranslator { - private HashMap lookupMap; - private int shortest = Integer.MAX_VALUE; - private int longest = 0; + private final HashMap lookupMap; + private final int shortest; + private final int longest; /** * Define the lookup table to be used in translation @@ -38,16 +38,20 @@ public class LookupTranslator extends CharSequenceTranslator { */ public LookupTranslator(CharSequence[][] lookup) { lookupMap = new HashMap(); + int _shortest = Integer.MAX_VALUE; + int _longest = 0; for(CharSequence[] seq : lookup) { this.lookupMap.put(seq[0], seq[1]); int sz = seq[0].length(); - if(sz < shortest) { - shortest = sz; + if(sz < _shortest) { + _shortest = sz; } - if(sz > longest) { - longest = sz; + if(sz > _longest) { + _longest = sz; } } + shortest = _shortest; + longest = _longest; } /**