aboutsummaryrefslogtreecommitdiff
path: root/src/main/java/de/hysky/skyblocker/utils/container/SimpleContainerSolver.java
blob: 7d8b74173dfc89a4ab2ccc7c9071c5dd01fe9d1f (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
package de.hysky.skyblocker.utils.container;

import org.intellij.lang.annotations.Language;
import org.jetbrains.annotations.NotNull;

import java.util.regex.Pattern;

/**
 * Simple implementation of a container solver. Extend this class to add a new gui solver,
 * like terminal solvers or experiment solvers and add it to {@link ContainerSolverManager#solvers}.
 */
public abstract class SimpleContainerSolver extends RegexContainerMatcher implements ContainerSolver {
    /**
     * Utility constructor that will compile the given string into a pattern.
     *
     * @see #SimpleContainerSolver(Pattern)
     */
    protected SimpleContainerSolver(@NotNull @Language("RegExp") String titlePattern) {
        super(titlePattern);
    }

    /**
     * Creates a ContainerSolver that will be applied to screens with titles that match the given pattern.
     *
     * @param titlePattern The pattern to match the screen title against.
     */
    protected SimpleContainerSolver(@NotNull Pattern titlePattern) {
        super(titlePattern);
    }

    // A container solver that applies to every screen doesn't make sense,
    // so we don't provide a constructor for that and force getTitlePattern to be @NotNull
    @Override
    public @NotNull Pattern getTitlePattern() {
	    assert super.getTitlePattern() != null;
	    return super.getTitlePattern();
    }
}