Example usage for org.apache.commons.lang.math FloatRange containsRange

List of usage examples for org.apache.commons.lang.math FloatRange containsRange

Introduction

In this page you can find the example usage for org.apache.commons.lang.math FloatRange containsRange.

Prototype

public boolean containsRange(Range range) 

Source Link

Document

Tests whether the specified range occurs entirely within this range using float comparison.

null is handled and returns false.

Usage

From source file:au.org.ala.delta.model.DiffUtils.java

private static boolean doCompareRange(FloatRange attr1Range, FloatRange attr2Range, boolean attr1Unknown,
        boolean attr2Unknown, boolean attr1Inapplicable, boolean attr2Inapplicable, boolean matchUnknowns,
        boolean matchInapplicables, MatchType matchType) {

    // If both attributes are unknown or inapplicable this is considered a
    // match. Otherwise, the return value depends on setting for
    // matchInapplicable or matchUnknown.
    if ((attr1Unknown || attr1Inapplicable) && (attr2Unknown || attr2Inapplicable)) {
        return true;
    }/*  www .  j a  va  2 s  .  c  o m*/

    if ((attr1Unknown && attr1Inapplicable) || (attr2Unknown && attr2Inapplicable)) {
        return matchInapplicables;
    }

    if ((attr1Unknown && !attr1Inapplicable) || (attr2Unknown && !attr2Inapplicable)) {
        return matchUnknowns;
    }

    boolean match = false;

    switch (matchType) {
    case EXACT:
        match = attr1Range.equals(attr2Range);
        break;
    case SUBSET:
        // is the first a subset of the second
        match = attr2Range.containsRange(attr1Range);
        break;
    case OVERLAP:
        match = attr1Range.overlapsRange(attr2Range);
        break;
    default:
        throw new RuntimeException(String.format("Unrecognized match type %s", matchType.toString()));
    }

    return match;
}