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

see #8465 - use diamond operator where applicable

Location:
trunk/src/org/openstreetmap/josm/command
Files:
10 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/command/AddPrimitivesCommand.java

    r6069 r7005  
    2424public class AddPrimitivesCommand extends Command {
    2525
    26     private List<PrimitiveData> data = new ArrayList<PrimitiveData>();
    27     private Collection<PrimitiveData> toSelect = new ArrayList<PrimitiveData>();
     26    private List<PrimitiveData> data = new ArrayList<>();
     27    private Collection<PrimitiveData> toSelect = new ArrayList<>();
    2828
    2929    // only filled on undo
     
    7171        Collection<OsmPrimitive> primitivesToSelect;
    7272        if (createdPrimitives == null) { // first time execution
    73             List<OsmPrimitive> newPrimitives = new ArrayList<OsmPrimitive>(data.size());
    74             primitivesToSelect = new ArrayList<OsmPrimitive>(toSelect.size());
     73            List<OsmPrimitive> newPrimitives = new ArrayList<>(data.size());
     74            primitivesToSelect = new ArrayList<>(toSelect.size());
    7575
    7676            for (PrimitiveData pd : data) {
     
    115115
    116116        if (createdPrimitives == null) {
    117             createdPrimitives = new ArrayList<OsmPrimitive>(data.size());
    118             createdPrimitivesToSelect = new ArrayList<OsmPrimitive>(toSelect.size());
     117            createdPrimitives = new ArrayList<>(data.size());
     118            createdPrimitivesToSelect = new ArrayList<>(toSelect.size());
    119119
    120120            for (PrimitiveData pd : data) {
     
    162162            return createdPrimitives;
    163163
    164         Collection<OsmPrimitive> prims = new HashSet<OsmPrimitive>();
     164        Collection<OsmPrimitive> prims = new HashSet<>();
    165165        for (PrimitiveData d : data) {
    166166            OsmPrimitive osm = getLayer().data.getPrimitiveById(d);
  • trunk/src/org/openstreetmap/josm/command/ChangePropertyCommand.java

    r6881 r7005  
    4949     */
    5050    public ChangePropertyCommand(Collection<? extends OsmPrimitive> objects, AbstractMap<String, String> tags) {
    51         this.objects = new LinkedList<OsmPrimitive>();
     51        this.objects = new LinkedList<>();
    5252        this.tags = tags;
    5353        init(objects);
     
    6262     */
    6363    public ChangePropertyCommand(Collection<? extends OsmPrimitive> objects, String key, String value) {
    64         this.objects = new LinkedList<OsmPrimitive>();
    65         this.tags = new HashMap<String, String>(1);
     64        this.objects = new LinkedList<>();
     65        this.tags = new HashMap<>(1);
    6666        this.tags.put(key, value);
    6767        init(objects);
     
    201201        if (objects.size() == 1)
    202202            return null;
    203         List<PseudoCommand> children = new ArrayList<PseudoCommand>();
     203        List<PseudoCommand> children = new ArrayList<>();
    204204        for (final OsmPrimitive osm : objects) {
    205205            children.add(new PseudoCommand() {
  • trunk/src/org/openstreetmap/josm/command/ChangePropertyKeyCommand.java

    r6329 r7005  
    5454     */
    5555    public ChangePropertyKeyCommand(Collection<? extends OsmPrimitive> objects, String key, String newKey) {
    56         this.objects = new LinkedList<OsmPrimitive>(objects);
     56        this.objects = new LinkedList<>(objects);
    5757        this.key = key;
    5858        this.newKey = newKey;
     
    101101        if (objects.size() == 1)
    102102            return null;
    103         List<PseudoCommand> children = new ArrayList<PseudoCommand>();
     103        List<PseudoCommand> children = new ArrayList<>();
    104104
    105105        final NameVisitor v = new NameVisitor();
  • trunk/src/org/openstreetmap/josm/command/Command.java

    r6901 r7005  
    3939
    4040    private static final class CloneVisitor extends AbstractVisitor {
    41         public final Map<OsmPrimitive, PrimitiveData> orig = new LinkedHashMap<OsmPrimitive, PrimitiveData>();
     41        public final Map<OsmPrimitive, PrimitiveData> orig = new LinkedHashMap<>();
    4242
    4343        @Override
     
    7676
    7777    /** the map of OsmPrimitives in the original state to OsmPrimitives in cloned state */
    78     private Map<OsmPrimitive, PrimitiveData> cloneMap = new HashMap<OsmPrimitive, PrimitiveData>();
     78    private Map<OsmPrimitive, PrimitiveData> cloneMap = new HashMap<>();
    7979
    8080    /** the layer which this command is applied to */
     
    106106    public boolean executeCommand() {
    107107        CloneVisitor visitor = new CloneVisitor();
    108         Collection<OsmPrimitive> all = new ArrayList<OsmPrimitive>();
     108        Collection<OsmPrimitive> all = new ArrayList<>();
    109109        fillModifiedData(all, all, all);
    110110        for (OsmPrimitive osm : all) {
  • trunk/src/org/openstreetmap/josm/command/DeleteCommand.java

    r6901 r7005  
    5151     */
    5252    private final Collection<? extends OsmPrimitive> toDelete;
    53     private final Map<OsmPrimitive, PrimitiveData> clonedPrimitives = new HashMap<OsmPrimitive, PrimitiveData>();
     53    private final Map<OsmPrimitive, PrimitiveData> clonedPrimitives = new HashMap<>();
    5454
    5555    /**
     
    150150
    151151    private Set<OsmPrimitiveType> getTypesToDelete() {
    152         Set<OsmPrimitiveType> typesToDelete = new HashSet<OsmPrimitiveType>();
     152        Set<OsmPrimitiveType> typesToDelete = new HashSet<>();
    153153        for (OsmPrimitive osm : toDelete) {
    154154            typesToDelete.add(OsmPrimitiveType.from(osm));
     
    201201            return null;
    202202        else {
    203             List<PseudoCommand> children = new ArrayList<PseudoCommand>(toDelete.size());
     203            List<PseudoCommand> children = new ArrayList<>(toDelete.size());
    204204            for (final OsmPrimitive osm : toDelete) {
    205205                children.add(new PseudoCommand() {
     
    278278     */
    279279    protected static Collection<Node> computeNodesToDelete(OsmDataLayer layer, Collection<OsmPrimitive> primitivesToDelete) {
    280         Collection<Node> nodesToDelete = new HashSet<Node>();
     280        Collection<Node> nodesToDelete = new HashSet<>();
    281281        for (Way way : OsmPrimitive.getFilteredList(primitivesToDelete, Way.class)) {
    282282            for (Node n : way.getNodes()) {
     
    339339            return null;
    340340
    341         Set<OsmPrimitive> primitivesToDelete = new HashSet<OsmPrimitive>(selection);
     341        Set<OsmPrimitive> primitivesToDelete = new HashSet<>(selection);
    342342
    343343        Collection<Relation> relationsToDelete = Utils.filteredCollection(primitivesToDelete, Relation.class);
     
    345345            return null;
    346346
    347         Collection<Way> waysToBeChanged = new HashSet<Way>();
     347        Collection<Way> waysToBeChanged = new HashSet<>();
    348348
    349349        if (alsoDeleteNodesInWay) {
     
    359359        waysToBeChanged.addAll(OsmPrimitive.getFilteredSet(OsmPrimitive.getReferrer(primitivesToDelete), Way.class));
    360360
    361         Collection<Command> cmds = new LinkedList<Command>();
     361        Collection<Command> cmds = new LinkedList<>();
    362362        for (Way w : waysToBeChanged) {
    363363            Way wnew = new Way(w);
     
    415415            // the way shouldn't be splitted
    416416
    417             List<Node> n = new ArrayList<Node>();
     417            List<Node> n = new ArrayList<>();
    418418
    419419            n.addAll(ws.way.getNodes().subList(ws.lowerIndex + 1, ws.way.getNodesCount() - 1));
     
    426426        }
    427427
    428         List<Node> n1 = new ArrayList<Node>(), n2 = new ArrayList<Node>();
     428        List<Node> n1 = new ArrayList<>(), n2 = new ArrayList<>();
    429429
    430430        n1.addAll(ws.way.getNodes().subList(0, ws.lowerIndex + 1));
     
    440440            return new ChangeCommand(ws.way, wnew);
    441441        } else {
    442             List<List<Node>> chunks = new ArrayList<List<Node>>(2);
     442            List<List<Node>> chunks = new ArrayList<>(2);
    443443            chunks.add(n1);
    444444            chunks.add(n2);
  • trunk/src/org/openstreetmap/josm/command/MoveCommand.java

    r6890 r7005  
    3030     * The objects that should be moved.
    3131     */
    32     private Collection<Node> nodes = new LinkedList<Node>();
     32    private Collection<Node> nodes = new LinkedList<>();
    3333    /**
    3434     * Starting position, base command point, current (mouse-drag) position = startEN + (x,y) =
     
    5151     * List of all old states of the objects.
    5252     */
    53     private List<OldNodeState> oldState = new LinkedList<OldNodeState>();
     53    private List<OldNodeState> oldState = new LinkedList<>();
    5454
    5555    /**
  • trunk/src/org/openstreetmap/josm/command/PurgeCommand.java

    r6890 r7005  
    6868
    6969    protected final void saveIncomplete(Collection<OsmPrimitive> makeIncomplete) {
    70         makeIncompleteData = new Storage<PrimitiveData>(new Storage.PrimitiveIdHash());
     70        makeIncompleteData = new Storage<>(new Storage.PrimitiveIdHash());
    7171        makeIncompleteData_byPrimId = makeIncompleteData.foreignKey(new Storage.PrimitiveIdHash());
    7272
     
    143143     */
    144144    public static List<OsmPrimitive> topoSort(Collection<OsmPrimitive> sel) {
    145         Set<OsmPrimitive> in = new HashSet<OsmPrimitive>(sel);
    146 
    147         List<OsmPrimitive> out = new ArrayList<OsmPrimitive>(in.size());
     145        Set<OsmPrimitive> in = new HashSet<>(sel);
     146
     147        List<OsmPrimitive> out = new ArrayList<>(in.size());
    148148
    149149        // Nodes not deleted in the first pass
    150         Set<OsmPrimitive> remainingNodes = new HashSet<OsmPrimitive>(in.size());
     150        Set<OsmPrimitive> remainingNodes = new HashSet<>(in.size());
    151151
    152152        /**
     
    198198        @SuppressWarnings({ "unchecked", "rawtypes" })
    199199        Set<Relation> inR = (Set) in;
    200         Set<Relation> childlessR = new HashSet<Relation>();
    201         List<Relation> outR = new ArrayList<Relation>(inR.size());
    202 
    203         HashMap<Relation, Integer> numChilds = new HashMap<Relation, Integer>();
     200        Set<Relation> childlessR = new HashSet<>();
     201        List<Relation> outR = new ArrayList<>(inR.size());
     202
     203        HashMap<Relation, Integer> numChilds = new HashMap<>();
    204204
    205205        // calculate initial number of childs
  • trunk/src/org/openstreetmap/josm/command/RemoveNodesCommand.java

    r6881 r7005  
    3737    public RemoveNodesCommand(Way way, List<Node> rmNodes) {
    3838        this.way = way;
    39         this.rmNodes = new HashSet<Node>(rmNodes);
     39        this.rmNodes = new HashSet<>(rmNodes);
    4040    }
    4141
  • trunk/src/org/openstreetmap/josm/command/SequenceCommand.java

    r6450 r7005  
    108108    @Override
    109109    public Collection<? extends OsmPrimitive> getParticipatingPrimitives() {
    110         Collection<OsmPrimitive> prims = new HashSet<OsmPrimitive>();
     110        Collection<OsmPrimitive> prims = new HashSet<>();
    111111        for (Command c : sequence) {
    112112            prims.addAll(c.getParticipatingPrimitives());
  • trunk/src/org/openstreetmap/josm/command/TransformNodesCommand.java

    r6890 r7005  
    2727     * The nodes to transform.
    2828     */
    29     protected Collection<Node> nodes = new LinkedList<Node>();
     29    protected Collection<Node> nodes = new LinkedList<>();
    3030
    3131
     
    3333     * List of all old states of the nodes.
    3434     */
    35     protected Map<Node, OldNodeState> oldStates = new HashMap<Node, OldNodeState>();
     35    protected Map<Node, OldNodeState> oldStates = new HashMap<>();
    3636
    3737    /**
Note: See TracChangeset for help on using the changeset viewer.