class LoggingStatisticCollector implements RuntimeStatisticsCollector, StatisticsCollectorMXBean {

    public String print() {
        final Map<String, StatSet> localMap = map;
        final StringBuilder sb = new StringBuilder(1024);
        final List<StatSet> list = new ArrayList<LoggingStatisticCollector.StatSet>(localMap.values());
        Collections.sort(list, new Comparator<StatSet>() {
            @Override
            public int compare(StatSet o1, StatSet o2) {
                return o1.mpId.compareToIgnoreCase(o2.mpId);
            }
        });
        for (StatSet ss : list) {
            sb.append(toString(ss));
            sb.append("\n");
        }
        if (sb.length() > 0) {
            sb.deleteCharAt(sb.length() - 1);
        }
        return sb.toString();
    }

}