2018-11-15 19:50:46 +01:00
|
|
|
package de.vanitasvitae.imi.codes.types;
|
2018-11-14 20:38:51 +01:00
|
|
|
|
2018-11-15 17:54:34 +01:00
|
|
|
import java.util.regex.Pattern;
|
2018-11-14 20:38:51 +01:00
|
|
|
|
2018-11-15 19:50:46 +01:00
|
|
|
import de.vanitasvitae.imi.codes.input.InputValidator;
|
|
|
|
import de.vanitasvitae.imi.codes.input.InvalidOptionException;
|
|
|
|
|
2018-11-15 17:54:34 +01:00
|
|
|
/**
|
|
|
|
* Sub-class of {@link CharSequence}, which can only represent char sequences of length 1 from the alphabet [a-zA-Z0-9].
|
|
|
|
*/
|
|
|
|
public class SampleType extends BoundedCharSequence {
|
2018-11-14 20:38:51 +01:00
|
|
|
|
2018-11-15 17:54:34 +01:00
|
|
|
private static final Pattern REGEX = Pattern.compile(InputValidator.REGEX_ALPHABET);
|
2018-11-15 01:30:41 +01:00
|
|
|
|
|
|
|
/**
|
2018-11-15 17:54:34 +01:00
|
|
|
* Create a new {@link SampleType} sequence. The constructor checks, whether the input String is of length 1 and from
|
|
|
|
* the alphabet [a-zA-Z9-0].
|
2018-11-15 01:30:41 +01:00
|
|
|
*
|
2018-11-15 17:54:34 +01:00
|
|
|
* @param value input string
|
|
|
|
* @throws InvalidOptionException if the input doesn't match the regex.
|
2018-11-15 01:30:41 +01:00
|
|
|
*/
|
2018-11-15 17:54:34 +01:00
|
|
|
public SampleType(String value) throws InvalidOptionException {
|
|
|
|
super(REGEX, value);
|
2018-11-14 20:38:51 +01:00
|
|
|
}
|
|
|
|
}
|