com.google.common.collect.Multisets Java Examples
The following examples show how to use
com.google.common.collect.Multisets.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SlotMachineSimulation.java From levelup-java-exercises with Apache License 2.0 | 8 votes |
/** * Method should return the number of times an occurrence of a reel * * @param reels * @return */ static int determinePayOutPercentage(List<String> reels) { Multiset<String> reelCount = HashMultiset.create(); reelCount.addAll(reels); // order the number of elements by the higest ImmutableMultiset<String> highestCountFirst = Multisets.copyHighestCountFirst(reelCount); int count = 0; for (Entry<String> entry : highestCountFirst.entrySet()) { count = entry.getCount(); break; } return count; }
Example #2
Source File: AbstractIdentifierRenamings.java From naturalize with BSD 3-Clause "New" or "Revised" License | 6 votes |
/** * @param relevantNgrams * @param currentName * @return */ public Multiset<String> getAlternativeNames( final Multiset<NGram<String>> relevantNgrams, final String currentName) { // Get all alternative namings final Multiset<String> nameAlternatives = ngramLM .getAlternativeNamings(relevantNgrams, WILDCARD_TOKEN); nameAlternatives.add(currentName); // Give the current identifier a // chance... // Prune naming alternatives final Multiset<String> toKeep = TreeMultiset.create(); int seen = 0; for (final Entry<String> ent : Multisets.copyHighestCountFirst( nameAlternatives).entrySet()) { if (seen > 1000) { break; } toKeep.add(ent.getElement(), ent.getCount()); seen++; } toKeep.add(AbstractNGramLM.UNK_SYMBOL); return toKeep; }
Example #3
Source File: LevelCalcByChunk.java From askyblock with GNU General Public License v2.0 | 6 votes |
private Collection<String> sortedReport(int total, Multiset<MaterialData> materialDataCount) { Collection<String> result = new ArrayList<>(); Iterable<Multiset.Entry<MaterialData>> entriesSortedByCount = Multisets.copyHighestCountFirst(materialDataCount).entrySet(); for (Entry<MaterialData> en : entriesSortedByCount) { MaterialData type = en.getElement(); int value = 0; if (Settings.blockValues.containsKey(type)) { // Specific value = Settings.blockValues.get(type); } else if (Settings.blockValues.containsKey(new MaterialData(type.getItemType()))) { // Generic value = Settings.blockValues.get(new MaterialData(type.getItemType())); } if (value > 0) { result.add(type.toString() + ":" + String.format("%,d", en.getCount()) + " blocks x " + value + " = " + (value * en.getCount())); total += (value * en.getCount()); } } result.add("Subtotal = " + total); result.add("=================================="); return result; }
Example #4
Source File: ByEventTypeResultWriter.java From tac-kbp-eal with MIT License | 6 votes |
@Override public void writeResult(final List<EALScorer2015Style.Result> perDocResults, final File eventTypesDir) throws IOException { final Multiset<Symbol> eventTypesSeen = gatherEventTypesSeen(perDocResults); for (final Multiset.Entry<Symbol> typeEntry : Multisets.copyHighestCountFirst(eventTypesSeen) .entrySet()) { final Symbol type = typeEntry.getElement(); final Function<EALScorer2015Style.ArgResult, EALScorer2015Style.ArgResult> filterFunction = new Function<EALScorer2015Style.ArgResult, EALScorer2015Style.ArgResult>() { @Override public EALScorer2015Style.ArgResult apply(final EALScorer2015Style.ArgResult input) { return input.copyFiltered(compose(equalTo(type), type())); } }; final File eventTypeDir = new File(eventTypesDir, type.asString()); eventTypeDir.mkdirs(); writeOverallArgumentScoresForTransformedResults(perDocResults, filterFunction, eventTypeDir); } }
Example #5
Source File: CorpusAnalysis.java From tac-kbp-eal with MIT License | 6 votes |
public static ImmutableMultiset<Symbol> toNumberOfDocsPerEventType( final ImmutableSet<TypeRoleFillerRealis> equivClasses) { // for each docid, a set of event types final ImmutableMap<Symbol, ImmutableSet<Symbol>> eventTypesInEachDoc = getEventTypesInEachDoc(equivClasses); final ImmutableMultiset.Builder<Symbol> ret = ImmutableMultiset.builder(); for(final Map.Entry<Symbol, ImmutableSet<Symbol>> entry : eventTypesInEachDoc.entrySet()) { for(final Symbol et : entry.getValue()) { ret.add(et); } } return Multisets.copyHighestCountFirst(ret.build()); }
Example #6
Source File: CorpusAnalysis.java From tac-kbp-eal with MIT License | 6 votes |
public static ImmutableMultiset<Symbol> toEventHopperCounts(final ImmutableSet<EventArgumentLinking> linkings) { final ImmutableMultiset.Builder<Symbol> ret = ImmutableMultiset.builder(); for(final EventArgumentLinking eal : linkings) { for (final TypeRoleFillerRealisSet ef : eal.eventFrames()) { final ImmutableSet<Symbol> eventTypes = ImmutableSet.copyOf(FluentIterable.from(ef.asSet()) .transform(type())); if(eventTypes.size()==1) { final Symbol eventType = FluentIterable.from(eventTypes).first().get(); ret.add(eventType); } else { log.info("ERROR: a responseLinking set from document {} has multiple event types", eal.docID().toString()); } } } return Multisets.copyHighestCountFirst(ret.build()); }
Example #7
Source File: CorpusAnalysis.java From tac-kbp-eal with MIT License | 6 votes |
public static ImmutableMultiset<Symbol> toMentionTypeCounts( final ImmutableSet<TypeRoleFillerRealis> targetEquivClasses, final ImmutableMultimap<TypeRoleFillerRealis, AssessedResponse> equivClassToAssessedResponse) { final ImmutableMultiset.Builder<Symbol> mentionTypes = ImmutableMultiset.builder(); for(final TypeRoleFillerRealis equivClass : targetEquivClasses) { final AssessedResponse assessedResponse = Collections.max(equivClassToAssessedResponse.get(equivClass), Old2014ID); if(assessedResponse.response().role() == TIME) { mentionTypes.add(TIME); } else { final Optional<FillerMentionType> mentionType = assessedResponse.assessment().mentionTypeOfCAS(); if (mentionType.isPresent()) { mentionTypes.add(Symbol.from(mentionType.get().name())); } } } return Multisets.copyHighestCountFirst(mentionTypes.build()); }
Example #8
Source File: CorpusAnalysis.java From tac-kbp-eal with MIT License | 6 votes |
public static ImmutableMultiset<Symbol> toRealisCounts( final ImmutableSet<TypeRoleFillerRealis> equivClasses) { return Multisets.copyHighestCountFirst( ImmutableMultiset.copyOf(Iterables.transform(equivClasses, Functions.compose(RealisSymbol, Realis)))); /* final ImmutableMultimap<KBPRealis, TypeRoleFillerRealis> realisToEquivClass = Multimaps.index(equivClasses, TypeRoleFillerRealis.realisFunction()); final List<ElementWithCount> elements = Lists.newArrayList(); for(final Map.Entry<KBPRealis, Collection<TypeRoleFillerRealis>> entry : realisToEquivClass.asMap().entrySet()) { elements.add( ElementWithCount.from(entry.getKey(), entry.getValue().size()) ); } Collections.sort(elements, ElementCount); return ImmutableList.copyOf(elements); */ }
Example #9
Source File: Rebanker.java From easyccg with MIT License | 6 votes |
private void writeCatList(Multiset<Category> cats, File outputFile) throws IOException { Multiset<Category> catsNoPPorPRfeatures = HashMultiset.create(); for (Category cat : cats) { catsNoPPorPRfeatures.add(cat.dropPPandPRfeatures()); } FileWriter fw = new FileWriter(outputFile.getAbsoluteFile()); BufferedWriter bw = new BufferedWriter(fw); int categories = 0; for (Category type : Multisets.copyHighestCountFirst(cats).elementSet()) { if (catsNoPPorPRfeatures.count(type.dropPPandPRfeatures()) >= 10) { bw.write(type.toString()); bw.newLine(); categories++; } } System.out.println("Number of cats occurring 10 times: " + categories); bw.flush(); bw.close(); }
Example #10
Source File: MotherlodePlugin.java From plugins with GNU General Public License v3.0 | 6 votes |
@Subscribe void onItemContainerChanged(ItemContainerChanged event) { final ItemContainer container = event.getItemContainer(); if (!inMlm || !shouldUpdateOres || inventorySnapshot == null || container != client.getItemContainer(InventoryID.INVENTORY)) { return; } // Build set of current inventory Multiset<Integer> current = HashMultiset.create(); Arrays.stream(container.getItems()) .filter(item -> MLM_ORE_TYPES.contains(item.getId())) .forEach(item -> current.add(item.getId(), item.getQuantity())); // Take the difference Multiset<Integer> delta = Multisets.difference(current, inventorySnapshot); // Update the session delta.forEachEntry(session::updateOreFound); inventorySnapshot = null; shouldUpdateOres = false; }
Example #11
Source File: GetJobsAction.java From spinach with Apache License 2.0 | 6 votes |
private void reconnectToNearestProducer(DisqueConnection<K, V> disqueConnection, boolean forcedReconnect) { log.debug("reconnectToNearestProducer()"); Set<Multiset.Entry<String>> stats = Multisets.copyHighestCountFirst(nodePrefixes).entrySet(); nodePrefixes.clear(); if (!isNodeSwitchNecessary(stats) && !forcedReconnect) { return; } String nodeIdPrefix = getNodeIdPrefix(stats); if (nodeIdPrefix != null) { log.debug("Set preferred node prefix to {}", nodeIdPrefix); socketAddressSupplier.setPreferredNodeIdPrefix(nodeIdPrefix); } if (disqueConnection.isOpen()) { if (nodeIdPrefix == null) { log.info("Initiating reconnect"); } else { log.info("Initiating reconnect to preferred node with prefix {}", nodeIdPrefix); } disconnect((RedisChannelHandler<?, ?>) disqueConnection); } }
Example #12
Source File: Word2VecTrainer.java From Word2VecJava with MIT License | 6 votes |
/** @return Tokens with their count, sorted by frequency decreasing, then lexicographically ascending */ private ImmutableMultiset<String> filterAndSort(final Multiset<String> counts) { // This isn't terribly efficient, but it is deterministic // Unfortunately, Guava's multiset doesn't give us a clean way to order both by count and element return Multisets.copyHighestCountFirst( ImmutableSortedMultiset.copyOf( Multisets.filter( counts, new Predicate<String>() { @Override public boolean apply(String s) { return counts.count(s) >= minFrequency; } } ) ) ); }
Example #13
Source File: TimeGraphViewTest.java From tracecompass with Eclipse Public License 2.0 | 6 votes |
/** * Test the line entries */ @Test public void testTimeLine() { String lines = "pulse"; resetTimeRange(); SWTBotTimeGraph timegraph = fTimeGraph; assertEquals(0, timegraph.selection().columnCount()); ImageHelper currentImage = ImageHelper.waitForNewImage(fBounds, null); SWTBotTimeGraphEntry entry = timegraph.getEntry(lines); // make sure it's visible entry = timegraph.getEntry(lines).select(); ImageHelper.waitForNewImage(fBounds, currentImage); Rectangle rect = entry.absoluteLocation(); ImageHelper image = ImageHelper.grabImage(rect); ImmutableMultiset<RGB> ms = Multisets.copyHighestCountFirst(image.getHistogram()); int black = ms.count(new RGB(0, 0, 0)); RGB bgColor = ms.elementSet().iterator().next(); int bgCount = ms.count(bgColor); float actual = ((float) black) / (bgCount); assertEquals(0.113f, actual, 0.05f); }
Example #14
Source File: QueryAssertions.java From presto with Apache License 2.0 | 6 votes |
public static void assertEqualsIgnoreOrder(Iterable<?> actual, Iterable<?> expected, String message) { assertNotNull(actual, "actual is null"); assertNotNull(expected, "expected is null"); ImmutableMultiset<?> actualSet = ImmutableMultiset.copyOf(actual); ImmutableMultiset<?> expectedSet = ImmutableMultiset.copyOf(expected); if (!actualSet.equals(expectedSet)) { Multiset<?> unexpectedRows = Multisets.difference(actualSet, expectedSet); Multiset<?> missingRows = Multisets.difference(expectedSet, actualSet); int limit = 100; fail(format( "%snot equal\n" + "Actual rows (up to %s of %s extra rows shown, %s rows in total):\n %s\n" + "Expected rows (up to %s of %s missing rows shown, %s rows in total):\n %s\n", message == null ? "" : (message + "\n"), limit, unexpectedRows.size(), actualSet.size(), Joiner.on("\n ").join(Iterables.limit(unexpectedRows, limit)), limit, missingRows.size(), expectedSet.size(), Joiner.on("\n ").join(Iterables.limit(missingRows, limit)))); } }
Example #15
Source File: MotherlodePlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
@Subscribe public void onItemContainerChanged(ItemContainerChanged event) { final ItemContainer container = event.getItemContainer(); if (!inMlm || !shouldUpdateOres || inventorySnapshot == null || container != client.getItemContainer(InventoryID.INVENTORY)) { return; } // Build set of current inventory Multiset<Integer> current = HashMultiset.create(); Arrays.stream(container.getItems()) .filter(item -> MLM_ORE_TYPES.contains(item.getId())) .forEach(item -> current.add(item.getId(), item.getQuantity())); // Take the difference Multiset<Integer> delta = Multisets.difference(current, inventorySnapshot); // Update the session delta.forEachEntry(session::updateOreFound); inventorySnapshot = null; shouldUpdateOres = false; }
Example #16
Source File: LootTrackerPlugin.java From runelite with BSD 2-Clause "Simplified" License | 6 votes |
private void processInventoryLoot(String event, LootRecordType lootRecordType, ItemContainer inventoryContainer, Collection<ItemStack> groundItems) { if (inventorySnapshot != null) { Multiset<Integer> currentInventory = HashMultiset.create(); Arrays.stream(inventoryContainer.getItems()) .forEach(item -> currentInventory.add(item.getId(), item.getQuantity())); groundItems.stream() .forEach(item -> currentInventory.add(item.getId(), item.getQuantity())); final Multiset<Integer> diff = Multisets.difference(currentInventory, inventorySnapshot); List<ItemStack> items = diff.entrySet().stream() .map(e -> new ItemStack(e.getElement(), e.getCount(), client.getLocalPlayer().getLocalLocation())) .collect(Collectors.toList()); addLoot(event, -1, lootRecordType, items); inventorySnapshot = null; } }
Example #17
Source File: CollectionUtil.java From tassal with BSD 3-Clause "New" or "Revised" License | 5 votes |
/** * Return the elements that have been seen at least nSeen times. * * @param nSeen * @param baseMultiset * @return */ public static <T> Set<T> getElementsUpToCount(final int nSeen, final Multiset<T> baseMultiset) { checkArgument(nSeen > 0); final Set<T> toKeep = Sets.newHashSet(); for (final Entry<T> entry : Multisets.copyHighestCountFirst( checkNotNull(baseMultiset)).entrySet()) { if (entry.getCount() < nSeen) { break; } toKeep.add(entry.getElement()); } return toKeep; }
Example #18
Source File: BootstrappedPerEventResultWriter.java From tac-kbp-eal with MIT License | 5 votes |
@Override public void observeSample(final Iterable<EALScorer2015Style.Result> perDocResults) { // TODO: refactor this with non-bootstrapped version final Multiset<Symbol> eventTypesSeen = ByEventTypeResultWriter.gatherEventTypesSeen(perDocResults); for (final Multiset.Entry<Symbol> typeEntry : Multisets.copyHighestCountFirst(eventTypesSeen) .entrySet()) { final Symbol type = typeEntry.getElement(); final Function<EALScorer2015Style.ArgResult, EALScorer2015Style.ArgResult> filterFunction = new Function<EALScorer2015Style.ArgResult, EALScorer2015Style.ArgResult>() { @Override public EALScorer2015Style.ArgResult apply(final EALScorer2015Style.ArgResult input) { return input .copyFiltered(compose(equalTo(type), TypeRoleFillerRealisFunctions.type())); } }; final ImmutableList<EALScorer2015Style.ArgResult> relevantArgumentScores = FluentIterable.from(perDocResults).transform(ByEventTypeResultWriter.GET_ARG_SCORES_ONLY) .transform(filterFunction) .toList(); eventTypeToArgScores.put(typeEntry.getElement().asString(), AggregateResultWriter.computeArgScoresFromArgResults(relevantArgumentScores)); } }
Example #19
Source File: Validator.java From presto with Apache License 2.0 | 5 votes |
public String getResultsComparison(int precision) { List<List<Object>> controlResults = controlResult.getResults(); List<List<Object>> testResults = testResult.getResults(); if (valid() || (controlResults == null) || (testResults == null)) { return ""; } Multiset<List<Object>> control = ImmutableSortedMultiset.copyOf(rowComparator(precision), controlResults); Multiset<List<Object>> test = ImmutableSortedMultiset.copyOf(rowComparator(precision), testResults); try { Iterable<ChangedRow> diff = ImmutableSortedMultiset.<ChangedRow>naturalOrder() .addAll(Iterables.transform(Multisets.difference(control, test), row -> new ChangedRow(Changed.REMOVED, row, precision))) .addAll(Iterables.transform(Multisets.difference(test, control), row -> new ChangedRow(Changed.ADDED, row, precision))) .build(); diff = Iterables.limit(diff, 100); StringBuilder sb = new StringBuilder(); sb.append(format("Control %s rows, Test %s rows%n", control.size(), test.size())); if (verboseResultsComparison) { Joiner.on("\n").appendTo(sb, diff); } else { sb.append("RESULTS DO NOT MATCH\n"); } return sb.toString(); } catch (TypesDoNotMatchException e) { return e.getMessage(); } }
Example #20
Source File: AbstractAtomicMultimapService.java From atomix with Apache License 2.0 | 5 votes |
@Override public IteratorBatch<Multiset.Entry<byte[]>> nextValuesSet(long iteratorId, int position) { IteratorContext context = entryIterators.get(iteratorId); if (context == null) { return null; } List<Multiset.Entry<byte[]>> entries = new ArrayList<>(); int size = 0; while (context.iterator.hasNext()) { context.position++; if (context.position > position) { Map.Entry<String, MapEntryValues> entry = context.iterator.next(); if (!entry.getValue().values().isEmpty()) { byte[] value = entry.getValue().values().iterator().next(); int count = entry.getValue().values().size(); size += value.length + 4; entries.add(Multisets.immutableEntry(value, count)); } if (size >= MAX_ITERATOR_BATCH_SIZE) { break; } } } if (entries.isEmpty()) { return null; } return new IteratorBatch<>(iteratorId, context.position, entries, !context.iterator.hasNext()); }
Example #21
Source File: DefaultDistributedMultisetService.java From atomix with Apache License 2.0 | 5 votes |
@Override public IteratorBatch<Multiset.Entry<String>> nextEntries(long iteratorId, int position) { IteratorContext context = entryIterators.get(iteratorId); if (context == null) { return null; } List<Multiset.Entry<String>> entries = new ArrayList<>(); int size = 0; while (context.iterator.hasNext()) { context.position++; if (context.position > position) { Multiset.Entry<String> entry = context.iterator.next(); entries.add(Multisets.immutableEntry(entry.getElement(), entry.getCount())); size += entry.getElement().length() + 4; if (size >= MAX_ITERATOR_BATCH_SIZE) { break; } } } if (entries.isEmpty()) { return null; } return new IteratorBatch<>(iteratorId, context.position, entries, !context.iterator.hasNext()); }
Example #22
Source File: TranscodingAsyncDistributedMultiset.java From atomix with Apache License 2.0 | 5 votes |
@Override public AsyncDistributedSet<Multiset.Entry<E1>> entrySet() { Function<Multiset.Entry<E1>, Multiset.Entry<E2>> entryEncoder = entry -> Multisets.immutableEntry(elementEncoder.apply(entry.getElement()), entry.getCount()); Function<Multiset.Entry<E2>, Multiset.Entry<E1>> entryDecoder = entry -> Multisets.immutableEntry(elementDecoder.apply(entry.getElement()), entry.getCount()); return new TranscodingAsyncDistributedSet<>(backingMultiset.entrySet(), entryEncoder, entryDecoder); }
Example #23
Source File: SPARQLInferenceTest.java From neo4j-sparql-extension with GNU General Public License v3.0 | 5 votes |
@Test public void subset() throws QueryEvaluationException, TupleQueryResultHandlerException, IOException, QueryResultParseException, QueryResultHandlerException { QueryResult q = this.runQuery(); assertTrue( q.getNonInferred() + " should be a subset of " + q.getActual(), Multisets.containsOccurrences( q.getActual(), q.getNonInferred() )); }
Example #24
Source File: MultisetType.java From javers with Apache License 2.0 | 5 votes |
/** * @return immutable Multiset */ @Override public Object map(Object sourceEnumerable, EnumerableFunction mapFunction, OwnerContext owner) { Validate.argumentIsNotNull(mapFunction); Multiset sourceMultiset = toNotNullMultiset(sourceEnumerable); Multiset targetMultiset = HashMultiset.create(); EnumerationAwareOwnerContext enumeratorContext = new EnumerationAwareOwnerContext(owner, true); for (Object sourceVal : sourceMultiset) { targetMultiset.add(mapFunction.apply(sourceVal, enumeratorContext)); } return Multisets.unmodifiableMultiset(targetMultiset); }
Example #25
Source File: MultisetProperty.java From FreeBuilder with Apache License 2.0 | 5 votes |
private void addGetter(SourceBuilder code) { code.addLine("") .addLine("/**") .addLine(" * Returns an unmodifiable view of the multiset that will be returned by") .addLine(" * %s.", datatype.getType().javadocNoArgMethodLink(property.getGetterName())) .addLine(" * Changes to this builder will be reflected in the view.") .addLine(" */") .addLine("public %s<%s> %s() {", Multiset.class, elementType, getter(property)) .addLine(" return %s.unmodifiableMultiset(%s);", Multisets.class, property.getField()) .addLine("}"); }
Example #26
Source File: CollectionUtil.java From api-mining with GNU General Public License v3.0 | 5 votes |
/** * Return the elements that have been seen at least nSeen times. * * @param nSeen * @param baseMultiset * @return */ public static <T> Set<T> getElementsUpToCount(final int nSeen, final Multiset<T> baseMultiset) { checkArgument(nSeen > 0); final Set<T> toKeep = Sets.newHashSet(); for (final Entry<T> entry : Multisets.copyHighestCountFirst( checkNotNull(baseMultiset)).entrySet()) { if (entry.getCount() < nSeen) { break; } toKeep.add(entry.getElement()); } return toKeep; }
Example #27
Source File: LinkArrayWritable.java From wikireverse with MIT License | 5 votes |
public String getMostUsedArticleCasing() { HashMultiset<String> articleNames = HashMultiset.create(); String result; for (Writable writable: super.get()) { LinkWritable link = (LinkWritable)writable; articleNames.add(link.getArticle().toString()); } ImmutableMultiset<String> sorted = Multisets.copyHighestCountFirst(articleNames); result = (String)sorted.elementSet().toArray()[0]; return result; }
Example #28
Source File: Util.java From EasySRL with Apache License 2.0 | 5 votes |
public static <T> void print(final Multiset<T> multiset, final int number) { int i = 0; for (final T type : Multisets.copyHighestCountFirst(multiset).elementSet()) { System.out.println(type + ": " + multiset.count(type)); i++; if (i == number) { break; } } System.out.println(); }
Example #29
Source File: SeenRules.java From EasySRL with Apache License 2.0 | 5 votes |
private static void makeFromCorpus(final ParallelCorpusReader corpus) throws IOException { final Iterator<Sentence> sentences = corpus.readCorpus(false); final Multiset<String> result = HashMultiset.create(); while (sentences.hasNext()) { final Sentence sentence = sentences.next(); getRulesFromParse(sentence.getCcgbankParse(), result); } for (final String rule : Multisets.copyHighestCountFirst(result).elementSet()) { System.out.println(rule); } }
Example #30
Source File: LootTrackerPlugin.java From plugins with GNU General Public License v3.0 | 4 votes |
private void processInventoryLoot(String event, LootRecordType lootRecordType, ItemContainer inventoryContainer, Collection<ItemStack> groundItems) { if (client.getLocalPlayer() == null) { return; } if (inventorySnapshot != null) { Multiset<Integer> currentInventory = HashMultiset.create(); Arrays.stream(inventoryContainer.getItems()) .forEach(item -> currentInventory.add(item.getId(), item.getQuantity())); groundItems .forEach(item -> currentInventory.add(item.getId(), item.getQuantity())); final Multiset<Integer> diff = Multisets.difference(currentInventory, inventorySnapshot); List<ItemStack> items = diff.entrySet().stream() .map(e -> new ItemStack(e.getElement(), e.getCount(), client.getLocalPlayer().getLocalLocation())) .collect(Collectors.toList()); if (gotPet) { ItemStack pet = null; switch (event) { case HERBIBOAR_EVENT: pet = handlePet("Herbiboar"); break; case WINTERTODT_EVENT: pet = handlePet("Wintertodt"); break; case GAUNTLET_EVENT: pet = handlePet("Gauntlet"); break; } if (pet == null) { log.warn("Error finding pet for npc name: Herbiboar"); } else { items.add(pet); } } final LootTrackerItem[] entries = buildEntries(stack(items)); LootRecord lootRecord = new LootRecord(event, client.getLocalPlayer().getName(), LootRecordType.EVENT, toGameItems(items), Instant.now()); SwingUtilities.invokeLater(() -> panel.add(event, client.getLocalPlayer().getName(), lootRecord.getType(), -1, entries)); if (config.saveLoot()) { synchronized (queuedLoots) { queuedLoots.add(lootRecord); } } if (config.localPersistence()) { saveLocalLootRecord(lootRecord); } eventBus.post(LootReceived.class, new LootReceived(event, -1, LootRecordType.EVENT, items)); inventorySnapshot = null; } }