Class PBytes

java.lang.Object
org.praxislive.core.Value
org.praxislive.core.types.PBytes

public final class PBytes extends Value
  • Field Details

  • Method Details

    • toString

      public String toString()
      Description copied from class: Value
      Values must override the default method to return a string representation that is immutable.
      Specified by:
      toString in class Value
      Returns:
      String representation
    • read

      public void read(byte[] dst)
    • asInputStream

      public InputStream asInputStream()
    • size

      public int size()
    • hashCode

      public int hashCode()
      Description copied from class: Value
      Values must override the default hashcode method.
      Specified by:
      hashCode in class Value
      Returns:
      int hashcode
    • equals

      public boolean equals(Object obj)
      Description copied from class: Value
      Values must override the default equals method. This method should only return true if the supplied Object is of the same type as the implementing Value. Values of an unknown type should be coerced before calling this method. This method does not have to guarantee that this.equals(that) == this.toString().equals(that.toString())
      Specified by:
      equals in class Value
      Parameters:
      obj -
      Returns:
      boolean
    • equivalent

      public boolean equivalent(Value arg)
      Description copied from class: Value
      Indicates whether some other Value is equivalent to this one. Unlike Value.equals(java.lang.Object) this method is not symmetric - a value of a different type might be equivalent to this without the other type considering the reverse to be true.

      The default implementation uses identity or String equality.

      Overrides:
      equivalent in class Value
      Parameters:
      arg - value to test for equivalence
      Returns:
      true if value is equivalent to this
    • isEmpty

      public boolean isEmpty()
      Description copied from class: Value
      Check whether this Value is an empty value and has a zero length string representation. Subclasses may wish to override this for efficiency if the String representation is lazily created.
      Overrides:
      isEmpty in class Value
      Returns:
      boolean true if empty
    • deserialize

      public <T extends Serializable> T deserialize(Class<T> type) throws IOException
      Extract serialized object from data. Will throw an exception if this PBytes doesn't contain a valid object of the correct type.
      Type Parameters:
      T -
      Parameters:
      type - class of expected object
      Returns:
      deserialized object
      Throws:
      IOException
    • forEachIn

      public <T extends DataObject> void forEachIn(T container, Consumer<T> consumer)
      Iterate through data by decoding into provided container DataObject and calling consumer. Changes to the container are ignored outside of the consumer.
      Type Parameters:
      T - DataObject sub-type
      Parameters:
      container -
      consumer -
    • transformIn

      public <T extends DataObject> PBytes transformIn(T container, Consumer<T> transformer)
      Transform data by iterating into provided container and calling provided consumer before writing container into new PBytes
      Type Parameters:
      T - DataObject sub-type
      Parameters:
      container -
      transformer -
      Returns:
      transformed data
    • streamOf

      public <T extends DataObject> Stream<T> streamOf(Supplier<T> supplier)
      Create a Stream over the data by decoding into DataObjects provided by supplier
      Type Parameters:
      T -
      Parameters:
      supplier - of DataObject
      Returns:
      Stream of DataObject
    • streamOf

      public <T extends DataObject> Stream<T> streamOf(int count, Supplier<T> supplier)
      Create a Stream over the data by decoding into count number of DataObjects provided by supplier. Extra DataObjects with default values will be generated if required to reach count.
      Type Parameters:
      T -
      Parameters:
      count -
      supplier -
      Returns:
      Stream of DataObject
    • collector

      public static <T extends DataObject> Collector<T,?,PBytes> collector()
      Collector to take Stream of DataObject subclasses and write into new PBytes.
      Type Parameters:
      T -
      Returns:
      collector
    • valueOf

      public static PBytes valueOf(byte[] bytes)
    • parse

      public static PBytes parse(String str) throws ValueFormatException
      Throws:
      ValueFormatException
    • of

      public static PBytes of(List<? extends DataObject> list)
      Encode the provided List of DataObject subclasses into a new PBytes
      Parameters:
      list -
      Returns:
      PBytes of data
    • serialize

      public static PBytes serialize(Serializable obj) throws IOException
      Create a PBytes of the serialized form of the provided object.
      Parameters:
      obj -
      Returns:
      PBytes of serialized data
      Throws:
      IOException
    • from

      public static Optional<PBytes> from(Value arg)
    • info

      public static ArgumentInfo info()