/** * Compares this version with the specified API and returns true if this version * is greater or equal than the requested API -- that is the current version is a * suitable min-api-level for the argument API. */ public boolean isGreaterOrEqualThan(int api) { return compareTo(api, null /*codename*/) >= 0; }
/** * Compares this object with the specified object for order. Returns a * negative integer, zero, or a positive integer as this object is less * than, equal to, or greater than the specified object. * * @param o the Object to be compared. * @return a negative integer, zero, or a positive integer as this object is * less than, equal to, or greater than the specified object. */ @Override public int compareTo(@NonNull AndroidVersion o) { return compareTo(o.mApiLevel, o.mCodename); }
@Override public int compareTo(IAndroidTarget o) { return getVersion().compareTo(o.getVersion()); } }
@Override public int compareTo(@NonNull IAndroidTarget o) { int res = getVersion().compareTo(o.getVersion()); if (res != 0) { return res; } return o.isPlatform() ? 0 : -1; }
@Override public int compareTo(@NonNull IAndroidTarget target) { // quick check. if (this == target) { return 0; } int versionDiff = getVersion().compareTo(target.getVersion()); // only if the versions are the same do we care about platform/add-ons. if (versionDiff == 0) { // platforms go before add-ons. if (target.isPlatform()) { return +1; } else { AddonTarget targetAddOn = (AddonTarget) target; // both are add-ons of the same version. Compare per vendor then by name int vendorDiff = getVendor().compareTo(targetAddOn.getVendor()); if (vendorDiff == 0) { return getName().compareTo(targetAddOn.getName()); } else { return vendorDiff; } } } return versionDiff; }
@Override public boolean isUpdateFor(PkgDesc thisPkgDesc, IPkgDesc existingDesc) { if (existingDesc == null || !thisPkgDesc.getType().equals(existingDesc.getType())) { return false; } // This package is unique in the SDK. It's an update if the API is newer // or the revision is newer for the same API. int diff = thisPkgDesc.getAndroidVersion().compareTo( existingDesc.getAndroidVersion()); return diff > 0 || (diff == 0 && thisPkgDesc.getRevision().compareTo( existingDesc.getRevision()) > 0); } };
t1 = getAndroidVersion().compareTo(o.getAndroidVersion()); if (t1 != 0) { return t1;