Got rid of Guava lib: java 8 has its features builtin

This commit is contained in:
Federico Fissore 2015-08-05 12:09:24 +02:00
parent 50cacc1756
commit cb292d6114
25 changed files with 80 additions and 508 deletions

View File

@ -28,7 +28,6 @@
<classpathentry combineaccessrules="false" kind="src" path="/arduino-core"/>
<classpathentry kind="lib" path="test-lib/jcip-annotations-1.0.jar"/>
<classpathentry kind="lib" path="lib/commons-lang3-3.3.2.jar"/>
<classpathentry kind="lib" path="lib/guava-18.0.jar"/>
<classpathentry kind="lib" path="lib/java-semver-0.8.0.jar"/>
<classpathentry kind="lib" path="lib/rsyntaxtextarea-2.5.7.1+arduino.jar"/>
<classpathentry kind="output" path="bin"/>

View File

@ -1,203 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Binary file not shown.

View File

@ -34,9 +34,6 @@ import cc.arduino.contributions.filters.InstalledPredicate;
import cc.arduino.contributions.packages.ContributedPackage;
import cc.arduino.contributions.packages.ContributedPlatform;
import cc.arduino.view.Event;
import com.google.common.collect.Collections2;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import processing.app.Base;
import processing.app.BaseNoGui;
import processing.app.I18n;
@ -44,7 +41,7 @@ import processing.app.PreferencesData;
import javax.swing.*;
import java.awt.event.ActionEvent;
import java.util.LinkedList;
import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
@ -72,7 +69,7 @@ public class BuiltInCoreIsNewerCheck implements Runnable {
return;
}
LinkedList<ContributedPlatform> contributedPlatforms = Lists.newLinkedList(Iterables.concat(Collections2.transform(BaseNoGui.indexer.getPackages(), ContributedPackage::getPlatforms)));
List<ContributedPlatform> contributedPlatforms = BaseNoGui.indexer.getPackages().stream().map(ContributedPackage::getPlatforms).flatMap(Collection::stream).collect(Collectors.toList());
List<ContributedPlatform> installedBuiltInPlatforms = contributedPlatforms.stream().filter(new InstalledPredicate()).filter(new BuiltInPredicate()).collect(Collectors.toList());
if (installedBuiltInPlatforms.size() != 1) {

View File

@ -38,7 +38,6 @@ import cc.arduino.contributions.libraries.filters.OnlyUpstreamReleasePredicate;
import cc.arduino.contributions.ui.InstallerTableCell;
import cc.arduino.contributions.ui.listeners.DelegatingKeyListener;
import cc.arduino.utils.ReverseComparator;
import com.google.common.collect.Lists;
import processing.app.Base;
import javax.swing.*;
@ -51,11 +50,12 @@ import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
import java.util.stream.Collectors;
import static processing.app.I18n.tr;
import static processing.app.I18n.format;
import static processing.app.I18n.tr;
@SuppressWarnings("serial")
public class ContributedLibraryTableCell extends InstallerTableCell {
@ -158,8 +158,8 @@ public class ContributedLibraryTableCell extends InstallerTableCell {
HTMLDocument html = (HTMLDocument) doc;
StyleSheet stylesheet = html.getStyleSheet();
stylesheet.addRule("body { margin: 0; padding: 0;"
+ "font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;"
+ "font-size: 100%;" + "font-size: 0.95em; }");
+ "font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;"
+ "font-size: 100%;" + "font-size: 0.95em; }");
}
description.setOpaque(false);
description.setBorder(new EmptyBorder(4, 7, 7, 7));
@ -236,19 +236,17 @@ public class ContributedLibraryTableCell extends InstallerTableCell {
downgradeChooser.removeAllItems();
downgradeChooser.addItem(tr("Select version"));
final List<ContributedLibrary> uninstalledPreviousReleases = Lists.newLinkedList();
final List<ContributedLibrary> uninstalledNewerReleases = Lists.newLinkedList();
final List<ContributedLibrary> uninstalledPreviousReleases = new LinkedList<>();
final List<ContributedLibrary> uninstalledNewerReleases = new LinkedList<>();
final VersionComparator versionComparator = new VersionComparator();
Lists.newLinkedList(Lists.transform(uninstalledReleases, input -> {
uninstalledReleases.stream().forEach(input -> {
if (installed == null || versionComparator.greaterThan(installed.getParsedVersion(), input.getParsedVersion())) {
uninstalledPreviousReleases.add(input);
} else {
uninstalledNewerReleases.add(input);
}
return input;
}));
});
uninstalledNewerReleases.forEach(downgradeChooser::addItem);
uninstalledPreviousReleases.forEach(downgradeChooser::addItem);

View File

@ -39,7 +39,6 @@ import cc.arduino.contributions.packages.ContributedPlatform;
import cc.arduino.contributions.ui.InstallerTableCell;
import cc.arduino.contributions.ui.listeners.DelegatingKeyListener;
import cc.arduino.utils.ReverseComparator;
import com.google.common.collect.Lists;
import processing.app.Base;
import javax.swing.*;
@ -55,8 +54,8 @@ import java.util.Collections;
import java.util.LinkedList;
import java.util.stream.Collectors;
import static processing.app.I18n.tr;
import static processing.app.I18n.format;
import static processing.app.I18n.tr;
@SuppressWarnings("serial")
public class ContributedPlatformTableCell extends InstallerTableCell {
@ -170,8 +169,8 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
HTMLDocument html = (HTMLDocument) doc;
StyleSheet stylesheet = html.getStyleSheet();
stylesheet.addRule("body { margin: 0; padding: 0;"
+ "font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;"
+ "font-size: 100%;" + "font-size: 0.95em; }");
+ "font-family: Verdana, Geneva, Arial, Helvetica, sans-serif;"
+ "font-size: 100%;" + "font-size: 0.95em; }");
}
description.setOpaque(false);
description.setBorder(new EmptyBorder(4, 7, 7, 7));
@ -248,19 +247,17 @@ public class ContributedPlatformTableCell extends InstallerTableCell {
downgradeChooser.removeAllItems();
downgradeChooser.addItem(tr("Select version"));
final java.util.List<ContributedPlatform> uninstalledPreviousReleases = Lists.newLinkedList();
final java.util.List<ContributedPlatform> uninstalledNewerReleases = Lists.newLinkedList();
final java.util.List<ContributedPlatform> uninstalledPreviousReleases = new LinkedList<>();
final java.util.List<ContributedPlatform> uninstalledNewerReleases = new LinkedList<>();
final VersionComparator versionComparator = new VersionComparator();
Lists.newLinkedList(Lists.transform(uninstalledReleases, input -> {
uninstalledReleases.stream().forEach(input -> {
if (installed == null || versionComparator.greaterThan(installed.getParsedVersion(), input.getParsedVersion())) {
uninstalledPreviousReleases.add(input);
} else {
uninstalledNewerReleases.add(input);
}
return input;
}));
});
uninstalledNewerReleases.forEach(downgradeChooser::addItem);
uninstalledPreviousReleases.forEach(downgradeChooser::addItem);

View File

@ -29,8 +29,6 @@
package cc.arduino.view.preferences;
import com.google.common.base.Joiner;
import com.google.common.collect.FluentIterable;
import processing.app.Base;
import java.awt.*;
@ -39,6 +37,7 @@ import java.awt.event.ActionListener;
import java.awt.event.WindowEvent;
import java.util.Arrays;
import java.util.Collection;
import java.util.stream.Collectors;
import static processing.app.I18n.tr;
@ -174,17 +173,17 @@ public class AdditionalBoardsManagerURLTextArea extends javax.swing.JDialog {
public void setText(String text) {
Collection<String> urls = splitAndTrim(text, ",");
additionalBoardsManagerURLs.setText(Joiner.on("\n").skipNulls().join(urls));
additionalBoardsManagerURLs.setText(urls.stream().filter(s -> s != null).collect(Collectors.joining("\n")));
}
private Collection<String> splitAndTrim(String text, String separator) {
Collection<String> urls = Arrays.asList(text.split(separator));
return FluentIterable.from(urls).transform(String::trim).filter(url -> !url.isEmpty()).toList();
return urls.stream().map(String::trim).filter(url -> !url.isEmpty()).collect(Collectors.toList());
}
public String getText() {
Collection<String> urls = splitAndTrim(additionalBoardsManagerURLs.getText(), "\n");
return Joiner.on(",").skipNulls().join(urls);
return urls.stream().filter(s -> s != null).collect(Collectors.joining(","));
}
// Variables declaration - do not modify//GEN-BEGIN:variables

View File

@ -38,9 +38,6 @@ import cc.arduino.utils.Progress;
import cc.arduino.view.Event;
import cc.arduino.view.JMenuUtils;
import cc.arduino.view.SplashScreenHelper;
import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
import com.google.common.collect.Collections2;
import org.apache.commons.compress.utils.IOUtils;
import org.apache.commons.lang3.StringUtils;
import processing.app.debug.TargetBoard;
@ -65,9 +62,11 @@ import java.awt.event.*;
import java.io.*;
import java.util.*;
import java.util.List;
import java.util.function.Predicate;
import java.util.logging.Handler;
import java.util.logging.Level;
import java.util.logging.Logger;
import java.util.stream.Collectors;
import static processing.app.I18n.tr;
@ -82,7 +81,7 @@ public class Base {
public static final Predicate<UserLibrary> CONTRIBUTED = new Predicate<UserLibrary>() {
@Override
public boolean apply(UserLibrary library) {
public boolean test(UserLibrary library) {
return library.getTypes() == null || library.getTypes().isEmpty() || library.getTypes().contains("Contributed");
}
};
@ -1143,13 +1142,13 @@ public class Base {
public LibraryList getIDELibs() {
LibraryList installedLibraries = new LibraryList(BaseNoGui.librariesIndexer.getInstalledLibraries());
List<UserLibrary> libs = new LinkedList<UserLibrary>(Collections2.filter(new LinkedList<UserLibrary>(installedLibraries), Predicates.not(CONTRIBUTED)));
List<UserLibrary> libs = installedLibraries.stream().filter(CONTRIBUTED.negate()).collect(Collectors.toList());
return new LibraryList(libs);
}
public LibraryList getUserLibs() {
LibraryList installedLibraries = new LibraryList(BaseNoGui.librariesIndexer.getInstalledLibraries());
List<UserLibrary> libs = new LinkedList<UserLibrary>(Collections2.filter(new LinkedList<UserLibrary>(installedLibraries), CONTRIBUTED));
List<UserLibrary> libs = installedLibraries.stream().filter(CONTRIBUTED).collect(Collectors.toList());
return new LibraryList(libs);
}

View File

@ -28,7 +28,6 @@ import cc.arduino.packages.Uploader;
import cc.arduino.packages.uploaders.SerialUploader;
import cc.arduino.view.StubMenuListener;
import cc.arduino.view.findreplace.FindReplace;
import com.google.common.base.Predicate;
import com.jcraft.jsch.JSchException;
import jssc.SerialPortException;
import org.fife.ui.rsyntaxtextarea.RSyntaxDocument;
@ -72,6 +71,7 @@ import java.net.URL;
import java.net.URLClassLoader;
import java.util.*;
import java.util.List;
import java.util.function.Predicate;
import java.util.zip.ZipEntry;
import java.util.zip.ZipFile;
@ -92,7 +92,7 @@ public class Editor extends JFrame implements RunnerListener {
private static class ShouldSaveIfModified implements Predicate<Sketch> {
@Override
public boolean apply(Sketch sketch) {
public boolean test(Sketch sketch) {
return PreferencesData.getBoolean("editor.save_on_verify") && sketch.isModified() && !sketch.isReadOnly();
}
}
@ -100,7 +100,7 @@ public class Editor extends JFrame implements RunnerListener {
private static class ShouldSaveReadOnly implements Predicate<Sketch> {
@Override
public boolean apply(Sketch sketch) {
public boolean test(Sketch sketch) {
return sketch.isReadOnly();
}
}
@ -1947,7 +1947,7 @@ public class Editor extends JFrame implements RunnerListener {
private void handleRun(final boolean verbose, Predicate<Sketch> shouldSavePredicate, Runnable verboseHandler, Runnable nonVerboseHandler) {
internalCloseRunner();
if (shouldSavePredicate.apply(sketch)) {
if (shouldSavePredicate.test(sketch)) {
handleSave(true);
}
toolbar.activateRun();

View File

@ -23,7 +23,6 @@
<classpathentry kind="lib" path="lib/commons-codec-1.7.jar"/>
<classpathentry kind="lib" path="lib/commons-compress-1.8.jar"/>
<classpathentry kind="lib" path="lib/commons-lang3-3.3.2.jar"/>
<classpathentry kind="lib" path="lib/guava-18.0.jar"/>
<classpathentry kind="lib" path="lib/jackson-annotations-2.2.3.jar"/>
<classpathentry kind="lib" path="lib/jackson-core-2.2.3.jar"/>
<classpathentry kind="lib" path="lib/jackson-databind-2.2.3.jar"/>

View File

@ -1,203 +0,0 @@
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
APPENDIX: How to apply the Apache License to your work.
To apply the Apache License to your work, attach the following
boilerplate notice, with the fields enclosed by brackets "[]"
replaced with your own identifying information. (Don't include
the brackets!) The text should be enclosed in the appropriate
comment syntax for the file format. We also recommend that a
file or class name and description of purpose be included on the
same "printed page" as the copyright notice for easier
identification within third-party archives.
Copyright [yyyy] [name of copyright owner]
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.

Binary file not shown.

View File

@ -30,7 +30,8 @@
package cc.arduino.contributions.filters;
import cc.arduino.contributions.DownloadableContribution;
import com.google.common.base.Predicate;
import java.util.function.Predicate;
public class DownloadableContributionWithVersionPredicate implements Predicate<DownloadableContribution> {
private final String version;
@ -40,7 +41,7 @@ public class DownloadableContributionWithVersionPredicate implements Predicate<D
}
@Override
public boolean apply(DownloadableContribution contribution) {
public boolean test(DownloadableContribution contribution) {
return version.equals(contribution.getParsedVersion());
}

View File

@ -32,7 +32,6 @@ package cc.arduino.contributions.libraries;
import cc.arduino.contributions.DownloadableContributionBuiltInAtTheBottomComparator;
import cc.arduino.contributions.filters.InstalledPredicate;
import cc.arduino.contributions.libraries.filters.LibraryWithNamePredicate;
import com.google.common.collect.Collections2;
import java.util.*;
import java.util.stream.Collectors;
@ -42,7 +41,7 @@ public abstract class LibrariesIndex {
public abstract List<ContributedLibrary> getLibraries();
public List<ContributedLibrary> find(final String name) {
return new LinkedList<ContributedLibrary>(Collections2.filter(getLibraries(), new LibraryWithNamePredicate(name)));
return getLibraries().stream().filter(new LibraryWithNamePredicate(name)).collect(Collectors.toList());
}
public ContributedLibrary find(String name, String version) {

View File

@ -30,7 +30,8 @@
package cc.arduino.contributions.libraries.filters;
import cc.arduino.contributions.libraries.ContributedLibrary;
import com.google.common.base.Predicate;
import java.util.function.Predicate;
public class LibraryWithNamePredicate implements Predicate<ContributedLibrary> {
@ -41,7 +42,7 @@ public class LibraryWithNamePredicate implements Predicate<ContributedLibrary> {
}
@Override
public boolean apply(ContributedLibrary contributedLibrary) {
public boolean test(ContributedLibrary contributedLibrary) {
return name.equals(contributedLibrary.getName());
}

View File

@ -37,7 +37,6 @@ import cc.arduino.filters.FileExecutablePredicate;
import cc.arduino.utils.ArchiveExtractor;
import cc.arduino.utils.MultiStepProgress;
import cc.arduino.utils.Progress;
import com.google.common.collect.Collections2;
import org.apache.commons.exec.CommandLine;
import org.apache.commons.exec.DefaultExecutor;
import org.apache.commons.exec.Executor;
@ -54,9 +53,10 @@ import java.io.IOException;
import java.net.URL;
import java.nio.file.Files;
import java.util.*;
import java.util.stream.Collectors;
import static processing.app.I18n.tr;
import static processing.app.I18n.format;
import static processing.app.I18n.tr;
public class ContributionInstaller {
@ -174,7 +174,7 @@ public class ContributionInstaller {
}
private void findAndExecutePostInstallScriptIfAny(File folder, boolean trusted, boolean trustAll) throws IOException {
Collection<File> scripts = Collections2.filter(platform.postInstallScripts(folder), new FileExecutablePredicate());
Collection<File> scripts = platform.postInstallScripts(folder).stream().filter(new FileExecutablePredicate()).collect(Collectors.toList());
if (scripts.isEmpty()) {
String[] subfolders = folder.list(new OnlyDirs());
@ -190,7 +190,7 @@ public class ContributionInstaller {
}
private void findAndExecutePreUninstallScriptIfAny(File folder, boolean trusted, boolean trustAll) throws IOException {
Collection<File> scripts = Collections2.filter(platform.preUninstallScripts(folder), new FileExecutablePredicate());
Collection<File> scripts = platform.preUninstallScripts(folder).stream().filter(new FileExecutablePredicate()).collect(Collectors.toList());
if (scripts.isEmpty()) {
String[] subfolders = folder.list(new OnlyDirs());

View File

@ -33,9 +33,6 @@ import cc.arduino.contributions.DownloadableContributionBuiltInAtTheBottomCompar
import cc.arduino.contributions.filters.DownloadableContributionWithVersionPredicate;
import cc.arduino.contributions.filters.InstalledPredicate;
import cc.arduino.contributions.packages.filters.PlatformArchitecturePredicate;
import com.google.common.collect.Collections2;
import com.google.common.collect.Iterables;
import com.google.common.collect.Lists;
import java.util.ArrayList;
import java.util.Collection;
@ -64,8 +61,7 @@ public abstract class ContributionsIndex {
if (aPackage == null) {
return null;
}
Collection<ContributedPlatform> platforms = Collections2.filter(aPackage.getPlatforms(), new PlatformArchitecturePredicate(platformArch));
return Lists.newLinkedList(platforms);
return aPackage.getPlatforms().stream().filter(new PlatformArchitecturePredicate(platformArch)).collect(Collectors.toList());
}
public ContributedPlatform findPlatform(String packageName, final String platformArch, final String platformVersion) {
@ -79,7 +75,7 @@ public abstract class ContributionsIndex {
return null;
}
Collection<ContributedPlatform> platforms = Collections2.filter(platformsByName, new DownloadableContributionWithVersionPredicate(platformVersion));
Collection<ContributedPlatform> platforms = platformsByName.stream().filter(new DownloadableContributionWithVersionPredicate(platformVersion)).collect(Collectors.toList());
if (platforms.isEmpty()) {
return null;
}
@ -107,7 +103,7 @@ public abstract class ContributionsIndex {
}
private List<ContributedPlatform> getPlatforms() {
return Lists.newLinkedList(Iterables.concat(Collections2.transform(getPackages(), ContributedPackage::getPlatforms)));
return getPackages().stream().map(ContributedPackage::getPlatforms).flatMap(Collection::stream).collect(Collectors.toList());
}
private final List<String> categories = new ArrayList<>();

View File

@ -39,10 +39,6 @@ import cc.arduino.contributions.filters.InstalledPredicate;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.module.mrbean.MrBeanModule;
import com.google.common.collect.Collections2;
import com.google.common.collect.ImmutableListMultimap;
import com.google.common.collect.Iterables;
import com.google.common.collect.Multimaps;
import org.apache.commons.compress.utils.IOUtils;
import processing.app.I18n;
import processing.app.Platform;
@ -96,7 +92,7 @@ public class ContributionsIndexer {
}
List<ContributedPackage> packages = index.getPackages();
Collection<ContributedPackage> packagesWithTools = Collections2.filter(packages, input -> input.getTools() != null);
Collection<ContributedPackage> packagesWithTools = packages.stream().filter(input -> input.getTools() != null).collect(Collectors.toList());
for (ContributedPackage pack : packages) {
for (ContributedPlatform platform : pack.getPlatforms()) {
@ -352,17 +348,16 @@ public class ContributionsIndexer {
}
for (ContributedPackage pack : index.getPackages()) {
Collection<ContributedPlatform> platforms = pack.getPlatforms().stream().filter(new InstalledPredicate()).collect(Collectors.toList());
ImmutableListMultimap<String, ContributedPlatform> platformsByName = Multimaps.index(platforms, ContributedPlatform::getName);
Map<String, List<ContributedPlatform>> platformsByName = platforms.stream().collect(Collectors.groupingBy(ContributedPlatform::getName));
for (Map.Entry<String, Collection<ContributedPlatform>> entry : platformsByName.asMap().entrySet()) {
Collection<ContributedPlatform> platformsWithName = entry.getValue();
platformsByName.forEach((platformName, platformsWithName) -> {
if (platformsWithName.size() > 1) {
platformsWithName = platformsWithName.stream().filter(new BuiltInPredicate().negate()).collect(Collectors.toList());
}
for (ContributedPlatform platform : platformsWithName) {
tools.addAll(platform.getResolvedTools());
}
}
});
}
return tools;
}
@ -416,11 +411,11 @@ public class ContributionsIndexer {
}
public ContributedPlatform getPlatformByFolder(final File folder) {
com.google.common.base.Optional<ContributedPlatform> platformOptional = Iterables.tryFind(getInstalledPlatforms(), contributedPlatform -> {
Optional<ContributedPlatform> platformOptional = getInstalledPlatforms().stream().filter(contributedPlatform -> {
assert contributedPlatform.getInstalledFolder() != null;
return FileUtils.isSubDirectory(contributedPlatform.getInstalledFolder(), folder);
});
}).findFirst();
return platformOptional.orNull();
return platformOptional.orElse(null);
}
}

View File

@ -30,7 +30,8 @@
package cc.arduino.contributions.packages.filters;
import cc.arduino.contributions.packages.ContributedPlatform;
import com.google.common.base.Predicate;
import java.util.function.Predicate;
public class PlatformArchitecturePredicate implements Predicate<ContributedPlatform> {
@ -41,7 +42,7 @@ public class PlatformArchitecturePredicate implements Predicate<ContributedPlatf
}
@Override
public boolean apply(ContributedPlatform contributedPlatform) {
public boolean test(ContributedPlatform contributedPlatform) {
return platformArch.equals(contributedPlatform.getArchitecture());
}

View File

@ -29,14 +29,13 @@
package cc.arduino.filters;
import com.google.common.base.Predicate;
import java.io.File;
import java.util.function.Predicate;
public class FileExecutablePredicate implements Predicate<File> {
@Override
public boolean apply(File file) {
public boolean test(File file) {
return file.isFile() && file.exists() && file.canRead() && file.canExecute();
}

View File

@ -1,6 +1,5 @@
package processing.app;
import com.google.common.base.Joiner;
import org.apache.commons.compress.utils.IOUtils;
import processing.app.helpers.PreferencesHelper;
import processing.app.helpers.PreferencesMap;
@ -15,6 +14,7 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
import java.util.MissingResourceException;
import java.util.stream.Collectors;
import static processing.app.I18n.tr;
@ -248,7 +248,7 @@ public class PreferencesData {
}
public static void setCollection(String key, Collection<String> values) {
String value = Joiner.on(',').join(values);
String value = values.stream().collect(Collectors.joining(","));
set(key, value);
}
}

View File

@ -1,29 +1,37 @@
package processing.app;
import com.google.common.collect.FluentIterable;
import static processing.app.I18n.tr;
import java.io.File;
import java.io.IOException;
import java.util.*;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static processing.app.I18n.tr;
public class SketchData {
public static final List<String> SKETCH_EXTENSIONS = Arrays.asList("ino", "pde");
public static final List<String> OTHER_ALLOWED_EXTENSIONS = Arrays.asList("c", "cpp", "h", "hh", "hpp", "s");
public static final List<String> EXTENSIONS = new LinkedList<String>(FluentIterable.from(SKETCH_EXTENSIONS).append(OTHER_ALLOWED_EXTENSIONS).toList());
public static final List<String> EXTENSIONS = Stream.concat(SKETCH_EXTENSIONS.stream(), OTHER_ALLOWED_EXTENSIONS.stream()).collect(Collectors.toList());
/** main pde file for this sketch. */
/**
* main pde file for this sketch.
*/
private File primaryFile;
/** folder that contains this sketch */
/**
* folder that contains this sketch
*/
private File folder;
/** data folder location for this sketch (may not exist yet) */
/**
* data folder location for this sketch (may not exist yet)
*/
private File dataFolder;
/** code folder location for this sketch (may not exist yet) */
/**
* code folder location for this sketch (may not exist yet)
*/
private File codeFolder;
/**
@ -79,15 +87,15 @@ public class SketchData {
/**
* Build the list of files.
* <P>
* <p>
* Generally this is only done once, rather than
* each time a change is made, because otherwise it gets to be
* a nightmare to keep track of what files went where, because
* not all the data will be saved to disk.
* <P>
* <p>
* This also gets called when the main sketch file is renamed,
* because the sketch has to be reloaded from a different folder.
* <P>
* <p>
* Another exception is when an external editor is in use,
* in which case the load happens each time "run" is hit.
*/
@ -106,7 +114,7 @@ public class SketchData {
// codeDocs = new SketchCodeDoc[list.length];
clearCodeDocs();
// data.setCodeDocs(codeDocs);
for (String filename : list) {
// Ignoring the dot prefix files is especially important to avoid files
// with the ._ prefix on Mac OS X. (You'll see this with Mac files on

View File

@ -1,8 +1,5 @@
package processing.app.windows;
import com.google.common.base.Predicate;
import com.google.common.collect.Iterables;
import java.util.Arrays;
import java.util.List;
@ -17,12 +14,7 @@ public class RegQueryParser {
private void parse(String regQueryOutput) {
List<String> rows = Arrays.asList(regQueryOutput.replace(" ", "\t").replace("\r", "\n").replace("\n\n", "\n").split("\n"));
String row = Iterables.find(rows, new Predicate<String>() {
@Override
public boolean apply(String input) {
return input.startsWith("\t");
}
});
String row = rows.stream().filter(input -> input.startsWith("\t")).findFirst().get();
String[] cols = row.split("\t");
assert cols.length == 4;

View File

@ -19,7 +19,6 @@
<cp>%EXEDIR%/lib/commons-lang3-3.3.2.jar</cp>
<cp>%EXEDIR%/lib/commons-logging-1.0.4.jar</cp>
<cp>%EXEDIR%/lib/ecj.jar</cp>
<cp>%EXEDIR%/lib/guava-18.0.jar</cp>
<cp>%EXEDIR%/lib/jackson-annotations-2.2.3.jar</cp>
<cp>%EXEDIR%/lib/jackson-core-2.2.3.jar</cp>
<cp>%EXEDIR%/lib/jackson-databind-2.2.3.jar</cp>

View File

@ -19,7 +19,6 @@
<cp>%EXEDIR%/lib/commons-lang3-3.3.2.jar</cp>
<cp>%EXEDIR%/lib/commons-logging-1.0.4.jar</cp>
<cp>%EXEDIR%/lib/ecj.jar</cp>
<cp>%EXEDIR%/lib/guava-18.0.jar</cp>
<cp>%EXEDIR%/lib/jackson-annotations-2.2.3.jar</cp>
<cp>%EXEDIR%/lib/jackson-core-2.2.3.jar</cp>
<cp>%EXEDIR%/lib/jackson-databind-2.2.3.jar</cp>