1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-16 11:21:18 +03:00

Continuing improving library manager

This commit is contained in:
Federico Fissore
2015-03-16 12:34:26 +01:00
parent 8e5a04f6a9
commit 103f2e433a
6 changed files with 114 additions and 23 deletions

View File

@ -28,12 +28,12 @@
*/
package cc.arduino.libraries.contributions;
import java.util.Comparator;
import java.util.List;
import cc.arduino.packages.contributions.DownloadableContribution;
import processing.app.I18n;
import java.util.Comparator;
import java.util.List;
import static processing.app.I18n._;
public abstract class ContributedLibrary extends DownloadableContribution {
@ -90,15 +90,14 @@ public abstract class ContributedLibrary extends DownloadableContribution {
*/
public boolean supportsArchitecture(String reqArch) {
return getArchitectures().contains(reqArch) ||
getArchitectures().contains("*");
getArchitectures().contains("*");
}
/**
* Returns <b>true</b> if the library declares to support at least one of the
* specified architectures.
*
* @param reqArchs
* A List of architectures to check
* @param reqArchs A List of architectures to check
* @return
*/
public boolean supportsArchitecture(List<String> reqArchs) {
@ -146,4 +145,22 @@ public abstract class ContributedLibrary extends DownloadableContribution {
return res;
}
@Override
public boolean equals(Object obj) {
if (!(obj instanceof ContributedLibrary)) {
return false;
}
String thisVersion = getVersion();
String otherVersion = ((ContributedLibrary) obj).getVersion();
boolean versionEquals = thisVersion == null || otherVersion == null || thisVersion == otherVersion || thisVersion.equals(otherVersion);
String thisName = getName();
String otherName = ((ContributedLibrary) obj).getName();
boolean nameEquals = thisName == null || otherName == null || thisName == otherName || thisName.equals(otherName);
return versionEquals && nameEquals;
}
}

View File

@ -53,6 +53,24 @@ public class VersionComparator implements Comparator<String> {
return versionA.compareTo(versionB);
}
public boolean greaterThan(String a, String b) {
// null is always less than any other value
if (a == null && b == null) {
return false;
}
if (a == null) {
return false;
}
if (b == null) {
return true;
}
Version versionA = valueOf(a);
Version versionB = valueOf(b);
return versionA.greaterThan(versionB);
}
private Version valueOf(String ver) {
String[] verParts = ver.split("\\.");
if (verParts.length < 3) {