下面列出了io.netty.util.internal.ObjectUtil#checkNotNull ( ) 实例代码,或者点击链接到github查看源代码,也可以在右侧发表评论。
@Override
public void putValue(String name, Object value) {
ObjectUtil.checkNotNull(name, "name");
ObjectUtil.checkNotNull(value, "value");
Map<String, Object> values = this.values;
if (values == null) {
// Use size of 2 to keep the memory overhead small
values = this.values = new HashMap<String, Object>(2);
}
Object old = values.put(name, value);
if (value instanceof SSLSessionBindingListener) {
((SSLSessionBindingListener) value).valueBound(new SSLSessionBindingEvent(this, name));
}
notifyUnbound(old, name);
}
/**
* Sets the SSL session ticket keys of this context.设置此上下文的SSL会话票据密钥。
*/
public void setTicketKeys(OpenSslSessionTicketKey... keys) {
ObjectUtil.checkNotNull(keys, "keys");
SessionTicketKey[] ticketKeys = new SessionTicketKey[keys.length];
for (int i = 0; i < ticketKeys.length; i++) {
ticketKeys[i] = keys[i].key;
}
Lock writerLock = context.ctxLock.writeLock();
writerLock.lock();
try {
SSLContext.clearOptions(context.ctx, SSL.SSL_OP_NO_TICKET);
SSLContext.setSessionTicketKeys(context.ctx, ticketKeys);
} finally {
writerLock.unlock();
}
}
@Override
public ScheduledFuture<?> scheduleAtFixedRate(Runnable command, long initialDelay, long period, TimeUnit unit) {
ObjectUtil.checkNotNull(command, "command");
ObjectUtil.checkNotNull(unit, "unit");
if (initialDelay < 0) {
throw new IllegalArgumentException(
String.format("initialDelay: %d (expected: >= 0)", initialDelay));
}
if (period <= 0) {
throw new IllegalArgumentException(
String.format("period: %d (expected: > 0)", period));
}
return schedule(new ScheduledFutureTask<Void>(
this, Executors.<Void>callable(command, null),
ScheduledFutureTask.deadlineNanos(unit.toNanos(initialDelay)), unit.toNanos(period)));
}
DnsNameResolverContext(DnsNameResolver parent,
String hostname,
DnsRecord[] additionals,
DnsCache resolveCache,
DnsServerAddressStream nameServerAddrs) {
this.parent = parent;
this.hostname = hostname;
this.additionals = additionals;
this.resolveCache = resolveCache;
this.nameServerAddrs = ObjectUtil.checkNotNull(nameServerAddrs, "nameServerAddrs");
maxAllowedQueries = parent.maxQueriesPerResolve();
resolvedInternetProtocolFamilies = parent.resolvedInternetProtocolFamiliesUnsafe();
allowedQueries = maxAllowedQueries;
}
/**
* Set the specific {@link AttributeKey} with the given value on every child {@link Channel}. If the value is
* {@code null} the {@link AttributeKey} is removed
*/
public <T> UkcpServerBootstrap childAttr(AttributeKey<T> childKey, T value) {
ObjectUtil.checkNotNull(childKey, "childKey");
if (value == null) {
childAttrs.remove(childKey);
} else {
childAttrs.put(childKey, value);
}
return this;
}
public UnaryPromiseNotifier(Promise<? super T> promise) {
this.promise = ObjectUtil.checkNotNull(promise, "promise");
}
private PemPrivateKey(ByteBuf content) {
this.content = ObjectUtil.checkNotNull(content, "content");
}
protected AbstractBootstrapConfig(B bootstrap) {
this.bootstrap = ObjectUtil.checkNotNull(bootstrap, "bootstrap");
}
/**
* Create {@link LineSeparator} with the specified {@code lineSeparator} string.
*/
public LineSeparator(String lineSeparator) {
this.value = ObjectUtil.checkNotNull(lineSeparator, "lineSeparator");
}
private static DnsQuestion validateQuestion(DnsQuestion question) {
return ObjectUtil.checkNotNull(question, "question");
}
UniSequentialDnsServerAddressStreamProvider(DnsServerAddresses addresses) {
this.addresses = ObjectUtil.checkNotNull(addresses, "addresses");
}
public DefaultHttp2SettingsFrame(Http2Settings settings) {
this.settings = ObjectUtil.checkNotNull(settings, "settings");
}
public Http2StreamChannelBootstrap(Channel channel) {
this.channel = ObjectUtil.checkNotNull(channel, "channel");
}
DefaultSmtpRequest(SmtpCommand command, List<CharSequence> parameters) {
this.command = ObjectUtil.checkNotNull(command, "command");
this.parameters = parameters != null ?
Collections.unmodifiableList(parameters) : Collections.<CharSequence>emptyList();
}
public PemValue(ByteBuf content, boolean sensitive) {
this.content = ObjectUtil.checkNotNull(content, "content");
this.sensitive = sensitive;
}
/**
* <p>Sets the promise to be notified when all combined futures have finished. If all combined futures succeed,
* then the aggregate promise will succeed. If one or more combined futures fails, then the aggregate promise will
* fail with the cause of one of the failed futures. If more than one combined future fails, then exactly which
* failure will be assigned to the aggregate promise is undefined.</p>
*
* <p>After this method is called, no more futures may be added via the {@link PromiseCombiner#add(Future)} or
* {@link PromiseCombiner#addAll(Future[])} methods.</p>
*
* @param aggregatePromise the promise to notify when all combined futures have finished
* 设定所有组合期货交易完成后的通知。如果所有联合期货都成功,那么总的承诺将成功。如果一个或多个联合期货失败,那么总的承诺将会因为其中一个失败期货的原因而失败。如果不止一个组合的未来失败,那么将分配给聚合承诺的具体失败是不确定的。
在调用此方法之后,不再可以通过add(Future)或addAll(Future)方法添加未来。
*/
public void finish(Promise<Void> aggregatePromise) {
if (doneAdding) {
throw new IllegalStateException("Already finished");
}
doneAdding = true;
this.aggregatePromise = ObjectUtil.checkNotNull(aggregatePromise, "aggregatePromise");
if (doneCount == expectedCount) {
tryPromise();
}
}
/**
* Creates a new instance.
* @param messagePool the predefined message pool.
*/
public RedisEncoder(RedisMessagePool messagePool) {
this.messagePool = ObjectUtil.checkNotNull(messagePool, "messagePool");
}
/**
* Creates a new instance using the specified input.
* @param input {@link ChunkedInput} containing data to write
* @param rsv RSV1, RSV2, RSV3 used for extensions
*
* @throws NullPointerException if {@code input} is null
*/
public WebSocketChunkedInput(ChunkedInput<ByteBuf> input, int rsv) {
this.input = ObjectUtil.checkNotNull(input, "input");
this.rsv = rsv;
}
/**
* Creates a SNI detection handler with configured {@link SslContext}
* maintained by {@link AsyncMapping}
* 使用配置的SslContext创建一个SNI检测处理程序,由异步映射维护
*
* @param mapping the mapping of domain name to {@link SslContext}
*/
@SuppressWarnings("unchecked")
public SniHandler(AsyncMapping<? super String, ? extends SslContext> mapping) {
this.mapping = (AsyncMapping<String, SslContext>) ObjectUtil.checkNotNull(mapping, "mapping");
}
/**
* Creates a new instance with the specified fallback protocol name.使用指定的回退协议名称创建一个新实例。
*
* @param fallbackProtocol the name of the protocol to use when
* ALPN/NPN negotiation fails or the client does not support ALPN/NPN
*/
protected ApplicationProtocolNegotiationHandler(String fallbackProtocol) {
this.fallbackProtocol = ObjectUtil.checkNotNull(fallbackProtocol, "fallbackProtocol");
}