/** * Creates a new instance. * * @param channel * the {@link Channel} associated with this future */ public DefaultChannelPromise(Channel channel, EventExecutor executor) { super(executor); this.channel = checkNotNull(channel, "channel"); }
SimpleLeakAwareByteBuf(ByteBuf wrapped, ByteBuf trackedByteBuf, ResourceLeakTracker<ByteBuf> leak) { super(wrapped); this.trackedByteBuf = ObjectUtil.checkNotNull(trackedByteBuf, "trackedByteBuf"); this.leak = ObjectUtil.checkNotNull(leak, "leak"); }
@Override public ChannelConfig setRecvByteBufAllocator(RecvByteBufAllocator allocator) { rcvBufAllocator = checkNotNull(allocator, "allocator"); return this; }
/** * Set the factory's singleton instance. This has to be called before the static initializer of the * {@link ResourceLeakDetector} is called by all the callers of this factory. That is, before initializing a * Netty Bootstrap. * * @param factory the instance that will become the current {@link ResourceLeakDetectorFactory}'s singleton */ public static void setResourceLeakDetectorFactory(ResourceLeakDetectorFactory factory) { factoryInstance = ObjectUtil.checkNotNull(factory, "factory"); }
/** * @param executor the {@link EventExecutor} which is used to notify the listeners of the {@link Future} returned * by {@link #resolve(String)} */ protected SimpleNameResolver(EventExecutor executor) { this.executor = checkNotNull(executor, "executor"); }
@Override public void validateName(Object name) { checkNotNull(name, "name"); } };
/** * Creates a new instance. */ public ProtobufDecoderNano(Class<? extends MessageNano> clazz) { this.clazz = ObjectUtil.checkNotNull(clazz, "You must provide a Class"); }
/** * Constructor with initial capacity of the map holding the mappings * * @param initialCapacity initial capacity for the internal map * @param defaultValue the default value for {@link DomainNameMapping#map(String)} to return * when nothing matches the input */ public DomainNameMappingBuilder(int initialCapacity, V defaultValue) { this.defaultValue = checkNotNull(defaultValue, "defaultValue"); map = new LinkedHashMap<String, V>(initialCapacity); }
private static String checkNotNullAndNotEmpty(String name) { ObjectUtil.checkNotNull(name, "name"); if (name.isEmpty()) { throw new IllegalArgumentException("empty name"); } return name; }
/** * Creates a new instance with the specified line separator and character set. */ public LineEncoder(LineSeparator lineSeparator, Charset charset) { this.charset = ObjectUtil.checkNotNull(charset, "charset"); this.lineSeparator = ObjectUtil.checkNotNull(lineSeparator, "lineSeparator").value().getBytes(charset); }
/** * Checks that the given argument is neither null nor empty. * If it is, throws {@link NullPointerException} or {@link IllegalArgumentException}. * Otherwise, returns the argument. */ public static <T> T[] checkNonEmpty(T[] array, String name) { checkNotNull(array, name); checkPositive(array.length, name + ".length"); return array; }
@Override public T setObject(K name, Object value) { checkNotNull(value, "value"); V convertedValue = checkNotNull(valueConverter.convertObject(value), "convertedValue"); return set(name, convertedValue); }
/** * @param executor the {@link EventExecutor} which is used to notify the listeners of the {@link Future} returned * by {@link #resolve(SocketAddress)} */ protected AbstractAddressResolver(EventExecutor executor) { this.executor = checkNotNull(executor, "executor"); matcher = TypeParameterMatcher.find(this, AbstractAddressResolver.class, "T"); }
/** * @param executor the {@link EventExecutor} which is used to notify the listeners of the {@link Future} returned * by {@link #resolve(SocketAddress)} * @param addressType the type of the {@link SocketAddress} supported by this resolver */ protected AbstractAddressResolver(EventExecutor executor, Class<? extends T> addressType) { this.executor = checkNotNull(executor, "executor"); matcher = TypeParameterMatcher.get(addressType); }
@Override public <V> ScheduledFuture<V> schedule(Callable<V> callable, long delay, TimeUnit unit) { ObjectUtil.checkNotNull(callable, "callable"); ObjectUtil.checkNotNull(unit, "unit"); if (delay < 0) { delay = 0; } validateScheduled0(delay, unit); return schedule(new ScheduledFutureTask<V>( this, callable, ScheduledFutureTask.deadlineNanos(unit.toNanos(delay)))); }
@Override public Object set(int index, Object element) { checkNotNull(element, "element"); checkIndex(index); Object old = array[index]; insert(index, element); return old; }
/** * Format a {@link Date} into RFC1123 format * @param date the date to format * @return a RFC1123 string */ public static String format(Date date) { return formatter().format0(checkNotNull(date, "date")); }
@Override public ChannelFuture register(ChannelPromise promise) { ObjectUtil.checkNotNull(promise, "promise"); promise.channel().unsafe().register(this, promise); return promise; }
@Override public V getAndRemove(K name) { int h = hashingStrategy.hashCode(name); return remove0(h, index(h), checkNotNull(name, "name")); }
@Override public T add(K name, V value) { nameValidator.validateName(name); checkNotNull(value, "value"); int h = hashingStrategy.hashCode(name); int i = index(h); add0(h, i, name, value); return thisT(); }