• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java Preconditions类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中jersey.repackaged.com.google.common.base.Preconditions的典型用法代码示例。如果您正苦于以下问题:Java Preconditions类的具体用法?Java Preconditions怎么用?Java Preconditions使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



Preconditions类属于jersey.repackaged.com.google.common.base包,在下文中一共展示了Preconditions类的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: checkForNullValues

import jersey.repackaged.com.google.common.base.Preconditions; //导入依赖的package包/类
private static void checkForNullValues(String name, Object[] values) {
    Preconditions.checkNotNull(name, "name is 'null'.");

    List<Integer> indexes = new LinkedList<Integer>();
    for (int i = 0; i < values.length; i++) {
        if (values[i] == null) {
            indexes.add(i);
        }
    }
    final int failedIndexCount = indexes.size();
    if (failedIndexCount > 0) {
        final String valueTxt;
        final String indexTxt;
        if (failedIndexCount == 1) {
            valueTxt = "value";
            indexTxt = "index";
        } else {
            valueTxt = "values";
            indexTxt = "indexes";
        }

        throw new NullPointerException(
                String.format("'null' %s detected for parameter '%s' on %s : %s",
                        valueTxt, name, indexTxt, indexes.toString()));
    }
}
 
开发者ID:martinjmares,项目名称:javaone2015-cloudone,代码行数:27,代码来源:C1WebTargetImpl.java


示例2: getMapping

import jersey.repackaged.com.google.common.base.Preconditions; //导入依赖的package包/类
public ElasticMapping getMapping(NamespaceKey datasetPath){
  if(datasetPath.size() != 3){
    return null;
  }

  final ElasticConnection connection = this.connectionPool.getRandomConnection();
  try {
    final String schema = datasetPath.getPathComponents().get(1);
    final String type = datasetPath.getPathComponents().get(2);
    ClusterMetadata clusterMetadata = connection.execute(new ElasticActions.GetClusterMetadata().setIndex(datasetPath.getPathComponents().get(1)));
    List<ElasticIndex> indices = clusterMetadata.getIndices();
    if(indices.isEmpty()){
      return null;
    }

    final ElasticIndex firstIndex = indices.get(0);
    if(firstIndex.getName().equals(schema)){
      // not an alias.
      ElasticIndex index = firstIndex.filterToType(type);
      if(index == null){
        // no type for this path.
        return null;
      }
      Preconditions.checkArgument(indices.size() == 1, "More than one Index returned for alias %s.", schema);
      return firstIndex.getMappings().get(0);
    } else {

      ElasticMappingSet ems = new ElasticMappingSet(indices).filterToType(type);
      if(ems.isEmpty()){
        return null;
      }
      return ems.getMergedMapping();
    }
  } catch (Exception ex){
    logger.info("Failure while attempting to retrieve dataset {}", datasetPath, ex);
    return null;
  }
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:39,代码来源:ElasticsearchStoragePlugin2.java


示例3: matrixParam

import jersey.repackaged.com.google.common.base.Preconditions; //导入依赖的package包/类
@Override
public C1WebTarget matrixParam(String name, Object... values) throws NullPointerException {
    checkNotClosed();
    Preconditions.checkNotNull(name, "Matrix parameter name must not be 'null'.");

    if (values == null || values.length == 0 || (values.length == 1 && values[0] == null)) {
        return new C1WebTargetImpl(getUriBuilder().replaceMatrixParam(name, (Object[]) null), this);
    }

    checkForNullValues(name, values);
    return new C1WebTargetImpl(getUriBuilder().matrixParam(name, values), this);
}
 
开发者ID:martinjmares,项目名称:javaone2015-cloudone,代码行数:13,代码来源:C1WebTargetImpl.java


示例4: resolveTemplate

import jersey.repackaged.com.google.common.base.Preconditions; //导入依赖的package包/类
@Override
public C1WebTarget resolveTemplate(String name, Object value, boolean encodeSlashInPath) throws NullPointerException {
    checkNotClosed();
    Preconditions.checkNotNull(name, "name is 'null'.");
    Preconditions.checkNotNull(value, "value is 'null'.");
    return new C1WebTargetImpl(getUriBuilder().resolveTemplate(name, value, encodeSlashInPath), this);
}
 
开发者ID:martinjmares,项目名称:javaone2015-cloudone,代码行数:8,代码来源:C1WebTargetImpl.java


示例5: resolveTemplateFromEncoded

import jersey.repackaged.com.google.common.base.Preconditions; //导入依赖的package包/类
@Override
public C1WebTarget resolveTemplateFromEncoded(String name, Object value)
        throws NullPointerException {
    checkNotClosed();
    Preconditions.checkNotNull(name, "name is 'null'.");
    Preconditions.checkNotNull(value, "value is 'null'.");

    return new C1WebTargetImpl(getUriBuilder().resolveTemplateFromEncoded(name, value), this);
}
 
开发者ID:martinjmares,项目名称:javaone2015-cloudone,代码行数:10,代码来源:C1WebTargetImpl.java


示例6: checkTemplateValues

import jersey.repackaged.com.google.common.base.Preconditions; //导入依赖的package包/类
/**
 * Check template values for {@code null} values. Throws {@code NullPointerException} if the name-value map or any of the
 * names or encoded values in the map is {@code null}.
 *
 * @param templateValues map to check.
 * @throws NullPointerException if the name-value map or any of the names or encoded values in the map
 * is {@code null}.
 */
private void checkTemplateValues(final Map<String, Object> templateValues) throws NullPointerException {
    Preconditions.checkNotNull(templateValues, "templateValues is 'null'.");

    for (final Map.Entry entry : templateValues.entrySet()) {
        Preconditions.checkNotNull(entry.getKey(), "name is 'null'.");
        Preconditions.checkNotNull(entry.getValue(), "value is 'null'.");
    }
}
 
开发者ID:martinjmares,项目名称:javaone2015-cloudone,代码行数:17,代码来源:C1WebTargetImpl.java


示例7: createPageCacheFactory

import jersey.repackaged.com.google.common.base.Preconditions; //导入依赖的package包/类
public static final PageCacheFactory createPageCacheFactory(@Nonnull CACHE_TYPE type) {
	Preconditions.checkNotNull(type);
	return new PageCacheFactory() {

		@Override
		public PageCache getPageCache(String configurationFileName) {
			return type.createPageCache(configurationFileName);
		}
	};
}
 
开发者ID:rrauschenbach,项目名称:FeedExpander,代码行数:11,代码来源:PageCacheFactory.java


示例8: DockerCredConfig

import jersey.repackaged.com.google.common.base.Preconditions; //导入依赖的package包/类
@DataBoundConstructor
public DockerCredConfig(@Nullable String credentialsId, @Nullable String serverAddress) {
    Preconditions.checkArgument(
            Strings.isNullOrEmpty(credentialsId) || !Strings.isNullOrEmpty(serverAddress));
    this.credentialsId = credentialsId;
    this.serverAddress = serverAddress;
}
 
开发者ID:jenkinsci,项目名称:docker-build-step-plugin,代码行数:8,代码来源:DockerCredConfig.java


示例9: getDatasetInternal

import jersey.repackaged.com.google.common.base.Preconditions; //导入依赖的package包/类
private SourceTableDefinition getDatasetInternal(NamespaceKey datasetPath, DatasetConfig oldConfig, boolean ignoreAuthErrors) throws Exception {
  if(datasetPath.size() != 3){
    return null;
  }

  final ElasticConnection connection = this.connectionPool.getRandomConnection();
  try {
    final String schema = datasetPath.getPathComponents().get(1);
    final String type = datasetPath.getPathComponents().get(2);
    ClusterMetadata clusterMetadata = connection.execute(new ElasticActions.GetClusterMetadata().setIndex(datasetPath.getPathComponents().get(1)));
    List<ElasticIndex> indices = clusterMetadata.getIndices();
    if(indices.isEmpty()){
      return null;
    }

    final ElasticIndex firstIndex = indices.get(0);
    if(firstIndex.getName().equals(schema)){
      // not an alias.
      ElasticIndex filteredIndex = firstIndex.filterToType(type);
      if(filteredIndex == null){
        // no type for this path.
        return null;
      }
      Preconditions.checkArgument(indices.size() == 1, "More than one Index returned for alias %s.", schema);
      return new ElasticTableBuilder(connection, datasetPath, oldConfig, context.getAllocator(), context.getConfig(), config, context.getOptionManager(), filteredIndex.getMergedMapping(), ImmutableList.<String>of(), false);
    } else {

      ElasticMappingSet ems = new ElasticMappingSet(indices).filterToType(type);
      if(ems.isEmpty()){
        return null;
      }
      ElasticMapping mapping = ems.getMergedMapping();
      final List<String> indicesList = FluentIterable.from(indices).transform(new Function<ElasticIndex, String>(){
        @Override
        public String apply(ElasticIndex input) {
          return input.getName();
        }}).toList();

      return new ElasticTableBuilder(connection, datasetPath, oldConfig, context.getAllocator(), context.getConfig(), config, context.getOptionManager(), mapping, indicesList, true);
    }


  } catch (Exception ex){
    logger.info("Failure while attempting to retrieve dataset {}", datasetPath, ex);
  }

  // failure or not found.
  return null;
}
 
开发者ID:dremio,项目名称:dremio-oss,代码行数:50,代码来源:ElasticsearchStoragePlugin2.java


示例10: fill

import jersey.repackaged.com.google.common.base.Preconditions; //导入依赖的package包/类
@Override
public Optional<WarpData> fill(DataHolder dataHolder, MergeFunction mergeFn) {
    WarpData warpData = Preconditions.checkNotNull(mergeFn).merge(copy(), dataHolder.get(WarpData.class).orElse(copy()));
    return Optional.of(set(WARP, warpData.get(WARP).get()));
}
 
开发者ID:RobertHerhold,项目名称:BLWarps,代码行数:6,代码来源:WarpData.java


示例11: Id

import jersey.repackaged.com.google.common.base.Preconditions; //导入依赖的package包/类
protected Id(T value) {
	Preconditions.checkNotNull(value);
	this.value = value;
}
 
开发者ID:saucelabs,项目名称:testobject-java-api,代码行数:5,代码来源:Id.java



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java OutputMutator类代码示例发布时间:2022-05-22
下一篇:
Java PhoneNumberType类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap