From c7ad4caefc14b2eff9f4114f4fed263c3a81ff30 Mon Sep 17 00:00:00 2001 From: Ed Merks Date: Tue, 22 Feb 2022 10:48:33 +0000 Subject: [578891] Accommodate the latest changes in p2, particularly around the support for PGP keys https://bugs.eclipse.org/bugs/show_bug.cgi?id=578891--- .../eclipse/oomph/internal/util/HTTPServer.java | 14 +++++----- .../eclipse/oomph/internal/util/UtilPlugin.java | 2 ++ .../oomph/internal/util/table/AbstractRange.java | 30 ++++++++++++++++------ .../eclipse/oomph/internal/util/table/Cell.java | 7 +---- .../oomph/internal/util/table/ComposedRange.java | 10 ++++---- .../oomph/internal/util/table/Coordinate.java | 8 ++---- .../eclipse/oomph/internal/util/table/Formula.java | 5 ++++ .../oomph/internal/util/table/Generator.java | 2 ++ .../org/eclipse/oomph/util/AbstractIterator.java | 12 +++++++++ .../src/org/eclipse/oomph/util/CollectionUtil.java | 2 +- .../org/eclipse/oomph/util/ComposedIterator.java | 5 ++-- .../src/org/eclipse/oomph/util/Confirmer.java | 3 +++ .../src/org/eclipse/oomph/util/IOUtil.java | 8 +++--- .../src/org/eclipse/oomph/util/OS.java | 10 ++++---- .../src/org/eclipse/oomph/util/OomphPlugin.java | 10 ++++++-- .../src/org/eclipse/oomph/util/Pair.java | 6 ++--- .../src/org/eclipse/oomph/util/Predicates.java | 13 +++++++--- .../org/eclipse/oomph/util/ProbingSubMonitor.java | 16 +++++++----- .../src/org/eclipse/oomph/util/PropertiesUtil.java | 10 ++++---- .../src/org/eclipse/oomph/util/PropertyFile.java | 2 +- .../src/org/eclipse/oomph/util/Request.java | 2 ++ .../src/org/eclipse/oomph/util/ServiceUtil.java | 2 +- .../src/org/eclipse/oomph/util/StringUtil.java | 2 +- .../src/org/eclipse/oomph/util/SubMonitor.java | 10 ++++++++ .../src/org/eclipse/oomph/util/ThreadPool.java | 1 + .../src/org/eclipse/oomph/util/WorkerPool.java | 13 ++++++---- .../src/org/eclipse/oomph/util/XMLUtil.java | 1 + .../src/org/eclipse/oomph/util/ZIPUtil.java | 4 +++ 28 files changed, 137 insertions(+), 73 deletions(-) (limited to 'plugins/org.eclipse.oomph.util/src/org') diff --git a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/HTTPServer.java b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/HTTPServer.java index bfa1ff58a..c14b3c4bc 100644 --- a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/HTTPServer.java +++ b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/HTTPServer.java @@ -64,7 +64,7 @@ public final class HTTPServer private static final boolean DEBUG_RESPONSE = false; - private static final Map CONTENT_TYPES = new HashMap(); + private static final Map CONTENT_TYPES = new HashMap<>(); private static final ImageContext IMAGE_CONTEXT = new ImageContext(); @@ -86,7 +86,7 @@ public final class HTTPServer private static final String STATUS_NOT_IMPLEMENTED = "501 Not Implemented"; - private final List contexts = new ArrayList(); + private final List contexts = new ArrayList<>(); private final ExecutorService threadPool = Executors.newCachedThreadPool(); @@ -304,6 +304,7 @@ public final class HTTPServer this.socket = socket; } + @Override public void run() { InputStream inputStream = null; @@ -486,6 +487,7 @@ public final class HTTPServer return allowDirectory; } + @Override public final int compareTo(Context o) { return o.path.length() - path.length(); @@ -546,6 +548,7 @@ public final class HTTPServer final String finalPath = path; Arrays.sort(children, new Comparator() { + @Override public int compare(String n1, String n2) { int t1 = getType(n1); @@ -705,12 +708,7 @@ public final class HTTPServer } catch (IOException ex) { - if (ignoreExceptions) - { - return; - } - - if (ex instanceof SocketException && ex.getMessage().equals("Software caused connection abort: socket write error")) + if (ignoreExceptions || (ex instanceof SocketException && ex.getMessage().equals("Software caused connection abort: socket write error"))) { return; } diff --git a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/UtilPlugin.java b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/UtilPlugin.java index 494867aa2..98af23ee0 100644 --- a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/UtilPlugin.java +++ b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/UtilPlugin.java @@ -36,11 +36,13 @@ public final class UtilPlugin extends OomphPlugin return "/instance/org.eclipse.ui.workbench//org.eclipse.ui.commands/state/" + id + "/org.eclipse.ui.commands.toggleState"; //$NON-NLS-1$ //$NON-NLS-2$ } + @Override public void setEnabled(String id, boolean enabled) { preferences.putBoolean(getPreferenceKey(id), enabled); } + @Override public boolean isEnabled(String id) { return preferences.getBoolean(getPreferenceKey(id), false); diff --git a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/table/AbstractRange.java b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/table/AbstractRange.java index 39be994e6..49c9b4a14 100644 --- a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/table/AbstractRange.java +++ b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/table/AbstractRange.java @@ -25,24 +25,29 @@ import java.util.Set; */ public abstract class AbstractRange implements Range { + @Override public abstract Table table(); + @Override public abstract Iterator iterator(); + @Override public Set set() { - Set set = new HashSet(); + Set set = new HashSet<>(); fillCells(set); return set; } + @Override public List list() { - List list = new ArrayList(); + List list = new ArrayList<>(); fillCells(list); return list; } + @Override public int accept(Visitor visitor) throws Exception { int n = 0; @@ -57,6 +62,7 @@ public abstract class AbstractRange implements Range return n; } + @Override public boolean contains(int col, int row) { for (Cell cell : this) @@ -70,16 +76,19 @@ public abstract class AbstractRange implements Range return false; } + @Override public boolean contains(Coordinate coordinate) { return contains(coordinate.col, coordinate.row); } + @Override public boolean contains(Cell cell) { return contains(cell.col, cell.row); } + @Override public boolean contains(Range range) { for (Cell cell : range) @@ -93,43 +102,51 @@ public abstract class AbstractRange implements Range return true; } + @Override public Range offset(int cols, int rows) { return new OffsetRange(this, cols, rows); } + @Override public Range addRange(Coordinate coordinate1, Coordinate coordinate2) { return addRanges(table().range(coordinate1, coordinate2)); } + @Override public Range addRange(int col1, int row1, int col2, int row2) { return addRange(new Coordinate(col1, row1), new Coordinate(col2, row2)); } + @Override public Range addRanges(Range... ranges) { Range result = new ComposedRange(table(), this); return result.addRanges(ranges); } + @Override public Range subtractRange(Coordinate coordinate1, Coordinate coordinate2) { return subtractRanges(table().range(coordinate1, coordinate2)); } + @Override public Range subtractRange(int col1, int row1, int col2, int row2) { return subtractRange(new Coordinate(col1, row1), new Coordinate(col2, row2)); } + @Override public Range subtractRanges(Range... ranges) { Range result = new ComposedRange(table(), this); return result.subtractRanges(ranges); } + @Override public Range value(Object value) { for (Cell cell : this) @@ -140,6 +157,7 @@ public abstract class AbstractRange implements Range return this; } + @Override public Range format(Format format) { for (Cell cell : this) @@ -150,6 +168,7 @@ public abstract class AbstractRange implements Range return this; } + @Override public Range alignment(Alignment alignment) { for (Cell cell : this) @@ -174,12 +193,7 @@ public abstract class AbstractRange implements Range return true; } - if (obj == null) - { - return false; - } - - if (getClass() != obj.getClass()) + if ((obj == null) || (getClass() != obj.getClass())) { return false; } diff --git a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/table/Cell.java b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/table/Cell.java index 1a63234bd..b305ecdde 100644 --- a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/table/Cell.java +++ b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/table/Cell.java @@ -185,12 +185,7 @@ public final class Cell extends AbstractRange return true; } - if (obj == null) - { - return false; - } - - if (Cell.class != obj.getClass()) + if ((obj == null) || (Cell.class != obj.getClass())) { return false; } diff --git a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/table/ComposedRange.java b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/table/ComposedRange.java index 444f119a0..1d7cf1bfc 100644 --- a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/table/ComposedRange.java +++ b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/table/ComposedRange.java @@ -28,9 +28,9 @@ final class ComposedRange extends AbstractRange { final Table table; - final List inclusions = new ArrayList(); + final List inclusions = new ArrayList<>(); - final List exclusions = new ArrayList(); + final List exclusions = new ArrayList<>(); public ComposedRange(ComposedRange source) { @@ -76,7 +76,7 @@ final class ComposedRange extends AbstractRange Iterator iterator = ComposedIterator.fromIterables(inclusions); if (!exclusions.isEmpty()) { - Set excludedCells = new HashSet(); + Set excludedCells = new HashSet<>(); for (Range range : exclusions) { for (Cell cell : range) @@ -85,10 +85,10 @@ final class ComposedRange extends AbstractRange } } - iterator = new PredicateIterator(Predicates.excluded(excludedCells), iterator); + iterator = new PredicateIterator<>(Predicates.excluded(excludedCells), iterator); } - return new PredicateIterator(Predicates.unique(), iterator); + return new PredicateIterator<>(Predicates.unique(), iterator); } private static void addRanges(List list, Range... ranges) diff --git a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/table/Coordinate.java b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/table/Coordinate.java index abcd1d97b..84afef5a5 100644 --- a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/table/Coordinate.java +++ b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/table/Coordinate.java @@ -60,12 +60,7 @@ public final class Coordinate implements Comparable return true; } - if (obj == null) - { - return false; - } - - if (Coordinate.class != obj.getClass()) + if ((obj == null) || (Coordinate.class != obj.getClass())) { return false; } @@ -74,6 +69,7 @@ public final class Coordinate implements Comparable return col == other.col && row == other.row; } + @Override public int compareTo(Coordinate o) { int result = row - o.row; diff --git a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/table/Formula.java b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/table/Formula.java index 3e29b5794..8db63a91f 100644 --- a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/table/Formula.java +++ b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/table/Formula.java @@ -29,6 +29,7 @@ public interface Formula this.range = range; } + @Override public Double evaluate() { double sum = 0.0; @@ -57,6 +58,7 @@ public interface Formula this.range = range; } + @Override public Double evaluate() { double min = Double.MAX_VALUE; @@ -88,6 +90,7 @@ public interface Formula this.range = range; } + @Override public Double evaluate() { double max = Double.MIN_VALUE; @@ -119,6 +122,7 @@ public interface Formula this.range = range; } + @Override public Double evaluate() { double sum = 0.0; @@ -154,6 +158,7 @@ public interface Formula this.range = range; } + @Override public Integer evaluate() { int count = 0; diff --git a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/table/Generator.java b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/table/Generator.java index 49f543671..c4228eed5 100644 --- a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/table/Generator.java +++ b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/internal/util/table/Generator.java @@ -62,6 +62,7 @@ public interface Generator return value; } + @Override public Object nextValue() { try @@ -108,6 +109,7 @@ public interface Generator return repeat; } + @Override public T nextValue() { if (iterator.hasNext()) diff --git a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/AbstractIterator.java b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/AbstractIterator.java index 8c8085c35..1f33f7e5d 100644 --- a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/AbstractIterator.java +++ b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/AbstractIterator.java @@ -34,6 +34,7 @@ public abstract class AbstractIterator implements Iterator { } + @Override public final boolean hasNext() { if (nextComputed) @@ -55,6 +56,7 @@ public abstract class AbstractIterator implements Iterator return true; } + @Override public final T next() { if (!hasNext()) @@ -66,6 +68,7 @@ public abstract class AbstractIterator implements Iterator return next; } + @Override public void remove() { throw new UnsupportedOperationException(); @@ -89,46 +92,55 @@ public abstract class AbstractIterator implements Iterator { private static final ListIterator INSTANCE = new EmptyIterator(); + @Override public boolean hasNext() { return false; } + @Override public Object next() { throw new NoSuchElementException(); } + @Override public boolean hasPrevious() { return false; } + @Override public Object previous() { throw new NoSuchElementException(); } + @Override public int nextIndex() { throw new NoSuchElementException(); } + @Override public int previousIndex() { throw new NoSuchElementException(); } + @Override public void remove() { throw new UnsupportedOperationException(); } + @Override public void set(Object e) { throw new UnsupportedOperationException(); } + @Override public void add(Object e) { throw new UnsupportedOperationException(); diff --git a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/CollectionUtil.java b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/CollectionUtil.java index 82f955585..05e2b457f 100644 --- a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/CollectionUtil.java +++ b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/CollectionUtil.java @@ -29,7 +29,7 @@ public final class CollectionUtil Set set = map.get(key); if (set == null) { - set = new LinkedHashSet(); + set = new LinkedHashSet<>(); map.put(key, set); } diff --git a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/ComposedIterator.java b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/ComposedIterator.java index baf38a155..1872b45cf 100644 --- a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/ComposedIterator.java +++ b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/ComposedIterator.java @@ -27,6 +27,7 @@ public class ComposedIterator extends AbstractIterator private Iterator currentDelegate; + @SafeVarargs public ComposedIterator(Iterator... delegates) { this(Arrays.asList(delegates)); @@ -66,12 +67,12 @@ public class ComposedIterator extends AbstractIterator public static Iterator fromIterables(Collection> iterables) { - List> iterators = new ArrayList>(); + List> iterators = new ArrayList<>(); for (Iterable iterable : iterables) { iterators.add(iterable.iterator()); } - return new ComposedIterator(iterators.iterator()); + return new ComposedIterator<>(iterators.iterator()); } } diff --git a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/Confirmer.java b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/Confirmer.java index 204fc5e22..1cf8d9ffc 100644 --- a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/Confirmer.java +++ b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/Confirmer.java @@ -17,6 +17,7 @@ public interface Confirmer { public static final Confirmer ACCEPT = new Confirmer() { + @Override public Confirmation confirm(boolean defaultConfirmed, Object info) { return new Confirmation(true, false); @@ -25,6 +26,7 @@ public interface Confirmer public static final Confirmer DECLINE = new Confirmer() { + @Override public Confirmation confirm(boolean defaultConfirmed, Object info) { return new Confirmation(false, false); @@ -33,6 +35,7 @@ public interface Confirmer public static final Confirmer DEFAULT = new Confirmer() { + @Override public Confirmation confirm(boolean defaultConfirmed, Object info) { return new Confirmation(defaultConfirmed, false); diff --git a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/IOUtil.java b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/IOUtil.java index 7b577e632..7ff080d4b 100644 --- a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/IOUtil.java +++ b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/IOUtil.java @@ -724,7 +724,7 @@ public final class IOUtil public static List readLines(File file, String charsetName) { - List lines = new ArrayList(); + List lines = new ArrayList<>(); if (file.exists()) { @@ -750,7 +750,7 @@ public final class IOUtil public static List readLines(InputStream in, String charsetName) { - List lines = new ArrayList(); + List lines = new ArrayList<>(); Reader reader = null; BufferedReader bufferedReader = null; @@ -1042,7 +1042,7 @@ public final class IOUtil */ private static class FileCollector implements IOVisitor { - private List files = new ArrayList(); + private List files = new ArrayList<>(); public FileCollector() { @@ -1053,6 +1053,7 @@ public final class IOUtil return files; } + @Override public boolean visit(File file) throws IOException { files.add(file); @@ -1082,6 +1083,7 @@ public final class IOUtil this.classLoader = classLoader; } + @Override public Class resolveClass(ObjectStreamClass v) throws ClassNotFoundException { String className = v.getName(); diff --git a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/OS.java b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/OS.java index d195005d5..9d9aed198 100644 --- a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/OS.java +++ b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/OS.java @@ -325,7 +325,7 @@ public abstract class OS private static List createAll() { - List result = new ArrayList(); + List result = new ArrayList<>(); result.add(Win64.INSTANCE); result.add(Win32.INSTANCE); @@ -410,7 +410,7 @@ public abstract class OS { if (terminal) { - List terminalCommand = new ArrayList(); + List terminalCommand = new ArrayList<>(); terminalCommand.add("cmd"); //$NON-NLS-1$ terminalCommand.add("/C"); //$NON-NLS-1$ terminalCommand.add("start"); //$NON-NLS-1$ @@ -533,7 +533,7 @@ public abstract class OS String commandLine = getCommandLine(command); IOUtil.writeUTF8(commandFile, commandLine); - List chmodCommand = new ArrayList(); + List chmodCommand = new ArrayList<>(); chmodCommand.add("chmod"); //$NON-NLS-1$ chmodCommand.add("a+x"); //$NON-NLS-1$ chmodCommand.add(commandPath); @@ -542,7 +542,7 @@ public abstract class OS Process chmodProcess = chmodProcessBuilder.start(); chmodProcess.waitFor(); - List terminalCommand = new ArrayList(); + List terminalCommand = new ArrayList<>(); terminalCommand.add("open"); //$NON-NLS-1$ terminalCommand.add("-b"); //$NON-NLS-1$ terminalCommand.add("com.apple.terminal"); //$NON-NLS-1$ @@ -631,7 +631,7 @@ public abstract class OS { try { - List terminalCommand = new ArrayList(); + List terminalCommand = new ArrayList<>(); terminalCommand.add(xterm); terminalCommand.add("-e"); //$NON-NLS-1$ terminalCommand.add(commandLine); diff --git a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/OomphPlugin.java b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/OomphPlugin.java index 3d991c10d..9a6e9d668 100644 --- a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/OomphPlugin.java +++ b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/OomphPlugin.java @@ -198,20 +198,24 @@ public abstract class OomphPlugin extends EMFPlugin { return new ILog() { + @Override public void removeLogListener(ILogListener listener) { } + @Override public void log(IStatus status) { System.out.println(status); } + @Override public Bundle getBundle() { return null; } + @Override public void addLogListener(ILogListener listener) { } @@ -580,7 +584,7 @@ public abstract class OomphPlugin extends EMFPlugin public static List getClassPath(Bundle bundle) throws Exception { - final List cp = new ArrayList(); + final List cp = new ArrayList<>(); final File file = FileLocator.getBundleFile(bundle); if (file.isFile()) @@ -599,6 +603,7 @@ public abstract class OomphPlugin extends EMFPlugin Element rootElement = XMLUtil.loadRootElement(documentBuilder, classpathFile); XMLUtil.handleElementsByTagName(rootElement, "classpathentry", new XMLUtil.ElementHandler() //$NON-NLS-1$ { + @Override public void handleElement(Element element) throws Exception { if ("output".equals(element.getAttribute("kind"))) //$NON-NLS-1$ //$NON-NLS-2$ @@ -708,7 +713,7 @@ public abstract class OomphPlugin extends EMFPlugin { if (children == null) { - children = new ArrayList(); + children = new ArrayList<>(); Bundle bundle = getBundle(); String path = "/" + getPath(); //$NON-NLS-1$ @@ -882,6 +887,7 @@ public abstract class OomphPlugin extends EMFPlugin } } + @Override public int compareTo(BundleFile o) { return name.compareTo(o.getName()); diff --git a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/Pair.java b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/Pair.java index 462339997..8465d649d 100644 --- a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/Pair.java +++ b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/Pair.java @@ -86,16 +86,16 @@ public class Pair public Pair copy() { - return new Pair(this); + return new Pair<>(this); } public static Pair create() { - return new Pair(); + return new Pair<>(); } public static Pair create(T1 element1, T2 element2) { - return new Pair(element1, element2); + return new Pair<>(element1, element2); } } diff --git a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/Predicates.java b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/Predicates.java index 5a735d691..c723c4fce 100644 --- a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/Predicates.java +++ b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/Predicates.java @@ -24,17 +24,17 @@ public final class Predicates public static Predicate included(Set inclusions) { - return new IncludedPredicate(inclusions); + return new IncludedPredicate<>(inclusions); } public static Predicate excluded(Set exclusions) { - return new ExcludedPredicate(exclusions); + return new ExcludedPredicate<>(exclusions); } public static Predicate unique() { - return new UniquePredicate(); + return new UniquePredicate<>(); } @SuppressWarnings("unchecked") @@ -61,6 +61,7 @@ public final class Predicates this.inclusions = inclusions; } + @Override public boolean apply(T element) { return inclusions.contains(element); @@ -79,6 +80,7 @@ public final class Predicates this.exclusions = exclusions; } + @Override public boolean apply(T element) { return !exclusions.contains(element); @@ -90,8 +92,9 @@ public final class Predicates */ public static final class UniquePredicate implements Predicate { - private final Set applied = new HashSet(); + private final Set applied = new HashSet<>(); + @Override public boolean apply(T element) { return applied.add(element); @@ -105,6 +108,7 @@ public final class Predicates { private static final Predicate INSTANCE = new FalsePredicate(); + @Override public boolean apply(Object element) { return false; @@ -118,6 +122,7 @@ public final class Predicates { private static final Predicate INSTANCE = new TruePredicate(); + @Override public boolean apply(Object element) { return true; diff --git a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/ProbingSubMonitor.java b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/ProbingSubMonitor.java index 344fc8f9d..93695a34f 100644 --- a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/ProbingSubMonitor.java +++ b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/ProbingSubMonitor.java @@ -95,11 +95,11 @@ public final class ProbingSubMonitor extends org.eclipse.oomph.util.SubMonitor { private static final boolean TRACE = Boolean.getBoolean("submonitor.probing.trace"); //$NON-NLS-1$ - private static final Map STATISTICS = new HashMap(); + private static final Map STATISTICS = new HashMap<>(); - private static final Map MAP = new ConcurrentHashMap(); + private static final Map MAP = new ConcurrentHashMap<>(); - private static final ReferenceQueue QUEUE = new ReferenceQueue(); + private static final ReferenceQueue QUEUE = new ReferenceQueue<>(); private static final AtomicInteger COUNTER = new AtomicInteger(); @@ -119,7 +119,7 @@ public final class ProbingSubMonitor extends org.eclipse.oomph.util.SubMonitor private final int key; - private final Map probes = new HashMap(); + private final Map probes = new HashMap<>(); private StackTraceElement location = determineLocation(); @@ -522,11 +522,11 @@ public final class ProbingSubMonitor extends org.eclipse.oomph.util.SubMonitor List newRows; if (rows == null) { - newRows = new ArrayList(10); + newRows = new ArrayList<>(10); } else { - newRows = new ArrayList(10 + rows.length); + newRows = new ArrayList<>(10 + rows.length); for (int i = 0; i < rows.length; i++) { Row row = rows[i]; @@ -653,7 +653,7 @@ public final class ProbingSubMonitor extends org.eclipse.oomph.util.SubMonitor { if (forkTargets.length != 1 || probe.forkTargets.length != 1 || !forkTargets[0].equals(probe.forkTargets[0])) { - Set set = new HashSet(); + Set set = new HashSet<>(); set.addAll(Arrays.asList(forkTargets)); set.addAll(Arrays.asList(probe.forkTargets)); @@ -678,6 +678,7 @@ public final class ProbingSubMonitor extends org.eclipse.oomph.util.SubMonitor public abstract void footer(Table table, int rows); + @Override public int compareTo(Row o) { int result = location.getFileName().compareTo(o.location.getFileName()); @@ -769,6 +770,7 @@ public final class ProbingSubMonitor extends org.eclipse.oomph.util.SubMonitor table.cell(++col, row).format(MILLIS).value(max); table.cell(++col, row).format(MILLIS).value(new Formula() { + @Override public Object evaluate() { return max - min; diff --git a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/PropertiesUtil.java b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/PropertiesUtil.java index e39c4a99a..4b2fc275a 100644 --- a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/PropertiesUtil.java +++ b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/PropertiesUtil.java @@ -215,12 +215,12 @@ public final class PropertiesUtil Collection keys = properties.keySet(); if (sort) { - List keyList = new ArrayList(keys); + List keyList = new ArrayList<>(keys); Collections.sort(keyList); keys = keyList; } - LinkedHashMap objectMap = new LinkedHashMap(); + LinkedHashMap objectMap = new LinkedHashMap<>(); for (String key : keys) { objectMap.put(key, properties.get(key)); @@ -235,12 +235,12 @@ public final class PropertiesUtil Collection keys = properties.keySet(); if (sort) { - List keyList = new ArrayList(keys); + List keyList = new ArrayList<>(keys); Collections.sort(keyList); keys = keyList; } - Vector keyVector = new Vector(); + Vector keyVector = new Vector<>(); for (String key : keys) { keyVector.add(key); @@ -340,6 +340,6 @@ public final class PropertiesUtil return loadProperties(file); } - return new LinkedHashMap(); + return new LinkedHashMap<>(); } } diff --git a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/PropertyFile.java b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/PropertyFile.java index f377ec4c3..44a172a51 100644 --- a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/PropertyFile.java +++ b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/PropertyFile.java @@ -92,7 +92,7 @@ public class PropertyFile // Ignore. } - return new LinkedHashMap(); + return new LinkedHashMap<>(); } public void saveProperties(Map properties) diff --git a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/Request.java b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/Request.java index a3b3858f3..a64f2691e 100644 --- a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/Request.java +++ b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/Request.java @@ -142,6 +142,7 @@ public final class Request extends HashMap { public static final Handler SYSTEM_BROWSER = new Handler() { + @Override public boolean handleRequest(Request request) { return OS.INSTANCE.openSystemBrowser(request.getURI().toString()); @@ -162,6 +163,7 @@ public final class Request extends HashMap this.delegate = delegate; } + @Override public boolean handleRequest(Request request) { request = request.copy(); diff --git a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/ServiceUtil.java b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/ServiceUtil.java index a22b432b4..56f19de6d 100644 --- a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/ServiceUtil.java +++ b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/ServiceUtil.java @@ -23,7 +23,7 @@ import java.util.Map; */ public final class ServiceUtil { - private static Map> services = new IdentityHashMap>(); + private static Map> services = new IdentityHashMap<>(); private ServiceUtil() { diff --git a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/StringUtil.java b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/StringUtil.java index 15e79dc86..1579764d3 100644 --- a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/StringUtil.java +++ b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/StringUtil.java @@ -352,7 +352,7 @@ public final class StringUtil public static List explode(String string, String separators, char escapeCharacter) { - List tokens = new ArrayList(); + List tokens = new ArrayList<>(); StringBuilder builder = new StringBuilder(); boolean separator = false; diff --git a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/SubMonitor.java b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/SubMonitor.java index 15ecfb639..321ee8114 100644 --- a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/SubMonitor.java +++ b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/SubMonitor.java @@ -547,6 +547,7 @@ public class SubMonitor implements IProgressMonitorWithBlocking * (non-Javadoc) * @see org.eclipse.core.runtime.IProgressMonitor#isCanceled() */ + @Override public final boolean isCanceled() { return root.isCanceled(); @@ -556,6 +557,7 @@ public class SubMonitor implements IProgressMonitorWithBlocking * (non-Javadoc) * @see org.eclipse.core.runtime.IProgressMonitor#setTaskName(java.lang.String) */ + @Override public final void setTaskName(String name) { checkCancelation(); @@ -580,6 +582,7 @@ public class SubMonitor implements IProgressMonitorWithBlocking * * @see org.eclipse.core.runtime.IProgressMonitor#beginTask(java.lang.String, int) */ + @Override public final void beginTask(String name, int totalWork) { if ((flags & SUPPRESS_BEGINTASK) == 0 && name != null) @@ -594,6 +597,7 @@ public class SubMonitor implements IProgressMonitorWithBlocking * @see org.eclipse.core.runtime.IProgressMonitor#done() */ // Can't be final because ProbingSubMonitor overrides it. + @Override public void done() { cleanupActiveChild(); @@ -613,6 +617,7 @@ public class SubMonitor implements IProgressMonitorWithBlocking * (non-Javadoc) * @see org.eclipse.core.runtime.IProgressMonitor#internalWorked(double) */ + @Override public final void internalWorked(double work) { checkCancelation(); @@ -629,6 +634,7 @@ public class SubMonitor implements IProgressMonitorWithBlocking * (non-Javadoc) * @see org.eclipse.core.runtime.IProgressMonitor#subTask(java.lang.String) */ + @Override public final void subTask(String name) { checkCancelation(); @@ -652,6 +658,7 @@ public class SubMonitor implements IProgressMonitorWithBlocking * @see org.eclipse.core.runtime.IProgressMonitor#worked(int) */ // Can't be final because ProbingSubMonitor overrides it. + @Override public void worked(int work) { internalWorked(work); @@ -678,6 +685,7 @@ public class SubMonitor implements IProgressMonitorWithBlocking * (non-Javadoc) * @see org.eclipse.core.runtime.IProgressMonitor#setCanceled(boolean) */ + @Override public final void setCanceled(boolean b) { root.setCanceled(b); @@ -875,6 +883,7 @@ public class SubMonitor implements IProgressMonitorWithBlocking * (non-Javadoc) * @see org.eclipse.core.runtime.IProgressMonitorWithBlocking#clearBlocked() */ + @Override public final void clearBlocked() { checkCancelation(); @@ -885,6 +894,7 @@ public class SubMonitor implements IProgressMonitorWithBlocking * (non-Javadoc) * @see org.eclipse.core.runtime.IProgressMonitorWithBlocking#setBlocked(org.eclipse.core.runtime.IStatus) */ + @Override public final void setBlocked(IStatus reason) { checkCancelation(); diff --git a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/ThreadPool.java b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/ThreadPool.java index 0369cfbad..76cf1cefa 100644 --- a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/ThreadPool.java +++ b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/ThreadPool.java @@ -24,6 +24,7 @@ public class ThreadPool extends ThreadPoolExecutor private static final ThreadFactory THREAD_FACTORY = new ThreadFactory() { + @Override public Thread newThread(Runnable r) { Thread thread = new Thread(r); diff --git a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/WorkerPool.java b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/WorkerPool.java index f7097d36b..874a06161 100644 --- a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/WorkerPool.java +++ b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/WorkerPool.java @@ -42,8 +42,9 @@ public abstract class WorkerPool

, K, W extends Wor * Otherwise workers are processed in the {@link Worker#id identifier order}, * i.e., first come first serve. */ - private static final Comparator> COMPARATOR = new Comparator>() + private static final Comparator> COMPARATOR = new Comparator<>() { + @Override public int compare(Worker o1, Worker o2) { int result = (o2.secondary ? 0 : 1) - (o1.secondary ? 0 : 1); @@ -64,12 +65,12 @@ public abstract class WorkerPool

, K, W extends Wor /** * The map of the worker key to the worker associated with that key. */ - private final Map workers = new HashMap(); + private final Map workers = new HashMap<>(); /** * The workers waiting to perform their work. */ - private final List pendingWorkers = new ArrayList(); + private final List pendingWorkers = new ArrayList<>(); /** * Whether the workers have been canceled. @@ -191,6 +192,7 @@ public abstract class WorkerPool

, K, W extends Wor * Performs the work for the given keys, * blocking until the work has been performed. */ + @SafeVarargs public final void perform(K... keys) { perform(Arrays.asList(keys)); @@ -250,6 +252,7 @@ public abstract class WorkerPool

, K, W extends Wor * The work will be performed at some later point in time on a different thread. * Returns whether any work is actually scheduled (needed) for any of the given keys. */ + @SafeVarargs public final boolean schedule(K... keys) { return schedule(Arrays.asList(keys)); @@ -323,7 +326,7 @@ public abstract class WorkerPool

, K, W extends Wor * If there are no remaining {@link #workers}, * the {@link #latch latch} is unlatched. */ - private synchronized void deschedule(K key) + synchronized void deschedule(K key) { workers.remove(key); @@ -385,7 +388,7 @@ public abstract class WorkerPool

, K, W extends Wor /** * The priority {@link WorkerPool#createWorker(Object, int, boolean) allocated} by the pool to this worker. */ - private boolean secondary; + boolean secondary; /** * Creates an instance with the given Job name, diff --git a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/XMLUtil.java b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/XMLUtil.java index 2c9da9b86..52ea2d1f3 100644 --- a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/XMLUtil.java +++ b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/XMLUtil.java @@ -137,6 +137,7 @@ public final class XMLUtil this.tagName = tagName; handleElementsByTagName(rootElement, tagName, new ElementHandler() { + @Override public void handleElement(Element element) throws Exception { if (element.getParentNode() == rootElement) diff --git a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/ZIPUtil.java b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/ZIPUtil.java index c39a7723f..f1f7eb8c9 100644 --- a/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/ZIPUtil.java +++ b/plugins/org.eclipse.oomph.util/src/org/eclipse/oomph/util/ZIPUtil.java @@ -246,6 +246,7 @@ public final class ZIPUtil List list = IOUtil.listBreadthFirst(sourceFolder); Collections.sort(list, new Comparator() { + @Override public int compare(File f1, File f2) { String path1 = getPath(f1, baseLength); @@ -338,6 +339,7 @@ public final class ZIPUtil } } + @Override public void handleEntry(EntryContext context) throws IOException { if (files.hasNext()) @@ -387,6 +389,7 @@ public final class ZIPUtil return targetFolder; } + @Override public void unzipDirectory(String name) { File directory = new File(targetFolder, name); @@ -396,6 +399,7 @@ public final class ZIPUtil } } + @Override public void unzipFile(String name, InputStream zipStream) { File targetFile = new File(targetFolder, name); -- cgit v1.2.3