org.hibernate.envers.query.criteria.MatchMode Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of hibernate-envers Show documentation
Show all versions of hibernate-envers Show documentation
Hibernate's entity version (audit/history) support
/*
* Hibernate, Relational Persistence for Idiomatic Java
*
* License: GNU Lesser General Public License (LGPL), version 2.1 or later.
* See the lgpl.txt file in the root directory or .
*/
package org.hibernate.envers.query.criteria;
/**
* A strategy for matching strings using "like".
*
* @author Chris Cranford
*/
public enum MatchMode {
/**
* Match the pattern exactly.
*/
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 prepending/append "%".
*
* @param pattern The pattern to convert according to the mode.
* @return The converted pattern.
*/
public abstract String toMatchString(String pattern);
}