Ignore:
Timestamp:
2014-04-26T17:39:23+02:00 (11 years ago)
Author:
Don-vip
Message:

see #8465 - use diamond operator where applicable

Location:
trunk/src/org/openstreetmap/josm/tools
Files:
20 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/tools/CopyList.java

    r6717 r7005  
    116116    @Override
    117117    public Object clone() {
    118         return new CopyList<E>(array, size);
     118        return new CopyList<>(array, size);
    119119    }
    120120
  • trunk/src/org/openstreetmap/josm/tools/Diff.java

    r6889 r7005  
    9696     */
    9797    public Diff(Object[] a, Object[] b) {
    98         Map<Object,Integer> h = new HashMap<Object,Integer>(a.length + b.length);
     98        Map<Object,Integer> h = new HashMap<>(a.length + b.length);
    9999        filevec = new FileData[] { new FileData(a,h),new FileData(b,h) };
    100100    }
  • trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java

    r6830 r7005  
    7878    public static Pair<OsmPrimitive, Collection<OsmPrimitive>> parsePreconditionFailed(String msg) {
    7979        final String ids = "(\\d+(?:,\\d+)*)";
    80         final Collection<OsmPrimitive> refs = new TreeSet<OsmPrimitive>(); // error message can contain several times the same way
     80        final Collection<OsmPrimitive> refs = new TreeSet<>(); // error message can contain several times the same way
    8181        Matcher m;
    8282        m = Pattern.compile(".*Node (\\d+) is still used by relations " + ids + ".*").matcher(msg);
  • trunk/src/org/openstreetmap/josm/tools/FallbackDateParser.java

    r6104 r7005  
    4242    public FallbackDateParser() {
    4343        // Build a list of candidate date parsers.
    44         dateParsers = new ArrayList<DateFormat>(formats.length);
     44        dateParsers = new ArrayList<>(formats.length);
    4545        for (String format : formats) {
    4646            dateParsers.add(new SimpleDateFormat(format));
  • trunk/src/org/openstreetmap/josm/tools/Geometry.java

    r6934 r7005  
    6666        boolean[] changedWays = new boolean[n];
    6767
    68         Set<Node> intersectionNodes = new LinkedHashSet<Node>();
     68        Set<Node> intersectionNodes = new LinkedHashSet<>();
    6969
    7070        //copy node arrays for local usage.
    7171        for (int pos = 0; pos < n; pos ++) {
    72             newNodes[pos] = new ArrayList<Node>(ways.get(pos).getNodes());
     72            newNodes[pos] = new ArrayList<>(ways.get(pos).getNodes());
    7373            wayBounds[pos] = getNodesBounds(newNodes[pos]);
    7474            changedWays[pos] = false;
     
    828828
    829829    public static class MultiPolygonMembers {
    830         public final Set<Way> outers = new HashSet<Way>();
    831         public final Set<Way> inners = new HashSet<Way>();
     830        public final Set<Way> outers = new HashSet<>();
     831        public final Set<Way> inners = new HashSet<>();
    832832
    833833        public MultiPolygonMembers(Relation multiPolygon) {
  • trunk/src/org/openstreetmap/josm/tools/I18n.java

    r6984 r7005  
    129129    private static Map<String, String> strings = null;
    130130    private static Map<String, String[]> pstrings = null;
    131     private static Map<String, PluralMode> languages = new HashMap<String, PluralMode>();
     131    private static Map<String, PluralMode> languages = new HashMap<>();
    132132
    133133    /**
     
    324324     */
    325325    public static final Locale[] getAvailableTranslations() {
    326         Collection<Locale> v = new ArrayList<Locale>(languages.size());
     326        Collection<Locale> v = new ArrayList<>(languages.size());
    327327        if(getTranslationFile("en") != null)
    328328        {
     
    490490            p = pstrings;
    491491        } else {
    492             s = new HashMap<String, String>();
    493             p = new HashMap<String, String[]>();
     492            s = new HashMap<>();
     493            p = new HashMap<>();
    494494        }
    495495        /* file format:
  • trunk/src/org/openstreetmap/josm/tools/ImageProvider.java

    r6995 r7005  
    111111     * The icon cache
    112112     */
    113     private static final Map<String, ImageResource> cache = new HashMap<String, ImageResource>();
     113    private static final Map<String, ImageResource> cache = new HashMap<>();
    114114
    115115    /**
    116116     * Caches the image data for rotated versions of the same image.
    117117     */
    118     private static final Map<Image, Map<Long, ImageResource>> ROTATE_CACHE = new HashMap<Image, Map<Long, ImageResource>>();
     118    private static final Map<Image, Map<Long, ImageResource>> ROTATE_CACHE = new HashMap<>();
    119119
    120120    private static final ExecutorService IMAGE_FETCHER = Executors.newSingleThreadExecutor();
     
    677677        if (path != null && path.startsWith("resource://")) {
    678678            String p = path.substring("resource://".length());
    679             Collection<ClassLoader> classLoaders = new ArrayList<ClassLoader>(PluginHandler.getResourceClassLoaders());
     679            Collection<ClassLoader> classLoaders = new ArrayList<>(PluginHandler.getResourceClassLoaders());
    680680            if (additionalClassLoaders != null) {
    681681                classLoaders.addAll(additionalClassLoaders);
     
    896896            Map<Long, ImageResource> cacheByAngle = ROTATE_CACHE.get(img);
    897897            if (cacheByAngle == null) {
    898                 ROTATE_CACHE.put(img, cacheByAngle = new HashMap<Long, ImageResource>());
     898                ROTATE_CACHE.put(img, cacheByAngle = new HashMap<>());
    899899            }
    900900
  • trunk/src/org/openstreetmap/josm/tools/ImageResource.java

    r6316 r7005  
    2525     * Caches the image data for resized versions of the same image.
    2626     */
    27     private Map<Dimension, Image> imgCache = new HashMap<Dimension, Image>();
     27    private Map<Dimension, Image> imgCache = new HashMap<>();
    2828    private SVGDiagram svg;
    2929    public static final Dimension DEFAULT_DIMENSION = new Dimension(-1, -1);
  • trunk/src/org/openstreetmap/josm/tools/MultiMap.java

    r5822 r7005  
    2222    private final Map<A, Set<B>> map;
    2323
     24    /**
     25     * Constructs a new {@code MultiMap}.
     26     */
    2427    public MultiMap() {
    25         map = new HashMap<A, Set<B>>();
     28        map = new HashMap<>();
    2629    }
    2730
     31    /**
     32     * Constructs a new {@code MultiMap} with the specified initial capacity.
     33     * @param capacity the initial capacity
     34     */
    2835    public MultiMap(int capacity) {
    29         map = new HashMap<A, Set<B>>(capacity);
     36        map = new HashMap<>(capacity);
    3037    }
    3138
     
    3845        Set<B> vals = map.get(key);
    3946        if (vals == null) {
    40             vals = new LinkedHashSet<B>();
     47            vals = new LinkedHashSet<>();
    4148            map.put(key, vals);
    4249        }
     
    6471        Set<B> vals = map.get(key);
    6572        if (vals == null) {
    66             vals = new LinkedHashSet<B>(values);
     73            vals = new LinkedHashSet<>(values);
    6774            map.put(key, vals);
    6875        }
     
    93100    public Set<B> getValues(A key) {
    94101        if (!map.containsKey(key))
    95             return new LinkedHashSet<B>();
     102            return new LinkedHashSet<>();
    96103        return map.get(key);
    97104    }
     
    161168    @Override
    162169    public String toString() {
    163         List<String> entries = new ArrayList<String>(map.size());
     170        List<String> entries = new ArrayList<>(map.size());
    164171        for (A key : map.keySet()) {
    165172            entries.add(key + "->{" + Utils.join(",", map.get(key)) + "}");
  • trunk/src/org/openstreetmap/josm/tools/MultikeyActionsHandler.java

    r6362 r7005  
    3232    private static final String STATUS_BAR_ID = "multikeyShortcut";
    3333
    34     private Map<MultikeyShortcutAction, MyAction> myActions = new HashMap<MultikeyShortcutAction,MyAction>();
     34    private Map<MultikeyShortcutAction, MyAction> myActions = new HashMap<>();
    3535
    3636    private class MyKeyEventDispatcher implements KeyEventDispatcher {
  • trunk/src/org/openstreetmap/josm/tools/OsmUrlToBounds.java

    r7004 r7005  
    4444        }
    4545        String[] args = url.substring(i+1).split("&");
    46         HashMap<String, String> map = new HashMap<String, String>();
     46        HashMap<String, String> map = new HashMap<>();
    4747        for (String arg : args) {
    4848            int eq = arg.indexOf('=');
     
    146146        final String shortLink = url.substring(SHORTLINK_PREFIX.length());
    147147
    148         final Map<Character, Integer> array = new HashMap<Character, Integer>();
     148        final Map<Character, Integer> array = new HashMap<>();
    149149
    150150        for (int i=0; i<SHORTLINK_CHARS.length; ++i) {
     
    229229        double y = Math.floor((1 - Math.log(Math.tan(Math.toRadians(lat)) + 1 / Math.cos(Math.toRadians(lat))) / Math.PI)
    230230                / 2 * Math.pow(2.0, zoom));
    231         return new Pair<Double, Double>(x, y);
     231        return new Pair<>(x, y);
    232232    }
    233233
  • trunk/src/org/openstreetmap/josm/tools/Pair.java

    r6156 r7005  
    4444
    4545    public static <T> ArrayList<T> toArrayList(Pair<T, T> p) {
    46         ArrayList<T> l = new ArrayList<T>(2);
     46        ArrayList<T> l = new ArrayList<>(2);
    4747        l.add(p.a);
    4848        l.add(p.b);
     
    7171     */
    7272    public static <U,V> Pair<U,V> create(U u, V v) {
    73         return new Pair<U,V>(u,v);
     73        return new Pair<>(u,v);
    7474    }
    7575}
  • trunk/src/org/openstreetmap/josm/tools/Shortcut.java

    r6889 r7005  
    148148    // create a shortcut object from an string as saved in the preferences
    149149    private Shortcut(String prefString) {
    150         List<String> s = (new ArrayList<String>(Main.pref.getCollection(prefString)));
     150        List<String> s = (new ArrayList<>(Main.pref.getCollection(prefString)));
    151151        this.shortText = prefString.substring(15);
    152152        this.longText = s.get(0);
     
    232232
    233233    // here we store our shortcuts
    234     private static Map<String, Shortcut> shortcuts = new LinkedHashMap<String, Shortcut>();
     234    private static Map<String, Shortcut> shortcuts = new LinkedHashMap<>();
    235235
    236236    // and here our modifier groups
    237     private static Map<Integer, Integer> groups= new HashMap<Integer, Integer>();
     237    private static Map<Integer, Integer> groups= new HashMap<>();
    238238
    239239    // check if something collides with an existing shortcut
     
    252252     */
    253253    public static List<Shortcut> listAll() {
    254         List<Shortcut> l = new ArrayList<Shortcut>();
     254        List<Shortcut> l = new ArrayList<>();
    255255        for(Shortcut c : shortcuts.values())
    256256        {
     
    299299        Main.platform.initSystemShortcuts();
    300300        // (2) User defined shortcuts
    301         LinkedList<Shortcut> newshortcuts = new LinkedList<Shortcut>();
     301        LinkedList<Shortcut> newshortcuts = new LinkedList<>();
    302302        for(String s : Main.pref.getAllPrefixCollectionKeys("shortcut.entry.")) {
    303303            newshortcuts.add(new Shortcut(s));
  • trunk/src/org/openstreetmap/josm/tools/TaggingPresetNameTemplateList.java

    r6362 r7005  
    2525        return instance;
    2626    }
    27     private final List<TaggingPreset> presetsWithPattern = new LinkedList<TaggingPreset>();
     27    private final List<TaggingPreset> presetsWithPattern = new LinkedList<>();
    2828
    2929    private TaggingPresetNameTemplateList() {
  • trunk/src/org/openstreetmap/josm/tools/TextTagParser.java

    r6830 r7005  
    5858        Map<String, String>  getFreeParsedTags() {
    5959            String k, v;
    60             Map<String, String> tags = new HashMap<String,String>();
     60            Map<String, String> tags = new HashMap<>();
    6161
    6262            while (true) {
     
    164164         String[] lines = text.split(splitRegex);
    165165         Pattern p = Pattern.compile(tagRegex);
    166          Map<String, String> tags = new HashMap<String,String>();
     166         Map<String, String> tags = new HashMap<>();
    167167         String k=null, v=null;
    168168         for (String  line: lines) {
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r7004 r7005  
    122122
    123123    public static <T> Collection<T> filter(Collection<? extends T> collection, Predicate<? super T> predicate) {
    124         return new FilteredCollection<T>(collection, predicate);
     124        return new FilteredCollection<>(collection, predicate);
    125125    }
    126126
     
    142142     */
    143143    public static <S, T extends S> SubclassFilteredCollection<S, T> filteredCollection(Collection<S> collection, final Class<T> klass) {
    144         return new SubclassFilteredCollection<S, T>(collection, new Predicate<S>() {
     144        return new SubclassFilteredCollection<>(collection, new Predicate<S>() {
    145145            @Override
    146146            public boolean evaluate(S o) {
     
    523523     */
    524524    public static <T> List<T> topologicalSort(final MultiMap<T,T> dependencies) {
    525         MultiMap<T,T> deps = new MultiMap<T,T>();
     525        MultiMap<T,T> deps = new MultiMap<>();
    526526        for (T key : dependencies.keySet()) {
    527527            deps.putVoid(key);
     
    533533
    534534        int size = deps.size();
    535         List<T> sorted = new ArrayList<T>();
     535        List<T> sorted = new ArrayList<>();
    536536        for (int i=0; i<size; ++i) {
    537537            T parentless = null;
     
    906906    public static List<String> getMatches(final Matcher m) {
    907907        if (m.matches()) {
    908             List<String> result = new ArrayList<String>(m.groupCount() + 1);
     908            List<String> result = new ArrayList<>(m.groupCount() + 1);
    909909            for (int i = 0; i <= m.groupCount(); i++) {
    910910                result.add(m.group(i));
  • trunk/src/org/openstreetmap/josm/tools/XmlObjectParser.java

    r6906 r7005  
    6666
    6767    private class Parser extends DefaultHandler {
    68         Stack<Object> current = new Stack<Object>();
     68        Stack<Object> current = new Stack<>();
    6969        StringBuilder characters = new StringBuilder(64);
    7070
     
    186186        boolean onStart;
    187187        boolean both;
    188         private final Map<String, Field> fields = new HashMap<String, Field>();
    189         private final Map<String, Method> methods = new HashMap<String, Method>();
     188        private final Map<String, Field> fields = new HashMap<>();
     189        private final Map<String, Method> methods = new HashMap<>();
    190190
    191191        public Entry(Class<?> klass, boolean onStart, boolean both) {
     
    226226    }
    227227
    228     private Map<String, Entry> mapping = new HashMap<String, Entry>();
     228    private Map<String, Entry> mapping = new HashMap<>();
    229229    private DefaultHandler parser;
    230230
     
    232232     * The queue of already parsed items from the parsing thread.
    233233     */
    234     private List<Object> queue = new LinkedList<Object>();
     234    private List<Object> queue = new LinkedList<>();
    235235    private Iterator<Object> queueIterator = null;
    236236
  • trunk/src/org/openstreetmap/josm/tools/template_engine/Condition.java

    r6986 r7005  
    88public class Condition implements TemplateEntry {
    99
    10     private final List<TemplateEntry> entries = new ArrayList<TemplateEntry>();
     10    private final List<TemplateEntry> entries = new ArrayList<>();
    1111
    1212    public List<TemplateEntry> getEntries() {
  • trunk/src/org/openstreetmap/josm/tools/template_engine/ContextSwitchTemplate.java

    r4817 r7005  
    6666            }
    6767
    68             List<OsmPrimitive> result = new ArrayList<OsmPrimitive>();
     68            List<OsmPrimitive> result = new ArrayList<>();
    6969            for (OsmPrimitive child: children) {
    7070                for (OsmPrimitive parent: child.getReferrers(true)) {
     
    100100                parents = Collections.emptyList();
    101101            }
    102             List<OsmPrimitive> result = new ArrayList<OsmPrimitive>();
     102            List<OsmPrimitive> result = new ArrayList<>();
    103103            for (OsmPrimitive p: parents) {
    104104                if (p instanceof Way) {
     
    137137        @Override
    138138        List<OsmPrimitive> getPrimitives(OsmPrimitive root) {
    139             List<OsmPrimitive> result = new ArrayList<OsmPrimitive>();
     139            List<OsmPrimitive> result = new ArrayList<>();
    140140            for (OsmPrimitive o: lhs.getPrimitives(root)) {
    141141                if (condition == null || condition.match(o)) {
     
    168168        @Override
    169169        List<OsmPrimitive> getPrimitives(OsmPrimitive root) {
    170             List<OsmPrimitive> result = new ArrayList<OsmPrimitive>();
     170            List<OsmPrimitive> result = new ArrayList<>();
    171171            List<OsmPrimitive> lhsList = lhs.getPrimitives(root);
    172172            for (OsmPrimitive o: rhs.getPrimitives(root)) {
  • trunk/src/org/openstreetmap/josm/tools/template_engine/TemplateParser.java

    r4546 r7005  
    3939
    4040    private TemplateEntry parseExpression(Collection<TokenType> endTokens) throws ParseError {
    41         List<TemplateEntry> entries = new ArrayList<TemplateEntry>();
     41        List<TemplateEntry> entries = new ArrayList<>();
    4242        while (true) {
    4343            TemplateEntry templateEntry;
Note: See TracChangeset for help on using the changeset viewer.