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


Java Preconditions.checkNotNull方法代码示例

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


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

示例1: indexParsedDocument

import com.google.api.client.repackaged.com.google.common.base.Preconditions; //导入方法依赖的package包/类
public void indexParsedDocument(ParsedComment document) {
    Preconditions.checkNotNull(indexWriter,
            "The index writer is not initialized");
    Document newDoc = new Document();
    newDoc.add(new TextField(ParsedComment.Fields.SEARCHABLE_TEXT.name(),
            document.fullSearchableText(), Field.Store.YES));
    newDoc.add(new StringField(ParsedComment.Fields.ID.name(),
            document.getId(), Field.Store.YES));
    newDoc.add(new StringField(ParsedComment.Fields.PRODUCT_NAME.name(),
            document.getProductName(), Field.Store.YES));
    newDoc.add(new StringField(ParsedComment.Fields.COMMENT.name(),
            document.getComment(), Field.Store.YES));
    newDoc.add(new StringField(ParsedComment.Fields.URL.name(),
            document.getCommentUrl(), Field.Store.YES));
    newDoc.add(new StringField(ParsedComment.Fields.SOURCE.name(),
            document.getSource().name(), Field.Store.YES));
    newDoc.add(new StringField(ParsedComment.Fields.LABEL.name(),
            document.getCommentLabel(), Field.Store.YES));
    try {
        indexWriter.addDocument(newDoc);
        indexWriter.commit();
    } catch (IOException e) {
        throw new RuntimeException(
                "Could not write new document to the index directory", e);
    }
}
 
开发者ID:victor-guoyu,项目名称:Review-It,代码行数:27,代码来源:Indexer.java

示例2: ErrorReportDialog

import com.google.api.client.repackaged.com.google.common.base.Preconditions; //导入方法依赖的package包/类
public ErrorReportDialog (Stage owner, Collection<ErrorModel> errs) throws IOException {
	super (owner) ;
	
	Preconditions.checkNotNull(errs);
	
	initStyle(StageStyle.UTILITY);
	setTitle("Error Report");
	initOwner(owner);
	initModality (Modality.WINDOW_MODAL );
	
	final FXMLLoader loader = new FXMLLoader(getClass().getResource("/fxml/ErrorReportView.fxml"));
	final Parent parent = (Parent) loader.load();
	final ErrorReportViewController controller = loader.<ErrorReportViewController> getController();

	controller.addErrors(errs);
	
	setMinHeight(300.0);
	setMinWidth(400.0);

	setHeight(500.0);
	setWidth(750.0);
	
	setScene(new Scene(parent));
}
 
开发者ID:roikku,项目名称:drive-uploader,代码行数:25,代码来源:ErrorReportDialog.java

示例3: getHttpClient

import com.google.api.client.repackaged.com.google.common.base.Preconditions; //导入方法依赖的package包/类
public static CloseableHttpClient getHttpClient (HasProxySettings proxySetting) {
	// http://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html#d5e475
	
	CloseableHttpClient httpclient = null ;
	if (proxySetting != null && proxySetting.isActive()) {
		logger.info("Set the http proxy (" + proxySetting.getHost() + ":" + proxySetting.getPort() + ")") ;
		CredentialsProvider credsProvider = Preconditions.checkNotNull(proxySetting.getCredentialsProvider()) ;
    	HttpHost proxy = new HttpHost(proxySetting.getHost(), proxySetting.getPort());
    	DefaultProxyRoutePlanner routePlanner = new DefaultProxyRoutePlanner(proxy);
    	httpclient = HttpClients.custom()
    	        .setRoutePlanner(routePlanner).setDefaultCredentialsProvider(credsProvider)
    	        .build();
	} else {
		httpclient = HttpClients.createDefault();
	}
	return httpclient ;
}
 
开发者ID:roikku,项目名称:drive-uploader,代码行数:18,代码来源:HttpClientUtils.java

示例4: DriveAuth

import com.google.api.client.repackaged.com.google.common.base.Preconditions; //导入方法依赖的package包/类
public DriveAuth(boolean useOldApi, HasConfiguration config) throws IOException {
	super () ;
	this.config = Preconditions.checkNotNull(config) ;
	this.proxySetting = config.getHttpProxySettings() ;

    clientSecret = config.getAuthenticationSettings().getClientSecret();
    clientId = config.getAuthenticationSettings().getClientId();
    config.getAuthenticationSettings().getCallBackUrl();
    refreshToken = config.getCredential().getRefreshToken() ;

    int retry = 0;
    boolean tokensOK = false;
    while (!tokensOK && retry < maxRetries) {
        tokensOK = updateAccessToken();
        ++retry;
    }
    if (!tokensOK) {
    	logger.info("Authentication aborted after " + maxRetries + " retries.");
        throw new IllegalStateException () ;
    }
}
 
开发者ID:roikku,项目名称:drive-uploader,代码行数:22,代码来源:DriveAuth.java

示例5: getExtractor

import com.google.api.client.repackaged.com.google.common.base.Preconditions; //导入方法依赖的package包/类
/**
 * As Google Drive extractor needs file system helper, it invokes to initialize file system helper.
 * {@inheritDoc}
 * @see org.apache.gobblin.source.Source#getExtractor(org.apache.gobblin.configuration.WorkUnitState)
 */
@Override
public Extractor<S, D> getExtractor(WorkUnitState state) throws IOException {
  Preconditions.checkNotNull(state, "WorkUnitState should not be null");
  LOG.info("WorkUnitState from getExtractor: " + state);

  try {
    //GoogleDriveExtractor needs GoogleDriveFsHelper
    initFileSystemHelper(state);
  } catch (FileBasedHelperException e) {
    throw new IOException(e);
  }

  Preconditions.checkNotNull(fsHelper, "File system helper should not be null");
  return new GoogleDriveExtractor<>(state, fsHelper);
}
 
开发者ID:apache,项目名称:incubator-gobblin,代码行数:21,代码来源:GoogleDriveSource.java

示例6: getIndexWriter

import com.google.api.client.repackaged.com.google.common.base.Preconditions; //导入方法依赖的package包/类
/**
 * @return IndexWriter based on the Stop words provided
 */
private IndexWriter getIndexWriter() {
    Preconditions.checkNotNull(indexDir, "No index directory specified!");
    Preconditions.checkNotNull(enAnalyzer, "The English analyzer has not initialized.");
    IndexWriterConfig config = new IndexWriterConfig(Version.LUCENE_4_10_3, enAnalyzer);
    try {
        return new IndexWriter(indexDir, config);
    } catch (IOException e) {
        throw new RuntimeException("Unable to initialize index writer: ", e);
    }
}
 
开发者ID:victor-guoyu,项目名称:Review-It,代码行数:14,代码来源:Indexer.java

示例7: addErrors

import com.google.api.client.repackaged.com.google.common.base.Preconditions; //导入方法依赖的package包/类
public void addErrors (Collection<ErrorModel> errs) {
	Preconditions.checkNotNull(tableErrorView) ;
	Preconditions.checkNotNull(errs) ;
	logger.info("Show erros");
	final ObservableList<ErrorModel> data = tableErrorView.getItems();
	for (ErrorModel err : errs) {
		data.add(err) ;
	}
}
 
开发者ID:roikku,项目名称:drive-uploader,代码行数:10,代码来源:ErrorReportViewController.java

示例8: evict

import com.google.api.client.repackaged.com.google.common.base.Preconditions; //导入方法依赖的package包/类
/**
 * @see SwapJob#evict(String) for high-level description.
 *
 * 1. Acquires the project lock.
 * 2. Gets a bz2 stream and size of a project from the repo store, or throws
 * 3. Uploads the bz2 stream and size to the projName in the swapStore.
 * 4. Sets the last accessed time in the dbStore to null, which makes our
 *    state SWAPPED
 * 5. Removes the project from the repo store.
 * @param projName
 * @throws IOException
 */
@Override
public void evict(String projName) throws IOException {
    Preconditions.checkNotNull(projName, "projName was null");
    Log.info("Evicting project: {}", projName);
    try (LockGuard __ = lock.lockGuard(projName)) {
        long[] sizePtr = new long[1];
        try (InputStream blob = repoStore.bzip2Project(projName, sizePtr)) {
            swapStore.upload(projName, blob, sizePtr[0]);
            dbStore.setLastAccessedTime(projName, null);
            repoStore.remove(projName);
        }
    }
    Log.info("Evicted project: {}", projName);
}
 
开发者ID:winstonli,项目名称:writelatex-git-bridge,代码行数:27,代码来源:SwapJobImpl.java

示例9: TrackingEventBuilder

import com.google.api.client.repackaged.com.google.common.base.Preconditions; //导入方法依赖的package包/类
TrackingEventBuilder(SendsEvents eventSender, String category, String action) {
  this.eventSender = Preconditions.checkNotNull(eventSender);
  this.category = Preconditions.checkNotNull(category);
  this.action = Preconditions.checkNotNull(action);
}
 
开发者ID:GoogleCloudPlatform,项目名称:google-cloud-intellij,代码行数:6,代码来源:TrackingEventBuilder.java

示例10: ErrorModel

import com.google.api.client.repackaged.com.google.common.base.Preconditions; //导入方法依赖的package包/类
public ErrorModel(Path srcPath, DriveDirectory destDir, Throwable err) {
	this(Preconditions.checkNotNull(srcPath), Preconditions.checkNotNull(destDir), Preconditions.checkNotNull(err), null);
	errStr.set(err.getMessage());
	errLevelStr.set(ErrorLevel.ERROR.toString());
}
 
开发者ID:roikku,项目名称:drive-uploader,代码行数:6,代码来源:ErrorModel.java

示例11: PlainTextContent

import com.google.api.client.repackaged.com.google.common.base.Preconditions; //导入方法依赖的package包/类
public PlainTextContent(String text) {
  this.text = Preconditions.checkNotNull( text );
}
 
开发者ID:icoretech,项目名称:audiobox-jlib,代码行数:4,代码来源:PlainTextContent.java

示例12: listFiles

import com.google.api.client.repackaged.com.google.common.base.Preconditions; //导入方法依赖的package包/类
@Override
public Iterator<FileHeader> listFiles(String prefix, int limit) {
  return new AbstractIterator<FileHeader>() {
    String nextPageToken = null;
    Iterator<FileHeader> currentBatch = null;
    boolean done = false;
    long remaining = limit;

    @Override
    protected FileHeader computeNext() {
      if (currentBatch != null && currentBatch.hasNext()) {
        return currentBatch.next();
      } else if (done) {
        return endOfData();
      }

      Objects result;
      try {
        result =
            retry(
                () -> {
                  costTracker.trackList();
                  Storage.Objects.List list = client.objects().list(bucket);
                  list.setPrefix(filePrefix + prefix);
                  list.setMaxResults(Math.min(1000, remaining));
                  list.setFields("nextPageToken,items(name,size,md5Hash,metadata/*)");
                  if (nextPageToken != null) {
                    list.setPageToken(nextPageToken);
                  }
                  return list.execute();
                });
      } catch (Exception e) {
        throw new IllegalStateException(e);
      }

      Preconditions.checkNotNull(result);
      List<FileHeader> batch = new ArrayList<>();
      for (StorageObject object : result.getItems()) {
        batch.add(toFile(object));
      }
      remaining -= batch.size();
      currentBatch = batch.iterator();
      if (batch.size() < 1000 || remaining <= 0) {
        done = true;
        nextPageToken = null;
      } else {
        nextPageToken = Preconditions.checkNotNull(result.getNextPageToken());
      }
      return computeNext();
    }
  };
}
 
开发者ID:pmoor,项目名称:gletscher,代码行数:53,代码来源:GoogleCloudFileStorage.java

示例13: WatchableObject

import com.google.api.client.repackaged.com.google.common.base.Preconditions; //导入方法依赖的package包/类
public WatchableObject(T object) {
  this.object = Preconditions.checkNotNull(object);
}
 
开发者ID:codeka,项目名称:wwmmo,代码行数:4,代码来源:WatchableObject.java


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