Changeset 10717 in josm for trunk


Ignore:
Timestamp:
2016-08-03T15:39:00+02:00 (8 years ago)
Author:
simon04
Message:

see #11390, see #12890 - Lambda can be replaced with method reference

Location:
trunk
Files:
17 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/actions/UnGlueAction.java

    r10716 r10717  
    250250
    251251        private static boolean isTagged(final Collection<Node> existingNodes) {
    252             return existingNodes.stream().anyMatch(selectedNode -> selectedNode.hasKeys());
     252            return existingNodes.stream().anyMatch(Node::hasKeys);
    253253        }
    254254
  • trunk/src/org/openstreetmap/josm/actions/relation/DownloadSelectedIncompleteMembersAction.java

    r10657 r10717  
    5959    public void setPrimitives(Collection<? extends OsmPrimitive> primitives) {
    6060        // selected relations with incomplete members
    61         this.relations = SubclassFilteredCollection.filter(getRelations(primitives), r -> r.hasIncompleteMembers());
     61        this.relations = SubclassFilteredCollection.filter(getRelations(primitives), Relation::hasIncompleteMembers);
    6262        this.incompleteMembers = buildSetOfIncompleteMembers(relations);
    6363        updateEnabledState();
  • trunk/src/org/openstreetmap/josm/data/osm/NoteData.java

    r10657 r10717  
    153153            } else {
    154154                final Note existingNote = noteList.get(newNote);
    155                 final boolean isDirty = existingNote.getComments().stream().anyMatch(object -> object.isNew());
     155                final boolean isDirty = existingNote.getComments().stream().anyMatch(NoteComment::isNew);
    156156                if (!isDirty) {
    157157                    noteList.put(newNote);
  • trunk/src/org/openstreetmap/josm/data/osm/Relation.java

    r10716 r10717  
    401401
    402402    public List<OsmPrimitive> getMemberPrimitivesList() {
    403         return Utils.transform(getMembers(), (Function<RelationMember, OsmPrimitive>) x -> x.getMember());
     403        return Utils.transform(getMembers(), RelationMember::getMember);
    404404    }
    405405
  • trunk/src/org/openstreetmap/josm/gui/conflict/tags/RelationMemberConflictResolverModel.java

    r10716 r10717  
    234234                    iterators.add(i.iterator());
    235235                }
    236                 while (iterators.stream().allMatch(it -> it.hasNext())) {
     236                while (iterators.stream().allMatch(Iterator::hasNext)) {
    237237                    final List<RelationMemberConflictDecision> decisions = new ArrayList<>();
    238238                    final Collection<String> roles = new HashSet<>();
  • trunk/src/org/openstreetmap/josm/gui/dialogs/OsmIdSelectionDialog.java

    r10680 r10717  
    206206                    .collect(Collectors.joining(", "));
    207207            tfId.tryToPasteFrom(parsedText);
    208             final Set<OsmPrimitiveType> types = ids.stream().map(x -> x.getType()).collect(Collectors.toSet());
     208            final Set<OsmPrimitiveType> types = ids.stream().map(SimplePrimitiveId::getType).collect(Collectors.toSet());
    209209            if (types.size() == 1) {
    210210                // select corresponding type
  • trunk/src/org/openstreetmap/josm/gui/dialogs/changeset/ChangesetContentPanel.java

    r10638 r10717  
    300300        @Override
    301301        public void actionPerformed(ActionEvent arg0) {
    302             final List<PrimitiveId> primitiveIds = model.getSelectedPrimitives().stream().map(x -> x.getPrimitiveId())
     302            final List<PrimitiveId> primitiveIds = model.getSelectedPrimitives().stream().map(HistoryOsmPrimitive::getPrimitiveId)
    303303                    .collect(Collectors.toList());
    304304            Main.worker.submit(new DownloadPrimitivesWithReferrersTask(false, primitiveIds, true, true, null, null));
  • trunk/src/org/openstreetmap/josm/gui/layer/LayerPositionStrategy.java

    r10715 r10717  
    3737     */
    3838    LayerPositionStrategy BEFORE_FIRST_BACKGROUND_LAYER = inFrontOfFirst(
    39             layer -> layer.isBackgroundLayer());
     39            Layer::isBackgroundLayer);
    4040
    4141    /**
  • trunk/src/org/openstreetmap/josm/gui/mappaint/mapcss/Condition.java

    r10715 r10717  
    166166        ONE_OF((test, prototype) -> Arrays.asList(test.split("\\s*;\\s*")).contains(prototype)),
    167167        /** The value needs to begin with the reference string. */
    168         BEGINS_WITH((test, prototype) -> test.startsWith(prototype)),
     168        BEGINS_WITH(String::startsWith),
    169169        /** The value needs to end with the reference string. */
    170         ENDS_WITH((test, prototype) -> test.endsWith(prototype)),
     170        ENDS_WITH(String::endsWith),
    171171        /** The value needs to contain the reference string. */
    172         CONTAINS((test, prototype) -> test.contains(prototype));
     172        CONTAINS(String::contains);
    173173
    174174        static final Set<Op> NEGATED_OPS = EnumSet.of(NEQ, NREGEX);
  • trunk/src/org/openstreetmap/josm/io/imagery/WMSImagery.java

    r10670 r10717  
    234234
    235235            formats = getChildrenStream(child, "Format")
    236                     .map(x -> x.getTextContent())
     236                    .map(Node::getTextContent)
    237237                    .filter(WMSImagery::isImageFormatSupportedWarn)
    238238                    .collect(Collectors.toList());
  • trunk/src/org/openstreetmap/josm/io/remotecontrol/handler/ImageryHandler.java

    r10689 r10717  
    132132    public String[] getUsageExamples() {
    133133        final String types = Utils.join("|", Utils.transform(Arrays.asList(ImageryInfo.ImageryType.values()),
    134                 (Function<ImageryType, String>) x -> x.getTypeString()));
     134                ImageryType::getTypeString));
    135135        return new String[] {
    136136            "/imagery?title=osm&type=tms&url=https://a.tile.openstreetmap.org/%7Bzoom%7D/%7Bx%7D/%7By%7D.png",
  • trunk/src/org/openstreetmap/josm/tools/ExceptionUtil.java

    r10689 r10717  
    1616import java.util.Date;
    1717import java.util.TreeSet;
    18 import java.util.function.Function;
    1918import java.util.regex.Matcher;
    2019import java.util.regex.Pattern;
     
    142141            OsmPrimitive firstRefs = conflict.b.iterator().next();
    143142            String objId = Long.toString(conflict.a.getId());
    144             Collection<Long> refIds = Utils.transform(conflict.b, (Function<OsmPrimitive, Long>) x -> x.getId());
     143            Collection<Long> refIds = Utils.transform(conflict.b, OsmPrimitive::getId);
    145144            String refIdsString = refIds.size() == 1 ? refIds.iterator().next().toString() : refIds.toString();
    146145            if (conflict.a instanceof Node) {
  • trunk/src/org/openstreetmap/josm/tools/MemoryManager.java

    r10598 r10717  
    8787     */
    8888    public synchronized long getAvailableMemory() {
    89         return getMaxMemory() - activeHandles.stream().mapToLong(h -> h.getSize()).sum();
     89        return getMaxMemory() - activeHandles.stream().mapToLong(MemoryHandle::getSize).sum();
    9090    }
    9191
     
    104104    protected synchronized List<MemoryHandle<?>> resetState() {
    105105        ArrayList<MemoryHandle<?>> toFree = new ArrayList<>(activeHandles);
    106         toFree.stream().forEach(h -> h.free());
     106        toFree.forEach(MemoryHandle::free);
    107107        return toFree;
    108108    }
  • trunk/src/org/openstreetmap/josm/tools/MultiLineFlowLayout.java

    r10622 r10717  
    4848    @Override
    4949    public Dimension preferredLayoutSize(Container target) {
    50         return getLayoutSize(target, c -> c.getPreferredSize());
     50        return getLayoutSize(target, Component::getPreferredSize);
    5151    }
    5252
    5353    @Override
    5454    public Dimension minimumLayoutSize(Container target) {
    55         return getLayoutSize(target, c -> c.getMinimumSize());
     55        return getLayoutSize(target, Component::getMinimumSize);
    5656    }
    5757
  • trunk/src/org/openstreetmap/josm/tools/Utils.java

    r10715 r10717  
    319319     */
    320320    public static String joinAsHtmlUnorderedList(Iterable<?> values) {
    321         return StreamUtils.toStream(values.iterator()).map(x -> x.toString()).collect(StreamUtils.toHtmlList());
     321        return StreamUtils.toStream(values.iterator()).map(Object::toString).collect(StreamUtils.toHtmlList());
    322322    }
    323323
     
    13411341     */
    13421342    public static Executor newDirectExecutor() {
    1343         return command -> command.run();
     1343        return Runnable::run;
    13441344    }
    13451345
  • trunk/test/unit/org/openstreetmap/josm/io/OsmWriterTest.java

    r10638 r10717  
    3232        Collections.sort(ids, OsmWriter.byIdComparator);
    3333
    34         final long[] longIds = ids.stream().mapToLong(x -> x.getUniqueId()).toArray();
     34        final long[] longIds = ids.stream().mapToLong(NodeData::getUniqueId).toArray();
    3535        assertArrayEquals(new long[] {
    3636                -3, -12, -20, -9223372036854775808L, 0, 2, 12, 65, 9223372036854775807L
  • trunk/test/unit/org/openstreetmap/josm/tools/MemoryManagerTest.java

    r10588 r10717  
    4848        assertTrue(testMemory.toString().startsWith("MemoryHandle"));
    4949
    50         manager.allocateMemory("test2", 10, () -> new Object());
     50        manager.allocateMemory("test2", 10, Object::new);
    5151        assertEquals(available - 20, manager.getAvailableMemory());
    5252
     
    6262    public void testUseAfterFree() throws NotEnoughMemoryException {
    6363        MemoryManager manager = MemoryManager.getInstance();
    64         MemoryHandle<Object> testMemory = manager.allocateMemory("test", 10, () -> new Object());
     64        MemoryHandle<Object> testMemory = manager.allocateMemory("test", 10, Object::new);
    6565        testMemory.free();
    6666        testMemory.get();
     
    7474    public void testFreeAfterFree() throws NotEnoughMemoryException {
    7575        MemoryManager manager = MemoryManager.getInstance();
    76         MemoryHandle<Object> testMemory = manager.allocateMemory("test", 10, () -> new Object());
     76        MemoryHandle<Object> testMemory = manager.allocateMemory("test", 10, Object::new);
    7777        testMemory.free();
    7878        testMemory.free();
     
    136136        assertTrue(manager.resetState().isEmpty());
    137137
    138         manager.allocateMemory("test", 10, () -> new Object());
    139         manager.allocateMemory("test2", 10, () -> new Object());
     138        manager.allocateMemory("test", 10, Object::new);
     139        manager.allocateMemory("test2", 10, Object::new);
    140140        assertEquals(2, manager.resetState().size());
    141141
     
    150150    public void testResetStateUseAfterFree() throws NotEnoughMemoryException {
    151151        MemoryManager manager = MemoryManager.getInstance();
    152         MemoryHandle<Object> testMemory = manager.allocateMemory("test", 10, () -> new Object());
     152        MemoryHandle<Object> testMemory = manager.allocateMemory("test", 10, Object::new);
    153153
    154154        assertFalse(manager.resetState().isEmpty());
Note: See TracChangeset for help on using the changeset viewer.