Java Code Examples for org.apache.commons.lang.ObjectUtils#compare()

The following examples show how to use org.apache.commons.lang.ObjectUtils#compare() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: DefaultResolvedDependency.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public int compare(ResolvedArtifact artifact1, ResolvedArtifact artifact2) {
    int diff = artifact1.getName().compareTo(artifact2.getName());
    if (diff != 0) {
        return diff;
    }
    diff = ObjectUtils.compare(artifact1.getClassifier(), artifact2.getClassifier());
    if (diff != 0) {
        return diff;
    }
    diff = artifact1.getExtension().compareTo(artifact2.getExtension());
    if (diff != 0) {
        return diff;
    }
    diff = artifact1.getType().compareTo(artifact2.getType());
    if (diff != 0) {
        return diff;
    }
    // Use an arbitrary ordering when the artifacts have the same public attributes
    return artifact1.hashCode() - artifact2.hashCode();
}
 
Example 2
Source File: DefaultResolvedDependency.java    From pushfish-android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public int compare(ResolvedArtifact artifact1, ResolvedArtifact artifact2) {
    int diff = artifact1.getName().compareTo(artifact2.getName());
    if (diff != 0) {
        return diff;
    }
    diff = ObjectUtils.compare(artifact1.getClassifier(), artifact2.getClassifier());
    if (diff != 0) {
        return diff;
    }
    diff = artifact1.getExtension().compareTo(artifact2.getExtension());
    if (diff != 0) {
        return diff;
    }
    diff = artifact1.getType().compareTo(artifact2.getType());
    if (diff != 0) {
        return diff;
    }
    // Use an arbitrary ordering when the artifacts have the same public attributes
    return artifact1.hashCode() - artifact2.hashCode();
}
 
Example 3
Source File: DefaultResolvedDependency.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public int compare(ResolvedArtifact artifact1, ResolvedArtifact artifact2) {
    int diff = artifact1.getName().compareTo(artifact2.getName());
    if (diff != 0) {
        return diff;
    }
    diff = ObjectUtils.compare(artifact1.getClassifier(), artifact2.getClassifier());
    if (diff != 0) {
        return diff;
    }
    diff = artifact1.getExtension().compareTo(artifact2.getExtension());
    if (diff != 0) {
        return diff;
    }
    diff = artifact1.getType().compareTo(artifact2.getType());
    if (diff != 0) {
        return diff;
    }
    // Use an arbitrary ordering when the artifacts have the same public attributes
    return artifact1.hashCode() - artifact2.hashCode();
}
 
Example 4
Source File: DefaultResolvedDependency.java    From Pushjet-Android with BSD 2-Clause "Simplified" License 6 votes vote down vote up
public int compare(ResolvedArtifact artifact1, ResolvedArtifact artifact2) {
    int diff = artifact1.getName().compareTo(artifact2.getName());
    if (diff != 0) {
        return diff;
    }
    diff = ObjectUtils.compare(artifact1.getClassifier(), artifact2.getClassifier());
    if (diff != 0) {
        return diff;
    }
    diff = artifact1.getExtension().compareTo(artifact2.getExtension());
    if (diff != 0) {
        return diff;
    }
    diff = artifact1.getType().compareTo(artifact2.getType());
    if (diff != 0) {
        return diff;
    }
    // Use an arbitrary ordering when the artifacts have the same public attributes
    return artifact1.hashCode() - artifact2.hashCode();
}
 
Example 5
Source File: AbstractPredicateUtil.java    From ranger with Apache License 2.0 6 votes vote down vote up
@Override
public int compare(RangerBaseModelObject o1, RangerBaseModelObject o2) {
	String val1 = null;
	String val2 = null;

	if(o1 != null) {
		if(o1 instanceof RangerServiceDef) {
			val1 = ((RangerServiceDef)o1).getName();
		} else if(o1 instanceof RangerService) {
			val1 = ((RangerService)o1).getType();
		}
	}

	if(o2 != null) {
		if(o2 instanceof RangerServiceDef) {
			val2 = ((RangerServiceDef)o2).getName();
		} else if(o2 instanceof RangerService) {
			val2 = ((RangerService)o2).getType();
		}
	}

	return ObjectUtils.compare(val1, val2);
}
 
Example 6
Source File: AbstractPredicateUtil.java    From ranger with Apache License 2.0 6 votes vote down vote up
@Override
public int compare(RangerBaseModelObject o1, RangerBaseModelObject o2) {
	String val1 = null;
	String val2 = null;

	if(o1 != null) {
		if(o1 instanceof RangerPolicy) {
			val1 = ((RangerPolicy)o1).getService();
		} else if(o1 instanceof RangerService) {
			val1 = ((RangerService)o1).getType();
		}
	}

	if(o2 != null) {
		if(o2 instanceof RangerPolicy) {
			val2 = ((RangerPolicy)o2).getService();
		} else if(o2 instanceof RangerService) {
			val2 = ((RangerService)o2).getType();
		}
	}

	return ObjectUtils.compare(val1, val2);
}
 
Example 7
Source File: AtlasTypeDefStoreInitializer.java    From atlas with Apache License 2.0 5 votes vote down vote up
private static boolean isTypeUpdateApplicable(AtlasBaseTypeDef oldTypeDef, AtlasBaseTypeDef newTypeDef, boolean checkVersion) {
    boolean ret = true;

    if (checkVersion) {
        String oldTypeVersion = oldTypeDef.getTypeVersion();
        String newTypeVersion = newTypeDef.getTypeVersion();

        ret = ObjectUtils.compare(newTypeVersion, oldTypeVersion) > 0;
    }

    return ret;
}
 
Example 8
Source File: AbstractPredicateUtil.java    From ranger with Apache License 2.0 5 votes vote down vote up
@Override
public int compare(RangerBaseModelObject o1, RangerBaseModelObject o2) {
	Long val1 = (o1 != null) ? o1.getId() : null;
	Long val2 = (o2 != null) ? o2.getId() : null;

	return ObjectUtils.compare(val1, val2);
}
 
Example 9
Source File: AbstractPredicateUtil.java    From ranger with Apache License 2.0 5 votes vote down vote up
@Override
public int compare(RangerBaseModelObject o1, RangerBaseModelObject o2) {
	Date val1 = (o1 != null) ? o1.getCreateTime() : null;
	Date val2 = (o2 != null) ? o2.getCreateTime() : null;

	return ObjectUtils.compare(val1, val2);
}
 
Example 10
Source File: AbstractPredicateUtil.java    From ranger with Apache License 2.0 5 votes vote down vote up
@Override
public int compare(RangerBaseModelObject o1, RangerBaseModelObject o2) {
	Date val1 = (o1 != null) ? o1.getUpdateTime() : null;
	Date val2 = (o2 != null) ? o2.getUpdateTime() : null;

	return ObjectUtils.compare(val1, val2);
}
 
Example 11
Source File: AbstractPredicateUtil.java    From ranger with Apache License 2.0 5 votes vote down vote up
@Override
public int compare(RangerBaseModelObject o1, RangerBaseModelObject o2) {
	String val1 = (o1 instanceof RangerPolicy) ? ((RangerPolicy)o1).getName() : null;
	String val2 = (o2 instanceof RangerPolicy) ? ((RangerPolicy)o2).getName() : null;

	return ObjectUtils.compare(val1, val2);
}
 
Example 12
Source File: AbstractPredicateUtil.java    From ranger with Apache License 2.0 5 votes vote down vote up
@Override
public int compare(RangerResourceDef o1, RangerResourceDef o2) {
	Integer val1 = (o1 != null) ? o1.getLevel() : null;
	Integer val2 = (o2 != null) ? o2.getLevel() : null;

	return ObjectUtils.compare(val1, val2);
}
 
Example 13
Source File: AbstractPredicateUtil.java    From ranger with Apache License 2.0 5 votes vote down vote up
@Override
public int compare(RangerBaseModelObject o1, RangerBaseModelObject o2) {
    String val1 = (o1 instanceof RangerSecurityZone) ? ((RangerSecurityZone)o1).getName() : null;
    String val2 = (o2 instanceof RangerSecurityZone) ? ((RangerSecurityZone)o2).getName() : null;

    return ObjectUtils.compare(val1, val2);
}
 
Example 14
Source File: SearchableAttributeStringValue.java    From rice with Educational Community License v2.0 5 votes vote down vote up
@Override
public Boolean isRangeValid(String lowerValue, String upperValue, boolean caseSensitive) {
    if (allowsRangeSearches()) {
        return StringUtils.isBlank(lowerValue) ||
               StringUtils.isBlank(upperValue) ||
               (caseSensitive ?
                 ObjectUtils.compare(lowerValue, upperValue) <= 0 :
                 String.CASE_INSENSITIVE_ORDER.compare(lowerValue, upperValue) <= 0);
    }
    return null;
}
 
Example 15
Source File: AtlasTypeDefStoreInitializer.java    From incubator-atlas with Apache License 2.0 4 votes vote down vote up
private static boolean isTypeUpdateApplicable(AtlasBaseTypeDef oldTypeDef, AtlasBaseTypeDef newTypeDef) {
    String oldTypeVersion = oldTypeDef.getTypeVersion();
    String newTypeVersion = newTypeDef.getTypeVersion();

    return ObjectUtils.compare(newTypeVersion, oldTypeVersion) > 0;
}