Class MediaBuilder

java.lang.Object
io.github.sosuisen.jfxbuilder.media.MediaBuilder

public class MediaBuilder extends Object
The MediaBuilder class constructs instances of the Media class and offers a fluent interface for creating and configuring it.

This class includes a static create method that accepts the same arguments as the original Media constructor and returns an instance of the MediaBuilder.

You can use method chaining to call the builder methods for configuring the Media. Finally, invoke the build method to generate an instance of the Media class.

Note that intermediate builder methods are not evaluated until the build method is called, meaning they are evaluated lazily.

Author:
Hidekazu Kubota <hidekazu.kubota@gmail.com>
  • Method Details

    • create

      public static MediaBuilder create(String source)
      Accepts the constructor arguments of Media(String) and returns an instance of MediaBuilder.
      Returns:
      an instance of the MediaBuilder.
    • build

      public Media build()
      Builds and returns an instance of the Media class.

      Intermediate builder methods are not evaluated until the build method is called; in other words, they are evaluated lazily.

      Returns:
      new instance of the Media class
    • apply

      public MediaBuilder apply(Consumer<Media> func)
      Applies a function to the Media instance being constructed. Most operations on the instance can be performed using this method.
      Returns:
      builder instance
    • onError

      public MediaBuilder onError(Runnable value)
      A builder method that invokes the setOnError method on the instance being constructed.
      Returns:
      builder instance
    • addTracks

      public final MediaBuilder addTracks(Track... elements)
      Calls the addAll method on the ObservableList returned by the Media#getTracks() method.
      Returns:
      builder instance
    • addTracks

      public final MediaBuilder addTracks(Collection<? extends Track> col)
      Calls the addAll method on the ObservableList returned by the Media#getTracks() method.
      Returns:
      builder instance
    • durationPropertyApply

      public MediaBuilder durationPropertyApply(Consumer<ReadOnlyObjectProperty<Duration>> op)
      Applies a function to the durationProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.durationProperty().bind(anotherProperty))
      
      // Use shorthand form
      .durationPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • errorPropertyApply

      public MediaBuilder errorPropertyApply(Consumer<ReadOnlyObjectProperty<MediaException>> op)
      Applies a function to the errorProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.errorProperty().bind(anotherProperty))
      
      // Use shorthand form
      .errorPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • heightPropertyApply

      public MediaBuilder heightPropertyApply(Consumer<ReadOnlyIntegerProperty> op)
      Applies a function to the heightProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.heightProperty().bind(anotherProperty))
      
      // Use shorthand form
      .heightPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • onErrorPropertyApply

      public MediaBuilder onErrorPropertyApply(Consumer<ObjectProperty<Runnable>> op)
      Applies a function to the onErrorProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.onErrorProperty().bind(anotherProperty))
      
      // Use shorthand form
      .onErrorPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance
    • widthPropertyApply

      public MediaBuilder widthPropertyApply(Consumer<ReadOnlyIntegerProperty> op)
      Applies a function to the widthProperty of the instance being constructed. This serves as a shorthand form of the apply method.

      Example:

      // Use apply
      .apply(obj -> obj.widthProperty().bind(anotherProperty))
      
      // Use shorthand form
      .widthPropertyApply(prop -> prop.bind(anotherProperty))
      
      Returns:
      builder instance