Java String Equal equalsOrExceeds(String version, String threshold)

Here you can find the source of equalsOrExceeds(String version, String threshold)

Description

Returns true if the given version is the same or more recent then the threshold version.

License

Open Source License

Parameter

Parameter Description
version the version to check
threshold the threshold with which the version will be compared

Return

false if any of the two versions is unknown, and boolean which indicates whether the version is at least at threshold otherwise

Declaration

public static boolean equalsOrExceeds(String version, String threshold) 

Method Source Code

//package com.java2s;
/*/* w ww .jav a  2s  .  co m*/
 * jLibrary, Open Source Document Management System
 * 
 * Copyright (c) 2003-2006, Mart?n P?rez Mari??n, Blandware (represented by
 * Andrey Grebnev), and individual contributors as indicated by the
 * @authors tag. See copyright.txt in the distribution for a full listing of
 * individual contributors. All rights reserved.
 * 
 * This is free software; you can redistribute it and/or modify it
 * under the terms of the Modified BSD License as published by the Free 
 * Software Foundation.
 * 
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the Modified
 * BSD License for more details.
 * 
 * You should have received a copy of the Modified BSD License along with 
 * this software; if not, write to the Free Software Foundation, Inc., 
 * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA, or see the
 * FSF site: http://www.fsf.org.
 */

import java.util.List;
import java.util.ArrayList;

public class Main {
    private static List knownVersions = new ArrayList();

    /**
     * Returns true if the given version is the same or more recent then the
     * threshold version.
     * If any of the versions are not known, false is returned.
     *
     * @param version   the version to check
     * @param threshold the threshold with which the version will be compared
     * @return false if any of the two versions is unknown, and boolean which
     * indicates whether the version is at least at threshold otherwise
     */
    public static boolean equalsOrExceeds(String version, String threshold) {
        int versionIndex = knownVersions.indexOf(version);
        int thresholdIndex = knownVersions.indexOf(threshold);
        if (versionIndex == -1 || thresholdIndex == -1) {
            return false;
        }
        return versionIndex >= thresholdIndex;
    }
}

Related

  1. areStringsEqual(String str1, String str2)
  2. collapseQualifier(String qualifier, boolean includeDots)
  3. equalsCaseless(String sA_, String sB_)
  4. equalsIgnoreCase(String s1, String s2)
  5. equalsIgnoreCase(String source, String query)
  6. getEquality(String str1, String str2)
  7. isEqual(String str, String str2, boolean isCaseSensitive)
  8. pathEquals(String path1, String path2)
  9. pathEquals(String path1, String path2)