本文整理汇总了Java中org.apache.commons.lang.ObjectUtils.compare方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectUtils.compare方法的具体用法?Java ObjectUtils.compare怎么用?Java ObjectUtils.compare使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类org.apache.commons.lang.ObjectUtils
的用法示例。
在下文中一共展示了ObjectUtils.compare方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: compare
import org.apache.commons.lang.ObjectUtils; //导入方法依赖的package包/类
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 = ObjectUtils.compare(artifact1.getExtension(), 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();
}
示例2: compareKeys
import org.apache.commons.lang.ObjectUtils; //导入方法依赖的package包/类
private int compareKeys(Optional<Record> record1, Optional<Record> record2, List<Column> primaryKeys) {
if (!record1.isPresent() && !record2.isPresent()) {
throw new IllegalStateException("Cannot compare two nonexistent records.");
}
if (!record1.isPresent()) {
return 1;
}
if (!record2.isPresent()) {
return -1;
}
for (Column keyCol : primaryKeys) {
Comparable<?> value1 = convertToComparableType(keyCol, record1.get());
Comparable<?> value2 = convertToComparableType(keyCol, record2.get());
int result = ObjectUtils.compare(value1, value2);
if (result != 0) {
return result;
}
}
return 0;
}
示例3: compareTo
import org.apache.commons.lang.ObjectUtils; //导入方法依赖的package包/类
/**
* Compares this key to another, by currency then name.
*
* @param other the other key, not null
* @return the comparison value
*/
@Override
public int compareTo(final VolatilitySurfaceKey other) {
if (other == null) {
throw new NullPointerException();
}
int i = _target.compareTo(other.getTarget());
if (i != 0) {
return i;
}
i = ObjectUtils.compare(_name, other._name);
if (i != 0) {
return i;
}
i = ObjectUtils.compare(_instrumentType, other._instrumentType);
if (i != 0) {
return i;
}
i = ObjectUtils.compare(_quoteType, other._quoteType);
if (i != 0) {
return i;
}
return ObjectUtils.compare(_quoteUnits, other._quoteUnits);
}
示例4: compareTo
import org.apache.commons.lang.ObjectUtils; //导入方法依赖的package包/类
/**
* Compares this key to another, by currency then name.
*
* @param other the other key, not null
* @return the comparison value
*/
@Override
public int compareTo(final VolatilityCubeKey other) {
if (other == null) {
throw new NullPointerException();
}
int i = ObjectUtils.compare(_definitionName, other._definitionName);
if (i != 0) {
return i;
}
i = ObjectUtils.compare(_specificationName, other._specificationName);
if (i != 0) {
return i;
}
i = ObjectUtils.compare(_quoteType, other._quoteType);
if (i != 0) {
return i;
}
return ObjectUtils.compare(_quoteUnits, other._quoteUnits);
}
示例5: compare
import org.apache.commons.lang.ObjectUtils; //导入方法依赖的package包/类
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();
}
示例6: compareTo
import org.apache.commons.lang.ObjectUtils; //导入方法依赖的package包/类
/**
* Compares this key to another by name.
*
* @param other the other key, not null
* @return the comparison value
*/
@Override
public int compareTo(final SurfaceKey other) {
if (other == null) {
throw new NullPointerException();
}
return ObjectUtils.compare(_name, other._name);
}
示例7: isRangeValid
import org.apache.commons.lang.ObjectUtils; //导入方法依赖的package包/类
@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;
}
示例8: getFilteredMembers
import org.apache.commons.lang.ObjectUtils; //导入方法依赖的package包/类
/**
* Looks for class members, that match the given predicate.
*
* @param clazz a class to look for members in
* @param memberPredicate predicated that must be fulfilled by the class members
* @return a list of class members that match the predicate
*/
public static List<Member> getFilteredMembers(Class<?> clazz, Predicate memberPredicate) {
List<Member> members = MemberUtil.getMembers(clazz, memberPredicate);
Set<Member> membersSet = new TreeSet<>(new Comparator<Member>() {
@Override
public int compare(Member member1, Member member2) {
String member1Name = MemberUtil.getFieldName(member1);
String member2Name = MemberUtil.getFieldName(member2);
return ObjectUtils.compare(member1Name, member2Name);
}
});
membersSet.addAll(members);
return new ArrayList<>(membersSet);
}
示例9: compareTo
import org.apache.commons.lang.ObjectUtils; //导入方法依赖的package包/类
@Override
public int compareTo(final FixedIncomeStrip other) {
int result = DateUtils.estimatedDuration(getEffectiveTenor().getPeriod()).compareTo(DateUtils.estimatedDuration(other.getEffectiveTenor().getPeriod()));
if (result != 0) {
return result;
}
if (_instrumentType == StripInstrumentType.SPREAD) {
result = getStrip1().compareTo(other.getStrip1());
if (result != 0) {
return result;
}
result = getStrip2().compareTo(other.getStrip2());
if (result != 0) {
return result;
}
return getOperation().ordinal() - other.getOperation().ordinal();
}
result = getInstrumentType().ordinal() - other.getInstrumentType().ordinal();
if (result != 0) {
return result;
} else if (getInstrumentType() == StripInstrumentType.FUTURE) {
result = getNumberOfFuturesAfterTenor() - other.getNumberOfFuturesAfterTenor();
} else if (getInstrumentType() == StripInstrumentType.PERIODIC_ZERO_DEPOSIT) {
result = getPeriodsPerYear() - other.getPeriodsPerYear();
} else if (getInstrumentType() == StripInstrumentType.SWAP || getInstrumentType() == StripInstrumentType.OIS_SWAP && getIndexType() != null) {
result = ObjectUtils.compare(getResetTenor(), other.getResetTenor());
if (result != 0) {
return result;
}
return ObjectUtils.compare(getIndexType(), other.getIndexType());
} else if (getInstrumentType() == StripInstrumentType.BASIS_SWAP) {
result = getPayTenor().compareTo(other.getPayTenor());
if (result != 0) {
return result;
}
result = ObjectUtils.compare(getReceiveTenor(), other.getReceiveTenor());
if (result != 0) {
return result;
}
result = ObjectUtils.compare(getPayIndexType(), other.getPayIndexType());
if (result != 0) {
return result;
}
result = ObjectUtils.compare(getReceiveIndexType(), other.getReceiveIndexType());
}
return result;
}
示例10: compare
import org.apache.commons.lang.ObjectUtils; //导入方法依赖的package包/类
/**
* Runnable task comparison. In runnable priority order (most preferable to run first):
* <ul>
* <li>PORTFOLIO_NODE</li>
* <li>PRIMITIVE</li>
* <li>SECURITY</li>
* <li>TRADE</li>
* <li>POSITION</li>
* </ul>
* Within a given computation target type, ordering is based on the unique identifier. The aim is to get tasks that will "complete" running sooner (i.e. the primitive and security level functions)
* to reduce the live memory footprint during a graph build. Portfolio node targets are performed at a high priority so that if individual positions are also requested then the graph build for both
* should run in parallel if the node function is a basic aggregation. Ordering the unique identifiers should group values on the same target to give better utilization of the computation target
* resolver cache.
* <p>
* Note this sorts into reverse order so that the most preferable to run are at the end of the array.
*/
@Override
public int compare(final ContextRunnable r1, final ContextRunnable r2) {
if (r1 instanceof ResolveTask) {
if (r2 instanceof ResolveTask) {
final ResolveTask rt1 = (ResolveTask) r1;
final ResolveTask rt2 = (ResolveTask) r2;
final ComputationTargetReference ctr1 = rt1.getValueRequirement().getTargetReference();
final ComputationTargetReference ctr2 = rt2.getValueRequirement().getTargetReference();
final Integer p1 = s_priority.get(ctr1.getType());
final Integer p2 = s_priority.get(ctr2.getType());
if (p1.intValue() < p2.intValue()) {
return 1;
} else if (p1.intValue() > p2.intValue()) {
return -1;
} else {
if (ctr1 instanceof ComputationTargetSpecification) {
if (ctr2 instanceof ComputationTargetSpecification) {
return ObjectUtils.compare(ctr2.getSpecification().getUniqueId(), ctr1.getSpecification().getUniqueId());
} else {
// Do requirement -> specification resolution (r2) first
return -1;
}
} else {
if (ctr2 instanceof ComputationTargetRequirement) {
return ctr2.getRequirement().getIdentifiers().compareTo(ctr1.getRequirement().getIdentifiers());
} else {
// Do requirement -> specification resolution (r1) first
return 1;
}
}
}
} else {
// Do non-ResolveTask (r2) first
return -1;
}
} else {
if (r2 instanceof ResolveTask) {
// Do non-ResolveTask (r1) first
return 1;
} else {
// Don't care
return 0;
}
}
}
示例11: isTypeUpdateApplicable
import org.apache.commons.lang.ObjectUtils; //导入方法依赖的package包/类
private static boolean isTypeUpdateApplicable(AtlasBaseTypeDef oldTypeDef, AtlasBaseTypeDef newTypeDef) {
String oldTypeVersion = oldTypeDef.getTypeVersion();
String newTypeVersion = newTypeDef.getTypeVersion();
return ObjectUtils.compare(newTypeVersion, oldTypeVersion) > 0;
}