code: public static void filteredCounterWrite(String member, Predicate<String> includeFilter,
        Predicate<String> includeCounterFilter,
        CounterMap counterMap, JsonGenerator jsonGenerator)
        throws IOException {
      if (includeFilter != null && includeCounterFilter == null) {
        if (includeFilter.apply(member)) {
          jsonGenerator.writeFieldName(member);
          jsonGenerator.writeObject(counterMap);
        }
      } else {
        if (includeCounterFilter != null) {
          // get group name, counter name,
          // check if it is wanted
          // if yes print it.
          boolean startObjectGroupMap = false;
          jsonGenerator.writeFieldName(member);
  
          String fullCounterName;
          jsonGenerator.writeStartObject();
  
          for (String group : counterMap.getGroups()) {
            Map<String, Counter> groupMap = counterMap.getGroup(group);
            for (Map.Entry<String, Counter> nameCounterEntry : groupMap.entrySet()) {
              Counter counter = nameCounterEntry.getValue();
              fullCounterName = group + "." + counter.getKey();
              if (includeCounterFilter.apply(fullCounterName)) {
                if (startObjectGroupMap == false) {
                  jsonGenerator.writeFieldName(group);
                  jsonGenerator.writeStartObject();
                  startObjectGroupMap = true;
                }
                jsonGenerator.writeFieldName(counter.getKey());
                jsonGenerator.writeNumber(counter.getValue());
              }
            }
            if (startObjectGroupMap) {
              jsonGenerator.writeEndObject();
              startObjectGroupMap = false;
            }
          }
          jsonGenerator.writeEndObject();
        }
      }
    }
docs: checks if the member is to be filtered out or no if filter itself is
  null, writes out that member
  
  @param member
  @param includeFilter
  @param jsonGenerator
  @throws JsonGenerationException
  @throws IOException