Interface StringReplacer

All Known Implementing Classes:
VariableManager

public interface StringReplacer
A simple interface for String replacement
  • Field Details

    • DUMMY

      static final StringReplacer DUMMY
      The dummy replacer that does nothing
  • Method Details

    • combine

      @NotNull static @NotNull StringReplacer combine(@NotNull @NotNull Collection<? extends StringReplacer> stringReplacers)
      Combine multiple string replacers
      Parameters:
      stringReplacers - the string replacers
      Returns:
      the combined string replacer
    • combine

      @NotNull static @NotNull StringReplacer combine(@NotNull @NotNull StringReplacer... stringReplacers)
      Combine multiple string replacers
      Parameters:
      stringReplacers - the string replacers
      Returns:
      the combined string replacer
    • either

      @NotNull static @NotNull StringReplacer either(@NotNull @NotNull Collection<? extends StringReplacer> stringReplacers)
      Combine multiple string replacers to a switch-styled string replacer
      Parameters:
      stringReplacers - the string replacers
      Returns:
      the combined string replacer
    • either

      @NotNull static @NotNull StringReplacer either(@NotNull @NotNull StringReplacer... stringReplacers)
      Combine multiple string replacers to a switch-styled string replacer
      Parameters:
      stringReplacers - the string replacers
      Returns:
      the combined string replacer
    • of

      @NotNull static @NotNull StringReplacer of(@NotNull @NotNull UnaryOperator<String> operator, @NotNull @NotNull BiFunction<String,UUID,String> function)
      Parameters:
      operator - the UnaryOperator
      function - the BiFunction
      Returns:
      the StringReplacer
    • of

      @NotNull static @NotNull StringReplacer of(@NotNull @NotNull UnaryOperator<String> operator)
      Parameters:
      operator - the UnaryOperator
      Returns:
      the StringReplacer
    • of

      @NotNull static @NotNull StringReplacer of(@NotNull @NotNull BiFunction<String,UUID,String> function)
      Parameters:
      function - the BiFunction
      Returns:
      the StringReplacer
    • replace

      @Nullable @Nullable String replace(@NotNull @NotNull String original)
      Replace a string
      Parameters:
      original - the original string
      Returns:
      the replaced string
    • replace

      @Nullable default @Nullable String replace(@NotNull @NotNull String original, @NotNull @NotNull UUID uuid)
      Replace a string based on the unique id
      Parameters:
      original - the original string
      uuid - the unique id
      Returns:
      the replaced string
    • tryReplace

      @Nullable default @Nullable String tryReplace(@NotNull @NotNull String original, @Nullable @Nullable UUID uuid)
      Try to replace a string based on the unique id. If the unique id is null, it will use replace(String). Otherwise, it will use replace(String, UUID).
      Parameters:
      original - the original string
      uuid - the unique id
      Returns:
      the replaced string
    • replaceOrDefault

      default String replaceOrDefault(@NotNull @NotNull String original, @Nullable @Nullable UUID uuid, @NotNull @NotNull String def)
      Replace a string or return the default value
      Parameters:
      original - the original string
      uuid - the unique id
      def - the default value
      Returns:
      the replaced string or the default value
    • replaceOrOriginal

      default String replaceOrOriginal(@NotNull @NotNull String original, @Nullable @Nullable UUID uuid)
      Replace a string or return the original value
      Parameters:
      original - the original string
      Returns:
      the replaced string or the original value