当前位置: 首页>>代码示例>>Java>>正文


Java Verify.verify方法代码示例

本文整理汇总了Java中com.google.common.base.Verify.verify方法的典型用法代码示例。如果您正苦于以下问题:Java Verify.verify方法的具体用法?Java Verify.verify怎么用?Java Verify.verify使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在com.google.common.base.Verify的用法示例。


在下文中一共展示了Verify.verify方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: TypevarContext

import com.google.common.base.Verify; //导入方法依赖的package包/类
TypevarContext(TypeElement element, String renderedTypeString) {
  List<? extends TypeParameterElement> typeParameters = element.getTypeParameters();
  if (!typeParameters.isEmpty()) {
    this.arguments = SourceTypes.extract(renderedTypeString).getValue();

    this.parameters = Lists.newArrayList();
    for (TypeParameterElement p : typeParameters) {
      parameters.add(p.getSimpleName().toString());
    }
    // we allow having no arguments in a string as raw type/unspecified argument scenario
    Verify.verify(arguments.isEmpty() || (parameters.size() == arguments.size()), parameters + " =/> " + arguments);
  } else {
    this.parameters = Collections.emptyList();
    this.arguments = Collections.emptyList();
  }
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:17,代码来源:TypeHierarchyCollector.java

示例2: signature

import com.google.common.base.Verify; //导入方法依赖的package包/类
private boolean signature(Statement.Builder builder) {
	Term t = terms.peek();
	if (t.is("@")) {
		do {
			builder.addAnnotations(terms.next());
			Verify.verify(terms.peek().isWordOrNumber());
			builder.addAnnotations(terms.next());
		} while (terms.peek().is("."));

		if (terms.peek().is("(")) {
			builder.addAllAnnotations(collectUntilMatching(")"));
		}
		return false;
	} else if (t.is("<")) {
		builder.addAllSignature(collectUntilMatching(">"));
		return false;
	} else if (t.is("class")) {
		builder.addSignature(terms.next());
		return true;
	} else {
		builder.addSignature(terms.next());
		return false;
	}
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:25,代码来源:Structurizer.java

示例3: createLocalHistory

import com.google.common.base.Verify; //导入方法依赖的package包/类
@Override
public final ClientLocalHistory createLocalHistory() {
    final LocalHistoryIdentifier historyId = new LocalHistoryIdentifier(getIdentifier(),
        nextHistoryId.getAndIncrement());

    final long stamp = lock.readLock();
    try {
        if (aborted != null) {
            Throwables.throwIfUnchecked(aborted);
            throw new RuntimeException(aborted);
        }

        final ClientLocalHistory history = new ClientLocalHistory(this, historyId);
        LOG.debug("{}: creating a new local history {}", persistenceId(), history);

        Verify.verify(histories.put(historyId, history) == null);
        return history;
    } finally {
        lock.unlockRead(stamp);
    }
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:22,代码来源:AbstractDataStoreClientBehavior.java

示例4: encodeBits

import com.google.common.base.Verify; //导入方法依赖的package包/类
/**
 * Encodes an arbitrary bitstring into a RAPPOR report.
 *
 * @param bits A bitstring in which only the least significant numBits bits may be 1.
 */
private byte[] encodeBits(BitSet bits) {
  BitSet permanentRandomizedResponse = computePermanentRandomizedResponse(bits);
  BitSet encodedBitSet = computeInstantaneousRandomizedResponse(permanentRandomizedResponse);

  // BitSet.toByteArray only returns enough bytes to capture the most significant bit
  // that is set.  For example, a BitSet with no bits set could return a length-0 array.
  // In contrast, we guarantee that our output is sized according to numBits.
  byte[] encodedBytes = encodedBitSet.toByteArray();
  byte[] output = new byte[(numBits + 7) / 8];
  Verify.verify(encodedBytes.length <= output.length);
  System.arraycopy(
      encodedBytes, // src
      0, // srcPos
      output, // dest
      0, // destPos
      encodedBytes.length); // length
  return output;
}
 
开发者ID:cleaninsights,项目名称:cleaninsights-android-sdk,代码行数:24,代码来源:Encoder.java

示例5: checkNotNull

import com.google.common.base.Verify; //导入方法依赖的package包/类
@SuppressWarnings("unchecked") // Callers shouldn't be accessing this method.
/* package */ PineappleField(Field field) {
    this.field = checkNotNull(field, "Null field");
    checkArgument(
        field.isAccessible()
        || Modifier.isPublic(field.getModifiers())
        && Modifier.isPublic(field.getDeclaringClass().getModifiers()),
        "Field isn't accessible: %s",
        field
    );
    this.declaringClass = (Class<T>) field.getDeclaringClass();
    this.fieldType = (Class<V>) field.getType();
    this.modifiers = field.getModifiers();
    this.primitiveType = PrimitiveType.fromClass(field.getType());
    Verify.verify(this.isPrimitive() == field.getType().isPrimitive());
}
 
开发者ID:Techcable,项目名称:PineappleCommons,代码行数:17,代码来源:PineappleField.java

示例6: 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();
}
 
开发者ID:FountainMC,项目名称:FountainVanilla,代码行数:25,代码来源:WetBlockState.java

示例7: CombatTagLegacySupport

import com.google.common.base.Verify; //导入方法依赖的package包/类
public CombatTagLegacySupport() {
    CombatTagApi api = null;
    Plugin plugin = Bukkit.getPluginManager().getPlugin(PLUGIN_NAME);
    try {
        api = CombatTagApi.getInstance();
    } catch (NoClassDefFoundError | NoSuchMethodError e) { // Old version or not installed
        try {
            if (plugin instanceof CombatTag) {
                api = new CombatTagApi((CombatTag) plugin);
            }
        } catch (NoClassDefFoundError | NoSuchMethodError ignored) {}
    }
    Verify.verify((plugin == null) == (api == null), "Could %s plugin, but could %s api!", plugin == null ? "not find" : "find", api == null ? "not find" : "find");
    this.api = api;
    this.plugin = plugin;
}
 
开发者ID:TechzoneMC,项目名称:SpawnShield,代码行数:17,代码来源:CombatTagLegacySupport.java

示例8: evaluateImpl

import com.google.common.base.Verify; //导入方法依赖的package包/类
@Nullable
@Override
public Object evaluateImpl(Long f) {
  Native.LongPtr out = new Native.LongPtr();
  boolean status = Native.modelEval(z3context, model, f, false, out);
  Verify.verify(status, "Error during model evaluation");
  long outValue = out.value;

  if (z3creator.isConstant(outValue)) {
    return z3creator.convertValue(outValue);
  }

  // Z3 does not give us a direct API to query for "irrelevant" ASTs during evaluation.
  // The only hint we get is that the input AST is not simplified down to a constant:
  // thus, it is assumed to be irrelevant.
  return null;
}
 
开发者ID:sosy-lab,项目名称:java-smt,代码行数:18,代码来源:Z3Model.java

示例9: from

import com.google.common.base.Verify; //导入方法依赖的package包/类
/** Classifies an identifier's case format. */
static JavaCaseFormat from(String name) {
  Verify.verify(!name.isEmpty());
  boolean firstUppercase = false;
  boolean hasUppercase = false;
  boolean hasLowercase = false;
  boolean first = true;
  for (int i = 0; i < name.length(); i++) {
    char c = name.charAt(i);
    if (!Character.isAlphabetic(c)) {
      continue;
    }
    if (first) {
      firstUppercase = Character.isUpperCase(c);
      first = false;
    }
    hasUppercase |= Character.isUpperCase(c);
    hasLowercase |= Character.isLowerCase(c);
  }
  if (firstUppercase) {
    return hasLowercase ? UPPER_CAMEL : UPPERCASE;
  } else {
    return hasUppercase ? LOWER_CAMEL : LOWERCASE;
  }
}
 
开发者ID:google,项目名称:google-java-format,代码行数:26,代码来源:TypeNameClassifier.java

示例10: getAndValidate

import com.google.common.base.Verify; //导入方法依赖的package包/类
/**
 * Variation of {@link #get} that throws an informative exception if the attribute
 * can't be resolved due to intrinsic contradictions in the configuration.
 */
private <T> T getAndValidate(String attributeName, Type<T> type) throws EvalException  {
  SelectorList<T> selectorList = getSelectorList(attributeName, type);
  if (selectorList == null) {
    // This is a normal attribute.
    return super.get(attributeName, type);
  }

  List<T> resolvedList = new ArrayList<>();
  for (Selector<T> selector : selectorList.getSelectors()) {
    ConfigKeyAndValue<T> resolvedPath = resolveSelector(attributeName, selector);
    if (!selector.isValueSet(resolvedPath.configKey)) {
      // Use the default. We don't have access to the rule here, so pass null to
      // Attribute.getValue(). This has the result of making attributes with condition
      // predicates ineligible for "None" values. But no user-facing attributes should
      // do that anyway, so that isn't a loss.
      Attribute attr = getAttributeDefinition(attributeName);
      Verify.verify(attr.getCondition() == Predicates.<AttributeMap>alwaysTrue());
      resolvedList.add((T) attr.getDefaultValue(null));
    } else {
      resolvedList.add(resolvedPath.value);
    }
  }
  return resolvedList.size() == 1 ? resolvedList.get(0) : type.concat(resolvedList);
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:29,代码来源:ConfiguredAttributeMapper.java

示例11: performRefine

import com.google.common.base.Verify; //导入方法依赖的package包/类
private static void performRefine(final Mutable<?, ?, ?> subStmtCtx, final StmtContext<?, ?, ?> usesParentCtx) {
    final Object refineArgument = subStmtCtx.getStatementArgument();
    InferenceException.throwIf(!(refineArgument instanceof SchemaNodeIdentifier),
        subStmtCtx.getStatementSourceReference(),
        "Invalid refine argument %s. It must be instance of SchemaNodeIdentifier.", refineArgument);

    final Optional<StmtContext<?, ?, ?>> optRefineTargetCtx = SchemaNodeIdentifierBuildNamespace.findNode(
        usesParentCtx, (SchemaNodeIdentifier) refineArgument);
    InferenceException.throwIf(!optRefineTargetCtx.isPresent(), subStmtCtx.getStatementSourceReference(),
        "Refine target node %s not found.", refineArgument);

    final StmtContext<?, ?, ?> refineTargetNodeCtx = optRefineTargetCtx.get();
    if (StmtContextUtils.isUnknownStatement(refineTargetNodeCtx)) {
        LOG.trace("Refine node '{}' in uses '{}' has target node unknown statement '{}'. "
            + "Refine has been skipped. At line: {}", subStmtCtx.getStatementArgument(),
            subStmtCtx.getParentContext().getStatementArgument(),
            refineTargetNodeCtx.getStatementArgument(), subStmtCtx.getStatementSourceReference());
        subStmtCtx.addAsEffectOfStatement(refineTargetNodeCtx);
        return;
    }

    Verify.verify(refineTargetNodeCtx instanceof StatementContextBase);
    addOrReplaceNodes(subStmtCtx, (StatementContextBase<?, ?, ?>) refineTargetNodeCtx);
    subStmtCtx.addAsEffectOfStatement(refineTargetNodeCtx);
}
 
开发者ID:opendaylight,项目名称:yangtools,代码行数:26,代码来源:UsesStatementImpl.java

示例12: sortResolvedDeps

import com.google.common.base.Verify; //导入方法依赖的package包/类
/**
 * Returns a copy of the output deps using the same key and value ordering as the input deps.
 *
 * @param originalDeps the input deps with the ordering to preserve
 * @param resolvedDeps the unordered output deps
 * @param attributesAndLabels collection of <attribute, depLabel> pairs guaranteed to match
 *   the ordering of originalDeps.entries(). This is a performance optimization: see
 *   {@link #resolveConfigurations#attributesAndLabels} for details.
 */
private static OrderedSetMultimap<Attribute, Dependency> sortResolvedDeps(
    OrderedSetMultimap<Attribute, Dependency> originalDeps,
    Multimap<AttributeAndLabel, Dependency> resolvedDeps,
    ArrayList<AttributeAndLabel> attributesAndLabels) {
  Iterator<AttributeAndLabel> iterator = attributesAndLabels.iterator();
  OrderedSetMultimap<Attribute, Dependency> result = OrderedSetMultimap.create();
  for (Map.Entry<Attribute, Dependency> depsEntry : originalDeps.entries()) {
    AttributeAndLabel attrAndLabel = iterator.next();
    if (depsEntry.getValue().hasExplicitConfiguration()) {
      result.put(attrAndLabel.attribute, depsEntry.getValue());
    } else {
      Collection<Dependency> resolvedDepWithSplit = resolvedDeps.get(attrAndLabel);
      Verify.verify(!resolvedDepWithSplit.isEmpty());
      if (resolvedDepWithSplit.size() > 1) {
        List<Dependency> sortedSplitList = new ArrayList<>(resolvedDepWithSplit);
        Collections.sort(sortedSplitList, SPLIT_DEP_ORDERING);
        resolvedDepWithSplit = sortedSplitList;
      }
      result.putAll(depsEntry.getKey(), resolvedDepWithSplit);
    }
  }
  return result;
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:33,代码来源:ConfigurationResolver.java

示例13: getArtifactOwnerTransition

import com.google.common.base.Verify; //导入方法依赖的package包/类
/**
 * Returns the transition that produces the "artifact owner" for this configuration, or null
 * if this configuration is its own owner.
 */
@Nullable
public PatchTransition getArtifactOwnerTransition() {
  PatchTransition ownerTransition = null;
  for (Fragment fragment : fragments.values()) {
    PatchTransition fragmentTransition = fragment.getArtifactOwnerTransition();
    if (fragmentTransition != null) {
      if (ownerTransition != null) {
        Verify.verify(ownerTransition == fragmentTransition,
            String.format(
                "cannot determine owner transition: fragments returning both %s and %s",
                ownerTransition.toString(), fragmentTransition.toString()));
      }
      ownerTransition = fragmentTransition;
    }
  }
  return ownerTransition;
}
 
开发者ID:bazelbuild,项目名称:bazel,代码行数:22,代码来源:BuildConfiguration.java

示例14: signature

import com.google.common.base.Verify; //导入方法依赖的package包/类
private boolean signature(Statement.Builder builder) {
  Term t = terms.peek();
  if (t.is("@")) {
    do {
      builder.addAnnotations(terms.next());
      Verify.verify(terms.peek().isWordOrNumber());
      builder.addAnnotations(terms.next());
    } while (terms.peek().is("."));

    if (terms.peek().is("(")) {
      builder.addAllAnnotations(collectUntilMatching(")"));
    }
    return false;
  } else if (t.is("<")) {
    builder.addAllSignature(collectUntilMatching(">"));
    return false;
  } else if (t.is("class") || t.is("interface")) {
    builder.addSignature(terms.next());
    return true;
  } else {
    builder.addSignature(terms.next());
    return false;
  }
}
 
开发者ID:immutables,项目名称:immutables,代码行数:25,代码来源:Structurizer.java

示例15: block

import com.google.common.base.Verify; //导入方法依赖的package包/类
private void block(Statement.Builder builder, boolean classDecl) {
	if (classDecl) {
		Verify.verify(terms.peek().is("{"));
		terms.next();
		while (terms.hasNext() && !terms.peek().is("}")) {
			builder.addDefinitions(statement());
		}
		Verify.verify(terms.next().is("}"));
	} else {
		builder.addAllBlock(collectUntilMatching("}"));
	}
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:13,代码来源:Structurizer.java


注:本文中的com.google.common.base.Verify.verify方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。