Previously, some developers accidentally introduced Java 7 Objects class utility methods. At that time, we once added Java 6 compatible implementation in com.ibm.icu.impl.Utility class. Now, we use Java 7 as the minimum supported Java version, so we can use Java 7 Objects class and methods.
There are some extra changes dropping generics type from constructor. For example from `ArrayList<String> output = new ArrayList<String>();` to `ArrayList<String> output = new ArrayList<>();`. The updated syntax is allowed since Java 7. We have eclipse project configured to normalize such expression, therefore, files touched by this commit were automatically updated. These changes are not directly related to Java 7 Objects method replacement.
import java.text.CharacterIterator;
import java.text.ParseException;
import java.util.Arrays;
+import java.util.Objects;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
import com.ibm.icu.impl.ClassLoaderUtil;
import com.ibm.icu.impl.Normalizer2Impl;
import com.ibm.icu.impl.Normalizer2Impl.ReorderingBuffer;
-import com.ibm.icu.impl.Utility;
import com.ibm.icu.impl.coll.BOCSU;
import com.ibm.icu.impl.coll.Collation;
import com.ibm.icu.impl.coll.CollationCompare;
*
* <p>
* <strong>Note</strong> that there are some differences between the Collation rule syntax used in Java and ICU4J:
- *
+ *
* <ul>
* <li>According to the JDK documentation: <br>
* <i>Modifier '!' : Turns on Thai/Lao vowel-consonant swapping. If this rule is in force when a Thai vowel of the range
* <strong>Examples</strong>
* <p>
* Creating Customized RuleBasedCollators: <blockquote>
- *
+ *
* <pre>
* String simple = "& a < b < c < d";
* RuleBasedCollator simpleCollator = new RuleBasedCollator(simple);
* + ", \u00C6 < \u00F8 , \u00D8";
* RuleBasedCollator norwegianCollator = new RuleBasedCollator(norwegian);
* </pre>
- *
+ *
* </blockquote>
- *
+ *
* Concatenating rules to combine <code>Collator</code>s: <blockquote>
- *
+ *
* <pre>
* // Create an en_US Collator object
* RuleBasedCollator en_USCollator = (RuleBasedCollator)
* new RuleBasedCollator(en_USRules + da_DKRules);
* // newCollator has the combined rules
* </pre>
- *
+ *
* </blockquote>
- *
+ *
* Making changes to an existing RuleBasedCollator to create a new <code>Collator</code> object, by appending changes to
* the existing rule: <blockquote>
- *
+ *
* <pre>
* // Create a new Collator object with additional rules
* String addRules = "& C < ch, cH, Ch, CH";
* new RuleBasedCollator(en_USCollator.getRules() + addRules);
* // myCollator contains the new rules
* </pre>
- *
+ *
* </blockquote>
- *
+ *
* How to change the order of non-spacing accents: <blockquote>
- *
+ *
* <pre>
* // old rule with main accents
* String oldRules = "= \u0301 ; \u0300 ; \u0302 ; \u0308 "
* String addOn = "& \u0300 ; \u0308 ; \u0302";
* RuleBasedCollator myCollator = new RuleBasedCollator(oldRules + addOn);
* </pre>
- *
+ *
* </blockquote>
- *
+ *
* Putting in a new primary ordering before the default setting, e.g. sort English characters before or after Japanese
* characters in the Japanese <code>Collator</code>: <blockquote>
- *
+ *
* <pre>
* // get en_US Collator rules
* RuleBasedCollator en_USCollator
* RuleBasedCollator myJapaneseCollator
* = new RuleBasedCollator(en_USCollator.getRules() + jaString);
* </pre>
- *
+ *
* </blockquote>
* <p>
* This class is not subclassable
/**
* Clones the RuleBasedCollator
- *
+ *
* @return a new instance of this RuleBasedCollator object
* @stable ICU 2.8
*/
/**
* Return a CollationElementIterator for the given String.
- *
+ *
* @see CollationElementIterator
* @stable ICU 2.8
*/
/**
* Return a CollationElementIterator for the given CharacterIterator. The source iterator's integrity will be
* preserved since a new copy will be created for use.
- *
+ *
* @see CollationElementIterator
* @stable ICU 2.8
*/
/**
* Return a CollationElementIterator for the given UCharacterIterator. The source iterator's integrity will be
* preserved since a new copy will be created for use.
- *
+ *
* @see CollationElementIterator
* @stable ICU 2.8
*/
try {
RuleBasedCollator result = (RuleBasedCollator) super.clone();
// since all collation data in the RuleBasedCollator do not change
- // we can safely assign the result.fields to this collator
+ // we can safely assign the result.fields to this collator
// except in cases where we can't
result.settings = settings.clone();
result.collationBuffer = null;
* Sets whether uppercase characters sort before lowercase characters or vice versa, in strength TERTIARY. The
* default mode is false, and so lowercase characters sort before uppercase characters. If true, sort upper case
* characters first.
- *
+ *
* @param upperfirst
* true to sort uppercase characters before lowercase characters, false to sort lowercase characters
* before uppercase characters
* Sets the orders of lower cased characters to sort before upper cased characters, in strength TERTIARY. The
* default mode is false. If true is set, the RuleBasedCollator will sort lower cased characters before the upper
* cased ones. Otherwise, if false is set, the RuleBasedCollator will ignore case preferences.
- *
+ *
* @param lowerfirst
* true for sorting lower cased characters before upper cased characters, false to ignore case
* preferences.
/**
* Sets the case first mode to the initial mode set during construction of the RuleBasedCollator. See
* setUpperCaseFirst(boolean) and setLowerCaseFirst(boolean) for more details.
- *
+ *
* @see #isLowerCaseFirst
* @see #isUpperCaseFirst
* @see #setLowerCaseFirst(boolean)
/**
* Sets the alternate handling mode to the initial mode set during construction of the RuleBasedCollator. See
* setAlternateHandling(boolean) for more details.
- *
+ *
* @see #setAlternateHandlingShifted(boolean)
* @see #isAlternateHandlingShifted()
* @stable ICU 2.8
/**
* Sets the case level mode to the initial mode set during construction of the RuleBasedCollator. See
* setCaseLevel(boolean) for more details.
- *
+ *
* @see #setCaseLevel(boolean)
* @see #isCaseLevel
* @stable ICU 2.8
/**
* Sets the decomposition mode to the initial mode set during construction of the RuleBasedCollator. See
* setDecomposition(int) for more details.
- *
+ *
* @see #getDecomposition
* @see #setDecomposition(int)
* @stable ICU 2.8
/**
* Sets the French collation mode to the initial mode set during construction of the RuleBasedCollator. See
* setFrenchCollation(boolean) for more details.
- *
+ *
* @see #isFrenchCollation
* @see #setFrenchCollation(boolean)
* @stable ICU 2.8
/**
* Sets the collation strength to the initial mode set during the construction of the RuleBasedCollator. See
* setStrength(int) for more details.
- *
+ *
* @see #setStrength(int)
* @see #getStrength
* @stable ICU 2.8
* which treats SECONDARY weights in the order they appear. If set to true, the SECONDARY weights will be sorted
* backwards. See the section on <a href="http://userguide.icu-project.org/collation/architecture">
* French collation</a> for more information.
- *
+ *
* @param flag
* true to set the French collation on, false to set it off
* @stable ICU 2.8
* the code points with non-ignorable primary weights in the same way. If the mode is set to true, the behavior
* corresponds to SHIFTED defined in UCA, this causes code points with PRIMARY orders that are equal or below the
* variable top value to be ignored in PRIMARY order and moved to the QUATERNARY order.
- *
+ *
* @param shifted
* true if SHIFTED behavior for alternate handling is desired, false for the NON_IGNORABLE behavior.
* @see #isAlternateHandlingShifted
* considered significant during comparison.
*
* <p>See the Collator class description for an example of use.
- *
+ *
* @param newStrength
* the new strength value.
* @see #getStrength
* the top of one of the supported reordering groups,
* and it must not be beyond the last of those groups.
* See {@link #setMaxVariable(int)}.
- *
+ *
* @param varTop
* one or more (if contraction) characters to which the variable top should be set
* @return variable top primary weight
* the top of one of the supported reordering groups,
* and it must not be beyond the last of those groups.
* See {@link #setMaxVariable(int)}.
- *
+ *
* @param varTop primary weight, as returned by setVariableTop or getVariableTop
* @see #getVariableTop
* @see #setVariableTop(String)
/**
* Gets the collation tailoring rules for this RuleBasedCollator.
* Equivalent to String getRules(false).
- *
+ *
* @return the collation tailoring rules
* @see #getRules(boolean)
* @stable ICU 2.8
* Returns current rules.
* The argument defines whether full rules (root collation + tailored) rules are returned
* or just the tailoring.
- *
+ *
* <p>The root collation rules are an <i>approximation</i> of the root collator's sort order.
* They are almost never used or useful at runtime and can be removed from the data.
* See <a href="http://userguide.icu-project.org/collation/customization#TOC-Building-on-Existing-Locales">User Guide:
/**
* Get a UnicodeSet that contains all the characters and sequences tailored in this collator.
- *
+ *
* @return a pointer to a UnicodeSet object containing all the code points and sequences that may sort differently
* than in the root collator.
* @stable ICU 2.4
/**
* Gets unicode sets containing contractions and/or expansions of a collator
- *
+ *
* @param contractions
* if not null, set to contain contractions
* @param expansions
* @internal
* @deprecated This API is ICU internal only.
*/
+ @Deprecated
void internalAddContractions(int c, UnicodeSet set) {
new ContractionsAndExpansions(set, null, null, false).forCodePoint(data, c);
}
* Gets the simpler form of a CollationKey for the String source following the rules of this Collator and stores the
* result into the user provided argument key. If key has a internal byte array of length that's too small for the
* result, the internal byte array will be grown to the exact required size.
- *
+ *
* @param source the text String to be transformed into a RawCollationKey
* @param key output RawCollationKey to store results
* @return If key is null, a new instance of RawCollationKey will be created and returned, otherwise the user
/**
* Return true if an uppercase character is sorted before the corresponding lowercase character. See
* setCaseFirst(boolean) for details.
- *
+ *
* @see #setUpperCaseFirst
* @see #setLowerCaseFirst
* @see #isLowerCaseFirst
/**
* Return true if a lowercase character is sorted before the corresponding uppercase character. See
* setCaseFirst(boolean) for details.
- *
+ *
* @see #setUpperCaseFirst
* @see #setLowerCaseFirst
* @see #isUpperCaseFirst
* then the alternate handling attribute for the Collator is SHIFTED. Otherwise if return value is false, then the
* alternate handling attribute for the Collator is NON_IGNORABLE See setAlternateHandlingShifted(boolean) for more
* details.
- *
+ *
* @return true or false
* @see #setAlternateHandlingShifted(boolean)
* @see #setAlternateHandlingDefault
/**
* Checks if case level is set to true. See setCaseLevel(boolean) for details.
- *
+ *
* @return the case level mode
* @see #setCaseLevelDefault
* @see #isCaseLevel
/**
* Checks if French Collation is set to true. See setFrenchCollation(boolean) for details.
- *
+ *
* @return true if French Collation is set to true, false otherwise
* @see #setFrenchCollation(boolean)
* @see #setFrenchCollationDefault
/**
* {@icu} Gets the variable top value of a Collator.
- *
+ *
* @return the variable top primary weight
* @see #getMaxVariable
* @stable ICU 2.6
/**
* Method to retrieve the numeric collation value. When numeric collation is turned on, this Collator generates a
* collation key for the numeric value of substrings of digits. This is a way to get '100' to sort AFTER '2'
- *
+ *
* @see #setNumericCollation
* @see #setNumericCollationDefault
* @return true if numeric collation is turned on, false otherwise
return (settings.readOnly().options & CollationSettings.NUMERIC) != 0;
}
- /**
+ /**
* Retrieves the reordering codes for this collator.
* These reordering codes are a combination of UScript codes and ReorderCodes.
- * @return a copy of the reordering codes for this collator;
+ * @return a copy of the reordering codes for this collator;
* if none are set then returns an empty array
* @see #setReorderCodes
* @see Collator#getEquivalentReorderCodes
* @stable ICU 4.8
- */
+ */
@Override
public int[] getReorderCodes() {
return settings.readOnly().reorderCodes.clone();
/**
* Generates a unique hash code for this RuleBasedCollator.
- *
+ *
* @return the unique hash code for this Collator
* @stable ICU 2.8
*/
/**
* Get the version of this collator object.
- *
+ *
* @return the version object associated with this collator
* @stable ICU 2.8
*/
/**
* Get the UCA version of this collator object.
- *
+ *
* @return the version object associated with this collator
* @stable ICU 2.8
*/
// Another check we could do is that the actual locale is at
// the same level or less specific than the valid locale.
// TODO: Starting with Java 7, use Objects.equals(a, b).
- if(Utility.objectEquals(actual, tailoring.actualLocale)) {
+ if(Objects.equals(actual, tailoring.actualLocale)) {
actualLocaleIsSameAsValid = false;
} else {
- assert(Utility.objectEquals(actual, valid));
+ assert(Objects.equals(actual, valid));
actualLocaleIsSameAsValid = true;
}
// Do not modify tailoring.actualLocale:
*/
package com.ibm.icu.impl;
+import java.util.Objects;
+
import com.ibm.icu.util.Freezable;
* Convenience Methods
*/
public static <C0, C1> R2<C0,C1> of(C0 p0, C1 p1) {
- return new R2<C0,C1>(p0,p1);
+ return new R2<>(p0,p1);
}
public static <C0, C1, C2> R3<C0,C1,C2> of(C0 p0, C1 p1, C2 p2) {
- return new R3<C0,C1,C2>(p0,p1,p2);
+ return new R3<>(p0,p1,p2);
}
public static <C0, C1, C2, C3> R4<C0,C1,C2,C3> of(C0 p0, C1 p1, C2 p2, C3 p3) {
- return new R4<C0,C1,C2,C3>(p0,p1,p2,p3);
+ return new R4<>(p0,p1,p2,p3);
}
public static <C0, C1, C2, C3, C4> R5<C0,C1,C2,C3,C4> of(C0 p0, C1 p1, C2 p2, C3 p3, C4 p4) {
- return new R5<C0,C1,C2,C3,C4>(p0,p1,p2,p3,p4);
+ return new R5<>(p0,p1,p2,p3,p4);
}
public static class R2<C0, C1> extends Row<C0, C1, C1, C1, C1> {
}
int i = 0;
for (Object item : items) {
- if (!Utility.objectEquals(item, that.items[i++])) {
+ if (!Objects.equals(item, that.items[i++])) {
return false;
}
}
import java.io.IOException;
import java.util.ArrayList;
-import java.util.Arrays;
import java.util.Locale;
import java.util.regex.Pattern;
return a == b;
}
- /**
- * Convenience utility. Does null checks on objects, then calls equals.
- */
- public final static boolean objectEquals(Object a, Object b) {
- return a == null ?
- b == null ? true : false :
- b == null ? false : a.equals(b);
- }
-
/**
* Convenience utility. Does null checks on objects, then calls compare.
*/
public static String[] split(String s, char divider) {
int last = 0;
int i;
- ArrayList<String> output = new ArrayList<String>();
+ ArrayList<String> output = new ArrayList<>();
for (i = 0; i < s.length(); ++i) {
if (s.charAt(i) == divider) {
output.add(s.substring(last,i));
return buffer.toString();
}
- /**
- * This implementation is equivalent to Java 7+ Objects#equals(Object a, Object b)
- *
- * @param a an object
- * @param b an object to be compared with a for equality
- * @return true if the arguments are equal to each other and false otherwise
- */
- public static boolean equals(Object a, Object b) {
- return (a == b)
- || (a != null && b != null && a.equals(b));
- }
-
- /**
- * This implementation is equivalent to Java 7+ Objects#hash(Object... values)
- * @param values the values to be hashed
- * @return a hash value of the sequence of input values
- */
- public static int hash(Object... values) {
- return Arrays.hashCode(values);
- }
-
- /**
- * This implementation is equivalent to Java 7+ Objects#hashCode(Object o)
- * @param o an object
- * @return a hash value of a non-null argument and 0 for null argument
- */
- public static int hashCode(Object o) {
- return o == null ? 0 : o.hashCode();
- }
-
- /**
- * This implementation is equivalent to Java 7+ Objects#toString(Object o)
- * @param o an object
- * @return the result of calling toStirng for a non-null argument and "null" for a
- * null argument
- */
- public static String toString(Object o) {
- return o == null ? "null" : o.toString();
- }
-
/**
* This implementation is equivalent to Java 8+ Math#addExact(int, int)
* @param x the first value
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Objects;
import java.util.Set;
import java.util.TreeMap;
import com.ibm.icu.impl.ICUData;
import com.ibm.icu.impl.ICUResourceBundle;
-import com.ibm.icu.impl.Utility;
import com.ibm.icu.impl.locale.XCldrStub.HashMultimap;
import com.ibm.icu.impl.locale.XCldrStub.Multimap;
import com.ibm.icu.impl.locale.XCldrStub.Multimaps;
static final Maker HASHMAP = new Maker() {
@Override
public Map<Object,Object> make() {
- return new HashMap<Object,Object>();
+ return new HashMap<>();
}
};
static final Maker TREEMAP = new Maker() {
@Override
public Map<Object,Object> make() {
- return new TreeMap<Object,Object>();
+ return new TreeMap<>();
}
};
}
UResourceBundle metadata = UResourceBundle.getBundleInstance(ICUData.ICU_BASE_NAME,"metadata",ICUResourceBundle.ICU_DATA_CLASS_LOADER);
UResourceBundle metadataAlias = metadata.get("alias");
UResourceBundle territoryAlias = metadataAlias.get(key);
- Map<String, String> toCanonical1 = new HashMap<String, String>();
+ Map<String, String> toCanonical1 = new HashMap<>();
for ( int i = 0 ; i < territoryAlias.getSize(); i++ ) {
UResourceBundle res = territoryAlias.get(i);
String aliasFrom = res.getKey();
}
@Override
public int hashCode() {
- return Utility.hash(language, script, region);
+ return Objects.hash(language, script, region);
}
}
}
private static Map<String, String> getDefaultRawData() {
- Map<String, String> rawData = new TreeMap<String, String>();
+ Map<String, String> rawData = new TreeMap<>();
UResourceBundle bundle = UResourceBundle.getBundleInstance( ICUData.ICU_BASE_NAME, "likelySubtags");
for (Enumeration<String> enumer = bundle.getKeys(); enumer.hasMoreElements();) {
String key = enumer.nextElement();
// Splitter bar = Splitter.on('_');
// int last = -1;
// set the base data
- Map<LSR,LSR> internCache = new HashMap<LSR,LSR>();
+ Map<LSR,LSR> internCache = new HashMap<>();
for (Entry<String, String> sourceTarget : rawData.entrySet()) {
LSR ltp = LSR.from(sourceTarget.getKey());
final String language = ltp.language;
if (value instanceof Map) {
show((Map<?,?>)value, indent+"\t", output);
} else {
- output.append("\t" + Utility.toString(value)).append("\n");
+ output.append("\t" + Objects.toString(value)).append("\n");
}
first = indent;
}
import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Objects;
import java.util.Set;
import java.util.TreeMap;
import java.util.TreeSet;
import com.ibm.icu.impl.ICUResourceBundle;
import com.ibm.icu.impl.Row;
import com.ibm.icu.impl.Row.R4;
-import com.ibm.icu.impl.Utility;
import com.ibm.icu.impl.locale.XCldrStub.CollectionUtilities;
import com.ibm.icu.impl.locale.XCldrStub.ImmutableMap;
import com.ibm.icu.impl.locale.XCldrStub.ImmutableMultimap;
static final LocaleDisplayNames english = LocaleDisplayNames.getInstance(ULocale.ENGLISH);
private static List<R4<String, String, Integer, Boolean>> xGetLanguageMatcherData() {
- List<R4<String, String, Integer, Boolean>> distanceList = new ArrayList<R4<String, String, Integer, Boolean>>();
+ List<R4<String, String, Integer, Boolean>> distanceList = new ArrayList<>();
ICUResourceBundle suppData = LocaleMatcher.getICUSupplementalData();
ICUResourceBundle languageMatchingNew = suppData.findTopLevel("languageMatchingNew");
ICUResourceBundle writtenParadigmLocales = (ICUResourceBundle) languageMatchingInfo.get("written")
.get("paradigmLocales");
// paradigmLocales{ "en", "en-GB",... }
- HashSet<String> paradigmLocales = new HashSet<String>(Arrays.asList(writtenParadigmLocales.getStringArray()));
+ HashSet<String> paradigmLocales = new HashSet<>(Arrays.asList(writtenParadigmLocales.getStringArray()));
return Collections.unmodifiableSet(paradigmLocales);
}
.get("matchVariable");
// matchVariable{ americas{"019"} cnsar{"HK+MO"} ...}
- HashMap<String,String> matchVariables = new HashMap<String,String>();
+ HashMap<String,String> matchVariables = new HashMap<>();
for (Enumeration<String> enumer = writtenMatchVariables.getKeys(); enumer.hasMoreElements(); ) {
String key = enumer.nextElement();
matchVariables.put(key, writtenMatchVariables.getString(key));
}
static class IdMakerFull<T> implements IdMapper<T,Integer> {
- private final Map<T, Integer> objectToInt = new HashMap<T, Integer>();
- private final List<T> intToObject = new ArrayList<T>();
+ private final Map<T, Integer> objectToInt = new HashMap<>();
+ private final List<T> intToObject = new ArrayList<>();
final String name; // for debugging
IdMakerFull(String name) {
(obj != null
&& obj.getClass() == this.getClass()
&& distance == (other = (StringDistanceNode) obj).distance
- && Utility.equals(distanceTable, other.distanceTable)
+ && Objects.equals(distanceTable, other.distanceTable)
&& super.equals(other));
}
@Override
public int hashCode() {
- return distance ^ Utility.hashCode(distanceTable);
+ return distance ^ Objects.hashCode(distanceTable);
}
StringDistanceNode(int distance) {
DistanceNode node = getNode(desired, supported);
if (node == null) {
// get the distance it would have
- Output<DistanceTable> node2 = new Output<DistanceTable>();
+ Output<DistanceTable> node2 = new Output<>();
int distance = getDistance(desired, supported, node2, true);
// now add it
node = addSubtable(desired, supported, distance);
@Override
public String toString(boolean abbreviate) {
- return toString(abbreviate, "", new IdMakerFull<Object>("interner"), new StringBuilder()).toString();
+ return toString(abbreviate, "", new IdMakerFull<>("interner"), new StringBuilder()).toString();
}
public StringBuilder toString(boolean abbreviate, String indent, IdMakerFull<Object> intern, StringBuilder buffer) {
@Override
public Set<String> getCloser(int threshold) {
- Set<String> result = new HashSet<String>();
+ Set<String> result = new HashSet<>();
for (Entry<String, Map<String, DistanceNode>> e1 : subtables.entrySet()) {
String desired = e1.getKey();
for (Entry<String, DistanceNode> e2 : e1.getValue().entrySet()) {
@Override
public Map<String, Set<String>> getInternalMatches() {
- Map<String, Set<String>> result = new LinkedHashMap<String, Set<String>>();
+ Map<String, Set<String>> result = new LinkedHashMap<>();
for (Entry<String, Map<String, DistanceNode>> entry : subtables.entrySet()) {
- result.put(entry.getKey(), new LinkedHashSet<String>(entry.getValue().keySet()));
+ result.put(entry.getKey(), new LinkedHashSet<>(entry.getValue().keySet()));
}
return result;
}
int threshold,
DistanceOption distanceOption) {
- Output<DistanceTable> subtable = new Output<DistanceTable>();
+ Output<DistanceTable> subtable = new Output<>();
int distance = languageDesired2Supported.getDistance(desiredLang, supportedlang, subtable, true);
boolean scriptFirst = distanceOption == DistanceOption.SCRIPT_FIRST;
@SuppressWarnings({"unchecked", "rawtypes"})
List<Row.R4<List<String>, List<String>, Integer, Boolean>>[] sorted = new ArrayList[3];
- sorted[0] = new ArrayList<Row.R4<List<String>, List<String>, Integer, Boolean>>();
- sorted[1] = new ArrayList<Row.R4<List<String>, List<String>, Integer, Boolean>>();
- sorted[2] = new ArrayList<Row.R4<List<String>, List<String>, Integer, Boolean>>();
+ sorted[0] = new ArrayList<>();
+ sorted[1] = new ArrayList<>();
+ sorted[2] = new ArrayList<>();
// sort the rules so that the language-only are first, then the language-script, and finally the language-script-region.
for (R4<String, String, Integer, Boolean> info : xGetLanguageMatcherData()) {
// if (rule[0].equals("en_*_*") || rule[1].equals("*_*_*")) {
// int debug = 0;
// }
- List<String> desiredBase = new ArrayList<String>(bar.splitToList(rule[0]));
- List<String> supportedBase = new ArrayList<String>(bar.splitToList(rule[1]));
+ List<String> desiredBase = new ArrayList<>(bar.splitToList(rule[0]));
+ List<String> supportedBase = new ArrayList<>(bar.splitToList(rule[1]));
Integer distance = 100-Integer.parseInt(rule[2]);
printMatchXml(desiredBase, supportedBase, distance, false);
}
private static String fixedName(List<String> match) {
- List<String> alt = new ArrayList<String>(match);
+ List<String> alt = new ArrayList<>(match);
int size = alt.size();
assert size >= 1 && size <= 3;
static class Builder {
final private Multimap<String, String> regionToRawPartition = TreeMultimap.create();
final private RegionSet regionSet = new RegionSet();
- final private Set<ULocale> paradigms = new LinkedHashSet<ULocale>();
+ final private Set<ULocale> paradigms = new LinkedHashSet<>();
void add(String variable, String barString) {
Set<String> tempRegions = regionSet.parseSet(barString);
}
RegionMapper build() {
- final IdMakerFull<Collection<String>> id = new IdMakerFull<Collection<String>>("partition");
+ final IdMakerFull<Collection<String>> id = new IdMakerFull<>("partition");
Multimap<String,String> variableToPartitions = TreeMultimap.create();
- Map<String,String> regionToPartition = new TreeMap<String,String>();
+ Map<String,String> regionToPartition = new TreeMap<>();
Multimap<String,String> partitionToRegions = TreeMultimap.create();
for (Entry<String, Set<String>> e : regionToRawPartition.asMap().entrySet()) {
private static class RegionSet {
private enum Operation {add, remove}
// temporaries used in processing
- final private Set<String> tempRegions = new TreeSet<String>();
+ final private Set<String> tempRegions = new TreeSet<>();
private Operation operation = null;
private Set<String> parseSet(String barString) {
}
private Set<String> inverse() {
- TreeSet<String> result = new TreeSet<String>(ALL_FINAL_REGIONS);
+ TreeSet<String> result = new TreeSet<>(ALL_FINAL_REGIONS);
result.removeAll(tempRegions);
return result;
}
if (toId(item) != null) {
return (Map<K, T>) intern(item);
}
- Map<K,T> copy = new LinkedHashMap<K,T>();
+ Map<K,T> copy = new LinkedHashMap<>();
for (Entry<K,T> entry : item.entrySet()) {
T value = entry.getValue();
if (value instanceof Map) {
package com.ibm.icu.impl.number;
import java.math.RoundingMode;
+import java.util.Objects;
-import com.ibm.icu.impl.Utility;
import com.ibm.icu.number.IntegerWidth;
import com.ibm.icu.number.Notation;
import com.ibm.icu.number.NumberFormatter.DecimalSeparatorDisplay;
@Override
public int hashCode() {
- return Utility.hash(notation,
+ return Objects.hash(notation,
unit,
perUnit,
precision,
if (!(_other instanceof MacroProps))
return false;
MacroProps other = (MacroProps) _other;
- return Utility.equals(notation, other.notation)
- && Utility.equals(unit, other.unit)
- && Utility.equals(perUnit, other.perUnit)
- && Utility.equals(precision, other.precision)
- && Utility.equals(roundingMode, other.roundingMode)
- && Utility.equals(grouping, other.grouping)
- && Utility.equals(padder, other.padder)
- && Utility.equals(integerWidth, other.integerWidth)
- && Utility.equals(symbols, other.symbols)
- && Utility.equals(unitWidth, other.unitWidth)
- && Utility.equals(sign, other.sign)
- && Utility.equals(decimal, other.decimal)
- && Utility.equals(affixProvider, other.affixProvider)
- && Utility.equals(scale, other.scale)
- && Utility.equals(rules, other.rules)
- && Utility.equals(loc, other.loc);
+ return Objects.equals(notation, other.notation)
+ && Objects.equals(unit, other.unit)
+ && Objects.equals(perUnit, other.perUnit)
+ && Objects.equals(precision, other.precision)
+ && Objects.equals(roundingMode, other.roundingMode)
+ && Objects.equals(grouping, other.grouping)
+ && Objects.equals(padder, other.padder)
+ && Objects.equals(integerWidth, other.integerWidth)
+ && Objects.equals(symbols, other.symbols)
+ && Objects.equals(unitWidth, other.unitWidth)
+ && Objects.equals(sign, other.sign)
+ && Objects.equals(decimal, other.decimal)
+ && Objects.equals(affixProvider, other.affixProvider)
+ && Objects.equals(scale, other.scale)
+ && Objects.equals(rules, other.rules)
+ && Objects.equals(loc, other.loc);
}
@Override
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
+import java.util.Objects;
import com.ibm.icu.impl.StandardPlural;
import com.ibm.icu.impl.StringSegment;
-import com.ibm.icu.impl.Utility;
import com.ibm.icu.impl.number.AffixPatternProvider;
import com.ibm.icu.impl.number.AffixUtils;
import com.ibm.icu.impl.number.PatternStringUtils;
// The affixes have interesting characters, or we are in strict mode.
// Use initial capacity of 6, the highest possible number of AffixMatchers.
StringBuilder sb = new StringBuilder();
- ArrayList<AffixMatcher> matchers = new ArrayList<AffixMatcher>(6);
+ ArrayList<AffixMatcher> matchers = new ArrayList<>(6);
boolean includeUnpaired = 0 != (parseFlags & ParsingUtils.PARSE_FLAG_INCLUDE_UNPAIRED_AFFIXES);
SignDisplay signDisplay = (0 != (parseFlags & ParsingUtils.PARSE_FLAG_PLUS_SIGN_ALLOWED))
? SignDisplay.ALWAYS
if (signum == 1) {
posPrefix = prefix;
posSuffix = suffix;
- } else if (Utility.equals(prefix, posPrefix) && Utility.equals(suffix, posSuffix)) {
+ } else if (Objects.equals(prefix, posPrefix) && Objects.equals(suffix, posSuffix)) {
// Skip adding these matchers (we already have equivalents)
continue;
}
matchers.add(getInstance(prefix, suffix, flags));
if (includeUnpaired && prefix != null && suffix != null) {
// The following if statements are designed to prevent adding two identical matchers.
- if (signum == 1 || !Utility.equals(prefix, posPrefix)) {
+ if (signum == 1 || !Objects.equals(prefix, posPrefix)) {
matchers.add(getInstance(prefix, null, flags));
}
- if (signum == 1 || !Utility.equals(suffix, posSuffix)) {
+ if (signum == 1 || !Objects.equals(suffix, posSuffix)) {
matchers.add(getInstance(null, suffix, flags));
}
}
return false;
}
AffixMatcher other = (AffixMatcher) _other;
- return Utility.equals(prefix, other.prefix)
- && Utility.equals(suffix, other.suffix)
+ return Objects.equals(prefix, other.prefix)
+ && Objects.equals(suffix, other.suffix)
&& flags == other.flags;
}
@Override
public int hashCode() {
- return Utility.hashCode(prefix) ^ Utility.hashCode(suffix) ^ flags;
+ return Objects.hashCode(prefix) ^ Objects.hashCode(suffix) ^ flags;
}
@Override
import java.math.BigInteger;
import java.text.Format;
+import java.util.Objects;
import java.util.concurrent.atomic.AtomicLongFieldUpdater;
import com.ibm.icu.impl.StandardPlural;
-import com.ibm.icu.impl.Utility;
import com.ibm.icu.impl.number.DecimalQuantity;
import com.ibm.icu.impl.number.DecimalQuantity_DualStorageBCD;
import com.ibm.icu.impl.number.LocalizedNumberFormatterAsFormat;
MeasureUnit unit = input.getUnit();
Number number = input.getNumber();
// Use this formatter if possible
- if (Utility.equals(resolve().unit, unit)) {
+ if (Objects.equals(resolve().unit, unit)) {
return format(number);
}
// This mechanism saves the previously used unit, so if the user calls this method with the
// same unit multiple times in a row, they get a more efficient code path.
LocalizedNumberFormatter withUnit = savedWithUnit;
- if (withUnit == null || !Utility.equals(withUnit.resolve().unit, unit)) {
+ if (withUnit == null || !Objects.equals(withUnit.resolve().unit, unit)) {
withUnit = new LocalizedNumberFormatter(this, KEY_UNIT, unit);
savedWithUnit = withUnit;
}
import java.util.Map;
import java.util.Map.Entry;
import java.util.MissingResourceException;
+import java.util.Objects;
import java.util.Set;
import com.ibm.icu.impl.ICUCache;
import com.ibm.icu.impl.UResource;
import com.ibm.icu.impl.UResource.Key;
import com.ibm.icu.impl.UResource.Value;
-import com.ibm.icu.impl.Utility;
import com.ibm.icu.util.Calendar;
import com.ibm.icu.util.Freezable;
import com.ibm.icu.util.ICUCloneNotSupportedException;
public boolean equals(Object a) {
if (a instanceof PatternInfo) {
PatternInfo patternInfo = (PatternInfo)a;
- return Utility.objectEquals(fIntervalPatternFirstPart, patternInfo.fIntervalPatternFirstPart) &&
- Utility.objectEquals(fIntervalPatternSecondPart, patternInfo.fIntervalPatternSecondPart) &&
+ return Objects.equals(fIntervalPatternFirstPart, patternInfo.fIntervalPatternFirstPart) &&
+ Objects.equals(fIntervalPatternSecondPart, patternInfo.fIntervalPatternSecondPart) &&
fFirstDateInPtnIsLaterDate == patternInfo.fFirstDateInPtnIsLaterDate;
}
return false;
private static String EARLIEST_FIRST_PREFIX = "earliestFirst:";
// DateIntervalInfo cache
- private final static ICUCache<String, DateIntervalInfo> DIICACHE = new SimpleCache<String, DateIntervalInfo>();
+ private final static ICUCache<String, DateIntervalInfo> DIICACHE = new SimpleCache<>();
// default interval pattern on the skeleton, {0} - {1}
@Deprecated
public DateIntervalInfo()
{
- fIntervalPatterns = new HashMap<String, Map<String, PatternInfo>>();
+ fIntervalPatterns = new HashMap<>();
fFallbackIntervalPattern = "{0} \u2013 {1}";
}
*/
private void setup(ULocale locale) {
int DEFAULT_HASH_SIZE = 19;
- fIntervalPatterns = new HashMap<String, Map<String, PatternInfo>>(DEFAULT_HASH_SIZE);
+ fIntervalPatterns = new HashMap<>(DEFAULT_HASH_SIZE);
// initialize to guard if there is no interval date format defined in
// resource files
fFallbackIntervalPattern = "{0} \u2013 {1}";
setFallbackIntervalPattern(fallbackPattern);
// Already loaded calendar types
- Set<String> loadedCalendarTypes = new HashSet<String>();
+ Set<String> loadedCalendarTypes = new HashSet<>();
while (calendarTypeToUse != null) {
// Throw an exception when a loop is detected
Map<String, PatternInfo> patternsOfOneSkeleton = fIntervalPatterns.get(skeleton);
boolean emptyHash = false;
if (patternsOfOneSkeleton == null) {
- patternsOfOneSkeleton = new HashMap<String, PatternInfo>();
+ patternsOfOneSkeleton = new HashMap<>();
emptyHash = true;
}
boolean order = fFirstDateInPtnIsLaterDate;
private static Map<String, Map<String, PatternInfo>> cloneIntervalPatterns(
Map<String, Map<String, PatternInfo>> patterns) {
- Map<String, Map<String, PatternInfo>> result = new HashMap<String, Map<String, PatternInfo>>();
+ Map<String, Map<String, PatternInfo>> result = new HashMap<>();
for (Entry<String, Map<String, PatternInfo>> skeletonEntry : patterns.entrySet()) {
String skeleton = skeletonEntry.getKey();
Map<String, PatternInfo> patternsOfOneSkeleton = skeletonEntry.getValue();
- Map<String, PatternInfo> oneSetPtn = new HashMap<String, PatternInfo>();
+ Map<String, PatternInfo> oneSetPtn = new HashMap<>();
for (Entry<String, PatternInfo> calEntry : patternsOfOneSkeleton.entrySet()) {
String calField = calEntry.getKey();
PatternInfo value = calEntry.getValue();
*/
@Deprecated
public Map<String,Set<String>> getPatterns() {
- LinkedHashMap<String,Set<String>> result = new LinkedHashMap<String,Set<String>>();
+ LinkedHashMap<String,Set<String>> result = new LinkedHashMap<>();
for (Entry<String, Map<String, PatternInfo>> entry : fIntervalPatterns.entrySet()) {
- result.put(entry.getKey(), new LinkedHashSet<String>(entry.getValue().keySet()));
+ result.put(entry.getKey(), new LinkedHashSet<>(entry.getValue().keySet()));
}
return result;
}
*/
@Deprecated
public Map<String, Map<String, PatternInfo>> getRawPatterns() {
- LinkedHashMap<String, Map<String, PatternInfo>> result = new LinkedHashMap<String, Map<String, PatternInfo>>();
+ LinkedHashMap<String, Map<String, PatternInfo>> result = new LinkedHashMap<>();
for (Entry<String, Map<String, PatternInfo>> entry : fIntervalPatterns.entrySet()) {
- result.put(entry.getKey(), new LinkedHashMap<String, PatternInfo>(entry.getValue()));
+ result.put(entry.getKey(), new LinkedHashMap<>(entry.getValue()));
}
return result;
}
import java.util.List;
import java.util.Locale;
import java.util.Map;
+import java.util.Objects;
import java.util.Set;
import com.ibm.icu.impl.PatternProps;
-import com.ibm.icu.impl.Utility;
import com.ibm.icu.number.NumberFormatter;
import com.ibm.icu.text.MessagePattern.ArgType;
import com.ibm.icu.text.MessagePattern.Part;
"This method is not available in MessageFormat objects " +
"that use alphanumeric argument names.");
}
- ArrayList<Format> list = new ArrayList<Format>();
+ ArrayList<Format> list = new ArrayList<>();
for (int partIndex = 0; (partIndex = nextTopLevelArgStart(partIndex)) >= 0;) {
int argNumber = msgPattern.getPart(partIndex + 1).getValue();
while (argNumber >= list.size()) {
* @stable ICU 3.0
*/
public Format[] getFormats() {
- ArrayList<Format> list = new ArrayList<Format>();
+ ArrayList<Format> list = new ArrayList<>();
for (int partIndex = 0; (partIndex = nextTopLevelArgStart(partIndex)) >= 0;) {
list.add(cachedFormatters == null ? null : cachedFormatters.get(partIndex));
}
* @stable ICU 4.8
*/
public Set<String> getArgumentNames() {
- Set<String> result = new HashSet<String>();
+ Set<String> result = new HashSet<>();
for (int partIndex = 0; (partIndex = nextTopLevelArgStart(partIndex)) >= 0;) {
result.add(getArgName(partIndex + 1));
}
* @stable ICU 3.8
*/
public Map<String, Object> parseToMap(String source, ParsePosition pos) {
- Map<String, Object> result = new HashMap<String, Object>();
+ Map<String, Object> result = new HashMap<>();
int backupStartPos = pos.getIndex();
parse(0, source, pos, null, result);
if (pos.getIndex() == backupStartPos) {
*/
public Map<String, Object> parseToMap(String source) throws ParseException {
ParsePosition pos = new ParsePosition(0);
- Map<String, Object> result = new HashMap<String, Object>();
+ Map<String, Object> result = new HashMap<>();
parse(0, source, pos, null, result);
if (pos.getIndex() == 0) // unchanged, returned object is null
throw new ParseException("MessageFormat parse error!",
MessageFormat other = (MessageFormat) super.clone();
if (customFormatArgStarts != null) {
- other.customFormatArgStarts = new HashSet<Integer>();
+ other.customFormatArgStarts = new HashSet<>();
for (Integer key : customFormatArgStarts) {
other.customFormatArgStarts.add(key);
}
}
if (cachedFormatters != null) {
- other.cachedFormatters = new HashMap<Integer, Format>();
+ other.cachedFormatters = new HashMap<>();
Iterator<Map.Entry<Integer, Format>> it = cachedFormatters.entrySet().iterator();
while (it.hasNext()){
Map.Entry<Integer, Format> entry = it.next();
if (obj == null || getClass() != obj.getClass())
return false;
MessageFormat other = (MessageFormat) obj;
- return Utility.objectEquals(ulocale, other.ulocale)
- && Utility.objectEquals(msgPattern, other.msgPattern)
- && Utility.objectEquals(cachedFormatters, other.cachedFormatters)
- && Utility.objectEquals(customFormatArgStarts, other.customFormatArgStarts);
+ return Objects.equals(ulocale, other.ulocale)
+ && Objects.equals(msgPattern, other.msgPattern)
+ && Objects.equals(cachedFormatters, other.cachedFormatters)
+ && Objects.equals(customFormatArgStarts, other.customFormatArgStarts);
// Note: It might suffice to only compare custom formatters
// rather than all formatters.
}
*/
private void setArgStartFormat(int argStart, Format formatter) {
if (cachedFormatters == null) {
- cachedFormatters = new HashMap<Integer, Format>();
+ cachedFormatters = new HashMap<>();
}
cachedFormatters.put(argStart, formatter);
}
private void setCustomArgStartFormat(int argStart, Format formatter) {
setArgStartFormat(argStart, formatter);
if (customFormatArgStarts == null) {
- customFormatArgStarts = new HashSet<Integer>();
+ customFormatArgStarts = new HashSet<>();
}
customFormatArgStarts.add(argStart);
}
}
public void useAttributes() {
- attributes = new ArrayList<AttributeAndPosition>();
+ attributes = new ArrayList<>();
}
public void append(CharSequence s) {
import java.text.FieldPosition;
import java.text.ParsePosition;
import java.util.List;
+import java.util.Objects;
import com.ibm.icu.impl.PatternProps;
-import com.ibm.icu.impl.Utility;
/**
* A class representing a single rule in a RuleBasedNumberFormat. A rule
* @param that The rule to compare this one against
* @return True if the two rules are functionally equivalent
*/
+ @Override
public boolean equals(Object that) {
if (that instanceof NFRule) {
NFRule that2 = (NFRule)that;
&& radix == that2.radix
&& exponent == that2.exponent
&& ruleText.equals(that2.ruleText)
- && Utility.objectEquals(sub1, that2.sub1)
- && Utility.objectEquals(sub2, that2.sub2);
+ && Objects.equals(sub1, that2.sub1)
+ && Objects.equals(sub2, that2.sub2);
}
return false;
}
-
+
+ @Override
public int hashCode() {
assert false : "hashCode not designed";
return 42;
* was created with, but it will produce the same result.
* @return A textual description of the rule
*/
+ @Override
public String toString() {
StringBuilder result = new StringBuilder();
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;
+import java.util.Objects;
import com.ibm.icu.impl.PatternProps;
-import com.ibm.icu.impl.Utility;
/**
* A collection of rules used by a RuleBasedNumberFormat to format and
public void parseRules(String description) {
// (the number of elements in the description list isn't necessarily
// the number of rules-- some descriptions may expend into two rules)
- List<NFRule> tempRules = new ArrayList<NFRule>();
+ List<NFRule> tempRules = new ArrayList<>();
// we keep track of the rule before the one we're currently working
// on solely to support >>> substitutions
private void setBestFractionRule(int originalIndex, NFRule newRule, boolean rememberRule) {
if (rememberRule) {
if (fractionRules == null) {
- fractionRules = new LinkedList<NFRule>();
+ fractionRules = new LinkedList<>();
}
fractionRules.add(newRule);
}
* @param that The other rule set
* @return true if the two rule sets are functionally equivalent.
*/
+ @Override
public boolean equals(Object that) {
// if different classes, they're not equal
if (!(that instanceof NFRuleSet)) {
// ...then compare the non-numerical rule lists...
for (int i = 0; i < nonNumericalRules.length; i++) {
- if (!Utility.objectEquals(nonNumericalRules[i], that2.nonNumericalRules[i])) {
+ if (!Objects.equals(nonNumericalRules[i], that2.nonNumericalRules[i])) {
return false;
}
}
}
}
+ @Override
public int hashCode() {
assert false : "hashCode not designed";
return 42;
* necessarily be the same description that the rule set was
* constructed with, but it will produce the same results.
*/
+ @Override
public String toString() {
StringBuilder result = new StringBuilder();
import java.text.ParsePosition;
import java.util.Locale;
import java.util.Map;
+import java.util.Objects;
-import com.ibm.icu.impl.Utility;
import com.ibm.icu.number.FormattedNumber;
import com.ibm.icu.number.LocalizedNumberFormatter;
import com.ibm.icu.text.PluralRules.FixedDecimal;
}
PluralFormat pf = (PluralFormat)rhs;
return
- Utility.objectEquals(ulocale, pf.ulocale) &&
- Utility.objectEquals(pluralRules, pf.pluralRules) &&
- Utility.objectEquals(msgPattern, pf.msgPattern) &&
- Utility.objectEquals(numberFormat, pf.numberFormat);
+ Objects.equals(ulocale, pf.ulocale) &&
+ Objects.equals(pluralRules, pf.pluralRules) &&
+ Objects.equals(msgPattern, pf.msgPattern) &&
+ Objects.equals(numberFormat, pf.numberFormat);
}
/**
import java.util.LinkedHashSet;
import java.util.Map;
import java.util.Map.Entry;
+import java.util.Objects;
import java.util.Set;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import com.ibm.icu.impl.Relation;
import com.ibm.icu.impl.Row;
import com.ibm.icu.impl.Row.R3;
-import com.ibm.icu.impl.Utility;
import com.ibm.icu.impl.locale.XLocaleDistance.DistanceOption;
import com.ibm.icu.impl.locale.XLocaleMatcher;
import com.ibm.icu.impl.locale.XLocaleMatcher.Builder;
private void addFiltered(String desired, R3<ULocale, ULocale, Double> localeToMaxAndWeight) {
Set<R3<ULocale, ULocale, Double>> map = desiredLanguageToPossibleLocalesToMaxLocaleToData.get(desired);
if (map == null) {
- desiredLanguageToPossibleLocalesToMaxLocaleToData.put(desired, map = new LinkedHashSet<R3<ULocale, ULocale, Double>>());
+ desiredLanguageToPossibleLocalesToMaxLocaleToData.put(desired, map = new LinkedHashSet<>());
}
map.add(localeToMaxAndWeight);
if (DEBUG) {
}
}
- Set<Row.R3<ULocale, ULocale, Double>> localeToMaxLocaleAndWeight = new LinkedHashSet<Row.R3<ULocale, ULocale, Double>>();
+ Set<Row.R3<ULocale, ULocale, Double>> localeToMaxLocaleAndWeight = new LinkedHashSet<>();
Map<String,Set<Row.R3<ULocale, ULocale, Double>>> desiredLanguageToPossibleLocalesToMaxLocaleToData
- = new LinkedHashMap<String,Set<Row.R3<ULocale, ULocale, Double>>>();
+ = new LinkedHashMap<>();
// =============== Special Mapping Information ==============
return false;
}
LocalePatternMatcher other = (LocalePatternMatcher) obj;
- return Utility.objectEquals(level, other.level)
- && Utility.objectEquals(lang, other.lang)
- && Utility.objectEquals(script, other.script)
- && Utility.objectEquals(region, other.region);
+ return Objects.equals(level, other.level)
+ && Objects.equals(lang, other.lang)
+ && Objects.equals(script, other.script)
+ && Objects.equals(region, other.region);
}
/* (non-Javadoc)
@SuppressWarnings("unused")
private static final double maxUnequal_changeEqual = 0.75;
- LinkedHashSet<Row.R3<LocalePatternMatcher,LocalePatternMatcher,Double>> scores = new LinkedHashSet<R3<LocalePatternMatcher, LocalePatternMatcher, Double>>();
+ LinkedHashSet<Row.R3<LocalePatternMatcher,LocalePatternMatcher,Double>> scores = new LinkedHashSet<>();
final Level level;
public ScoreData(Level level) {
private static final LanguageMatcherData defaultWritten;
- private static HashMap<String,String> canonicalMap = new HashMap<String, String>();
+ private static HashMap<String,String> canonicalMap = new HashMap<>();
static {
import java.util.Date;
import java.util.HashMap;
import java.util.Locale;
+import java.util.Objects;
import com.ibm.icu.impl.DateNumberFormat;
import com.ibm.icu.impl.TZDBTimeZoneNames;
import com.ibm.icu.impl.TimeZoneGenericNames;
import com.ibm.icu.impl.TimeZoneGenericNames.GenericNameType;
-import com.ibm.icu.impl.Utility;
import com.ibm.icu.text.ChineseDateFormat;
import com.ibm.icu.text.ChineseDateFormatSymbols;
import com.ibm.icu.text.CompactDecimalFormat;
for (long date : DATES) {
String nameA = tzgna.getDisplayName(tz, nt, date);
String nameB = tzgnb.getDisplayName(tz, nt, date);
- if (!Utility.objectEquals(nameA, nameB)) {
+ if (!Objects.equals(nameA, nameB)) {
return false;
}
}
for (long date : DATES) {
String nameA = tzdbna.getDisplayName(tzid, nt, date);
String nameB = tzdbnb.getDisplayName(tzid, nt, date);
- if (!Utility.objectEquals(nameA, nameB)) {
+ if (!Objects.equals(nameA, nameB)) {
return false;
}
}
import java.util.HashMap;
import java.util.List;
import java.util.Locale;
+import java.util.Objects;
import com.ibm.icu.dev.test.format.MeasureUnitTest;
import com.ibm.icu.dev.test.format.PluralRulesTest;
import com.ibm.icu.impl.OlsonTimeZone;
import com.ibm.icu.impl.TimeZoneAdapter;
import com.ibm.icu.impl.URLHandler;
-import com.ibm.icu.impl.Utility;
import com.ibm.icu.math.BigDecimal;
import com.ibm.icu.math.MathContext;
import com.ibm.icu.util.AnnualTimeZoneRule;
return a == null ? b == null :
b == null ? false :
a.getClass().equals(b.getClass()) &&
- Utility.objectEquals(a.getMessage(), b.getMessage()) &&
+ Objects.equals(a.getMessage(), b.getMessage()) &&
sameThrowable(a.getCause(), b.getCause());
}
}
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
+import java.util.Objects;
import com.ibm.icu.dev.test.AbstractTestLog;
import com.ibm.icu.dev.test.TestFmwk;
import com.ibm.icu.dev.util.CollectionUtilities;
-import com.ibm.icu.impl.Utility;
import com.ibm.icu.impl.locale.XCldrStub.FileUtilities;
import com.ibm.icu.impl.locale.XCldrStub.Splitter;
import com.ibm.icu.util.ICUUncheckedIOException;
protected TestFmwk framework = null;
protected int minArgumentCount = 3;
protected int maxArgumentCount = 4;
- private List<List<String>> lines = new ArrayList<List<String>>();
- private List<String> comments = new ArrayList<String>();
+ private List<List<String>> lines = new ArrayList<>();
+ private List<String> comments = new ArrayList<>();
public DataDrivenTestHelper setFramework(TestFmwk testFramework) {
this.framework = testFramework;
}
protected boolean assertEquals(String message, Object expected, Object actual) {
- return TestFmwk.handleAssert(Utility.equals(expected, actual), message, stringFor(expected), stringFor(actual), null, false);
+ return TestFmwk.handleAssert(Objects.equals(expected, actual), message, stringFor(expected), stringFor(actual), null, false);
}
private final String stringFor(Object obj) {
import java.util.ArrayList;
import java.util.HashSet;
import java.util.Iterator;
+import java.util.Objects;
import java.util.Set;
import com.ibm.icu.impl.ICUConfig;
import com.ibm.icu.impl.PatternProps;
-import com.ibm.icu.impl.Utility;
import com.ibm.icu.lang.UCharacter;
import com.ibm.icu.math.BigDecimal;
import com.ibm.icu.math.MathContext;
if (currencyPluralInfo == null) {
currencyPluralInfo = new CurrencyPluralInfo(symbols.getULocale());
}
- affixPatternsForCurrency = new HashSet<AffixForCurrency>();
+ affixPatternsForCurrency = new HashSet<>();
// save the current pattern, since it will be changed by
// applyPatternWithoutExpandAffix
// add plural pattern
Iterator<String> iter = currencyPluralInfo.pluralPatternIterator();
- Set<String> currencyUnitPatternSet = new HashSet<String>();
+ Set<String> currencyUnitPatternSet = new HashSet<>();
while (iter.hasNext()) {
String pluralCount = iter.next();
String currencyPattern = currencyPluralInfo.getCurrencyPluralPattern(pluralCount);
if (currencyPluralInfo != null) {
other.currencyPluralInfo = (CurrencyPluralInfo) currencyPluralInfo.clone();
}
- other.attributes = new ArrayList<FieldPosition>(); // #9240
+ other.attributes = new ArrayList<>(); // #9240
other.currencyUsage = currencyUsage;
// TODO: We need to figure out whether we share a single copy of DigitList by
&& (!useSignificantDigits || minSignificantDigits == other.minSignificantDigits
&& maxSignificantDigits == other.maxSignificantDigits)
&& symbols.equals(other.symbols)
- && Utility.objectEquals(currencyPluralInfo, other.currencyPluralInfo)
+ && Objects.equals(currencyPluralInfo, other.currencyPluralInfo)
&& currencyUsage.equals(other.currencyUsage);
}
// Proclaim JDK 1.1 serial compatibility.
private static final long serialVersionUID = 864413376551465018L;
- private ArrayList<FieldPosition> attributes = new ArrayList<FieldPosition>();
+ private ArrayList<FieldPosition> attributes = new ArrayList<>();
// The following are used in currency format