@SuppressWarnings("DuplicateBooleanBranch") private static boolean isValidIpV4Address(AsciiString ip, int from, int toExcluded) { int len = toExcluded - from; int i; return len <= 15 && len >= 7 && (i = ip.indexOf('.', from + 1)) > 0 && isValidIpV4Word(ip, from, i) && (i = ip.indexOf('.', from = i + 2)) > 0 && isValidIpV4Word(ip, from - 1, i) && (i = ip.indexOf('.', from = i + 2)) > 0 && isValidIpV4Word(ip, from - 1, i) && isValidIpV4Word(ip, i + 1, toExcluded); }
static WeakOrderQueue newQueue(Stack<?> stack, Thread thread) { final WeakOrderQueue queue = new WeakOrderQueue(stack, thread); // Done outside of the constructor to ensure WeakOrderQueue.this does not escape the constructor and so // may be accessed while its still constructed. stack.setHead(queue); return queue; }
/** * Allocate a new {@link WeakOrderQueue} or return {@code null} if not possible. */ static WeakOrderQueue allocate(Stack<?> stack, Thread thread) { // We allocated a Link so reserve the space return Head.reserveSpace(stack.availableSharedCapacity, LINK_CAPACITY) ? newQueue(stack, thread) : null; }
/** * Try to call {@link ReferenceCounted#release()} if the specified message implements {@link ReferenceCounted}. * If the specified message doesn't implement {@link ReferenceCounted}, this method does nothing. */ public static boolean release(Object msg) { if (msg instanceof ReferenceCounted) { return ((ReferenceCounted) msg).release(); } return false; }
/** * Returns reference count of a {@link ReferenceCounted} object. If object is not type of * {@link ReferenceCounted}, {@code -1} is returned. */ public static int refCnt(Object msg) { return msg instanceof ReferenceCounted ? ((ReferenceCounted) msg).refCnt() : -1; }
@Override public FileRegion retain(int increment) { super.retain(increment); return this; }
@Override public AddressedEnvelope<M, A> touch() { ReferenceCountUtil.touch(message); return this; }
/** * Creates a new {@link Constant} for the given {@code name} or fail with an * {@link IllegalArgumentException} if a {@link Constant} for the given {@code name} exists. */ public T newInstance(String name) { checkNotNullAndNotEmpty(name); return createOrThrow(name); }
/** * Determines if this {@code String} contains the sequence of characters in the {@code CharSequence} passed. * * @param cs the character sequence to search for. * @return {@code true} if the sequence of characters are contained in this string, otherwise {@code false}. */ public boolean contains(CharSequence cs) { return indexOf(cs) >= 0; }
private void closeLeak() { // Close the ResourceLeakTracker with the tracked ByteBuf as argument. This must be the same that was used when // calling DefaultResourceLeak.track(...). boolean closed = leak.close(trackedByteBuf); assert closed; }
/** * Returns a new instance of a {@link ResourceLeakDetector} with the given resource class. * * @param resource the resource class used to initialize the {@link ResourceLeakDetector} * @param <T> the type of the resource class * @return a new instance of {@link ResourceLeakDetector} */ public final <T> ResourceLeakDetector<T> newResourceLeakDetector(Class<T> resource) { return newResourceLeakDetector(resource, ResourceLeakDetector.SAMPLING_INTERVAL); }
/** * Returns {@code true} if a {@link ChannelOption} exists for the given {@code name}. */ public static boolean exists(String name) { return pool.exists(name); }
/** * Creates a new {@link AttributeKey} for the given {@code name} or fail with an * {@link IllegalArgumentException} if a {@link AttributeKey} for the given {@code name} exists. */ @SuppressWarnings("unchecked") public static <T> AttributeKey<T> newInstance(String name) { return (AttributeKey<T>) pool.newInstance(name); }
/** * Creates a new instance of immutable {@link DomainNameMapping} * Attempts to add new mappings to the result object will cause {@link UnsupportedOperationException} to be thrown * * @return new {@link DomainNameMapping} instance */ public DomainNameMapping<V> build() { return new ImmutableDomainNameMapping<V>(defaultValue, map); }
/** * Determine if {@code a} contains {@code b} in a case sensitive manner. */ public static boolean contains(CharSequence a, CharSequence b) { return contains(a, b, DefaultCharEqualityComparator.INSTANCE); }
@Override protected AttributeKey<Object> newConstant(int id, String name) { return new AttributeKey<Object>(id, name); } };
@Override public int refCnt() { if (message instanceof ReferenceCounted) { return ((ReferenceCounted) message).refCnt(); } else { return 1; } }
@SuppressWarnings("DuplicateBooleanBranch") private static boolean isValidIpV4Address0(CharSequence ip, int from, int toExcluded) { int len = toExcluded - from; int i; return len <= 15 && len >= 7 && (i = indexOf(ip, '.', from + 1)) > 0 && isValidIpV4Word(ip, from, i) && (i = indexOf(ip, '.', from = i + 2)) > 0 && isValidIpV4Word(ip, from - 1, i) && (i = indexOf(ip, '.', from = i + 2)) > 0 && isValidIpV4Word(ip, from - 1, i) && isValidIpV4Word(ip, i + 1, toExcluded); }
/** * Returns a new instance of a {@link ResourceLeakDetector} with the given resource class. * * @param resource the resource class used to initialize the {@link ResourceLeakDetector} * @param samplingInterval the interval on which sampling takes place * @param <T> the type of the resource class * @return a new instance of {@link ResourceLeakDetector} */ @SuppressWarnings("deprecation") public <T> ResourceLeakDetector<T> newResourceLeakDetector(Class<T> resource, int samplingInterval) { return newResourceLeakDetector(resource, ResourceLeakDetector.SAMPLING_INTERVAL, Long.MAX_VALUE); }