A Guard Clause Is Maybe a Tiny Parser - The Code Whisperer

Inspiring post! The functional and value type stuff is new to me, but I think it’s pretty neat. What are your thoughts on switching over types like this?

Summary
static void onBarcode(String text) {
    var barcode = Barcode.parse(text);

    switch (barcode) {
        case ValidBarcode v -> handleValidBarcode(v);
        case EmptyBarcode ignored -> System.out.println("Barcode is empty");
    }
}

static void handleValidBarcode(ValidBarcode validBarcode) {
    System.out.printf("Valid barcode: %s%n", validBarcode.text());
}

sealed interface Barcode permits EmptyBarcode, ValidBarcode {
    static Barcode parse(String text) {
        return !text.isEmpty()
               ? new ValidBarcode(text)
               : EmptyBarcode.INSTANCE;
    }
}

record ValidBarcode(String text) implements Barcode { }

enum EmptyBarcode implements Barcode { INSTANCE }