public static Optional<AwsArn> parse(String arn) {
        String[] base = arn.split(":", 6);
        if (base.length != 6) {
            return Optional.empty();
        }
        // First section must be "arn".
        if (!base[0].equals("arn")) {
            return Optional.empty();
        }
        // Sections for partition, service, and resource type must not be empty.
        if (base[1].isEmpty() || base[2].isEmpty() || base[5].isEmpty()) {
            return Optional.empty();
        }

        return Optional.of(builder()
                .partition(base[1])
                .service(base[2])
                .region(base[3])
                .accountId(base[4])
                .resource(Arrays.asList(base[5].split("[:/]", -1)))
                .build());
    }
Parses and returns the ARN components if the provided value is a valid AWS ARN.

@param arn the value to parse.
@return the optional ARN.
smithy-aws-endpoints/src/main/java/software/amazon/smithy/rulesengine/aws/language/functions/AwsArn.java