package com.discord.stores; import android.content.Context; import com.discord.api.commands.GuildApplicationCommands; import com.discord.models.commands.Application; import com.discord.models.commands.ApplicationCommand; import com.discord.models.user.User; import com.discord.stores.DiscoverCommands; import com.discord.stores.updates.ObservationDeck; import com.discord.stores.updates.ObservationDeckProvider; import com.discord.utilities.permissions.PermissionUtils; import com.discord.utilities.rest.RestAPI; import com.discord.utilities.rx.ObservableExtensionsKt; import d0.d0.f; import d0.g0.t; import d0.t.g0; import d0.t.h0; import d0.t.n; import d0.t.o; import d0.t.s; import d0.t.u; import d0.z.d.m; import java.util.ArrayList; import java.util.Collection; import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import kotlin.jvm.functions.Function0; import kotlin.jvm.functions.Function1; import kotlin.jvm.internal.DefaultConstructorMarker; import kotlin.jvm.internal.Ref$IntRef; import rx.Observable; /* compiled from: StoreApplicationCommands.kt */ public final class StoreApplicationCommands extends StoreV2 { public static final int COMMANDS_LIMIT_PER_REQUEST = 20; public static final Companion Companion = new Companion(null); private static final ObservationDeck.UpdateSource DiscoverCommandsUpdate = new StoreApplicationCommands$Companion$DiscoverCommandsUpdate$1(); private static final ObservationDeck.UpdateSource GuildApplicationsUpdate = new StoreApplicationCommands$Companion$GuildApplicationsUpdate$1(); private static final ObservationDeck.UpdateSource QueryCommandsUpdate = new StoreApplicationCommands$Companion$QueryCommandsUpdate$1(); public static final long TYPE_APPLICATION_COMMAND = 2; private Map applicationCommandIndexes; private String applicationNonce; private List applications; private Map applicationsMapSnapshot; private List applicationsSnapshot; private final BuiltInCommandsProvider builtInCommandsProvider; private boolean connectionReady; private int currentEndOffset; private int currentStartOffset; private Long discoverApplicationId; private DiscoverCommands discoverCommands; private String discoverCommandsNonce; private DiscoverCommands discoverCommandsSnapshot; private Long discoverGuildId; private final Dispatcher dispatcher; private boolean isLoadingDiscoveryCommands; private Long jumpedApplicationId; private int jumpedSequenceId; private boolean loadDirectionDown; private boolean loadDirectionUp; private int nonceCounter; private int numRemoteCommands; private final ObservationDeck observationDeck; private Long pendingGatewayGuildId; private String query; private final List queryCommands; private List queryCommandsSnapshot; private Long queryGuildId; private String queryNonce; private final RestAPI restApi; private final StoreGatewayConnection storeGatewayConnection; private final StoreGuilds storeGuilds; private final StorePermissions storePermissions; private final StoreUser storeUsers; /* compiled from: StoreApplicationCommands.kt */ public static final class Companion { private Companion() { } public /* synthetic */ Companion(DefaultConstructorMarker defaultConstructorMarker) { this(); } public final ObservationDeck.UpdateSource getDiscoverCommandsUpdate() { return StoreApplicationCommands.access$getDiscoverCommandsUpdate$cp(); } public final ObservationDeck.UpdateSource getGuildApplicationsUpdate() { return StoreApplicationCommands.access$getGuildApplicationsUpdate$cp(); } public final ObservationDeck.UpdateSource getQueryCommandsUpdate() { return StoreApplicationCommands.access$getQueryCommandsUpdate$cp(); } } public StoreApplicationCommands(StoreGatewayConnection storeGatewayConnection, StorePermissions storePermissions, StoreGuilds storeGuilds, StoreUser storeUser, Dispatcher dispatcher, RestAPI restAPI, ObservationDeck observationDeck, BuiltInCommandsProvider builtInCommandsProvider) { m.checkNotNullParameter(storeGatewayConnection, "storeGatewayConnection"); m.checkNotNullParameter(storePermissions, "storePermissions"); m.checkNotNullParameter(storeGuilds, "storeGuilds"); m.checkNotNullParameter(storeUser, "storeUsers"); m.checkNotNullParameter(dispatcher, "dispatcher"); m.checkNotNullParameter(restAPI, "restApi"); m.checkNotNullParameter(observationDeck, "observationDeck"); m.checkNotNullParameter(builtInCommandsProvider, "builtInCommandsProvider"); this.storeGatewayConnection = storeGatewayConnection; this.storePermissions = storePermissions; this.storeGuilds = storeGuilds; this.storeUsers = storeUser; this.dispatcher = dispatcher; this.restApi = restAPI; this.observationDeck = observationDeck; this.builtInCommandsProvider = builtInCommandsProvider; DiscoverCommands.Companion companion = DiscoverCommands.Companion; this.discoverCommands = companion.getDefaultModelDiscoveryCommands(); this.discoverCommandsSnapshot = companion.getDefaultModelDiscoveryCommands(); this.applicationCommandIndexes = new LinkedHashMap(); this.applications = n.emptyList(); this.applicationsSnapshot = n.emptyList(); this.applicationsMapSnapshot = h0.emptyMap(); this.queryCommands = new ArrayList(); this.queryCommandsSnapshot = n.emptyList(); } /* JADX INFO: this call moved to the top of the method (can break code semantics) */ public /* synthetic */ StoreApplicationCommands(StoreGatewayConnection storeGatewayConnection, StorePermissions storePermissions, StoreGuilds storeGuilds, StoreUser storeUser, Dispatcher dispatcher, RestAPI restAPI, ObservationDeck observationDeck, BuiltInCommandsProvider builtInCommandsProvider, int i, DefaultConstructorMarker defaultConstructorMarker) { this(storeGatewayConnection, storePermissions, storeGuilds, storeUser, dispatcher, (i & 32) != 0 ? RestAPI.Companion.getApi() : restAPI, (i & 64) != 0 ? ObservationDeckProvider.get() : observationDeck, (i & 128) != 0 ? new BuiltInCommands() : builtInCommandsProvider); } public static final /* synthetic */ String access$generateNonce(StoreApplicationCommands storeApplicationCommands) { return storeApplicationCommands.generateNonce(); } public static final /* synthetic */ Map access$getApplicationCommandIndexes$p(StoreApplicationCommands storeApplicationCommands) { return storeApplicationCommands.applicationCommandIndexes; } public static final /* synthetic */ void access$getApplicationCommandsViaRest(StoreApplicationCommands storeApplicationCommands, long j) { storeApplicationCommands.getApplicationCommandsViaRest(j); } public static final /* synthetic */ String access$getApplicationNonce$p(StoreApplicationCommands storeApplicationCommands) { return storeApplicationCommands.applicationNonce; } public static final /* synthetic */ List access$getApplications$p(StoreApplicationCommands storeApplicationCommands) { return storeApplicationCommands.applications; } public static final /* synthetic */ BuiltInCommandsProvider access$getBuiltInCommandsProvider$p(StoreApplicationCommands storeApplicationCommands) { return storeApplicationCommands.builtInCommandsProvider; } public static final /* synthetic */ Long access$getDiscoverApplicationId$p(StoreApplicationCommands storeApplicationCommands) { return storeApplicationCommands.discoverApplicationId; } public static final /* synthetic */ DiscoverCommands access$getDiscoverCommands$p(StoreApplicationCommands storeApplicationCommands) { return storeApplicationCommands.discoverCommands; } public static final /* synthetic */ String access$getDiscoverCommandsNonce$p(StoreApplicationCommands storeApplicationCommands) { return storeApplicationCommands.discoverCommandsNonce; } public static final /* synthetic */ ObservationDeck.UpdateSource access$getDiscoverCommandsUpdate$cp() { return DiscoverCommandsUpdate; } public static final /* synthetic */ Long access$getDiscoverGuildId$p(StoreApplicationCommands storeApplicationCommands) { return storeApplicationCommands.discoverGuildId; } public static final /* synthetic */ Dispatcher access$getDispatcher$p(StoreApplicationCommands storeApplicationCommands) { return storeApplicationCommands.dispatcher; } public static final /* synthetic */ ObservationDeck.UpdateSource access$getGuildApplicationsUpdate$cp() { return GuildApplicationsUpdate; } public static final /* synthetic */ Long access$getPendingGatewayGuildId$p(StoreApplicationCommands storeApplicationCommands) { return storeApplicationCommands.pendingGatewayGuildId; } public static final /* synthetic */ String access$getQuery$p(StoreApplicationCommands storeApplicationCommands) { return storeApplicationCommands.query; } public static final /* synthetic */ List access$getQueryCommands$p(StoreApplicationCommands storeApplicationCommands) { return storeApplicationCommands.queryCommands; } public static final /* synthetic */ ObservationDeck.UpdateSource access$getQueryCommandsUpdate$cp() { return QueryCommandsUpdate; } public static final /* synthetic */ Long access$getQueryGuildId$p(StoreApplicationCommands storeApplicationCommands) { return storeApplicationCommands.queryGuildId; } public static final /* synthetic */ String access$getQueryNonce$p(StoreApplicationCommands storeApplicationCommands) { return storeApplicationCommands.queryNonce; } public static final /* synthetic */ StoreGatewayConnection access$getStoreGatewayConnection$p(StoreApplicationCommands storeApplicationCommands) { return storeApplicationCommands.storeGatewayConnection; } public static final /* synthetic */ StorePermissions access$getStorePermissions$p(StoreApplicationCommands storeApplicationCommands) { return storeApplicationCommands.storePermissions; } public static final /* synthetic */ void access$handleDiscoverCommandsUpdate(StoreApplicationCommands storeApplicationCommands, List list) { storeApplicationCommands.handleDiscoverCommandsUpdate(list); } public static final /* synthetic */ void access$handleGuildApplicationsUpdate(StoreApplicationCommands storeApplicationCommands, List list) { storeApplicationCommands.handleGuildApplicationsUpdate(list); } public static final /* synthetic */ void access$handleQueryCommandsUpdate(StoreApplicationCommands storeApplicationCommands, List list) { storeApplicationCommands.handleQueryCommandsUpdate(list); } public static final /* synthetic */ boolean access$isLoadingDiscoveryCommands$p(StoreApplicationCommands storeApplicationCommands) { return storeApplicationCommands.isLoadingDiscoveryCommands; } public static final /* synthetic */ void access$setApplicationCommandIndexes$p(StoreApplicationCommands storeApplicationCommands, Map map) { storeApplicationCommands.applicationCommandIndexes = map; } public static final /* synthetic */ void access$setApplicationNonce$p(StoreApplicationCommands storeApplicationCommands, String str) { storeApplicationCommands.applicationNonce = str; } public static final /* synthetic */ void access$setApplications$p(StoreApplicationCommands storeApplicationCommands, List list) { storeApplicationCommands.applications = list; } public static final /* synthetic */ void access$setDiscoverApplicationId$p(StoreApplicationCommands storeApplicationCommands, Long l) { storeApplicationCommands.discoverApplicationId = l; } public static final /* synthetic */ void access$setDiscoverCommands$p(StoreApplicationCommands storeApplicationCommands, DiscoverCommands discoverCommands) { storeApplicationCommands.discoverCommands = discoverCommands; } public static final /* synthetic */ void access$setDiscoverCommandsNonce$p(StoreApplicationCommands storeApplicationCommands, String str) { storeApplicationCommands.discoverCommandsNonce = str; } public static final /* synthetic */ void access$setDiscoverGuildId$p(StoreApplicationCommands storeApplicationCommands, Long l) { storeApplicationCommands.discoverGuildId = l; } public static final /* synthetic */ void access$setLoadingDiscoveryCommands$p(StoreApplicationCommands storeApplicationCommands, boolean z2) { storeApplicationCommands.isLoadingDiscoveryCommands = z2; } public static final /* synthetic */ void access$setPendingGatewayGuildId$p(StoreApplicationCommands storeApplicationCommands, Long l) { storeApplicationCommands.pendingGatewayGuildId = l; } public static final /* synthetic */ void access$setQuery$p(StoreApplicationCommands storeApplicationCommands, String str) { storeApplicationCommands.query = str; } public static final /* synthetic */ void access$setQueryGuildId$p(StoreApplicationCommands storeApplicationCommands, Long l) { storeApplicationCommands.queryGuildId = l; } public static final /* synthetic */ void access$setQueryNonce$p(StoreApplicationCommands storeApplicationCommands, String str) { storeApplicationCommands.queryNonce = str; } public static final /* synthetic */ boolean access$shouldReturnApplicationCommands(StoreApplicationCommands storeApplicationCommands, Long l) { return storeApplicationCommands.shouldReturnApplicationCommands(l); } @StoreThread private final String generateNonce() { int i = this.nonceCounter; this.nonceCounter = i + 1; return String.valueOf(i); } private final void getApplicationCommandsViaRest(long j) { ObservableExtensionsKt.appSubscribe$default(ObservableExtensionsKt.restSubscribeOn$default(this.restApi.getApplicationCommands(j), false, 1, null), StoreApplicationCommands.class, (Context) null, (Function1) null, new StoreApplicationCommands$getApplicationCommandsViaRest$2(this), (Function0) null, (Function0) null, new StoreApplicationCommands$getApplicationCommandsViaRest$1(this, j), 54, (Object) null); } @StoreThread private final void handleDiscoverCommandsUpdate(List list) { this.isLoadingDiscoveryCommands = false; List mutableList = u.toMutableList((Collection) this.discoverCommands.getCommands()); int size = mutableList.size(); Long l = this.jumpedApplicationId; if (l != null) { mutableList = u.toMutableList((Collection) list); Integer num = this.applicationCommandIndexes.get(l); this.currentStartOffset = num != null ? num.intValue() : 0; } else if (this.loadDirectionUp) { ArrayList arrayList = new ArrayList(); for (Object obj : list) { ApplicationCommand applicationCommand = (ApplicationCommand) obj; ArrayList arrayList2 = new ArrayList(o.collectionSizeOrDefault(mutableList, 10)); for (ApplicationCommand applicationCommand2 : mutableList) { arrayList2.add(applicationCommand2.getId()); } if (!arrayList2.contains(applicationCommand.getId())) { arrayList.add(obj); } } for (ApplicationCommand applicationCommand3 : s.asReversed(arrayList)) { mutableList.add(0, applicationCommand3); } this.currentStartOffset -= mutableList.size() - size; } else if (this.loadDirectionDown) { ArrayList arrayList3 = new ArrayList(); for (Object obj2 : list) { ApplicationCommand applicationCommand4 = (ApplicationCommand) obj2; ArrayList arrayList4 = new ArrayList(o.collectionSizeOrDefault(mutableList, 10)); for (ApplicationCommand applicationCommand5 : mutableList) { arrayList4.add(applicationCommand5.getId()); } if (!arrayList4.contains(applicationCommand4.getId())) { arrayList3.add(obj2); } } mutableList = u.toMutableList((Collection) u.plus((Collection) mutableList, (Iterable) arrayList3)); } else { mutableList = u.toMutableList((Collection) list); this.currentStartOffset = 0; } if ((mutableList.size() + this.currentStartOffset) - 1 == this.numRemoteCommands - 1) { mutableList.addAll(this.builtInCommandsProvider.getBuiltInCommands()); } this.currentEndOffset = (mutableList.size() + this.currentStartOffset) - 1; this.discoverCommands = new DiscoverCommands(mutableList, this.currentStartOffset, this.currentEndOffset, this.currentStartOffset > 0 && (mutableList.isEmpty() ^ true), this.currentEndOffset < this.numRemoteCommands - 1, this.jumpedSequenceId, this.jumpedApplicationId); markChanged(DiscoverCommandsUpdate); } @StoreThread private final void handleGuildApplicationsUpdate(List list) { this.applications = list; this.numRemoteCommands = 0; int i = 0; for (Application application : list) { this.applicationCommandIndexes.put(Long.valueOf(application.getId()), Integer.valueOf(i)); i += application.getCommandCount(); if (!application.getBuiltIn()) { this.numRemoteCommands = application.getCommandCount() + this.numRemoteCommands; } } markChanged(GuildApplicationsUpdate); } @StoreThread private final void handleQueryCommandsUpdate(List list) { this.queryCommands.clear(); this.queryCommands.addAll(list); String str = this.query; if (str != null) { List list2 = this.queryCommands; List builtInCommands = this.builtInCommandsProvider.getBuiltInCommands(); ArrayList arrayList = new ArrayList(); for (Object obj : builtInCommands) { if (t.startsWith(((ApplicationCommand) obj).getName(), str, true)) { arrayList.add(obj); } } list2.addAll(arrayList); } markChanged(QueryCommandsUpdate); } private final void requestApplicationCommands(Long l, int i, Long l2, int i2) { this.dispatcher.schedule(new StoreApplicationCommands$requestApplicationCommands$1(this, l, i, i2, l2)); } public static /* synthetic */ void requestApplicationCommands$default(StoreApplicationCommands storeApplicationCommands, Long l, int i, Long l2, int i2, int i3, Object obj) { if ((i3 & 2) != 0) { i = 0; } if ((i3 & 4) != 0) { l2 = null; } if ((i3 & 8) != 0) { i2 = 20; } storeApplicationCommands.requestApplicationCommands(l, i, l2, i2); } private final boolean shouldReturnApplicationCommands(Long l) { Long l2 = this.discoverGuildId; return l2 == null || (l2 != null && l2.longValue() == 0) || PermissionUtils.can(2147483648L, l); } public final void clearQueryCommands() { this.dispatcher.schedule(new StoreApplicationCommands$clearQueryCommands$1(this)); } public final Map getApplicationMap() { return this.applicationsMapSnapshot; } public final List getApplications() { return this.applicationsSnapshot; } public final DiscoverCommands getDiscoverCommands() { return this.discoverCommandsSnapshot; } /* JADX DEBUG: Type inference failed for r0v0. Raw type applied. Possible types: java.util.List, java.util.List */ public final List getQueryCommands() { return this.queryCommandsSnapshot; } @StoreThread public final void handleApplicationCommandsUpdate(GuildApplicationCommands guildApplicationCommands) { m.checkNotNullParameter(guildApplicationCommands, "commandsGateway"); String c2 = guildApplicationCommands.c(); if (m.areEqual(c2, this.applicationNonce)) { List b = guildApplicationCommands.b(); ArrayList arrayList = new ArrayList(o.collectionSizeOrDefault(b, 10)); for (com.discord.api.commands.Application application : b) { arrayList.add(StoreApplicationCommandsKt.toDomainApplication(application)); } handleGuildApplicationsUpdate(u.plus((Collection) u.sortedWith(arrayList, new StoreApplicationCommands$handleApplicationCommandsUpdate$$inlined$sortedBy$1()), this.builtInCommandsProvider.getBuiltInApplication())); } else if (m.areEqual(c2, this.queryNonce)) { List a = guildApplicationCommands.a(); ArrayList arrayList2 = new ArrayList(o.collectionSizeOrDefault(a, 10)); for (com.discord.api.commands.ApplicationCommand applicationCommand : a) { arrayList2.add(StoreApplicationCommandsKt.toSlashCommand(applicationCommand)); } handleQueryCommandsUpdate(arrayList2); } else if (m.areEqual(c2, this.discoverCommandsNonce)) { List a2 = guildApplicationCommands.a(); ArrayList arrayList3 = new ArrayList(o.collectionSizeOrDefault(a2, 10)); for (com.discord.api.commands.ApplicationCommand applicationCommand2 : a2) { arrayList3.add(StoreApplicationCommandsKt.toSlashCommand(applicationCommand2)); } handleDiscoverCommandsUpdate(arrayList3); } } public final void handleConnectionReady(boolean z2) { Long l; this.connectionReady = z2; if (z2 && (l = this.pendingGatewayGuildId) != null) { requestApplications(l.longValue()); this.pendingGatewayGuildId = null; } } public final void handleDmUserApplication(User user) { m.checkNotNullParameter(user, "botUser"); if (user.isBot()) { this.dispatcher.schedule(new StoreApplicationCommands$handleDmUserApplication$1(this, user)); } } public final boolean hasFetchedApplicationCommands(long j) { Integer num = this.applicationCommandIndexes.get(Long.valueOf(j)); if (num == null) { return false; } int intValue = num.intValue(); return this.currentStartOffset <= intValue && this.currentEndOffset >= intValue; } public final Observable observeDiscoverCommands(long j) { Observable j2 = Observable.j(ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{DiscoverCommandsUpdate}, false, null, null, new StoreApplicationCommands$observeDiscoverCommands$1(this), 14, null).r(), this.storePermissions.observePermissionsForChannel(j), new StoreApplicationCommands$observeDiscoverCommands$2(this)); m.checkNotNullExpressionValue(j2, "Observable\n .comb… )\n }\n }"); return j2; } public final Observable> observeGuildApplications(long j) { return ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{GuildApplicationsUpdate, this.storePermissions}, false, null, null, new StoreApplicationCommands$observeGuildApplications$1(this, j), 14, null); } public final Observable> observeQueryCommands(long j) { Observable> r = ObservationDeck.connectRx$default(this.observationDeck, new ObservationDeck.UpdateSource[]{QueryCommandsUpdate, this.storePermissions}, false, null, null, new StoreApplicationCommands$observeQueryCommands$1(this, j), 14, null).r(); m.checkNotNullExpressionValue(r, "observationDeck.connectR… }.distinctUntilChanged()"); return r; } public final void requestApplicationCommandsQuery(Long l, String str) { m.checkNotNullParameter(str, "query"); this.dispatcher.schedule(new StoreApplicationCommands$requestApplicationCommandsQuery$1(this, l, str)); } public final void requestApplications(long j) { if (!this.connectionReady) { this.pendingGatewayGuildId = Long.valueOf(j); } else { this.dispatcher.schedule(new StoreApplicationCommands$requestApplications$1(this, j)); } } public final void requestDiscoverCommands(long j) { Long l = this.discoverGuildId; if (l != null) { l.longValue(); requestInitialApplicationCommands(l, Long.valueOf(j)); } } public final void requestInitialApplicationCommands(Long l, Long l2) { Ref$IntRef ref$IntRef = new Ref$IntRef(); int i = 0; ref$IntRef.element = 0; this.loadDirectionUp = false; this.loadDirectionDown = false; this.jumpedApplicationId = l2; if (l2 != null) { this.jumpedSequenceId++; } if (l2 != null) { long longValue = l2.longValue(); this.discoverCommands = DiscoverCommands.copy$default(this.discoverCommands, n.emptyList(), 0, 0, false, false, 0, null, 126, null); if (this.applicationCommandIndexes.containsKey(Long.valueOf(longValue))) { Integer num = this.applicationCommandIndexes.get(Long.valueOf(longValue)); if (num != null) { i = num.intValue(); } ref$IntRef.element = i; this.currentStartOffset = i; this.currentEndOffset = i; } if (longValue == this.builtInCommandsProvider.getBuiltInApplication().getId()) { this.dispatcher.schedule(new StoreApplicationCommands$requestInitialApplicationCommands$$inlined$let$lambda$1(this, ref$IntRef)); return; } } requestApplicationCommands$default(this, l, ref$IntRef.element, l2, 0, 8, null); } public final void requestLoadMoreDown() { Long l = this.discoverGuildId; if (l != null) { requestApplicationCommands$default(this, Long.valueOf(l.longValue()), this.currentEndOffset + 1, null, 20, 4, null); this.loadDirectionUp = false; this.loadDirectionDown = true; this.jumpedApplicationId = null; } } public final void requestLoadMoreUp() { int i; int i2; Long l = this.discoverGuildId; if (l != null) { long longValue = l.longValue(); int i3 = this.currentStartOffset; int i4 = i3 - 20; if (i4 < 0) { i = i3; i2 = 0; } else { i2 = i4; i = 20; } requestApplicationCommands$default(this, Long.valueOf(longValue), i2, null, i, 4, null); this.loadDirectionUp = true; this.loadDirectionDown = false; this.jumpedApplicationId = null; } } @Override // com.discord.stores.StoreV2 public void snapshotData() { if (getUpdateSources().contains(DiscoverCommandsUpdate)) { DiscoverCommands discoverCommands = this.discoverCommands; this.discoverCommandsSnapshot = DiscoverCommands.copy$default(discoverCommands, StoreApplicationCommandsKt.flattenSubCommands(discoverCommands.getCommands()), 0, 0, false, false, 0, null, 126, null); } if (getUpdateSources().contains(QueryCommandsUpdate)) { this.queryCommandsSnapshot = new ArrayList(StoreApplicationCommandsKt.flattenSubCommands(this.queryCommands)); } if (getUpdateSources().contains(GuildApplicationsUpdate)) { ArrayList arrayList = new ArrayList(this.applications); this.applicationsSnapshot = arrayList; LinkedHashMap linkedHashMap = new LinkedHashMap(f.coerceAtLeast(g0.mapCapacity(o.collectionSizeOrDefault(arrayList, 10)), 16)); for (Object obj : arrayList) { linkedHashMap.put(Long.valueOf(((Application) obj).getId()), obj); } this.applicationsMapSnapshot = linkedHashMap; } } }