DoubleStream.Builder
Stay organized with collections
Save and categorize content based on your preferences.
A mutable builder for a DoubleStream
.
A stream builder has a lifecycle, which starts in a building
phase, during which elements can be added, and then transitions to a built
phase, after which elements may not be added. The built phase
begins when the build()
method is called, which creates an
ordered stream whose elements are the elements that were added to the
stream builder, in the order they were added.
Public Method Summary
abstract
void
|
accept(double t)
Adds an element to the stream being built.
|
DoubleStream.Builder
|
add(double t)
Adds an element to the stream being built.
|
abstract
DoubleStream
|
build()
Builds the stream, transitioning this builder to the built state.
|
Public Methods
public
abstract
void
accept
(double t)
Adds an element to the stream being built.
Adds an element to the stream being built.
public
abstract
DoubleStream
build
()
Builds the stream, transitioning this builder to the built state.
An IllegalStateException
is thrown if there are further
attempts to operate on the builder after it has entered the built
state.
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License, and code samples are licensed under the Apache 2.0 License. For details, see the Google Developers Site Policies. Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2024-07-10 UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2024-07-10 UTC."],[[["\u003cp\u003e\u003ccode\u003eDoubleStream.Builder\u003c/code\u003e is used to create a \u003ccode\u003eDoubleStream\u003c/code\u003e by adding elements individually.\u003c/p\u003e\n"],["\u003cp\u003eIt has two phases: a building phase where elements are added and a built phase where the stream is created and no more elements can be added.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003eaccept(double)\u003c/code\u003e and \u003ccode\u003eadd(double)\u003c/code\u003e methods add elements to the stream during the building phase.\u003c/p\u003e\n"],["\u003cp\u003e\u003ccode\u003ebuild()\u003c/code\u003e method creates the \u003ccode\u003eDoubleStream\u003c/code\u003e and transitions the builder to the built state, after which no further modifications are allowed.\u003c/p\u003e\n"]]],["`DoubleStream.Builder` is a mutable builder for creating a `DoubleStream`. It has a building phase where elements are added using `accept(double t)` or `add(double t)`. The `build()` method transitions the builder to a built phase, creating an ordered stream from the added elements. Further additions after calling `build()` will throw an `IllegalStateException`. The interface also inherits from `DoubleConsumer`, allowing `andThen` operations.\n"],null,["public static interface **DoubleStream.Builder** implements [DoubleConsumer](../../../../reference/java/util/function/DoubleConsumer.html) \nA mutable builder for a `DoubleStream`.\n\nA stream builder has a lifecycle, which starts in a building\nphase, during which elements can be added, and then transitions to a built\nphase, after which elements may not be added. The built phase\nbegins when the [build()](../../../../reference/java/util/stream/DoubleStream.Builder.html#build()) method is called, which creates an\nordered stream whose elements are the elements that were added to the\nstream builder, in the order they were added. \n\nSee Also\n\n- [DoubleStream.builder()](../../../../reference/java/util/stream/DoubleStream.html#builder()) \n\nPublic Method Summary\n\n|------------------------------------------------------------------------------------------|-------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract void | [accept](../../../../reference/java/util/stream/DoubleStream.Builder.html#accept(double))(double t) Adds an element to the stream being built. |\n| [DoubleStream.Builder](../../../../reference/java/util/stream/DoubleStream.Builder.html) | [add](../../../../reference/java/util/stream/DoubleStream.Builder.html#add(double))(double t) Adds an element to the stream being built. |\n| abstract [DoubleStream](../../../../reference/java/util/stream/DoubleStream.html) | [build](../../../../reference/java/util/stream/DoubleStream.Builder.html#build())() Builds the stream, transitioning this builder to the built state. |\n\nInherited Method Summary \nFrom interface [java.util.function.DoubleConsumer](../../../../reference/java/util/function/DoubleConsumer.html) \n\n|--------------------------------------------------------------------------------|----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------|\n| abstract void | [accept](../../../../reference/java/util/function/DoubleConsumer.html#accept(double))(double value) Performs this operation on the given argument. |\n| [DoubleConsumer](../../../../reference/java/util/function/DoubleConsumer.html) | [andThen](../../../../reference/java/util/function/DoubleConsumer.html#andThen(java.util.function.DoubleConsumer))([DoubleConsumer](../../../../reference/java/util/function/DoubleConsumer.html) after) Returns a composed `DoubleConsumer` that performs, in sequence, this operation followed by the `after` operation. |\n\nPublic Methods \n\npublic abstract void\n**accept**\n(double t) \nAdds an element to the stream being built. \n\nParameters\n\n| t | the input argument |\n|---|--------------------|\n\nThrows\n\n| [IllegalStateException](../../../../reference/java/lang/IllegalStateException.html) | if the builder has already transitioned to the built state |\n|-------------------------------------------------------------------------------------|------------------------------------------------------------|\n\npublic [DoubleStream.Builder](../../../../reference/java/util/stream/DoubleStream.Builder.html)\n**add**\n(double t) \nAdds an element to the stream being built. \n\nParameters\n\n| t | the element to add |\n|---|--------------------|\n\nReturns\n\n- `this` builder \n\nThrows\n\n| [IllegalStateException](../../../../reference/java/lang/IllegalStateException.html) | if the builder has already transitioned to the built state |\n|-------------------------------------------------------------------------------------|------------------------------------------------------------|\n\npublic abstract [DoubleStream](../../../../reference/java/util/stream/DoubleStream.html)\n**build**\n() \nBuilds the stream, transitioning this builder to the built state.\nAn `IllegalStateException` is thrown if there are further\nattempts to operate on the builder after it has entered the built\nstate. \n\nReturns\n\n- the built stream \n\nThrows\n\n| [IllegalStateException](../../../../reference/java/lang/IllegalStateException.html) | if the builder has already transitioned to the built state |\n|-------------------------------------------------------------------------------------|------------------------------------------------------------|"]]