org.apache.commons.lang.ObjectUtils#compare ( )源码实例Demo

下面列出了org.apache.commons.lang.ObjectUtils#compare ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。

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();
}
 
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();
}
 
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();
}
 
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();
}
 
源代码5 项目: ranger   文件: AbstractPredicateUtil.java
@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);
}
 
源代码6 项目: ranger   文件: AbstractPredicateUtil.java
@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);
}
 
源代码7 项目: atlas   文件: AtlasTypeDefStoreInitializer.java
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;
}
 
源代码8 项目: ranger   文件: AbstractPredicateUtil.java
@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);
}
 
源代码9 项目: ranger   文件: AbstractPredicateUtil.java
@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);
}
 
源代码10 项目: ranger   文件: AbstractPredicateUtil.java
@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);
}
 
源代码11 项目: ranger   文件: AbstractPredicateUtil.java
@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);
}
 
源代码12 项目: ranger   文件: AbstractPredicateUtil.java
@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);
}
 
源代码13 项目: ranger   文件: AbstractPredicateUtil.java
@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);
}
 
源代码14 项目: rice   文件: SearchableAttributeStringValue.java
@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;
}
 
private static boolean isTypeUpdateApplicable(AtlasBaseTypeDef oldTypeDef, AtlasBaseTypeDef newTypeDef) {
    String oldTypeVersion = oldTypeDef.getTypeVersion();
    String newTypeVersion = newTypeDef.getTypeVersion();

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