#2436: Extend chat module with Joiner functional interface support
This commit is contained in:
parent
fa542c70df
commit
ceb9ea1e52
@ -166,6 +166,37 @@ public final class ComponentBuilder
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows joining additional components to this builder using the given
|
||||||
|
* {@link Joiner} and {@link FormatRetention#ALL}.
|
||||||
|
*
|
||||||
|
* Simply executes the provided joiner on this instance to facilitate a
|
||||||
|
* chain pattern.
|
||||||
|
*
|
||||||
|
* @param joiner joiner used for operation
|
||||||
|
* @return this ComponentBuilder for chaining
|
||||||
|
*/
|
||||||
|
public ComponentBuilder append(Joiner joiner)
|
||||||
|
{
|
||||||
|
return joiner.join( this, FormatRetention.ALL );
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Allows joining additional components to this builder using the given
|
||||||
|
* {@link Joiner}.
|
||||||
|
*
|
||||||
|
* Simply executes the provided joiner on this instance to facilitate a
|
||||||
|
* chain pattern.
|
||||||
|
*
|
||||||
|
* @param joiner joiner used for operation
|
||||||
|
* @param retention the formatting to retain
|
||||||
|
* @return this ComponentBuilder for chaining
|
||||||
|
*/
|
||||||
|
public ComponentBuilder append(Joiner joiner, FormatRetention retention)
|
||||||
|
{
|
||||||
|
return joiner.join( this, retention );
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the color of the current part.
|
* Sets the color of the current part.
|
||||||
*
|
*
|
||||||
@ -332,4 +363,25 @@ public final class ComponentBuilder
|
|||||||
*/
|
*/
|
||||||
ALL
|
ALL
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Functional interface to join additional components to a ComponentBuilder.
|
||||||
|
*/
|
||||||
|
public interface Joiner
|
||||||
|
{
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Joins additional components to the provided {@link ComponentBuilder}
|
||||||
|
* and then returns it to fulfill a chain pattern.
|
||||||
|
*
|
||||||
|
* Retention may be ignored and is to be understood as an optional
|
||||||
|
* recommendation to the Joiner and not as a guarantee to have a
|
||||||
|
* previous component in builder unmodified.
|
||||||
|
*
|
||||||
|
* @param componentBuilder to which to append additional components
|
||||||
|
* @param retention the formatting to possibly retain
|
||||||
|
* @return input componentBuilder for chaining
|
||||||
|
*/
|
||||||
|
ComponentBuilder join(ComponentBuilder componentBuilder, FormatRetention retention);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user