@Test public void toStringTest() throws Exception { DatasetMatchSummary summary = new DatasetMatchSummary(UUID.randomUUID()); summary.addNoMatch(Rank.KINGDOM); summary.addNoMatch(Rank.CLASS); summary.addNoMatch(Rank.CLASS); summary.addNoMatch(Rank.FORM); summary.addNoMatch(Rank.BIOVAR); summary.addNoMatch(Rank.SUBGENUS); summary.addNoMatch(Rank.UNRANKED); summary.addNoMatch(null); summary.addMatch(Rank.ORDER); summary.addMatch(Rank.FAMILY); summary.addMatch(Rank.GENUS); summary.addMatch(Rank.SPECIES); summary.addMatch(Rank.VARIETY); summary.addMatch(Rank.SPECIES); summary.addMatch(Rank.SUBSPECIES); summary.addMatch(null); System.out.println(summary); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("DatasetMatch ") .append(datasetKey) .append(": total=") .append(usages.get()) .append(", matches=") .append(matches.get()) .append(", unparsable=") .append(unparsable.get()) .append(", perc=") .append(percMatches()) .append(", percLower=") .append(percBackboneRelevantNoMatches()); sb.append("\n"); final AtomicInteger zero = new AtomicInteger(); usagesByRank.keySet().stream().sorted().forEach(rank -> { sb.append(" ") .append(rank) .append(": ") .append(matchesByRank.getOrDefault(rank, zero).get()) .append("/") .append(usagesByRank.get(rank).get()) .append("\n"); }); return sb.toString(); }
DatasetMatchSummary { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("DatasetMatch ") .append(datasetKey) .append(": total=") .append(usages.get()) .append(", matches=") .append(matches.get()) .append(", unparsable=") .append(unparsable.get()) .append(", perc=") .append(percMatches()) .append(", percLower=") .append(percBackboneRelevantNoMatches()); sb.append("\n"); final AtomicInteger zero = new AtomicInteger(); usagesByRank.keySet().stream().sorted().forEach(rank -> { sb.append(" ") .append(rank) .append(": ") .append(matchesByRank.getOrDefault(rank, zero).get()) .append("/") .append(usagesByRank.get(rank).get()) .append("\n"); }); return sb.toString(); } }
DatasetMatchSummary { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("DatasetMatch ") .append(datasetKey) .append(": total=") .append(usages.get()) .append(", matches=") .append(matches.get()) .append(", unparsable=") .append(unparsable.get()) .append(", perc=") .append(percMatches()) .append(", percLower=") .append(percBackboneRelevantNoMatches()); sb.append("\n"); final AtomicInteger zero = new AtomicInteger(); usagesByRank.keySet().stream().sorted().forEach(rank -> { sb.append(" ") .append(rank) .append(": ") .append(matchesByRank.getOrDefault(rank, zero).get()) .append("/") .append(usagesByRank.get(rank).get()) .append("\n"); }); return sb.toString(); } DatasetMatchSummary(UUID datasetKey); }
DatasetMatchSummary { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("DatasetMatch ") .append(datasetKey) .append(": total=") .append(usages.get()) .append(", matches=") .append(matches.get()) .append(", unparsable=") .append(unparsable.get()) .append(", perc=") .append(percMatches()) .append(", percLower=") .append(percBackboneRelevantNoMatches()); sb.append("\n"); final AtomicInteger zero = new AtomicInteger(); usagesByRank.keySet().stream().sorted().forEach(rank -> { sb.append(" ") .append(rank) .append(": ") .append(matchesByRank.getOrDefault(rank, zero).get()) .append("/") .append(usagesByRank.get(rank).get()) .append("\n"); }); return sb.toString(); } DatasetMatchSummary(UUID datasetKey); UUID getDatasetKey(); int getUnparsable(); int getTotalUsages(); int getMatches(); void addUnparsable(); void addNoMatch(@Nullable Rank rank); void addMatch(@Nullable Rank rank); int percMatches(); int percBackboneRelevantNoMatches(); @Override String toString(); }
DatasetMatchSummary { @Override public String toString() { StringBuilder sb = new StringBuilder(); sb.append("DatasetMatch ") .append(datasetKey) .append(": total=") .append(usages.get()) .append(", matches=") .append(matches.get()) .append(", unparsable=") .append(unparsable.get()) .append(", perc=") .append(percMatches()) .append(", percLower=") .append(percBackboneRelevantNoMatches()); sb.append("\n"); final AtomicInteger zero = new AtomicInteger(); usagesByRank.keySet().stream().sorted().forEach(rank -> { sb.append(" ") .append(rank) .append(": ") .append(matchesByRank.getOrDefault(rank, zero).get()) .append("/") .append(usagesByRank.get(rank).get()) .append("\n"); }); return sb.toString(); } DatasetMatchSummary(UUID datasetKey); UUID getDatasetKey(); int getUnparsable(); int getTotalUsages(); int getMatches(); void addUnparsable(); void addNoMatch(@Nullable Rank rank); void addMatch(@Nullable Rank rank); int percMatches(); int percBackboneRelevantNoMatches(); @Override String toString();  }