class Bookmark implements Serializable {

    public static Optional<Bookmark> parse(@Nullable String str) {
        // end::refguide[]

        if(str==null) {
            return Optional.empty();
        }
        val tokenizer = new StringTokenizer(str, SEPARATOR);
        int tokenCount = tokenizer.countTokens();
        if(tokenCount==2) {
            return Optional.of(Bookmark.of(tokenizer.nextToken(), tokenizer.nextToken()));
        }
        if(tokenCount>2) {
            return Optional.of(Bookmark.of(tokenizer.nextToken(), tokenizer.nextToken("").substring(1)));
        }
        return Optional.empty();

        // tag::refguide[]
        // ...
    }

}