Class MediaBuilder
java.lang.Object
io.github.sosuisen.jfxbuilder.media.MediaBuilder
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 Summary
Modifier and TypeMethodDescriptionfinal MediaBuilder
addTracks
(Collection<? extends Track> col) Calls theaddAll
method on the ObservableList returned by theMedia#getTracks()
method.final MediaBuilder
Calls theaddAll
method on the ObservableList returned by theMedia#getTracks()
method.Applies a function to the Media instance being constructed.build()
Builds and returns an instance of theMedia
class.static MediaBuilder
Accepts the constructor arguments ofMedia(String)
and returns an instance ofMediaBuilder
.Applies a function to thedurationProperty
of the instance being constructed.Applies a function to theerrorProperty
of the instance being constructed.Applies a function to theheightProperty
of the instance being constructed.A builder method that invokes thesetOnError
method on the instance being constructed.Applies a function to theonErrorProperty
of the instance being constructed.Applies a function to thewidthProperty
of the instance being constructed.
-
Method Details
-
create
Accepts the constructor arguments ofMedia(String)
and returns an instance ofMediaBuilder
.- Returns:
- an instance of the
MediaBuilder
.
-
build
-
apply
Applies a function to the Media instance being constructed. Most operations on the instance can be performed using this method.- Returns:
- builder instance
-
onError
A builder method that invokes thesetOnError
method on the instance being constructed.- Returns:
- builder instance
-
addTracks
Calls theaddAll
method on the ObservableList returned by theMedia#getTracks()
method.- Returns:
- builder instance
-
addTracks
Calls theaddAll
method on the ObservableList returned by theMedia#getTracks()
method.- Returns:
- builder instance
-
durationPropertyApply
Applies a function to thedurationProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.durationProperty().bind(anotherProperty)) // Use shorthand form .durationPropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-
errorPropertyApply
Applies a function to theerrorProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.errorProperty().bind(anotherProperty)) // Use shorthand form .errorPropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-
heightPropertyApply
Applies a function to theheightProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.heightProperty().bind(anotherProperty)) // Use shorthand form .heightPropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-
onErrorPropertyApply
Applies a function to theonErrorProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.onErrorProperty().bind(anotherProperty)) // Use shorthand form .onErrorPropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-
widthPropertyApply
Applies a function to thewidthProperty
of the instance being constructed. This serves as a shorthand form of theapply
method.Example:
// Use apply .apply(obj -> obj.widthProperty().bind(anotherProperty)) // Use shorthand form .widthPropertyApply(prop -> prop.bind(anotherProperty))
- Returns:
- builder instance
-