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


Java Preconditions.checkNotNull方法代码示例

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


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

示例1: SwitchRepresentation

import com.google.common.base.Preconditions; //导入方法依赖的package包/类
public SwitchRepresentation(@Nonnull IOFSwitch sw, @Nonnull OFSwitchHandshakeHandler handshakeHandler) {
    Preconditions.checkNotNull(sw, "switch must not be null");
    Preconditions.checkNotNull(handshakeHandler, "handshakeHandler must not be null");

    // IOFSwitch
    this.buffers = sw.getBuffers();
    this.capabilities = sw.getCapabilities();
    this.tables = sw.getNumTables();
    this.inetAddress = sw.getInetAddress();
    this.sortedPorts = sw.getSortedPorts();
    this.isConnected = sw.isConnected();
    this.connectedSince = sw.getConnectedSince();
    this.dpid = sw.getId();
    this.attributes = sw.getAttributes();
    this.isActive = sw.isActive();

    // OFSwitchHandshakeHandler
    this.connections = handshakeHandler.getConnections();
    this.handshakeState = handshakeHandler.getState();
    this.quarantineReason = handshakeHandler.getQuarantineReason();
}
 
开发者ID:xuraylei,项目名称:fresco_floodlight,代码行数:22,代码来源:SwitchRepresentation.java

示例2: buildRowKey

import com.google.common.base.Preconditions; //导入方法依赖的package包/类
@Override
public RowKey buildRowKey(StatEventKey statEventKey) {
    Preconditions.checkNotNull(statEventKey);

    long timeMs = statEventKey.getTimeMs();

    final byte[] partialTimestamp = buildPartialTimestamp(timeMs);
    final byte[] rollupBitMask = statEventKey.getRollupMask().asBytes();
    List<RowKeyTagValue> rowKeyTagValues = statEventKey.getTagValues().stream()
            .map(tagValue -> new RowKeyTagValue(tagValue.getTag(), tagValue.getValue()))
            .collect(Collectors.toList());

    TimeAgnosticRowKey timeAgnosticRowKey = new TimeAgnosticRowKey(
            statEventKey.getStatUuid(),
            rollupBitMask,
            rowKeyTagValues);

    //timeMs is already rounded to the column interval
    return new RowKey(timeAgnosticRowKey, partialTimestamp);
}
 
开发者ID:gchq,项目名称:stroom-stats,代码行数:21,代码来源:SimpleRowKeyBuilder.java

示例3: toByteArray

import com.google.common.base.Preconditions; //导入方法依赖的package包/类
@Override
public final byte[] toByteArray(boolean shrink) {
  ByteBuffer buffer = ByteBuffer.allocate(size());
  buffer.order(ByteOrder.LITTLE_ENDIAN);
  buffer.putShort((short) headerSize());
  buffer.putShort((short) flags());
  buffer.putInt(keyIndex());
  if (isComplex()) {
    buffer.putInt(parentEntry());
    buffer.putInt(values().size());
    for (Map.Entry<Integer, ResourceValue> entry : values().entrySet()) {
      buffer.putInt(entry.getKey());
      buffer.put(entry.getValue().toByteArray(shrink));
    }
  } else {
    ResourceValue value = value();
    Preconditions.checkNotNull(value, "A non-complex TypeChunk entry must have a value.");
    buffer.put(value.toByteArray());
  }
  return buffer.array();
}
 
开发者ID:xyxyLiu,项目名称:AndResM,代码行数:22,代码来源:TypeChunk.java

示例4: cancelDelegationToken

import com.google.common.base.Preconditions; //导入方法依赖的package包/类
/**
 * Cancels a delegation token from the server end-point. It does not require
 * being authenticated by the configured <code>Authenticator</code>.
 *
 * @param url the URL to cancel the delegation token from. Only HTTP/S URLs
 * are supported.
 * @param token the authentication token with the Delegation Token to cancel.
 * @param doAsUser the user to do as, which will be the token owner.
 * @throws IOException if an IO error occurred.
 */
public void cancelDelegationToken(URL url, Token token, String doAsUser)
    throws IOException {
  Preconditions.checkNotNull(url, "url");
  Preconditions.checkNotNull(token, "token");
  Preconditions.checkNotNull(token.delegationToken,
      "No delegation token available");
  try {
    ((KerberosDelegationTokenAuthenticator) getAuthenticator()).
        cancelDelegationToken(url, token, token.delegationToken, doAsUser);
  } finally {
    token.delegationToken = null;
  }
}
 
开发者ID:naver,项目名称:hadoop,代码行数:24,代码来源:DelegationTokenAuthenticatedURL.java

示例5: subscribe

import com.google.common.base.Preconditions; //导入方法依赖的package包/类
@Override
    public void subscribe(URL url, NotifyListener listener) {
        Preconditions.checkNotNull(url);
        Preconditions.checkNotNull(listener);

        URL urlCopy = url.clone0();
        doSubscribe(urlCopy, listener);

        //第一次订阅时主动推一次
//        List<URL> urls = doDiscover(urlCopy);
//        if (urls != null && urls.size() > 0) {
//            listener.notify(url, urls);
//        }
    }
 
开发者ID:TFdream,项目名称:mango,代码行数:15,代码来源:AbstractRegistry.java

示例6: join

import com.google.common.base.Preconditions; //导入方法依赖的package包/类
/**
 * Returns a normalized, combined path out of the given path segments.
 *
 * @param parts  path segments to combine
 * @see #normalize(String)
 */
public static final String join(final String... parts) {
  final StringBuilder sb = new StringBuilder();
  for (final String part:parts) {
    Preconditions.checkNotNull(part, "parts cannot contain null");
    if (!Strings.isNullOrEmpty(part)) {
      sb.append(part).append("/");
    }
  }
  if (sb.length() > 0) {
    sb.deleteCharAt(sb.length() - 1);
  }
  final String path = sb.toString();
  return normalize(path);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:21,代码来源:PathUtils.java

示例7: getSplitsQuery

import com.google.common.base.Preconditions; //导入方法依赖的package包/类
public static SearchQuery getSplitsQuery(DatasetConfig datasetConfig) {
  Preconditions.checkNotNull(datasetConfig.getReadDefinition());
  Preconditions.checkNotNull(datasetConfig.getReadDefinition().getSplitVersion());
  return SearchQueryUtils.and(
    SearchQueryUtils.newTermQuery(DATASET_ID, datasetConfig.getId().getId()),
    SearchQueryUtils.newTermQuery(SPLIT_VERSION.getIndexFieldName(), datasetConfig.getReadDefinition().getSplitVersion()));
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:8,代码来源:DatasetSplitId.java

示例8: ModelReference

import com.google.common.base.Preconditions; //导入方法依赖的package包/类
private ModelReference(@Nullable ModelPath path, ModelType<T> type, @Nullable ModelPath scope, @Nullable ModelNode.State state, @Nullable String description) {
    this.path = path;
    this.type = Preconditions.checkNotNull(type, "type");
    this.scope = scope;
    this.description = description;
    this.state = state != null ? state : ModelNode.State.GraphClosed;
}
 
开发者ID:lxxlxx888,项目名称:Reer,代码行数:8,代码来源:ModelReference.java

示例9: createFromEC2

import com.google.common.base.Preconditions; //导入方法依赖的package包/类
@Override
public EsInstance createFromEC2(Instance awsInstance) throws Exception {
  Preconditions.checkNotNull(awsInstance);

  EsInstance esInstance = new EsInstance();

  esInstance.setId(awsInstance.getInstanceId());
  esInstance.setState(awsInstance.getState().getName());
  esInstance.setLocation(awsInstance.getPlacement().getAvailabilityZone());

  //Region=location-last char. This is what CMDBV1 and people on internet do.
  //There should be a better way. Right now, keep as what it is
  esInstance.setRegion(
      esInstance.getLocation().substring(0, esInstance.getLocation().length() - 1));
  esInstance.setAwsLaunchTime(awsInstance.getLaunchTime());
  esInstance.setSubnetId(awsInstance.getSubnetId());
  esInstance.setVpcId(awsInstance.getVpcId());


  //Convert AWS instance to a map of property bags and save it.
  esInstance.getCloud()
      .put("aws", getAwsInstanceProperties(awsInstance));

  Date utcNow = DateTime.now(DateTimeZone.UTC).toDate();
  esInstance.setCreatedTime(utcNow);
  esInstance.setUpdatedTime(utcNow);

  return esInstance;
}
 
开发者ID:pinterest,项目名称:soundwave,代码行数:30,代码来源:BasicEsInstanceFactory.java

示例10: addDataPoint

import com.google.common.base.Preconditions; //导入方法依赖的package包/类
public StatisticDataSet addDataPoint(StatisticDataPoint dataPoint) {
    Preconditions.checkNotNull(dataPoint);
    //datapoint must be for the same statConfig as the dataset as a whole
    Preconditions.checkArgument(dataPoint.getStatisticConfiguration().getUuid().equals(statisticConfiguration.getUuid()));
    Preconditions.checkArgument(dataPoint.getTimeInterval().equals(timeInterval));

    this.statisticDataPoints.add(dataPoint);
    return this;
}
 
开发者ID:gchq,项目名称:stroom-stats,代码行数:10,代码来源:StatisticDataSet.java

示例11: addPartition

import com.google.common.base.Preconditions; //导入方法依赖的package包/类
/**
 * Creates a new partition with the given name.
 *
 * @throws IllegalArgumentException if such partition already exists.
 */
public Partition addPartition(String name) {
    Preconditions.checkNotNull(name, "Name cannot be null.");
    Preconditions.checkArgument(!mPartitionsByName.containsKey(name),
            "Partition with such name already exists.");
    Partition partition = new Partition(name);
    mPartitionsByName.put(name, partition);
    return partition;
}
 
开发者ID:googlesamples,项目名称:android-AutofillFramework,代码行数:14,代码来源:CustomVirtualView.java

示例12: serialize

import com.google.common.base.Preconditions; //导入方法依赖的package包/类
@Override
public JsonElement serialize(
        final ResolvedDependency resolvedDependency, final Type type, final JsonSerializationContext context) {

    Preconditions.checkNotNull(resolvedDependency);
    Preconditions.checkNotNull(type);
    Preconditions.checkNotNull(context);

    final JsonObject jsonObject = new JsonObject();

    final JsonElement sourceElement = Either.join(
        resolvedDependency.source,
        context::serialize,
        context::serialize);

    jsonObject.add("source", sourceElement);

    if (resolvedDependency.target.isPresent()) {
        jsonObject.addProperty("target", resolvedDependency.target.get());
    }

    if (!resolvedDependency.dependencies.isEmpty()) {
        jsonObject.add("dependencies", context.serialize(resolvedDependency.dependencies));
    }

    if (resolvedDependency.buckResource.isPresent()) {
        jsonObject.add("buck", context.serialize(resolvedDependency.buckResource.get(), RemoteFile.class));
    }

    return jsonObject;
}
 
开发者ID:LoopPerfect,项目名称:buckaroo,代码行数:32,代码来源:ResolvedDependencySerializer.java

示例13: verify

import com.google.common.base.Preconditions; //导入方法依赖的package包/类
private void verify() {
    Preconditions.checkNotNull(shardingService);
    Preconditions.checkNotNull(actorSystem);
    Preconditions.checkNotNull(cluster);
    Preconditions.checkNotNull(distributedConfigDatastore);
    Preconditions.checkNotNull(distributedOperDatastore);
}
 
开发者ID:hashsdn,项目名称:hashsdn-controller,代码行数:8,代码来源:ShardedDataTreeActor.java

示例14: builder

import com.google.common.base.Preconditions; //导入方法依赖的package包/类
@Override
public QueryBuilder builder() {
  return Preconditions.checkNotNull(builder);
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:5,代码来源:PredicateAnalyzer.java

示例15: hasPlacer

import com.google.common.base.Preconditions; //导入方法依赖的package包/类
public boolean hasPlacer(@Nonnull Block block) {
    Preconditions.checkNotNull(block, "block");

    return this.placedAnvils.containsKey(block);
}
 
开发者ID:WarzoneMC,项目名称:Warzone,代码行数:6,代码来源:SimpleAnvilTracker.java


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