= ReasonBuffer2
:Notice: Licensed to the Apache Software Foundation (ASF) under one or more contributor license agreements. See the NOTICE file distributed with this work for additional information regarding copyright ownership. The ASF licenses this file to you under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at. http://www.apache.org/licenses/LICENSE-2.0 . Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR  CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

Helper class to construct reason strings, with support for evaluating the condition.

An alternative is to use the (very simple) xref:refguide:applib:index/util/Reasons.adoc[Reasons] class or the (a bit more sophisticated) xref:refguide:applib:index/util/ReasonBuffer.adoc[ReasonBuffer] .

== API

[source,java]
.ReasonBuffer2.java
----
class ReasonBuffer2 {
  Builder builder()
  ReasonBuffer2 forAll()
  ReasonBuffer2 forSingle()
  ReasonBuffer2 forAll(String prefix)
  ReasonBuffer2 forSingle(String prefix)
  ReasonBuffer2 append(LazyReason lazyReason)
  void appendIfNotPresent(Optional<?> optional, String reason)
  ReasonBuffer2 append(String reason)     // <.>
  ReasonBuffer2 append(boolean condition, String reason)     // <.>
  ReasonBuffer2 append(Condition condition, String reason)     // <.>
  String getReason()     // <.>
  String appendReason(StringBuilder buf)     // <.>
  ReasonBuffer2 plus(ReasonBuffer2 other)     // <.>
}
----

<.> xref:#append_String[append(String)]
+
--
Append a reason to the list of existing reasons.
--
<.> xref:#append_boolean_String[append(boolean, String)]
+
--
Append a reason to the list of existing reasons if the condition flag is true.
--
<.> xref:#append_Condition_String[append(Condition, String)]
+
--
Append a reason to the list of existing reasons if the condition flag is true.
--
<.> xref:#getReason_[getReason()]
+
--
Return the combined set of reasons, or `null` if there are none.
--
<.> xref:#appendReason_StringBuilder[appendReason(StringBuilder)]
+
--
Appends reasons.
--
<.> xref:#plus_ReasonBuffer2[plus(ReasonBuffer2)]
+
--
Combines sets of reasons from another.
--

== Members

[#append_String]
=== append(String)

Append a reason to the list of existing reasons.

[#append_boolean_String]
=== append(boolean, String)

Append a reason to the list of existing reasons if the condition flag is true.

[#append_Condition_String]
=== append(Condition, String)

Append a reason to the list of existing reasons if the condition flag is true.

[#getReason_]
=== getReason()

Return the combined set of reasons, or `null` if there are none.

[#appendReason_StringBuilder]
=== appendReason(StringBuilder)

Appends reasons.

[#plus_ReasonBuffer2]
=== plus(ReasonBuffer2)

Combines sets of reasons from another.
