org.apache.hc.core5.util.Args.notNull()方法的使用及代码示例

x33g5p2x  于2022-01-17 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(182)

本文整理了Java中org.apache.hc.core5.util.Args.notNull()方法的一些代码示例,展示了Args.notNull()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Args.notNull()方法的具体详情如下:
包路径:org.apache.hc.core5.util.Args
类名称:Args
方法名:notNull

Args.notNull介绍

暂无

代码示例

代码示例来源:origin: apache/httpcomponents-client

public ExponentialBackOffSchedulingStrategy(
    final long backOffRate,
    final TimeValue initialExpiry,
    final TimeValue maxExpiry) {
  this.backOffRate = Args.notNegative(backOffRate, "BackOff rate");
  this.initialExpiry = Args.notNull(initialExpiry, "Initial expiry");
  this.maxExpiry = Args.notNull(maxExpiry, "Max expiry");
}

代码示例来源:origin: apache/httpcomponents-client

public FileResource(final File file) {
  super();
  Args.notNull(file, "File");
  this.fileRef = new AtomicReference<>(file);
  this.len = file.length();
}

代码示例来源:origin: apache/httpcomponents-client

public int getCount(final T identifier) {
  Args.notNull(identifier, "Identifier");
  final AtomicInteger count = map.get(identifier);
  return count != null ? count.get() : 0;
}

代码示例来源:origin: apache/httpcomponents-client

public AuthenticatingDecorator(final HttpServerRequestHandler requestHandler, final Authenticator authenticator) {
  this.requestHandler = Args.notNull(requestHandler, "Request handler");
  this.authenticator = Args.notNull(authenticator, "Authenticator");
  this.authTokenExtractor = new BasicAuthTokenExtractor();
}

代码示例来源:origin: apache/httpcomponents-client

public AuthenticatingAsyncDecorator(final AsyncServerExchangeHandler exchangeHandler, final Authenticator authenticator) {
  this.exchangeHandler = Args.notNull(exchangeHandler, "Request handler");
  this.authenticator = Args.notNull(authenticator, "Authenticator");
  this.responseProducerRef = new AtomicReference<>(null);
  this.authTokenExtractor = new BasicAuthTokenExtractor();
}

代码示例来源:origin: apache/httpcomponents-client

@Override
public Resource generate(final String requestId, final byte[] content) throws ResourceIOException {
  Args.notNull(content, "Content");
  return generate(requestId, content, 0, content.length);
}

代码示例来源:origin: apache/httpcomponents-client

@Override
public Map<String, HttpCacheEntry> getEntries(final Collection<String> keys) throws ResourceIOException {
  Args.notNull(keys, "Key");
  final Map<String, HttpCacheEntry> resultMap = new HashMap<>(keys.size());
  for (final String key: keys) {
    final HttpCacheEntry entry = getEntry(key);
    if (entry != null) {
      resultMap.put(key, entry);
    }
  }
  return resultMap;
}

代码示例来源:origin: apache/httpcomponents-client

@Override
public Map<String, HttpCacheEntry> getEntries(final Collection<String> keys) throws ResourceIOException {
  Args.notNull(keys, "Key");
  final Map<String, HttpCacheEntry> resultMap = new HashMap<>(keys.size());
  for (final String key: keys) {
    final HttpCacheEntry entry = getEntry(key);
    if (entry != null) {
      resultMap.put(key, entry);
    }
  }
  return resultMap;
}

代码示例来源:origin: apache/httpcomponents-client

@Override
public void writeTo(final OutputStream outStream) throws IOException {
  Args.notNull(outStream, "Output stream");
  try (InputStream inStream = getContent()) {
    int l;
    final byte[] tmp = new byte[2048];
    while ((l = inStream.read(tmp)) != -1) {
      outStream.write(tmp, 0, l);
    }
  }
}

代码示例来源:origin: apache/httpcomponents-client

@Override
public ScheduledFuture<?> schedule(final Runnable command, final TimeValue timeValue) throws RejectedExecutionException {
  Args.notNull(command, "Runnable");
  Args.notNull(timeValue, "Time value");
  return executorService.schedule(command, timeValue.getDuration(), timeValue.getTimeUnit());
}

代码示例来源:origin: apache/httpcomponents-client

public AbstractSerializingCacheStorage(final int maxUpdateRetries, final HttpCacheEntrySerializer<T> serializer) {
  this.maxUpdateRetries = Args.notNegative(maxUpdateRetries, "Max retries");
  this.serializer = Args.notNull(serializer, "Cache entry serializer");
}

代码示例来源:origin: apache/httpcomponents-client

@Override
public void putEntry(final String url, final HttpCacheEntry entry) throws ResourceIOException {
  Args.notNull(url, "URL");
  Args.notNull(entry, "Cache entry");
  ensureValidState();
  synchronized (this) {
    this.entries.put(url, entry);
    keepResourceReference(entry);
  }
}

代码示例来源:origin: apache/httpcomponents-client

@Override
public void awaitTermination(final Timeout timeout) throws InterruptedException {
  Args.notNull(timeout, "Timeout");
  executorService.awaitTermination(timeout.getDuration(), timeout.getTimeUnit());
}

代码示例来源:origin: apache/httpcomponents-client

@Override
public final Cancellable removeEntry(final String key, final FutureCallback<Boolean> callback) {
  Args.notNull(key, "Storage key");
  Args.notNull(callback, "Callback");
  try {
    final String storageKey = digestToStorageKey(key);
    return delete(storageKey, callback);
  } catch (final Exception ex) {
    callback.failed(ex);
    return Operations.nonCancellable();
  }
}

代码示例来源:origin: apache/httpcomponents-client

public ResourceReference(final HttpCacheEntry entry, final ReferenceQueue<HttpCacheEntry> q) {
  super(entry, q);
  Args.notNull(entry.getResource(), "Resource");
  this.resource = entry.getResource();
}

代码示例来源:origin: apache/httpcomponents-client

@Override
public Resource copy(
    final String requestId,
    final Resource resource) throws ResourceIOException {
  Args.notNull(resource, "Resource");
  return new HeapResource(resource.get());
}

代码示例来源:origin: apache/httpcomponents-client

@Override
public void removeEntry(final String url) throws ResourceIOException {
  Args.notNull(url, "URL");
  ensureValidState();
  synchronized (this) {
    // Cannot deallocate the associated resources immediately as the
    // cache entry may still be in use
    this.entries.remove(url);
  }
}

代码示例来源:origin: apache/httpcomponents-client

@Override
public Cancellable getEntries(final Collection<String> keys, final FutureCallback<Map<String, HttpCacheEntry>> callback) {
  Args.notNull(keys, "Key");
  Args.notNull(callback, "Callback");
  try {
    callback.completed(cacheStorage.getEntries(keys));
  } catch (final Exception ex) {
    callback.failed(ex);
  }
  return Operations.nonCancellable();
}

代码示例来源:origin: apache/httpcomponents-client

@Override
public Cancellable removeEntry(final String key, final FutureCallback<Boolean> callback) {
  Args.notEmpty(key, "Key");
  Args.notNull(callback, "Callback");
  try {
    cacheStorage.removeEntry(key);
    callback.completed(Boolean.TRUE);
  } catch (final Exception ex) {
    callback.failed(ex);
  }
  return Operations.nonCancellable();
}

代码示例来源:origin: apache/httpcomponents-client

@Override
public Cancellable getEntry(final String key, final FutureCallback<HttpCacheEntry> callback) {
  Args.notEmpty(key, "Key");
  Args.notNull(callback, "Callback");
  try {
    final HttpCacheEntry entry = cacheStorage.getEntry(key);
    callback.completed(entry);
  } catch (final Exception ex) {
    callback.failed(ex);
  }
  return Operations.nonCancellable();
}

相关文章