Changeset 16326 in josm for trunk/src/org


Ignore:
Timestamp:
2020-04-17T21:27:31+02:00 (5 years ago)
Author:
simon04
Message:

Java 8: use Stream.anyMatch

Location:
trunk/src/org/openstreetmap/josm/gui/datatransfer
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/org/openstreetmap/josm/gui/datatransfer/AbstractStackTransferHandler.java

    r12636 r16326  
    3535    public boolean canImport(TransferSupport support) {
    3636        // import everything for now, only support copy.
    37         for (AbstractOsmDataPaster df : getSupportedPasters()) {
    38             if (df.supports(support)) {
    39                 return true;
    40             }
    41         }
    42         return false;
     37        return getSupportedPasters().stream()
     38                .anyMatch(df -> df.supports(support));
    4339    }
    4440
  • trunk/src/org/openstreetmap/josm/gui/datatransfer/OsmTransferHandler.java

    r14500 r16326  
    9191        try {
    9292            Collection<DataFlavor> available = Arrays.asList(ClipboardUtils.getClipboard().getAvailableDataFlavors());
    93             for (AbstractOsmDataPaster s : SUPPORTED) {
    94                 if (s.supports(available)) {
    95                     return true;
    96                 }
    97             }
     93            return SUPPORTED.stream()
     94                    .anyMatch(s -> s.supports(available));
    9895        } catch (IllegalStateException e) {
    9996            Logging.debug(e);
  • trunk/src/org/openstreetmap/josm/gui/datatransfer/PrimitiveTransferable.java

    r14500 r16326  
    6262    public boolean isDataFlavorSupported(DataFlavor flavor) {
    6363        DataFlavor[] flavors = getTransferDataFlavors();
    64         for (DataFlavor f : flavors) {
    65             if (flavor.equals(f)) {
    66                 return true;
    67             }
    68         }
    69         return false;
     64        return Arrays.stream(flavors)
     65                .anyMatch(flavor::equals);
    7066    }
    7167
Note: See TracChangeset for help on using the changeset viewer.