本文整理汇总了Java中com.google.common.primitives.Booleans类的典型用法代码示例。如果您正苦于以下问题:Java Booleans类的具体用法?Java Booleans怎么用?Java Booleans使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
Booleans类属于com.google.common.primitives包,在下文中一共展示了Booleans类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: toArray
import com.google.common.primitives.Booleans; //导入依赖的package包/类
@SuppressWarnings({"unchecked", "rawtypes"}) // NOTE: We assume the component type matches the list
private Object toArray(Class<?> componentType, List<Object> values) {
if (componentType == boolean.class) {
return Booleans.toArray((Collection) values);
} else if (componentType == byte.class) {
return Bytes.toArray((Collection) values);
} else if (componentType == short.class) {
return Shorts.toArray((Collection) values);
} else if (componentType == int.class) {
return Ints.toArray((Collection) values);
} else if (componentType == long.class) {
return Longs.toArray((Collection) values);
} else if (componentType == float.class) {
return Floats.toArray((Collection) values);
} else if (componentType == double.class) {
return Doubles.toArray((Collection) values);
} else if (componentType == char.class) {
return Chars.toArray((Collection) values);
}
return values.toArray((Object[]) Array.newInstance(componentType, values.size()));
}
示例2: controleerVerzoekparameters
import com.google.common.primitives.Booleans; //导入依赖的package包/类
@Bedrijfsregel(Regel.R1274)
@Bedrijfsregel(Regel.R2377)
@Bedrijfsregel(Regel.R2295)
private void controleerVerzoekparameters(final GeefMedebewonersVerzoek verzoek) throws StapMeldingException {
//Persoonsidentificatie OF Identificatiecode nummeraanduiding OF Adrescriteria moet zijn ingevuld
final int booleanCount = Booleans.countTrue(
verzoek.geefMedebewonersGelijkeBAG(),
verzoek.geefMedebewonersGelijkAdres(),
verzoek.geefMedebewonersVanPersoon(),
verzoek.geefMedebewonersGelijkeIDcodeAdresseerbaarObject());
if (booleanCount != 1) {
throw new StapMeldingException(Regel.R2377);
}
//valideer peilmoment
if (verzoek.getParameters() != null && (verzoek.getParameters().getPeilmomentMaterieel() != null)) {
peilmomentValidatieService.valideerMaterieel(verzoek.getParameters().getPeilmomentMaterieel());
}
}
示例3: getValues
import com.google.common.primitives.Booleans; //导入依赖的package包/类
static
public List<?> getValues(Tensor tensor){
DataType dataType = tensor.dataType();
switch(dataType){
case FLOAT:
return Floats.asList(TensorUtil.toFloatArray(tensor));
case DOUBLE:
return Doubles.asList(TensorUtil.toDoubleArray(tensor));
case INT32:
return Ints.asList(TensorUtil.toIntArray(tensor));
case INT64:
return Longs.asList(TensorUtil.toLongArray(tensor));
case STRING:
return Arrays.asList(TensorUtil.toStringArray(tensor));
case BOOL:
return Booleans.asList(TensorUtil.toBooleanArray(tensor));
default:
throw new IllegalArgumentException();
}
}
示例4: compareTo
import com.google.common.primitives.Booleans; //导入依赖的package包/类
@Override
public int compareTo(Cut<C> that) {
if (that == belowAll()) {
return 1;
}
if (that == aboveAll()) {
return -1;
}
int result = Range.compareOrThrow(endpoint, that.endpoint);
if (result != 0) {
return result;
}
// same value. below comes before above
return Booleans.compare(
this instanceof AboveValue, that instanceof AboveValue);
}
示例5: andList
import com.google.common.primitives.Booleans; //导入依赖的package包/类
/**
* @param clazz type of elements in the {@code value} list; must be one of {@code Boolean.class},
* {@code Integer.class}, {@code Long.class}, {@code Double.class}, {@code String.class}
* or {@code ModelNode.class}
* @throws IllegalArgumentException if {@code clazz} is not one of the known types
* @throws ClassCastException if some elements of the {@code value} list are not of type {@code clazz}
* @throws ArrayStoreException if some elements of the {@code value} list are not of type {@code clazz}
*/
@SuppressWarnings({"unchecked", "SuspiciousToArrayCall"})
public <T> Values andList(Class<T> clazz, String name, List<T> value) {
if (clazz == Boolean.class) {
return andList(name, Booleans.toArray((List<Boolean>) value));
} else if (clazz == Integer.class) {
return andList(name, Ints.toArray((List<Integer>) value));
} else if (clazz == Long.class) {
return andList(name, Longs.toArray((List<Long>) value));
} else if (clazz == Double.class) {
return andList(name, Doubles.toArray((List<Double>) value));
} else if (clazz == String.class) {
return andList(name, value.toArray(new String[value.size()]));
} else if (clazz == ModelNode.class) {
return andList(name, value.toArray(new ModelNode[value.size()]));
} else {
throw new IllegalArgumentException("Only List<Boolean>, List<Integer>, List<Long>, List<Double>, "
+ "List<String> and List<ModelNode> are supported");
}
}
示例6: getExtraArgs
import com.google.common.primitives.Booleans; //导入依赖的package包/类
/** Extract additional signature information for BuiltinFunction-s */
public static ExtraArgKind[] getExtraArgs(SkylarkSignature annotation) {
final int numExtraArgs =
Booleans.countTrue(
annotation.useLocation(), annotation.useAst(), annotation.useEnvironment());
if (numExtraArgs == 0) {
return null;
}
final ExtraArgKind[] extraArgs = new ExtraArgKind[numExtraArgs];
int i = 0;
if (annotation.useLocation()) {
extraArgs[i++] = ExtraArgKind.LOCATION;
}
if (annotation.useAst()) {
extraArgs[i++] = ExtraArgKind.SYNTAX_TREE;
}
if (annotation.useEnvironment()) {
extraArgs[i++] = ExtraArgKind.ENVIRONMENT;
}
return extraArgs;
}
示例7: compareTo
import com.google.common.primitives.Booleans; //导入依赖的package包/类
@Override
public int compareTo(AbstractUnflavoredBuildTarget o) {
if (this == o) {
return 0;
}
int cmp = Booleans.compare(o.getCell().isPresent(), getCell().isPresent());
if (cmp != 0) {
return cmp;
}
if (getCell().isPresent() && o.getCell().isPresent()) {
cmp = StringsUtils.compareStrings(getCell().get(), o.getCell().get());
if (cmp != 0) {
return cmp;
}
}
cmp = StringsUtils.compareStrings(getBaseName(), o.getBaseName());
if (cmp != 0) {
return cmp;
}
return StringsUtils.compareStrings(getShortName(), o.getShortName());
}
示例8: onOptionsItemSelected
import com.google.common.primitives.Booleans; //导入依赖的package包/类
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_disable_sources) {
Collection<CharSequence> itemsList = new ArrayList<>();
Collection<Boolean> checkedList = new ArrayList<>();
List<NewsSources> newsSources = nm.getNewsSources();
// Populate the settings dialog from the NewsManager sources
for (NewsSources newsSource: newsSources) {
itemsList.add(newsSource.getTitle());
checkedList.add(Utils.getSettingBool(this, "news_source_" + newsSource.getId(), true));
}
CharSequence[] items = Iterables.toArray(itemsList, CharSequence.class);
boolean[] checkedItems = Booleans.toArray(checkedList);
new AlertDialog.Builder(this)
.setMultiChoiceItems(items, checkedItems, this)
.create()
.show();
return true;
}
return super.onOptionsItemSelected(item);
}
示例9: getMapBooleanList
import com.google.common.primitives.Booleans; //导入依赖的package包/类
public Map<Short, List<Boolean>> getMapBooleanList()
{
if (mapBooleanArray == null) {
return null;
}
return Maps.transformValues(mapBooleanArray, Booleans::asList);
}
示例10: compareTo
import com.google.common.primitives.Booleans; //导入依赖的package包/类
@Override
public int compareTo(Cut<C> that) {
if (that == belowAll()) {
return 1;
}
if (that == aboveAll()) {
return -1;
}
int result = Range.compareOrThrow(endpoint, that.endpoint);
if (result != 0) {
return result;
}
// same value. below comes before above
return Booleans.compare(this instanceof AboveValue, that instanceof AboveValue);
}
示例11: indexOf
import com.google.common.primitives.Booleans; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @throws NullPointerException
* if the wrapped array was <code>null</code>.
*/
@Override
public int indexOf(Object o) {
// Will make the method fail if array is null.
if (size() < 1) {
return -1;
}
if (o instanceof Boolean) {
return Booleans.indexOf(array, ((Boolean) o).booleanValue());
}
return -1;
}
示例12: lastIndexOf
import com.google.common.primitives.Booleans; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @throws NullPointerException
* if the wrapped array was <code>null</code>.
*/
@Override
public int lastIndexOf(Object o) {
// Will make the method fail if array is null.
if (size() < 1) {
return -1;
}
if (o instanceof Boolean) {
return Booleans.lastIndexOf(array, ((Boolean) o).booleanValue());
}
return -1;
}
示例13: contains
import com.google.common.primitives.Booleans; //导入依赖的package包/类
/**
* {@inheritDoc}
*
* @throws NullPointerException
* if the wrapped array was <code>null</code>.
*/
@Override
public boolean contains(Object o) {
// Will make the method fail if array is null.
if (size() < 1) {
return false;
}
if (o instanceof Boolean) {
return Booleans.contains(array, ((Boolean) o).booleanValue());
}
return false;
}
示例14: hashCode
import com.google.common.primitives.Booleans; //导入依赖的package包/类
@Override
public int hashCode() {
int hash = 17;
hash = 31 * hash + Booleans.hashCode(doDebug);
hash = 31 * hash + Booleans.hashCode(doSuspend);
hash = 31 * hash + Objects.hashCode(runnables);
return hash;
}
示例15: isUniqueHashPresent
import com.google.common.primitives.Booleans; //导入依赖的package包/类
/**
* Returns <code>true</code> if specified array contains at least one elements that is not contained in
* all the arrays in the specified list.
*/
private static boolean isUniqueHashPresent(long[] hash, List<long[]> hashes) {
boolean[] matches = new boolean[hash.length];
for (long[] next : hashes) {
if (next == hash)
continue;
for (int i = 0; i < hash.length; i++)
if (!matches[i])
matches[i] = hash[i] == next[i];
if (!Booleans.contains(matches, false))
return false;
}
return true;
}