當前位置: 首頁>>代碼示例>>Java>>正文


Java Booleans類代碼示例

本文整理匯總了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()));
}
 
開發者ID:TNG,項目名稱:ArchUnit,代碼行數:22,代碼來源:JavaClassProcessor.java

示例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());
    }
}
 
開發者ID:MinBZK,項目名稱:OperatieBRP,代碼行數:20,代碼來源:GeefMedebewonersMaakBerichtServiceImpl.java

示例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();
	}
}
 
開發者ID:jpmml,項目名稱:jpmml-tensorflow,代碼行數:22,代碼來源:TensorUtil.java

示例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);
}
 
開發者ID:cplutte,項目名稱:bts,代碼行數:17,代碼來源:Cut.java

示例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");
    }
}
 
開發者ID:wildfly-extras,項目名稱:creaper,代碼行數:28,代碼來源:Values.java

示例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;
}
 
開發者ID:bazelbuild,項目名稱:bazel,代碼行數:22,代碼來源:SkylarkSignatureProcessor.java

示例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());
}
 
開發者ID:facebook,項目名稱:buck,代碼行數:22,代碼來源:AbstractUnflavoredBuildTarget.java

示例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);

}
 
開發者ID:TCA-Team,項目名稱:TumCampusApp,代碼行數:25,代碼來源:NewsActivity.java

示例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);
}
 
開發者ID:airlift,項目名稱:drift,代碼行數:8,代碼來源:ArrayField.java

示例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);
}
 
開發者ID:zugzug90,項目名稱:guava-mock,代碼行數:16,代碼來源:Cut.java

示例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;
}
 
開發者ID:eclipse,項目名稱:xtext-lib,代碼行數:18,代碼來源:Conversions.java

示例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;
}
 
開發者ID:eclipse,項目名稱:xtext-lib,代碼行數:18,代碼來源:Conversions.java

示例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;
}
 
開發者ID:eclipse,項目名稱:xtext-lib,代碼行數:18,代碼來源:Conversions.java

示例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;
}
 
開發者ID:apache,項目名稱:twill,代碼行數:9,代碼來源:JvmOptions.java

示例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;
}
 
開發者ID:Whaka-project,項目名稱:whakamatautau-util,代碼行數:18,代碼來源:HashRowCollector.java


注:本文中的com.google.common.primitives.Booleans類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。