Package com.io7m.jproperties.monad
Class JPropertySuccess.Builder<A>
java.lang.Object
com.io7m.jproperties.monad.JPropertySuccess.Builder<A>
- Enclosing class:
- JPropertySuccess<A>
Builds instances of type
JPropertySuccess
.
Initialize attributes and then invoke the build()
method to create an
immutable instance.
Builder
is not thread-safe and generally should not be stored in a field or collection,
but instead used immediately to create instances.
-
Method Summary
Modifier and TypeMethodDescriptionfinal JPropertySuccess.Builder<A>
addAllErrors
(Iterable<? extends JPropertyError> elements) Adds elements toerrors
list.final JPropertySuccess.Builder<A>
addAllWarnings
(Iterable<? extends JPropertyWarning> elements) Adds elements towarnings
list.final JPropertySuccess.Builder<A>
addErrors
(JPropertyError element) Adds one element toerrors
list.final JPropertySuccess.Builder<A>
addErrors
(JPropertyError... elements) Adds elements toerrors
list.final JPropertySuccess.Builder<A>
addWarnings
(JPropertyWarning element) Adds one element towarnings
list.final JPropertySuccess.Builder<A>
addWarnings
(JPropertyWarning... elements) Adds elements towarnings
list.build()
Builds a newJPropertySuccess
.final JPropertySuccess.Builder<A>
from
(JPropertyParseMonadType.JPropertySuccessType<A> instance) Fill a builder with attribute values from the providedJPropertySuccessType
instance.final JPropertySuccess.Builder<A>
setErrors
(Iterable<? extends JPropertyError> elements) Sets or replaces all elements forerrors
list.final JPropertySuccess.Builder<A>
Initializes the value for theresult
attribute.final JPropertySuccess.Builder<A>
setWarnings
(Iterable<? extends JPropertyWarning> elements) Sets or replaces all elements forwarnings
list.
-
Method Details
-
from
public final JPropertySuccess.Builder<A> from(JPropertyParseMonadType.JPropertySuccessType<A> instance) Fill a builder with attribute values from the providedJPropertySuccessType
instance. Regular attribute values will be replaced with those from the given instance. Absent optional values will not replace present values. Collection elements and entries will be added, not replaced.- Parameters:
instance
- The instance from which to copy values- Returns:
this
builder for use in a chained invocation
-
setResult
Initializes the value for theresult
attribute.- Parameters:
result
- The value for result- Returns:
this
builder for use in a chained invocation
-
addWarnings
Adds one element towarnings
list.- Parameters:
element
- A warnings element- Returns:
this
builder for use in a chained invocation
-
addWarnings
Adds elements towarnings
list.- Parameters:
elements
- An array of warnings elements- Returns:
this
builder for use in a chained invocation
-
setWarnings
Sets or replaces all elements forwarnings
list.- Parameters:
elements
- An iterable of warnings elements- Returns:
this
builder for use in a chained invocation
-
addAllWarnings
public final JPropertySuccess.Builder<A> addAllWarnings(Iterable<? extends JPropertyWarning> elements) Adds elements towarnings
list.- Parameters:
elements
- An iterable of warnings elements- Returns:
this
builder for use in a chained invocation
-
addErrors
Adds one element toerrors
list.- Parameters:
element
- A errors element- Returns:
this
builder for use in a chained invocation
-
addErrors
Adds elements toerrors
list.- Parameters:
elements
- An array of errors elements- Returns:
this
builder for use in a chained invocation
-
setErrors
Sets or replaces all elements forerrors
list.- Parameters:
elements
- An iterable of errors elements- Returns:
this
builder for use in a chained invocation
-
addAllErrors
Adds elements toerrors
list.- Parameters:
elements
- An iterable of errors elements- Returns:
this
builder for use in a chained invocation
-
build
Builds a newJPropertySuccess
.- Returns:
- An immutable instance of JPropertySuccess
- Throws:
IllegalStateException
- if any required attributes are missing
-