All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.rx.net.BytesSegment Maven / Gradle / Ivy

There is a newer version: 3.0.0
Show newest version
package org.rx.net;

import lombok.Getter;

import java.util.function.Consumer;

import static org.rx.core.App.require;

public final class BytesSegment implements AutoCloseable {
    public Consumer Closed;
    @Getter
    public final byte[] array;
    @Getter
    public final int offset, count;

    public BytesSegment(byte[] array) {
        this(array, 0, array.length);
    }

    public BytesSegment(byte[] array, int offset, int count) {
        require(array);
        require(offset, offset >= 0);
        require(count, count >= 0);

        this.array = array;
        this.offset = offset;
        this.count = count;
    }

    @Override
    public void close() {
        if (Closed != null) {
            Closed.accept(this);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy