class Username {

    public static Username of(String username) {
        Preconditions.checkArgument(username != null, "username should not be null or empty");
        Preconditions.checkArgument(!username.trim().isEmpty(), "username should not be null or empty after being trimmed");
        Preconditions.checkArgument(username.length() <= MAXIMUM_MAIL_ADDRESS_LENGTH,
            "username length should not be longer than %s characters", MAXIMUM_MAIL_ADDRESS_LENGTH);

        List<String> parts = ImmutableList.copyOf(Splitter.on('@').split(username));
        switch (parts.size()) {
            case 1:
                return fromLocalPartWithoutDomain(username);
            case 2:
                return fromLocalPartWithDomain(parts.get(0), parts.get(1));
        }
        throw new IllegalArgumentException("The username should not contain multiple domain delimiter. Value: " + username);
    }

    private  Username(String localPart, Optional<Domain> domainPart);

}