Package org.apache.logging.log4j.message
Class ReusableObjectMessage
java.lang.Object
org.apache.logging.log4j.message.ReusableObjectMessage
- All Implemented Interfaces:
Serializable,Clearable,Message,ParameterVisitable,ReusableMessage,StringBuilderFormattable
public class ReusableObjectMessage
extends Object
implements ReusableMessage, ParameterVisitable, Clearable
Mutable Message wrapper around an Object message.
- Since:
- 2.6
- See Also:
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidclear()Resets the object to a clean state.<S> voidforEachParameter(ParameterConsumer<S> action, S state) Performs the given action for each parameter until all values have been processed or the action throws an exception.voidformatTo(StringBuilder buffer) Writes a text representation of this object into the specifiedStringBuilder, ideally without allocating temporary objects.Returns the object formatted using its toString method.Returns the formatted object message.Returns the object parameter.shortThis message has exactly one parameter (the object), so always returns one.Object[]Returns the object as if it were a parameter.Gets the message if it is a throwable.memento()Returns an immutable snapshot of the current internal state of this reusable message.voidObject[]swapParameters(Object[] emptyReplacement) This message has exactly one parameter (the object), so returns it as the first parameter in the array.toString()
-
Field Details
-
serialVersionUID
private static final long serialVersionUID- See Also:
-
obj
-
-
Constructor Details
-
ReusableObjectMessage
public ReusableObjectMessage()
-
-
Method Details
-
set
-
getFormattedMessage
Returns the formatted object message.- Specified by:
getFormattedMessagein interfaceMessage- Returns:
- the formatted object message.
-
formatTo
Description copied from interface:StringBuilderFormattableWrites a text representation of this object into the specifiedStringBuilder, ideally without allocating temporary objects.- Specified by:
formatToin interfaceStringBuilderFormattable- Parameters:
buffer- the StringBuilder to write into
-
getFormat
Returns the object formatted using its toString method. -
getParameter
Returns the object parameter.- Returns:
- The object.
- Since:
- 2.7
-
getParameters
Returns the object as if it were a parameter.- Specified by:
getParametersin interfaceMessage- Returns:
- The object.
-
toString
-
getThrowable
Gets the message if it is a throwable.- Specified by:
getThrowablein interfaceMessage- Returns:
- the message if it is a throwable.
-
swapParameters
This message has exactly one parameter (the object), so returns it as the first parameter in the array.- Specified by:
swapParametersin interfaceReusableMessage- Parameters:
emptyReplacement- the parameter array to return- Returns:
- the specified array
- See Also:
-
getParameterCount
public short getParameterCount()This message has exactly one parameter (the object), so always returns one.- Specified by:
getParameterCountin interfaceReusableMessage- Returns:
- 1
-
forEachParameter
Description copied from interface:ParameterVisitablePerforms the given action for each parameter until all values have been processed or the action throws an exception.The second parameter lets callers pass in a stateful object to be modified with the key-value pairs, so the TriConsumer implementation itself can be stateless and potentially reusable.
- Specified by:
forEachParameterin interfaceParameterVisitable- Type Parameters:
S- type of the third parameter- Parameters:
action- The action to be performed for each key-value pair in this collectionstate- the object to be passed as the third parameter to each invocation on the specified ParameterConsumer.
-
memento
Description copied from interface:ReusableMessageReturns an immutable snapshot of the current internal state of this reusable message. The returned snapshot will not be affected by subsequent modifications of this reusable message.- Specified by:
mementoin interfaceReusableMessage- Returns:
- an immutable snapshot of this message
-
clear
public void clear()Description copied from interface:ClearableResets the object to a clean state.
-