Interface BuildableBytesFunction<T>

All Superinterfaces:
BuildableFunction<T,byte[]>, Function<T,byte[]>

public interface BuildableBytesFunction<T> extends BuildableFunction<T,byte[]>
A function of one argument that generates a byte[] result, and supports building derived functional types.
  • Method Details

    • length

      default BuildableToIntFunction<T> length()
      Returns a function that returns the length of the extracted byte array.
      Returns:
      a byte array length function
    • range

      default BuildableBytesFunction<T> range(int start, int end)
      Returns a function that returns a range of the extracted byte array.

      If the requested range is provably out-of-bounds or otherwise invalid then an IllegalArgumentException will be thrown by this method. If the requested range is found to be out-of-bounds at evaluation time then the returned function will throw IndexOutOfBoundsException.

      Parameters:
      start - inclusive range start
      end - exclusive range end
      Returns:
      a range reading function
      Throws:
      IllegalArgumentException - if the selected range is provably out-of-bounds or otherwise invalid
    • head

      default BuildableBytesFunction<T> head(int length)
      Returns a function that returns the head of the extracted byte array.

      If the requested length is negative then an IllegalArgumentException will be thrown by this method. If the requested length is found to be out-of-bounds at evaluation time then the returned function will throw IndexOutOfBoundsException.

      Parameters:
      length - head length
      Returns:
      a head reading function
      Throws:
      IllegalArgumentException - if the length is negative
    • tail

      default BuildableBytesFunction<T> tail(int length)
      Returns a function that returns the tail of the extracted byte array.

      If the requested length is negative then an IllegalArgumentException will be thrown by this method. If the requested length is found to be out-of-bounds at evaluation time then the returned function will throw IndexOutOfBoundsException.

      Parameters:
      length - tail length
      Returns:
      a tail reading function
      Throws:
      IllegalArgumentException - if the length is negative
    • insert

      default BuildableBytesFunction<T> insert(int at, byte[] data)
      Returns a function that inserts the provided array at a specific offset.

      If the insertion is provably out-of-bounds or otherwise invalid then an IllegalArgumentException will be thrown by this method. If the insertion is found to be out-of-bounds at evaluation time then the returned function will throw IndexOutOfBoundsException.

      Parameters:
      at - insertion index
      data - array to insert
      Returns:
      an array insertion function
      Throws:
      IllegalArgumentException - if the insertion is provably out-of-bounds or otherwise invalid
    • remove

      default BuildableBytesFunction<T> remove(int start, int end)
      Returns a function that removes bytes in a given range.

      If the removal is provably out-of-bounds or otherwise invalid then an IllegalArgumentException will be thrown by this method. If the removal is found to be out-of-bounds at evaluation time then the returned function will throw IndexOutOfBoundsException.

      Parameters:
      start - inclusive range start
      end - exclusive range end
      Returns:
      an range removal function
      Throws:
      IllegalArgumentException - if the removal is provably out-of-bounds or otherwise invalid
    • append

      default BuildableBytesFunction<T> append(byte[] data)
      Returns a function that appends the provided array.
      Parameters:
      data - array to append
      Returns:
      an array appending function
    • truncate

      default BuildableBytesFunction<T> truncate(int count) throws IllegalArgumentException
      Returns a function that removes count bytes from the end of the array.

      If the requested count is negative then an IllegalArgumentException will be thrown by this method. If the truncation is found to be out-of-bounds at evaluation time then the returned function will throw IndexOutOfBoundsException.

      Parameters:
      count - number of bytes to remove
      Returns:
      a truncation function
      Throws:
      IllegalArgumentException - if the count is negative