All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.github.mivek.command.remark.SnowIncreaseCommand Maven / Gradle / Ivy

package io.github.mivek.command.remark;

import io.github.mivek.internationalization.Messages;
import io.github.mivek.utils.Regex;

import java.util.regex.Pattern;

/**
 * @author mivek
 */
public final class SnowIncreaseCommand implements Command {
    /** Snow increasing rapidly. */
    private static final Pattern SNOW_INCR_RAPIDLY = Pattern.compile("^SNINCR (\\d+)/(\\d+)");

    /** The message instance. */
    private final Messages fMessages;

    /**
     * Default constructor.
     */
    SnowIncreaseCommand() {
        fMessages = Messages.getInstance();
    }

    @Override public String execute(final String pRemark, final StringBuilder pStringBuilder) {
        String[] snowParts = Regex.pregMatch(SNOW_INCR_RAPIDLY, pRemark);
        pStringBuilder.append(fMessages.getString("Remark.Snow.Increasing.Rapidly", snowParts[1], snowParts[2])).append(" ");
        return pRemark.replaceFirst(SNOW_INCR_RAPIDLY.pattern(), "").trim();
    }

    @Override public boolean canParse(final String pInput) {
        return Regex.find(SNOW_INCR_RAPIDLY, pInput);
    }
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy