List of usage examples for com.google.common.collect Maps immutableEntry
@GwtCompatible(serializable = true) public static <K, V> Entry<K, V> immutableEntry(@Nullable K key, @Nullable V value)
From source file:org.spongepowered.api.service.permission.context.Context.java
/** * Create a new context instance/*from w w w . j a va2 s . c o m*/ * * @param type Context type. Must not be null. * @param name Context name. Must not be null. */ public Context(String type, String name) { checkNotNull(type, "type"); checkNotNull(name, "name"); this.wrapped = Maps.immutableEntry(type, name); }
From source file:ninja.leaping.permissionsex.backend.memory.MemoryDataStore.java
@Override public ImmutableSubjectData getDataInternal(String type, String identifier) { final Map.Entry<String, String> key = Maps.immutableEntry(type, identifier); ImmutableSubjectData ret = data.get(key); if (ret == null) { ret = new MemorySubjectData(); if (track) { final ImmutableSubjectData existingData = data.putIfAbsent(key, ret); if (existingData != null) { ret = existingData;/*w ww . j a va 2 s. c o m*/ } } } return ret; }
From source file:ninja.leaping.permissionsex.backend.file.FileOptionSubjectData.java
private static Set<Entry<String, String>> contextsFrom(ConfigurationNode node) { Set<Entry<String, String>> contexts = Collections.emptySet(); ConfigurationNode contextsNode = node.getNode(KEY_CONTEXTS); if (contextsNode.hasMapChildren()) { contexts = ImmutableSet.copyOf(Collections2.transform(contextsNode.getChildrenMap().entrySet(), new Function<Map.Entry<Object, ? extends ConfigurationNode>, Entry<String, String>>() { @Nullable//from w w w . j a v a 2 s . c o m @Override public Entry<String, String> apply(Map.Entry<Object, ? extends ConfigurationNode> ent) { return Maps.immutableEntry(ent.getKey().toString(), String.valueOf(ent.getValue().getValue())); } })); } return contexts; }
From source file:dagger.internal.codegen.DaggerStreams.java
/** * Returns a {@link Collector} that accumulates elements into an {@code ImmutableSetMultimap} * whose keys and values are the result of applying the provided mapping functions to the input * elements. Entries appear in the result {@code ImmutableSetMultimap} in encounter order. *//* w ww . j a va 2 s . co m*/ // TODO(b/68008628): Use ImmutableSetMultimap.toImmutableSetMultimap(). public static <T, K, V> Collector<T, ?, ImmutableSetMultimap<K, V>> toImmutableSetMultimap( Function<? super T, ? extends K> keyMapper, Function<? super T, ? extends V> valueMapper) { return Collectors.mapping(value -> Maps.immutableEntry(keyMapper.apply(value), valueMapper.apply(value)), Collector.of(ImmutableSetMultimap::builder, (ImmutableSetMultimap.Builder<K, V> builder, Map.Entry<K, V> entry) -> builder.put(entry), (left, right) -> left.putAll(right.build()), ImmutableSetMultimap.Builder::build)); }
From source file:me.lucko.luckperms.bukkit.processors.ChildPermissionProvider.java
private static void resolve( ImmutableMap.Builder<Map.Entry<String, Boolean>, ImmutableMap<String, Boolean>> accumulator, Permission permission, boolean value) { // accumulator for the child permissions being looked up Map<String, Boolean> children = new HashMap<>(); // resolve children for the permission, so pass a map containing just the permission being looked up. resolveChildren(children, Collections.singletonMap(permission.getName(), value), false); // remove self children.remove(permission.getName(), value); // only register the children if there are any. if (!children.isEmpty()) { accumulator.put(Maps.immutableEntry(permission.getName().toLowerCase(), value), ImmutableMap.copyOf(children)); }/*from www . j a va 2 s. co m*/ }
From source file:com.appenginefan.toolkit.persistence.PersistenceAdapter.java
@Override public List<Entry<String, T>> scan(String start, String end, int max) { List<Entry<String, T>> result = Lists.newArrayList(); for (Entry<String, S> entry : backend.scan(start, end, max)) { T value = null;//from w ww.j av a 2s. c om if (entry.getValue() != null) { value = makeType(entry.getValue()); } result.add(Maps.immutableEntry(entry.getKey(), value)); } return result; }
From source file:com.infinities.keystone4j.contrib.revoke.impl.RevokeApiImpl.java
private void registerListeners() { Map<Actions, List<Entry<String, ? extends NotificationCallback>>> callbacks = new HashMap<Actions, List<Entry<String, ? extends NotificationCallback>>>(); List<Entry<String, ? extends NotificationCallback>> deletedList = new ArrayList<Entry<String, ? extends NotificationCallback>>(); deletedList.add(Maps.immutableEntry("OS-TRUST:trust", new TrustCallback())); deletedList.add(Maps.immutableEntry("OS-OAUTH1:consumer", new ConsumerCallback())); deletedList.add(Maps.immutableEntry("OS-OAUTH1:access_token", new AccessTokenCallback())); deletedList.add(Maps.immutableEntry("role", new RoleCallback())); deletedList.add(Maps.immutableEntry("user", new UserCallback())); deletedList.add(Maps.immutableEntry("project", new ProjectCallback())); callbacks.put(Actions.deleted, deletedList); List<Entry<String, ? extends NotificationCallback>> disabledList = new ArrayList<Entry<String, ? extends NotificationCallback>>(); disabledList.add(Maps.immutableEntry("domain", new DomainCallback())); disabledList.add(Maps.immutableEntry("user", new UserCallback())); disabledList.add(Maps.immutableEntry("project", new ProjectCallback())); callbacks.put(Actions.disabled, disabledList); List<Entry<String, ? extends NotificationCallback>> internalList = new ArrayList<Entry<String, ? extends NotificationCallback>>(); disabledList.add(Maps.immutableEntry(Notifications.INVALIDATE_USER_TOKEN_PERSISTENCE, new UserCallback())); callbacks.put(Actions.internal, internalList); for (Entry<Actions, List<Entry<String, ? extends NotificationCallback>>> entry : callbacks.entrySet()) { Actions event = entry.getKey();/*ww w .j av a2s. c om*/ List<Entry<String, ? extends NotificationCallback>> cbInfos = entry.getValue(); for (Entry<String, ? extends NotificationCallback> cbInfo : cbInfos) { String resourceType = cbInfo.getKey(); NotificationCallback callbackFns = cbInfo.getValue(); Notifications.registerEventCallback(event, resourceType, callbackFns); } } }
From source file:io.atomix.core.barrier.impl.DefaultDistributedCyclicBarrierService.java
@Override public void backup(BackupOutput output) { output.writeObject(parties);/*from w w w. j a va 2 s. c o m*/ output.writeLong(barrierId); output.writeBoolean(broken); output.writeObject(waiters.entrySet().stream() .map(entry -> Maps.immutableEntry(entry.getKey(), entry.getValue().timeout)) .collect(Collectors.toMap(e -> e.getKey(), e -> e.getValue()))); }
From source file:ninja.leaping.permissionsex.bukkit.BukkitCommander.java
@Override public Set<Map.Entry<String, String>> getActiveContexts() { if (commandSource instanceof Player) { return ImmutableSet.of(Maps.immutableEntry("world", ((Player) commandSource).getWorld().getName())); } else {/*from w w w. j a va 2s.c o m*/ return ImmutableSet.of(); } }
From source file:me.lucko.luckperms.bukkit.model.SubscriptionManager.java
/** * Compares two sets/*from w w w . j a va 2s. c o m*/ * @param local the local set * @param remote the remote set * @return the entries to add to remote, and the entries to remove from remote */ private static Map.Entry<Set<String>, Set<String>> compareSets(Set<String> local, Set<String> remote) { // entries in local but not remote need to be added // entries in remote but not local need to be removed Set<String> toAdd = new HashSet<>(local); toAdd.removeAll(remote); Set<String> toRemove = new HashSet<>(remote); toRemove.removeAll(local); return Maps.immutableEntry(toAdd, toRemove); }