pdfbox-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From til...@apache.org
Subject svn commit: r1867521 - in /pdfbox/trunk: debugger/src/main/java/org/apache/pdfbox/debugger/hexviewer/ debugger/src/main/java/org/apache/pdfbox/debugger/streampane/ debugger/src/main/java/org/apache/pdfbox/debugger/ui/ fontbox/src/main/java/org/apache/f...
Date Wed, 25 Sep 2019 17:42:57 GMT
Author: tilman
Date: Wed Sep 25 17:42:57 2019
New Revision: 1867521

URL: http://svn.apache.org/viewvc?rev=1867521&view=rev
Log:
PDFBOX-4071: use jdk8 lambda expressions

Modified:
    pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/hexviewer/HexModel.java
    pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/StreamPane.java
    pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/ui/RecentFiles.java
    pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharString.java

Modified: pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/hexviewer/HexModel.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/hexviewer/HexModel.java?rev=1867521&r1=1867520&r2=1867521&view=diff
==============================================================================
--- pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/hexviewer/HexModel.java
(original)
+++ pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/hexviewer/HexModel.java
Wed Sep 25 17:42:57 2019
@@ -139,18 +139,7 @@ class HexModel implements HexChangeListe
         if (!data.get(index).equals(value))
         {
             data.set(index, value);
-            for (HexModelChangeListener listener: modelChangeListeners)
-            {
-                listener.hexModelChanged(new HexModelChangedEvent(index, HexModelChangedEvent.SINGLE_CHANGE));
-            }
-        }
-    }
-
-    private void fireModelChanged(int index)
-    {
-        for (HexModelChangeListener listener:modelChangeListeners)
-        {
-            listener.hexModelChanged(new HexModelChangedEvent(index, HexModelChangedEvent.SINGLE_CHANGE));
+            fireModelChanged(index);
         }
     }
 
@@ -164,4 +153,10 @@ class HexModel implements HexChangeListe
         }
         fireModelChanged(index);
     }
+
+    private void fireModelChanged(int index)
+    {
+        modelChangeListeners.forEach(listener ->
+                listener.hexModelChanged(new HexModelChangedEvent(index, HexModelChangedEvent.SINGLE_CHANGE)));
+    }
 }

Modified: pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/StreamPane.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/StreamPane.java?rev=1867521&r1=1867520&r2=1867521&view=diff
==============================================================================
--- pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/StreamPane.java
(original)
+++ pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/streampane/StreamPane.java
Wed Sep 25 17:42:57 2019
@@ -331,10 +331,8 @@ public class StreamPane implements Actio
                 return null;
             }
 
-            for (Object obj : parser.getTokens())
-            {
-                writeToken(obj, docu);
-            }
+            parser.getTokens().forEach(obj -> writeToken(obj, docu));
+
             return docu;
         }
 

Modified: pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/ui/RecentFiles.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/ui/RecentFiles.java?rev=1867521&r1=1867520&r2=1867521&view=diff
==============================================================================
--- pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/ui/RecentFiles.java (original)
+++ pdfbox/trunk/debugger/src/main/java/org/apache/pdfbox/debugger/ui/RecentFiles.java Wed
Sep 25 17:42:57 2019
@@ -23,6 +23,7 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Queue;
 import java.util.prefs.Preferences;
+import java.util.stream.Collectors;
 
 /**
  * A class to save recent file history in preference using java Preference api.
@@ -112,15 +113,9 @@ public class RecentFiles
     {
         if (!isEmpty())
         {
-            List<String> files = new ArrayList<>();
-            for (String path : filePaths)
-            {
-                File file = new File(path);
-                if (file.exists())
-                {
-                    files.add(path);
-                }
-            }
+            List<String> files = filePaths.stream().
+                    filter(path -> new File(path).exists()).
+                    collect(Collectors.toList());
             if (files.size() > maximum)
             {
                 files.remove(0);

Modified: pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharString.java
URL: http://svn.apache.org/viewvc/pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharString.java?rev=1867521&r1=1867520&r2=1867521&view=diff
==============================================================================
--- pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharString.java (original)
+++ pdfbox/trunk/fontbox/src/main/java/org/apache/fontbox/cff/Type2CharString.java Wed Sep
25 17:42:57 2019
@@ -255,8 +255,7 @@ public class Type2CharString extends Typ
             }
             else
             {
-                addCommand(Arrays.asList((Number) 0f, defWidthX),
-                        new CharStringCommand(13));
+                addCommand(Arrays.asList((Number) 0f, defWidthX), new CharStringCommand(13));
             }
         }
         return numbers;
@@ -355,10 +354,7 @@ public class Type2CharString extends Typ
 
     private void addCommandList(List<List<Number>> numbers, CharStringCommand
command)
     {
-        for (List<Number> ns : numbers)
-        {
-            addCommand(ns, command);
-        }
+        numbers.forEach(ns -> addCommand(ns, command));
     }
 
     private void addCommand(List<Number> numbers, CharStringCommand command)



Mime
View raw message