< prev index next >

src/java.base/share/classes/sun/util/locale/UnicodeLocaleExtension.java

Print this page
rev 52979 : 8215281: Use String.isEmpty() when applicable in java.base
Reviewed-by: TBD


  63             this.attributes = attributes;
  64         } else {
  65             this.attributes = Collections.emptySet();
  66         }
  67         if (keywords != null) {
  68             this.keywords = keywords;
  69         } else {
  70             this.keywords = Collections.emptyMap();
  71         }
  72 
  73         if (!this.attributes.isEmpty() || !this.keywords.isEmpty()) {
  74             StringJoiner sj = new StringJoiner(LanguageTag.SEP);
  75             for (String attribute : this.attributes) {
  76                 sj.add(attribute);
  77             }
  78             for (Entry<String, String> keyword : this.keywords.entrySet()) {
  79                 String key = keyword.getKey();
  80                 String value = keyword.getValue();
  81 
  82                 sj.add(key);
  83                 if (value.length() > 0) {
  84                     sj.add(value);
  85                 }
  86             }
  87             setValue(sj.toString());
  88         }
  89     }
  90 
  91     public Set<String> getUnicodeLocaleAttributes() {
  92         if (attributes == Collections.EMPTY_SET) {
  93             return attributes;
  94         }
  95         return Collections.unmodifiableSet(attributes);
  96     }
  97 
  98     public Set<String> getUnicodeLocaleKeys() {
  99         if (keywords == Collections.EMPTY_MAP) {
 100             return Collections.emptySet();
 101         }
 102         return Collections.unmodifiableSet(keywords.keySet());
 103     }




  63             this.attributes = attributes;
  64         } else {
  65             this.attributes = Collections.emptySet();
  66         }
  67         if (keywords != null) {
  68             this.keywords = keywords;
  69         } else {
  70             this.keywords = Collections.emptyMap();
  71         }
  72 
  73         if (!this.attributes.isEmpty() || !this.keywords.isEmpty()) {
  74             StringJoiner sj = new StringJoiner(LanguageTag.SEP);
  75             for (String attribute : this.attributes) {
  76                 sj.add(attribute);
  77             }
  78             for (Entry<String, String> keyword : this.keywords.entrySet()) {
  79                 String key = keyword.getKey();
  80                 String value = keyword.getValue();
  81 
  82                 sj.add(key);
  83                 if (!value.isEmpty()) {
  84                     sj.add(value);
  85                 }
  86             }
  87             setValue(sj.toString());
  88         }
  89     }
  90 
  91     public Set<String> getUnicodeLocaleAttributes() {
  92         if (attributes == Collections.EMPTY_SET) {
  93             return attributes;
  94         }
  95         return Collections.unmodifiableSet(attributes);
  96     }
  97 
  98     public Set<String> getUnicodeLocaleKeys() {
  99         if (keywords == Collections.EMPTY_MAP) {
 100             return Collections.emptySet();
 101         }
 102         return Collections.unmodifiableSet(keywords.keySet());
 103     }


< prev index next >