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

org.stagemonitor.configuration.converter.RegexValueConverter Maven / Gradle / Ivy

There is a newer version: 1.50.0
Show newest version
package org.stagemonitor.configuration.converter;

import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;

public class RegexValueConverter extends AbstractValueConverter {

	public static final RegexValueConverter INSTANCE = new RegexValueConverter();

	private RegexValueConverter() {
	}

	@Override
	public Pattern convert(String s) throws IllegalArgumentException {
		try {
			return Pattern.compile(s);
		} catch (PatternSyntaxException e) {
			throw new IllegalArgumentException("Error while trying to parse regex '" + s + "'");
		}
	}

	@Override
	public String toString(Pattern value) {
		return value.toString();
	}

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy