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(); static ContainerEndpoint endpointFromSlime(Inspector inspector); static List<ContainerEndpoint> endpointListFromSlime(Slime slime); static void endpointToSlime(Cursor cursor, ContainerEndpoint endpoint); static Slime endpointListToSlime(List<ContainerEndpoint> endpoints);  }
@Test public void readSingleEndpoint() { final var slime = new Slime(); final var entry = slime.setObject(); entry.setString("clusterId", "foobar"); final var entryNames = entry.setArray("names"); entryNames.addString("a"); entryNames.addString("b"); final var endpoint = ContainerEndpointSerializer.endpointFromSlime(slime.get()); assertEquals("foobar", endpoint.clusterId()); assertEquals(List.of("a", "b"), endpoint.names()); }