Apache Fluo Bytes is a simple library with the goal of providing an extremely stable API for handling bytes, suitable for use in Apache Fluo and other projects' APIs.
This project aims to fill a void in Java, by providing convenient objects to represent a sequence of bytes and associated utility classes for situations when a raw byte array is not appropriate.
Specifically, it provides a ByteSequence
interface, analogous to Java‘s CharSequence
, an immutable Bytes
implementation analogous to Java’s String
, and a corresponding BytesBuilder
analogous to Java's StringBuilder
.
The provided classes have appropriate methods for serialization, and proper equals and hashCode implementations, as well as a comparator for ByteSequence
, so they will be suitable for use in Set
s and as keys in Map
s.
An immutable bytes implementation makes it possible to pass data between APIs without the need for performance-killing protective copies. This benefit is compounded if this library is used by multiple projects, as the need to make protective copies while passing data between a project and its dependency's API is eliminated.
This project aims to provide a fluent and intuitive API, with support for conversions to/from other common types, such as ByteBuffer
, byte[]
, and CharSequence
/String
.
This project requires at least Java 8, and supports Stream
and functional APIs where appropriate.
See this blog post for some additional background.
Using an external library in a project's API poses some risks to that project, especially if it and its dependencies depend on different versions of that library. This project attempts to mitigate those risks, so that it can be used safely by other projects.
This project is made safe for reuse in other projects' APIs by adopting the following principles:
@since
tags in Javadocs to communicate minimum required versions for particular featuresThis project‘s public API are all the publicly visible classes, methods, and fields accessible outside the project’s packages.
Apache Fluo Bytes is an Apache Fluo project.