For use in a lexer class a have a class Token which represents a token of a specific type and its value, while the types are defined by the enum TokenType in which every token holds its own regular expression string, these again are stored in static final String variables.Now my problem is that I naturally would create two seperate files, one for Token and one for TokenType and locate the regex strings in TokenType, where they belong.Since this is not possible I currently have all three together in the Token class, but then all this is dragged along for every new Token object. And I can't really think of a reasonable wrapper-class to put around TokenType and its constants.public class Token {private static final String WHITESPACE_REGEX = [\\s\\f\\r\\n];private static final String COMMA_REGEX = WHITESPACE_REGEX + *, + WHITESPACE_REGEX + // ...public enum TokenType {    // can't be defined here...    WHITESPACE(WHITESPACE_REGEX + +),    COMMA(COMMA_REGEX),    // ...    // ... or here    public final String pattern;    private TokenType(String pattern) {        this.pattern = pattern;    }}private TokenType type;private String value;public Token(TokenType type, String value) {    this.type = type;    this.value = value;}public TokenType getType() {    return type;}public String getValue() {    return value;}}
Class design for Token, TokenType and regex constants
java;class design;class