Changeset 18070 in josm
Legend:
- Unmodified
- Added
- Removed
-
trunk/README
r18054 r18070 170 170 -> http://commons.apache.org/proper/commons-validator 171 171 * SVG Salamander: Support for SVG image format 172 src/com/kitfox/svg173 172 -> https://github.com/blackears/svgSalamander 174 173 * Metadata Extractor: Read EXIF Metadata of photos -
trunk/ivy.xml
r17969 r18070 30 30 <dependency conf="api->default" org="com.adobe.xmp" name="xmpcore" rev="6.1.11"/> 31 31 <dependency conf="api->default" org="com.drewnoakes" name="metadata-extractor" rev="2.16.0" transitive="false"/> 32 <dependency conf="api->default" org="com.formdev" name="svgSalamander" rev="1.1.2.4"/> 32 33 <dependency conf="api->default" org="ch.poole" name="OpeningHoursParser" rev="0.23.4"/> 33 34 <dependency conf="api->default" org="oauth.signpost" name="signpost-core" rev="2.1.1"/> … … 43 44 <dependency conf="sources->sources" org="com.adobe.xmp" name="xmpcore" rev="6.1.11"/> 44 45 <dependency conf="sources->sources" org="com.drewnoakes" name="metadata-extractor" rev="2.16.0" transitive="false"/> 46 <dependency conf="sources->default" org="com.formdev" name="svgSalamander" rev="1.1.2.4"/> 45 47 <dependency conf="sources->sources" org="ch.poole" name="OpeningHoursParser" rev="0.23.4"/> 46 48 <dependency conf="sources->sources" org="oauth.signpost" name="signpost-core" rev="2.1.1"/> -
trunk/src/org/openstreetmap/josm/tools/Utils.java
r18014 r18070 16 16 import java.io.InputStream; 17 17 import java.io.UnsupportedEncodingException; 18 import java.lang.reflect.Method; 18 19 import java.net.MalformedURLException; 19 20 import java.net.URI; … … 69 70 import org.openstreetmap.josm.spi.preferences.Config; 70 71 71 import com.kitfox.svg.xml.XMLParseUtil;72 73 72 /** 74 73 * Basic utils, that can be useful in different parts of the program. … … 98 97 private static final double TO_DEGREES = 180.0 / Math.PI; 99 98 private static final double TO_RADIANS = Math.PI / 180.0; 99 100 /** 101 * A reference to {@code Map.ofEntries()} available since Java 9 102 */ 103 static final Method mapOfEntries = mapOfEntriesMethod(); 104 105 private static Method mapOfEntriesMethod() { 106 try { 107 return Map.class.getMethod("ofEntries", Map.Entry[].class); 108 } catch (NoSuchMethodException e) { 109 return null; 110 } 111 } 100 112 101 113 private Utils() { … … 659 671 */ 660 672 public static <K, V> Map<K, V> toUnmodifiableMap(Map<K, V> map) { 661 return XMLParseUtil.toUnmodifiableMap(map); 673 if (map == null || map.isEmpty()) { 674 return Collections.emptyMap(); 675 } else if (map.size() == 1) { 676 final Map.Entry<K, V> entry = map.entrySet().iterator().next(); 677 return Collections.singletonMap(entry.getKey(), entry.getValue()); 678 } else if (mapOfEntries != null) { 679 try { 680 // Java 9: use Map.ofEntries(...) 681 return (Map<K, V>) mapOfEntries.invoke(null, new Object[]{map.entrySet().toArray(new Map.Entry[0])}); 682 } catch (Exception ignore) { 683 Logging.trace(ignore); 684 } 685 } 686 return Collections.unmodifiableMap(map); 662 687 } 663 688
Note:
See TracChangeset
for help on using the changeset viewer.