Skip to content

Commit

Permalink
Add Javadoc
Browse files Browse the repository at this point in the history
  • Loading branch information
Almighty-Satan committed Mar 7, 2024
1 parent d3b0acc commit f8a0620
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 0 deletions.
10 changes: 10 additions & 0 deletions core/src/main/java/io/github/almightysatan/slams/Placeholder.java
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,16 @@ public interface Placeholder extends PlaceholderResolver {
});
}

/**
* Returns a new {@link Placeholder}. This placeholder compares its first two arguments using the given function. If
* the function evaluates to {@code true}, this placeholder will return the third argument as its value, otherwise
* the fourth argument is returned.
* Example format: {@code <if_eq:<time>:1:1 second:<time> seconds>}
*
* @param key the placeholder's key
* @param comparisonFunction a function that compares the first two arguments of this placeholder
* @return a new placeholder
*/
static @NotNull Placeholder comparison(@NotNull String key, @NotNull ComparisonFunction comparisonFunction) {
Objects.requireNonNull(comparisonFunction);
return of(key, (context, arguments) -> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,21 @@ public interface PlaceholderResolver {
return of(placeholderResolvers.toArray(new PlaceholderResolver[0]));
}

/**
* Returns a {@link PlaceholderResolver} containing some built-in placeholders, including, but no limited to
* <ul>
* <li>if_eq</li>
* <li>if_neq</li>
* <li>if_num_eq</li>
* <li>if_num_neq</li>
* <li>if_num_lt</li>
* <li>if_num_gt</li>
* <li>if_num_le</li>
* <li>if_num_ge</li>
* </ul>
*
* @return a new {@link PlaceholderResolver}
*/
static @NotNull PlaceholderResolver builtInPlaceholders() {
return builder().builtIn().build();
}
Expand Down Expand Up @@ -391,6 +406,21 @@ interface Builder {
return this.add(Placeholder.conditional(key, supplier));
}

/**
* Adds built-in placeholders, including, but no limited to
* <ul>
* <li>if_eq</li>
* <li>if_neq</li>
* <li>if_num_eq</li>
* <li>if_num_neq</li>
* <li>if_num_lt</li>
* <li>if_num_gt</li>
* <li>if_num_le</li>
* <li>if_num_ge</li>
* </ul>
*
* @return this {@link Builder}
*/
default @NotNull Builder builtIn() {
BiFunction<String, BiFunction<BigDecimal, BigDecimal, Boolean>, Placeholder> numberComparison = (key, fun) ->
Placeholder.comparison(key, (arg0, arg1) -> {
Expand Down

0 comments on commit f8a0620

Please sign in to comment.