本文整理了Java中java.lang.Boolean.compare()
方法的一些代码示例,展示了Boolean.compare()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Boolean.compare()
方法的具体详情如下:
包路径:java.lang.Boolean
类名称:Boolean
方法名:compare
[英]Compares two boolean values.
[中]比较两个布尔值。
代码示例来源:origin: com.h2database/h2
@Override
protected int compareSecure(Value o, CompareMode mode) {
ValueBoolean v = (ValueBoolean) o;
return Boolean.compare(value, v.value);
}
代码示例来源:origin: looly/hutool
/**
* 比较
*
* @param other 其它 {@link MutableBool} 对象
* @return x==y返回0,x<y返回-1,x>y返回1
*/
@Override
public int compareTo(final MutableBool other) {
return Boolean.compare(this.value, other.value);
}
代码示例来源:origin: looly/hutool
/**
* 比较
*
* @param other 其它 {@link MutableBool} 对象
* @return x==y返回0,x<y返回-1,x>y返回1
*/
@Override
public int compareTo(final MutableBool other) {
return Boolean.compare(this.value, other.value);
}
代码示例来源:origin: robolectric/robolectric
@Override
public int compareTo(MetricKey o) {
int i = name.compareTo(o.name);
if (i != 0) {
return i;
}
i = resourcesMode.compareTo(o.resourcesMode);
if (i != 0) {
return i;
}
i = Integer.compare(sdkLevel, o.sdkLevel);
if (i != 0) {
return i;
}
return Boolean.compare(success, o.success);
}
}
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
SVMLinearClassificationModel mdl = (SVMLinearClassificationModel)o;
return Double.compare(mdl.intercept, intercept) == 0
&& Double.compare(mdl.threshold, threshold) == 0
&& Boolean.compare(mdl.isKeepingRawLabels, isKeepingRawLabels) == 0
&& Objects.equals(weights, mdl.weights);
}
代码示例来源:origin: apache/ignite
/** {@inheritDoc} */
@Override public boolean equals(Object o) {
if (this == o)
return true;
if (o == null || getClass() != o.getClass())
return false;
LogisticRegressionModel mdl = (LogisticRegressionModel)o;
return Double.compare(mdl.intercept, intercept) == 0
&& Double.compare(mdl.threshold, threshold) == 0
&& Boolean.compare(mdl.isKeepingRawLabels, isKeepingRawLabels) == 0
&& Objects.equals(weights, mdl.weights);
}
代码示例来源:origin: neo4j/neo4j
static int compareUsingIterators( SequenceValue a, SequenceValue b, Comparator<AnyValue> comparator )
{
int x = 0;
Iterator<AnyValue> aIterator = a.iterator();
Iterator<AnyValue> bIterator = b.iterator();
while ( aIterator.hasNext() && bIterator.hasNext() )
{
x = comparator.compare( aIterator.next(), bIterator.next() );
}
if ( x == 0 )
{
x = Boolean.compare( aIterator.hasNext(), bIterator.hasNext() );
}
return x;
}
代码示例来源:origin: prestodb/presto
@Override
public int compareTo(Block leftBlock, int leftPosition, Block rightBlock, int rightPosition)
{
boolean leftValue = leftBlock.getByte(leftPosition, 0) != 0;
boolean rightValue = rightBlock.getByte(rightPosition, 0) != 0;
return Boolean.compare(leftValue, rightValue);
}
代码示例来源:origin: prestodb/presto
@Override
public int compareTo(Block leftBlock, int leftPosition, Block rightBlock, int rightPosition)
{
boolean leftValue = leftBlock.getByte(leftPosition, 0) != 0;
boolean rightValue = rightBlock.getByte(rightPosition, 0) != 0;
return Boolean.compare(leftValue, rightValue);
}
代码示例来源:origin: apache/flink
private static String createQueryParameterHtmlList(Collection<MessageQueryParameter<?>> queryParameters) {
StringBuilder queryParameterList = new StringBuilder();
queryParameters.stream()
.sorted((param1, param2) -> Boolean.compare(param1.isMandatory(), param2.isMandatory()))
.forEach(parameter ->
queryParameterList.append(
String.format("<li><code>%s</code> (%s): %s</li>\n",
parameter.getKey(),
parameter.isMandatory() ? "mandatory" : "optional",
parameter.getDescription())
));
return queryParameterList.toString();
}
代码示例来源:origin: neo4j/neo4j
@Override
int compareValue( GenericKey left, GenericKey right )
{
if ( left.isHighestArray || right.isHighestArray )
{
return Boolean.compare( left.isHighestArray, right.isHighestArray );
}
int index = 0;
int compare = 0;
int length = min( left.arrayLength, right.arrayLength );
for ( ; compare == 0 && index < length; index++ )
{
compare = arrayElementComparator.compare( left, right, index );
}
return compare == 0 ? Integer.compare( left.arrayLength, right.arrayLength ) : compare;
}
代码示例来源:origin: real-logic/aeron
public int compareTo(final FilterResult other)
{
if (isLoopback == other.isLoopback)
{
return -compare(
interfaceAddress.getNetworkPrefixLength(),
other.interfaceAddress.getNetworkPrefixLength());
}
else
{
return compare(isLoopback, other.isLoopback);
}
}
}
代码示例来源:origin: gocd/gocd
@Override
public Comparator<UserModel> sorter() {
return (one, other) -> Boolean.compare(one.isEnabled(), other.isEnabled());
}
};
代码示例来源:origin: gocd/gocd
@Override
public Comparator<UserModel> sorter() {
return (one, other) -> Boolean.compare(one.isAdmin(), other.isAdmin());
}
},
代码示例来源:origin: google/error-prone
@Override
public int compare(MethodTree l, MethodTree r) {
return Boolean.compare(
l.getModifiers().getFlags().contains(Modifier.ABSTRACT),
r.getModifiers().getFlags().contains(Modifier.ABSTRACT));
}
}.reverse().immutableSortedCopy(Iterables.filter(tree.getMembers(), MethodTree.class));
代码示例来源:origin: speedment/speedment
@Override
default int compare(T first, T second) {
final boolean f = applyAsBoolean(first);
final boolean s = applyAsBoolean(second);
return Boolean.compare(f, s);
}
代码示例来源:origin: apache/ignite
/**
* @return Comparator for {@link PartitionHashRecordV2}.
*/
private Comparator<PartitionHashRecordV2> buildRecordComparator() {
return (o1, o2) -> {
int compare = Boolean.compare(o1.isPrimary(), o2.isPrimary());
if (compare != 0)
return compare;
return o1.consistentId().toString().compareTo(o2.consistentId().toString());
};
}
代码示例来源:origin: speedment/speedment
@Override
public int compare(T first, T second) {
final boolean f = isNull(first);
final boolean s = isNull(second);
if (f && s) return 0;
else if (f) return 1;
else if (s) return -1;
else return Boolean.compare(
original.applyAsBoolean(first),
original.applyAsBoolean(second)
);
}
代码示例来源:origin: speedment/speedment
@Override
public int compare(ENTITY first, ENTITY second) {
requireNonNulls(first, second);
final boolean a = field.getAsBoolean(first);
final boolean b = field.getAsBoolean(second);
return applyReversed(Boolean.compare(a, b));
}
代码示例来源:origin: neo4j/neo4j
public static int compareBooleanArrays( BooleanArray a, BooleanArray b )
{
int i = 0;
int x = 0;
int length = Math.min( a.length(), b.length() );
while ( x == 0 && i < length )
{
x = Boolean.compare( a.booleanValue( i ), b.booleanValue( i ) );
i++;
}
if ( x == 0 )
{
x = a.length() - b.length();
}
return x;
}
}
内容来源于网络,如有侵权,请联系作者删除!