private void initializeForFile(CounterInitializationContext context) { String language = context.getLeaf().getFileAttributes().getLanguageKey(); Optional<Measure> ncloc = context.getMeasure(CoreMetrics.NCLOC_KEY); if (ncloc.isPresent()) { multiset.add(language == null ? UNKNOWN_LANGUAGE_KEY : language, ncloc.get().getIntValue()); } }
@Override public void initialize(CounterInitializationContext context) { if (context.getLeaf().getType() == Component.Type.FILE) { initializeForFile(context); } initializeForOtherLeaf(context); }
private void initializeForOtherLeaf(CounterInitializationContext context) { Optional<Measure> measure = context.getMeasure(NCLOC_LANGUAGE_DISTRIBUTION_KEY); if (measure.isPresent()) { Map<String, Integer> parse = KeyValueFormat.parse( measure.get().getData(), newStringConverter(), newIntegerConverter()); for (Map.Entry<String, Integer> entry : parse.entrySet()) { multiset.add(entry.getKey(), entry.getValue()); } } }