javax0.geci.jamal.macros.Equals Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of javageci-jamal Show documentation
Show all versions of javageci-jamal Show documentation
Javageci jamal macro library
package javax0.geci.jamal.macros;
import javax0.jamal.api.BadSyntax;
import javax0.jamal.api.Input;
import javax0.jamal.api.Macro;
import javax0.jamal.api.Processor;
import static javax0.jamal.tools.InputHandler.getParts;
/**
* A simple implementation of the String.equals functionality. It can be used as
*
* {@code
* {%@equals /something/something%}
* }
*
* The return value of the macro is either the string literal {@code true} or the string literal {@code false}.
*
* The arguments can be separated by space in case the {@code something} does not contain any space, using any non alpha
* numeric character or using `regex` as defined in {@link javax0.jamal.tools.InputHandler#getParts(Input) getParts()}
*/
public class Equals implements Macro {
@Override
public String evaluate(Input in, Processor processor) throws BadSyntax {
final var parts = getParts(in, 2);
if (parts.length < 2) {
throw new BadSyntax("Macro equals needs two argument");
}
return "" + parts[0].equals(parts[1]);
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy