本文整理汇总了Java中com.google.common.base.Verify.verifyNotNull方法的典型用法代码示例。如果您正苦于以下问题:Java Verify.verifyNotNull方法的具体用法?Java Verify.verifyNotNull怎么用?Java Verify.verifyNotNull使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类com.google.common.base.Verify
的用法示例。
在下文中一共展示了Verify.verifyNotNull方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: readExternal
import com.google.common.base.Verify; //导入方法依赖的package包/类
@Override
public void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
final int metaSize = in.readInt();
Preconditions.checkArgument(metaSize >= 0, "Invalid negative metadata map length %s", metaSize);
// Default pre-allocate is 4, which should be fine
final Builder<Class<? extends ShardDataTreeSnapshotMetadata<?>>, ShardDataTreeSnapshotMetadata<?>>
metaBuilder = ImmutableMap.builder();
for (int i = 0; i < metaSize; ++i) {
final ShardDataTreeSnapshotMetadata<?> m = (ShardDataTreeSnapshotMetadata<?>) in.readObject();
if (m != null) {
metaBuilder.put(m.getType(), m);
} else {
LOG.warn("Skipping null metadata");
}
}
metadata = metaBuilder.build();
rootNode = Verify.verifyNotNull(SerializationUtils.deserializeNormalizedNode(in));
}
示例2: scanClasspath
import com.google.common.base.Verify; //导入方法依赖的package包/类
private static ImmutableMap<Block, BiFunction<WetServer, IBlockState, ? extends WetBlockState>> scanClasspath() {
ImmutableMap.Builder<Block, BiFunction<WetServer, IBlockState, ? extends WetBlockState>> builder = ImmutableMap.builder();
Reflections reflections = new Reflections(getReflectionsConfiguration("org.fountainmc.world.block"));
Set<Class<?>> types = reflections.getTypesAnnotatedWith(BlockStateImpl.class);
if (types != null) {
for (Class<?> type : types) {
Verify.verify(WetBlockState.class.isAssignableFrom(type), "Class %s isn't instanceof WetBlockState", type.getTypeName());
for (String blockName : ImmutableList.copyOf(type.getAnnotation(BlockStateImpl.class).value())) {
Block block = Verify.verifyNotNull(Block.getBlockFromName(blockName),
"Class %s specified unknown block name minecraft:%s.", type.getTypeName(), blockName);
builder.put(block, (server, state) -> {
try {
Constructor<?> constructor = type.getConstructor(WetServer.class, IBlockState.class);
return (WetBlockState) constructor.newInstance(server, state);
} catch (Exception e) {
e.printStackTrace();
}
return null;
});
}
}
}
return builder.build();
}
示例3: getCommitsBetweenReferences
import com.google.common.base.Verify; //导入方法依赖的package包/类
/**
* Returns a list of commits between two references.
* @param repoPath path to local git repository.
* @param startRef start reference.
* @param endRef end reference.
* @return a list of commits.
* @throws IOException if I/O error occurs.
* @throws GitAPIException if an error occurs when accessing Git API.
*/
private static Set<RevCommit> getCommitsBetweenReferences(String repoPath, String startRef,
String endRef) throws IOException, GitAPIException {
final FileRepositoryBuilder builder = new FileRepositoryBuilder();
final Path path = Paths.get(repoPath);
final Repository repo = builder.findGitDir(path.toFile()).readEnvironment().build();
final ObjectId startCommit = getActualRefObjectId(repo, startRef);
Verify.verifyNotNull(startCommit, "Start reference \"" + startRef + "\" is invalid!");
final ObjectId endCommit = getActualRefObjectId(repo, endRef);
final Iterable<RevCommit> commits =
new Git(repo).log().addRange(startCommit, endCommit).call();
return Sets.newLinkedHashSet(commits);
}
示例4: createTable
import com.google.common.base.Verify; //导入方法依赖的package包/类
void createTable(final DOMDataWriteTransaction tx) {
final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> tb =
ImmutableNodes.mapEntryBuilder();
tb.withNodeIdentifier((NodeIdentifierWithPredicates) this.tableId.getLastPathArgument());
tb.withChild(EMPTY_TABLE_ATTRIBUTES);
// tableId is keyed, but that fact is not directly visible from YangInstanceIdentifier, see BUG-2796
final NodeIdentifierWithPredicates tableKey =
(NodeIdentifierWithPredicates) this.tableId.getLastPathArgument();
for (final Map.Entry<QName, Object> e : tableKey.getKeyValues().entrySet()) {
tb.withChild(ImmutableNodes.leafNode(e.getKey(), e.getValue()));
}
final ChoiceNode routes = this.tableSupport.emptyRoutes();
Verify.verifyNotNull(routes, "Null empty routes in %s", this.tableSupport);
tx.put(LogicalDatastoreType.OPERATIONAL, this.tableId,
tb.withChild(ImmutableChoiceNodeBuilder.create(routes).withNodeIdentifier(
new NodeIdentifier(TablesUtil.BMP_ROUTES_QNAME)).build()).build());
}
示例5: createEmptyTableStructure
import com.google.common.base.Verify; //导入方法依赖的package包/类
@Override
public void createEmptyTableStructure(final DOMDataWriteTransaction tx, final YangInstanceIdentifier tableId) {
final DataContainerNodeBuilder<NodeIdentifierWithPredicates, MapEntryNode> tb = ImmutableNodes.mapEntryBuilder();
tb.withNodeIdentifier((NodeIdentifierWithPredicates)tableId.getLastPathArgument());
tb.withChild(EMPTY_TABLE_ATTRIBUTES);
// tableId is keyed, but that fact is not directly visible from YangInstanceIdentifier, see BUG-2796
final NodeIdentifierWithPredicates tableKey = (NodeIdentifierWithPredicates) tableId.getLastPathArgument();
for (final Entry<QName, Object> e : tableKey.getKeyValues().entrySet()) {
tb.withChild(ImmutableNodes.leafNode(e.getKey(), e.getValue()));
}
final ChoiceNode routes = this.ribSupport.emptyRoutes();
Verify.verifyNotNull(routes, "Null empty routes in %s", this.ribSupport);
Verify.verify(Routes.QNAME.equals(routes.getNodeType()), "Empty routes have unexpected identifier %s, expected %s", routes.getNodeType(), Routes.QNAME);
tx.put(LogicalDatastoreType.OPERATIONAL, tableId, tb.withChild(routes).build());
}
示例6: toCompressed
import com.google.common.base.Verify; //导入方法依赖的package包/类
MainNode<K, V> toCompressed(final TrieMap<?, ?> ct, final int lev, final Gen gen) {
int bmp = bitmap;
int i = 0;
BasicNode[] arr = array;
BasicNode[] tmparray = new BasicNode[arr.length];
while (i < arr.length) { // construct new bitmap
BasicNode sub = arr[i];
if (sub instanceof INode) {
final INode<?, ?> in = (INode<?, ?>) sub;
final MainNode<?, ?> inodemain = Verify.verifyNotNull(in.gcasRead(ct));
tmparray [i] = resurrect(in, inodemain);
} else if (sub instanceof SNode) {
tmparray [i] = sub;
}
i += 1;
}
return new CNode<K, V>(gen, bmp, tmparray).toContracted(lev);
}
示例7: enforceCases
import com.google.common.base.Verify; //导入方法依赖的package包/类
private void enforceCases(final NormalizedNode<?, ?> normalizedNode) {
Verify.verify(normalizedNode instanceof ChoiceNode);
final Collection<DataContainerChild<?, ?>> children = ((ChoiceNode) normalizedNode).getValue();
if (!children.isEmpty()) {
final DataContainerChild<?, ?> firstChild = children.iterator().next();
final CaseEnforcer enforcer = Verify.verifyNotNull(caseEnforcers.get(firstChild.getIdentifier()),
"Case enforcer cannot be null. Most probably, child node %s of choice node %s does not belong "
+ "in current tree type.", firstChild.getIdentifier(), normalizedNode.getIdentifier());
// Make sure no leaves from other cases are present
for (final CaseEnforcer other : exclusions.get(enforcer)) {
for (final PathArgument id : other.getAllChildIdentifiers()) {
final Optional<NormalizedNode<?, ?>> maybeChild = NormalizedNodes.getDirectChild(normalizedNode,
id);
Preconditions.checkArgument(!maybeChild.isPresent(),
"Child %s (from case %s) implies non-presence of child %s (from case %s), which is %s",
firstChild.getIdentifier(), enforcer, id, other, maybeChild.orElse(null));
}
}
// Make sure all mandatory children are present
enforcer.enforceOnTreeNode(normalizedNode);
}
}
示例8: DeclaredEffectiveStatementBase
import com.google.common.base.Verify; //导入方法依赖的package包/类
/**
* Constructor.
*
* @param ctx
* context of statement.
*/
protected DeclaredEffectiveStatementBase(final StmtContext<A, D, ?> ctx) {
super(ctx);
this.argument = ctx.getStatementArgument();
this.statementSource = ctx.getStatementSource();
/*
* Share original instance of declared statement between all effective
* statements which have been copied or derived from this original
* declared statement.
*/
@SuppressWarnings("unchecked")
final StmtContext<?, D, ?> lookupCtx = (StmtContext<?, D, ?>) ctx.getOriginalCtx().orElse(ctx);
declaredInstance = Verify.verifyNotNull(lookupCtx.buildDeclared(),
"Statement %s failed to build declared statement", lookupCtx);
}
示例9: toContext
import com.google.common.base.Verify; //导入方法依赖的package包/类
ContextHolder toContext() throws YangParserException {
final SchemaContext schemaContext = Verify.verifyNotNull(parser.buildSchemaContext());
final Set<Module> modules = new HashSet<>();
for (Module module : schemaContext.getModules()) {
final SourceIdentifier modId = Util.moduleToIdentifier(module);
LOG.debug("Looking for source {}", modId);
if (modelsInProject.containsKey(modId)) {
LOG.debug("Module {} belongs to current project", module);
modules.add(module);
for (Module sub : module.getSubmodules()) {
final SourceIdentifier subId = Util.moduleToIdentifier(sub);
if (modelsInProject.containsKey(subId)) {
LOG.warn("Submodule {} not found in input files", sub);
}
}
}
}
return new ContextHolder(schemaContext, modules, modelsInProject.keySet());
}
示例10: getDefaults
import com.google.common.base.Verify; //导入方法依赖的package包/类
/**
* Finds the given environment in the given set and returns the default environments for its
* group.
*/
private static Collection<EnvironmentWithGroup> getDefaults(Label env,
EnvironmentCollection allEnvironments) {
EnvironmentGroup group = null;
for (EnvironmentGroup candidateGroup : allEnvironments.getGroups()) {
if (candidateGroup.getDefaults().contains(env)) {
group = candidateGroup;
break;
}
}
Verify.verifyNotNull(group);
ImmutableSet.Builder<EnvironmentWithGroup> builder = ImmutableSet.builder();
for (Label defaultEnv : group.getDefaults()) {
builder.add(EnvironmentWithGroup.create(defaultEnv, group));
}
return builder.build();
}
示例11: canCommit
import com.google.common.base.Verify; //导入方法依赖的package包/类
final void canCommit(final VotingFuture<?> ret) {
checkReadWrite();
checkSealed();
// Precludes startReconnect() from interfering with the fast path
synchronized (this) {
if (STATE_UPDATER.compareAndSet(this, SEALED, FLUSHED)) {
final TransactionRequest<?> req = Verify.verifyNotNull(commitRequest(true));
sendRequest(req, t -> {
if (t instanceof TransactionCanCommitSuccess) {
ret.voteYes();
} else if (t instanceof RequestFailure) {
ret.voteNo(((RequestFailure<?, ?>) t).getCause().unwrap());
} else {
ret.voteNo(unhandledResponseException(t));
}
recordSuccessfulRequest(req);
LOG.debug("Transaction {} canCommit completed", this);
});
return;
}
}
// We have had some interference with successor injection, wait for it to complete and defer to the successor.
awaitSuccessor().canCommit(ret);
}
示例12: readExternal
import com.google.common.base.Verify; //导入方法依赖的package包/类
@Override
public final void readExternal(final ObjectInput in) throws IOException, ClassNotFoundException {
final int length = in.readInt();
serialized = new byte[length];
in.readFully(serialized);
identifier = Verify.verifyNotNull(readIdentifier(ByteStreams.newDataInput(serialized)));
}
示例13: startPreCommit
import com.google.common.base.Verify; //导入方法依赖的package包/类
@SuppressWarnings("checkstyle:IllegalCatch")
void startPreCommit(final SimpleShardDataTreeCohort cohort) {
final CommitEntry entry = pendingTransactions.peek();
Preconditions.checkState(entry != null, "Attempted to pre-commit of %s when no transactions pending", cohort);
final SimpleShardDataTreeCohort current = entry.cohort;
Verify.verify(cohort.equals(current), "Attempted to pre-commit %s while %s is pending", cohort, current);
LOG.debug("{}: Preparing transaction {}", logContext, current.getIdentifier());
final DataTreeCandidateTip candidate;
try {
candidate = tip.prepare(cohort.getDataTreeModification());
cohort.userPreCommit(candidate);
} catch (ExecutionException | TimeoutException | RuntimeException e) {
failPreCommit(e);
return;
}
// Set the tip of the data tree.
tip = Verify.verifyNotNull(candidate);
entry.lastAccess = readTime();
pendingTransactions.remove();
pendingCommits.add(entry);
LOG.debug("{}: Transaction {} prepared", logContext, current.getIdentifier());
cohort.successfulPreCommit(candidate);
processNextPendingTransaction();
}
示例14: finishReconnect
import com.google.common.base.Verify; //导入方法依赖的package包/类
@GuardedBy("lock")
@Override
ProxyHistory finishReconnect() {
final ProxyHistory ret = Verify.verifyNotNull(successor);
for (AbstractProxyTransaction t : proxies.values()) {
t.finishReconnect();
}
LOG.debug("Finished reconnecting proxy history {}", this);
lock.unlock();
return ret;
}
示例15: removeContainerStateFile
import com.google.common.base.Verify; //导入方法依赖的package包/类
@Override
public void removeContainerStateFile(IJavaProject javaProject, String id) throws CoreException {
IFile stateFile = getFile(javaProject, id, false);
Verify.verifyNotNull(stateFile);
if (stateFile.exists()) {
stateFile.delete(true, new NullProgressMonitor());
}
}
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-eclipse,代码行数:9,代码来源:LibraryClasspathContainerSerializer.java