Class ContentHandler<RECEIVER,SELF extends ContentHandler<RECEIVER,SELF>>
- java.lang.Object
-
- cc.carm.lib.configuration.value.text.function.ContentHandler<RECEIVER,SELF>
-
- All Implemented Interfaces:
Insertable<RECEIVER,SELF>,Replaceable<RECEIVER,SELF>
- Direct Known Subclasses:
TextParser
public abstract class ContentHandler<RECEIVER,SELF extends ContentHandler<RECEIVER,SELF>> extends java.lang.Object implements Replaceable<RECEIVER,SELF>, Insertable<RECEIVER,SELF>
-
-
Field Summary
Fields Modifier and Type Field Description protected booleandisableInsertionprotected @NotNull java.util.List<ContentInserter<RECEIVER>>insertersprotected @NotNull java.util.Map<java.lang.String,@Nullable java.util.function.Function<RECEIVER,java.util.List<java.lang.String>>>insertionUsed to store the insertion of the messageprotected java.lang.StringlineSeparatorprotected @NotNull ParamReplacer<RECEIVER>paramReplacerUsed to store the placeholders of the messageprotected @NotNull java.lang.String[]paramsprotected java.util.function.BiFunction<RECEIVER,java.lang.String,java.lang.String>parserprotected @NotNull java.util.List<ContentReplacer<RECEIVER>>replacers
-
Constructor Summary
Constructors Constructor Description ContentHandler()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description static java.util.Map<java.lang.String,java.lang.Object>buildParams(@NotNull java.util.function.UnaryOperator<java.lang.String> paramBuilder, @Nullable java.lang.String[] params, @Nullable java.lang.Object[] values)SELFdisableInsertion()Disable the insertion of the text.SELFenableInsertion()Enable the insertion of the text.@Nullable java.util.List<java.lang.String>getInsertion(@NotNull java.lang.String id, RECEIVER receiver)voidhandle(@NotNull TextContents contents, RECEIVER receiver, @NotNull java.util.function.Consumer<java.lang.String> lineConsumer)SELFinsert(@NotNull java.lang.String id, @Nullable java.util.function.Function<RECEIVER,java.util.List<java.lang.String>> supplier)Insert the specific contents by the id.SELFinserter(@NotNull ContentInserter<RECEIVER> inserter)java.util.List<ContentInserter<RECEIVER>>inserters()booleaninserting(@NotNull java.lang.String id)SELFlineSeparator(@NotNull java.lang.String lineSeparator)Set the line separator for the text.booleannoneInsertion()SELFparamReplacer(@NotNull ParamReplacer<RECEIVER> paramReplacer)SELFparams(@NotNull java.lang.String... params)Set the params for the text, used forplaceholders(Object...)to build the placeholders.protected @Nullable java.lang.Stringparse(RECEIVER receiver, @NotNull java.lang.String text)Parse the supplied single text for the receiver.SELFparser(@NotNull java.util.function.BiFunction<RECEIVER,java.lang.String,java.lang.String> parser)Set the parser for the text.SELFplaceholder(@NotNull java.lang.String key, @Nullable java.lang.Object value)Set the placeholder for the text.SELFplaceholders(@NotNull java.util.function.Consumer<java.util.Map<java.lang.String,java.lang.Object>> consumer)Set the placeholders for the text.SELFplaceholders(@NotNull java.util.Map<java.lang.String,java.lang.Object> placeholders)Set all the placeholders for the text.SELFplaceholders(@Nullable java.lang.Object... values)Set the placeholders for the text.SELFremoveInsert(@NotNull java.lang.String id)SELFreplacer(@NotNull ContentReplacer<RECEIVER> replacer)java.util.List<ContentReplacer<RECEIVER>>replacers()abstract SELFself()static java.lang.StringsetPlaceholders(@NotNull java.lang.String messages, @NotNull java.util.Map<java.lang.String,java.lang.Object> placeholders)-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface cc.carm.lib.configuration.value.text.function.inserter.Insertable
insert, insert, insert
-
Methods inherited from interface cc.carm.lib.configuration.value.text.function.replacer.Replaceable
applyReplacements, replace, replace, replace, replace, replace, replace, replace, replacer
-
-
-
-
Field Detail
-
parser
protected java.util.function.BiFunction<RECEIVER,java.lang.String,java.lang.String> parser
-
lineSeparator
protected java.lang.String lineSeparator
-
paramReplacer
@NotNull protected @NotNull ParamReplacer<RECEIVER> paramReplacer
Used to store the placeholders of the message
-
params
@NotNull protected @NotNull java.lang.String[] params
-
replacers
@NotNull protected @NotNull java.util.List<ContentReplacer<RECEIVER>> replacers
-
inserters
@NotNull protected @NotNull java.util.List<ContentInserter<RECEIVER>> inserters
-
insertion
@NotNull protected final @NotNull java.util.Map<java.lang.String,@Nullable java.util.function.Function<RECEIVER,java.util.List<java.lang.String>>> insertion
Used to store the insertion of the message
-
disableInsertion
protected boolean disableInsertion
-
-
Method Detail
-
self
public abstract SELF self()
-
disableInsertion
public SELF disableInsertion()
Disable the insertion of the text.
If the insertion is disabled, the text will be parsed directly.- Returns:
- the current
ContentHandlerinstance
-
enableInsertion
public SELF enableInsertion()
Enable the insertion of the text.- Returns:
- the current
ContentHandlerinstance
-
noneInsertion
public boolean noneInsertion()
- Specified by:
noneInsertionin interfaceInsertable<RECEIVER,SELF extends ContentHandler<RECEIVER,SELF>>
-
lineSeparator
public SELF lineSeparator(@NotNull @NotNull java.lang.String lineSeparator)
Set the line separator for the text.- Parameters:
lineSeparator- the line separator, default isSystem.lineSeparator()- Returns:
- the current
ContentHandlerinstance
-
placeholders
public SELF placeholders(@NotNull @NotNull java.util.Map<java.lang.String,java.lang.Object> placeholders)
Set all the placeholders for the text.
Will override the previous placeholders modifications.- Parameters:
placeholders- the placeholders- Returns:
- the current
ContentHandlerinstance
-
placeholders
public SELF placeholders(@NotNull @NotNull java.util.function.Consumer<java.util.Map<java.lang.String,java.lang.Object>> consumer)
Set the placeholders for the text.- Parameters:
consumer- the placeholders- Returns:
- the current
ContentHandlerinstance
-
placeholders
public SELF placeholders(@Nullable @Nullable java.lang.Object... values)
Set the placeholders for the text.- Parameters:
values- The values to replace theparams(String...).- Returns:
- the current
ContentHandlerinstance
-
placeholder
public SELF placeholder(@NotNull @NotNull java.lang.String key, @Nullable @Nullable java.lang.Object value)
Set the placeholder for the text.- Parameters:
key- the key of the placeholdervalue- the value of the placeholder- Returns:
- the current
ContentHandlerinstance
-
params
public SELF params(@NotNull @NotNull java.lang.String... params)
Set the params for the text, used forplaceholders(Object...)to build the placeholders.- Parameters:
params- the params- Returns:
- the current
ContentHandlerinstance
-
replacers
public java.util.List<ContentReplacer<RECEIVER>> replacers()
- Specified by:
replacersin interfaceReplaceable<RECEIVER,SELF extends ContentHandler<RECEIVER,SELF>>
-
replacer
public SELF replacer(@NotNull @NotNull ContentReplacer<RECEIVER> replacer)
- Specified by:
replacerin interfaceReplaceable<RECEIVER,SELF extends ContentHandler<RECEIVER,SELF>>
-
paramReplacer
public SELF paramReplacer(@NotNull @NotNull ParamReplacer<RECEIVER> paramReplacer)
-
inserters
public java.util.List<ContentInserter<RECEIVER>> inserters()
- Specified by:
insertersin interfaceInsertable<RECEIVER,SELF extends ContentHandler<RECEIVER,SELF>>
-
inserter
public SELF inserter(@NotNull @NotNull ContentInserter<RECEIVER> inserter)
- Specified by:
inserterin interfaceInsertable<RECEIVER,SELF extends ContentHandler<RECEIVER,SELF>>
-
insert
public SELF insert(@NotNull @NotNull java.lang.String id, @Nullable @Nullable java.util.function.Function<RECEIVER,java.util.List<java.lang.String>> supplier)
Description copied from interface:InsertableInsert the specific contents by the id.- Specified by:
insertin interfaceInsertable<RECEIVER,SELF extends ContentHandler<RECEIVER,SELF>>- Parameters:
id- the id of the insertion textsupplier- to supply the lines to insert- Returns:
- the current
ContentHandlerinstance
-
inserting
public boolean inserting(@NotNull @NotNull java.lang.String id)- Specified by:
insertingin interfaceInsertable<RECEIVER,SELF extends ContentHandler<RECEIVER,SELF>>
-
getInsertion
@Nullable public @Nullable java.util.List<java.lang.String> getInsertion(@NotNull @NotNull java.lang.String id, @Nullable RECEIVER receiver)- Specified by:
getInsertionin interfaceInsertable<RECEIVER,SELF extends ContentHandler<RECEIVER,SELF>>
-
removeInsert
public SELF removeInsert(@NotNull @NotNull java.lang.String id)
- Specified by:
removeInsertin interfaceInsertable<RECEIVER,SELF extends ContentHandler<RECEIVER,SELF>>
-
parser
public SELF parser(@NotNull @NotNull java.util.function.BiFunction<RECEIVER,java.lang.String,java.lang.String> parser)
Set the parser for the text.- Parameters:
parser- The parser- Returns:
- The current
ContentHandlerinstance
-
parse
@Nullable protected @Nullable java.lang.String parse(@Nullable RECEIVER receiver, @NotNull @NotNull java.lang.String text)Parse the supplied single text for the receiver.- Parameters:
receiver- the receivertext- the text to parse- Returns:
- the parsed text
-
handle
public void handle(@NotNull @NotNull TextContents contents, @Nullable RECEIVER receiver, @NotNull @NotNull java.util.function.Consumer<java.lang.String> lineConsumer)
-
setPlaceholders
public static java.lang.String setPlaceholders(@NotNull @NotNull java.lang.String messages, @NotNull @NotNull java.util.Map<java.lang.String,java.lang.Object> placeholders)
-
buildParams
public static java.util.Map<java.lang.String,java.lang.Object> buildParams(@NotNull @NotNull java.util.function.UnaryOperator<java.lang.String> paramBuilder, @Nullable @Nullable java.lang.String[] params, @Nullable @Nullable java.lang.Object[] values)
-
-