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

top.jfunc.common.db.condition.MatchMode Maven / Gradle / Ivy

The newest version!
package top.jfunc.common.db.condition;

/**
 * @author chenzhaoju
 * @author yangjian
 */
public enum MatchMode {

    /**
     * Match the entire string to the pattern
     */
    EXACT {
        @Override
        public String toMatchString(String pattern) {
            return pattern;
        }
    },

    /**
     * Match the start of the string to the pattern
     */
    START {
        @Override
        public String toMatchString(String pattern) {
            return pattern + '%';
        }
    },

    /**
     * Match the end of the string to the pattern
     */
    END {
        @Override
        public String toMatchString(String pattern) {
            return '%' + pattern;
        }
    },

    /**
     * Match the pattern anywhere in the string
     */
    ANYWHERE {
        @Override
        public String toMatchString(String pattern) {
            return '%' + pattern + '%';
        }
    };

    /**
     * Convert the pattern, by appending/prepending "%"
     *
     * @param pattern The pattern for convert according to the mode
     *
     * @return The converted pattern
     */
    public abstract String toMatchString(String pattern);

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy