class DefaultTextPatternService implements TextPatternService {

    @Override
    public Map<String, List<String>> getRequiredValues( TextPattern pattern )
    {
        return ImmutableMap.<String, List<String>>builder()
            .put( "REQUIRED", pattern.getSegments()
                .stream()
                .filter( this::isRequired )
                .map( segment -> segment.getMethod().name() )
                .collect( Collectors.toList() ) )
            .put( "OPTIONAL", pattern.getSegments()
                .stream()
                .filter( this::isOptional )
                .map( (segment -> segment.getMethod().name()) )
                .collect( Collectors.toList() ) )
            .build();
    }

}