NOTE:Implementers are not required to return a new instance from this method, however + * they are allowed to. Users of this method should always use the instance returned from this + * method. + * + *
Default Implementation:By default, this method will simply return {@code this}. + * + * @param limit the maximum number of bytes to limit this channel to + * @return The instance of channel which will respect the limit. + * @throws UnsupportedOperationException If the {@code this} instances does not support limiting + * @since 2.4.0 + */ + default ReadChannel limit(long limit) { + return this; + } + + /** + * The currently defined limit for this channel. Initial value is {@link Long#MAX_VALUE} + * + * @return the current limit for this channel + * @throws UnsupportedOperationException If the {@code this} instances does not support limiting + * @since 2.4.0 + */ + default long limit() { + return Long.MAX_VALUE; + } }