/** * Get the entries in the AdjacencyMap which match the provided source and * destination vertices. * * @param source the source vertex * @param destination the destination vertex * * @return the {@link Set} of edge objects relating to the specified * vertices */ public Set<Edge> getEdges(final Object source, final Object destination) { final Set<Edge> results = edgeGraph.get(source, destination); return null != results ? results : Collections.emptySet(); }
/** * Add an entry to the AdjacencyMap. * * @param source the source vertex * @param destination the destination vertex * @param edge the edge to add * * @return the {@link Set} containing the edge objects associated with the * source and destination vertices */ public Set<Edge> putEdge(final Object source, final Object destination, final Edge edge) { final Set<Edge> existing = edgeGraph.get(source, destination); if (null == existing) { final Set<Edge> set = Sets.newHashSet(edge); return edgeGraph.put(source, destination, set); } else { existing.add(edge); return existing; } }
public TServerInstance removeMove(TServerInstance src, String group) { List<Move> srcMoves = moves.get(src, group); if (srcMoves == null) { return null; } Move move = srcMoves.get(srcMoves.size() - 1); TServerInstance ret = move.dest.getTserverInstance(); totalMoves--; move.count--; if (move.count == 0) { srcMoves.remove(srcMoves.size() - 1); if (srcMoves.size() == 0) { moves.remove(src, group); } } return ret; }
public void move(String group, int num, TserverGroupInfo src, TserverGroupInfo dest) { checkArgument(num > 0); checkArgument(!src.equals(dest)); src.moveOff(group, num); dest.moveTo(group, num); List<Move> srcMoves = moves.get(src.getTserverInstance(), group); if (srcMoves == null) { srcMoves = new ArrayList<>(); moves.put(src.getTserverInstance(), group, srcMoves); } srcMoves.add(new Move(dest, num)); totalMoves += num; }
/** * Returns the permitted option occurrence within a message with the given code * * @param optionNumber the options number * @param messageCode the number corresponding to a message code * @return the permitted option occurrence within a message with the given code */ public static Occurence getPermittedOccurrence(int optionNumber, int messageCode) { Occurence result = OCCURENCE_CONSTRAINTS.get(messageCode, optionNumber); return result == null ? NONE : result; }
private CoapResponse getCoapResponse(InetSocketAddress remoteSocket, Token token) { try { this.lock.readLock().lock(); return this.transfers2.get(remoteSocket, token); } finally { this.lock.readLock().unlock(); } }
protected InetSocketAddress getFromAssignedByMe(EndpointID endpointID, Token token) { try{ lock.readLock().lock(); return this.assignedByMe1.get(endpointID, token); } finally { lock.readLock().unlock(); } }
private ClientCallback getCallback(InetSocketAddress remoteAddress, Token token) { try { this.lock.readLock().lock(); return this.clientCallbacks.get(remoteAddress, token); } finally { this.lock.readLock().unlock(); } }
protected EndpointID getFromAssignedByMe(InetSocketAddress remoteSocket, Token token) { try{ lock.readLock().lock(); return this.assignedByMe2.get(remoteSocket, token); } finally { lock.readLock().unlock(); } }
private ClientBlock1Helper getBlock1Helper(InetSocketAddress remoteSocket, Token token) { try { this.lock.readLock().lock(); return this.block1Helpers.get(remoteSocket, token); } finally { this.lock.readLock().unlock(); } }
private ServerBlock2Helper getBlock2Helper(InetSocketAddress remoteSocket, Token token) { try { this.lock.readLock().lock(); return this.block2Helpers.get(remoteSocket, token); } finally { this.lock.readLock().unlock(); } }
/** * Revoke any of the user's permissions to the {@code environment}. * * @param environment */ @SuppressWarnings("unchecked") private void revoke(String environment) { Map<String, Object> permissions = (Map<String, Object>) accounts .get(id, AccountAttribute.PERMISSIONS.key()); if(permissions != null) { permissions.remove(environment); } }
/** * Return the user's username as a hex string. * * @return the username */ private String usernameAsHex() { return (String) accounts.get(id, AccountAttribute.USERNAME.key()); }
public static String getDescription(String locale, NamespacedKey power, String property) { Plugin plugin = extensions.get(power.getNamespace()); if (!PowerManager.descriptionResolvers.contains(plugin, locale)) { return null; } return PowerManager.descriptionResolvers.get(plugin, locale).apply(power, property); }
public static <T extends Power> T adaptPower(Power power, Class<T> specified) { List<Class<? extends Power>> generals = Arrays.asList(getMeta(power.getNamespacedKey()).generalInterface()); Set<Class<? extends Power>> statics = Power.getStaticInterfaces(power.getClass()); List<Class<? extends Power>> preferences = generals.stream().filter(statics::contains).collect(Collectors.toList()); for (Class<? extends Power> general : preferences) { if (adapters.contains(general, specified)) { return (T) adapters.get(general, specified).apply(power); } } throw new ClassCastException(); }
/** * Execute a routine on all of the usernames known to this service. * * @param consumer */ public void forEachUser(Consumer<ByteBuffer> consumer) { accounts.rowKeySet().forEach(id -> { ByteBuffer username = ByteBuffers.decodeFromHex( (String) accounts.get(id, AccountAttribute.USERNAME.key())); consumer.accept(username); }); }
private PropertyDef getPropDefFromClass( NominalType nominalType, String pname) { while (nominalType.getPropDeclaredType(pname) != null) { Preconditions.checkArgument(nominalType.isFinalized()); Preconditions.checkArgument(nominalType.isClass()); if (propertyDefs.get(nominalType.getId(), pname) != null) { return propertyDefs.get(nominalType.getId(), pname); } nominalType = nominalType.getInstantiatedSuperclass(); } return null; }
/** * Return {@code true} if this user is enabled. * * @return {@code true} if this user is enabled */ private boolean isEnabled() { Object enabled = accounts.get(id, AccountAttribute.ENABLED.key()); if(enabled == null) { enabled = true; accounts.put(id, AccountAttribute.ENABLED.key(), enabled); } return (boolean) enabled; }
MatchStatus checkCache(JSType subType, JSType superType) { if (this.matchCache == null) { this.matchCache = HashBasedTable.create(); } // check the cache if (this.matchCache.contains(subType, superType)) { return this.matchCache.get(subType, superType); } else { this.updateCache(subType, superType, MatchStatus.PROCESSING); return null; } } }
MatchStatus checkCache(JSType subType, JSType superType) { if (this.matchCache == null) { this.matchCache = HashBasedTable.create(); } // check the cache if (this.matchCache.contains(subType, superType)) { return this.matchCache.get(subType, superType); } else { this.updateCache(subType, superType, MatchStatus.PROCESSING); return null; } } }