public static Literal fromNode(Node node) {
        return node.accept(new NodeVisitor<Literal>() {
            @Override
            public Literal arrayNode(ArrayNode arrayNode) {
                List<Literal> elements = arrayNode.getElementsAs(node -> node.accept(this));
                return new TupleLiteral(elements, arrayNode);
            }

            @Override
            public Literal booleanNode(BooleanNode booleanNode) {
                return new BooleanLiteral(booleanNode);
            }

            @Override
            public Literal nullNode(NullNode nullNode) {
                throw new RuntimeException("null node not supported");
            }

            @Override
            public Literal numberNode(NumberNode numberNode) {
                return new IntegerLiteral(numberNode);
            }

            @Override
            public Literal objectNode(ObjectNode objectNode) {
                Map<Identifier, Literal> members = new LinkedHashMap<>();
                for (Map.Entry<String, Node> entry : objectNode.getStringMap().entrySet()) {
                    members.put(Identifier.of(entry.getKey()), entry.getValue().accept(this));
                }
                return new RecordLiteral(members, objectNode);
            }

            @Override
            public Literal stringNode(StringNode stringNode) {
                return new StringLiteral(new Template(stringNode), stringNode);
            }
        });
    }
Constructs a literal from a {@link Node} based on the Node's type.

@param node a node to construct as a literal.
@return the literal representation of the node.
smithy-rules-engine/src/main/java/software/amazon/smithy/rulesengine/language/syntax/expressions/literal/Literal.java