static Set<ShareGroupState> shareGroupStatesFromString(String input) {
        Set<ShareGroupState> parsedStates =
            Arrays.stream(input.split(",")).map(s -> ShareGroupState.parse(s.trim())).collect(Collectors.toSet());
        if (parsedStates.contains(ShareGroupState.UNKNOWN)) {
            Collection<ShareGroupState> validStates =
                Arrays.stream(ShareGroupState.values()).filter(s -> s != ShareGroupState.UNKNOWN).collect(Collectors.toList());
            throw new IllegalArgumentException("Invalid state list '" + input + "'. Valid states are: " +
                validStates.stream().map(Object::toString).collect(Collectors.joining(", ")));
        }
        return parsedStates;
    }
@Test
    public void testShareGroupStatesFromString() {
        Set<ShareGroupState> result = ShareGroupCommand.shareGroupStatesFromString("Stable");
        assertEquals(Collections.singleton(ShareGroupState.STABLE), result);

        result = ShareGroupCommand.shareGroupStatesFromString("stable");
        assertEquals(new HashSet<>(Collections.singletonList(ShareGroupState.STABLE)), result);

        result = ShareGroupCommand.shareGroupStatesFromString("dead");
        assertEquals(new HashSet<>(Collections.singletonList(ShareGroupState.DEAD)), result);

        result = ShareGroupCommand.shareGroupStatesFromString("empty");
        assertEquals(new HashSet<>(Collections.singletonList(ShareGroupState.EMPTY)), result);

        assertThrows(IllegalArgumentException.class, () -> ShareGroupCommand.shareGroupStatesFromString("bad, wrong"));

        assertThrows(IllegalArgumentException.class, () -> ShareGroupCommand.shareGroupStatesFromString("  bad, Stable"));

        assertThrows(IllegalArgumentException.class, () -> ShareGroupCommand.shareGroupStatesFromString("   ,   ,"));
    }