class ContainerEndpointSerializer {

    public static ContainerEndpoint endpointFromSlime(Inspector inspector) {
        final var clusterId = inspector.field(clusterIdField).asString();
        final var namesInspector = inspector.field(namesField);

        if (clusterId.isEmpty()) {
            throw new IllegalStateException("'clusterId' missing on serialized ContainerEndpoint");
        }

        if (! namesInspector.valid()) {
            throw new IllegalStateException("'names' missing on serialized ContainerEndpoint");
        }

        final var names = new ArrayList<String>();

        namesInspector.traverse((ArrayTraverser) (idx, nameInspector) -> {
            final var containerName = nameInspector.asString();
            names.add(containerName);
        });

        return new ContainerEndpoint(clusterId, names);
    }

    private  ContainerEndpointSerializer();

}