class SegmentProcessor {

    static void process(List<String[]> segments, Consumer<String[]> consumer) {
        if (segments != null) {
            int index = 0;
            int length = segments.size();
            for (String[] segment : segments) {
                String key = segment[0];
                String value = segment[1];
                if (key != null && value != null) {
                    switch (key) {
                        case HOST:
                            if (length > 1 && index == 0) {
                                value = "*";
                            }
                            break;

                        case PROFILE:
                        case SERVER_GROUP:
                            if (index == 0) {
                                value = "*";
                            }
                            break;

                        case SERVER:
                        case SERVER_CONFIG:
                            if (index == 1) {
                                value = "*";
                            }
                            break;
                        default:
                            break;
                    }
                }
                consumer.accept(new String[]{key, value});
                index++;
            }
        }
    }

}

class SegmentProcessorTest {

    private AsListConsumer consumer;

    @Test
    public void serverConfig2() throws Exception {

        Fixture fixture = new Fixture.Builder("server-config2")
                .segments("host", "*", "server-config", "server-one", "jvm", "*")
                .expected("host", "*", "server-config", "*", "jvm", "*")
                .build();
        SegmentProcessor.process(fixture.segments, consumer);
        assertFixture(fixture, consumer.result);
    }

}