mirror of
https://github.com/PlaceholderAPI/PlaceholderAPI
synced 2026-02-08 12:52:47 +01:00
replacer api, unit tests, and benchmarks (#354)
* added abstracted replacer api, and both char and regex based implementations * added test dependencies for jmh and junit * added unit tests and benchmarks for the replacer implementations * updated replacers to accept specific closure types, added test to verify malformed placeholder handling * updated jmh to 1.23, updated junit to 5.6.2
This commit is contained in:
33
src/main/java/me/clip/placeholderapi/replacer/Replacer.java
Normal file
33
src/main/java/me/clip/placeholderapi/replacer/Replacer.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package me.clip.placeholderapi.replacer;
|
||||
|
||||
import me.clip.placeholderapi.PlaceholderHook;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
|
||||
import java.util.function.Function;
|
||||
|
||||
public interface Replacer
|
||||
{
|
||||
|
||||
@NotNull
|
||||
String apply(@NotNull final String text, @Nullable final OfflinePlayer player, @NotNull final Function<String, @Nullable PlaceholderHook> lookup);
|
||||
|
||||
|
||||
enum Closure
|
||||
{
|
||||
BRACES('{', '}'),
|
||||
BRACKETS('[', ']'),
|
||||
PERCENT('%', '%');
|
||||
|
||||
|
||||
public final char head, tail;
|
||||
|
||||
Closure(final char head, final char tail)
|
||||
{
|
||||
this.head = head;
|
||||
this.tail = tail;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user