@Override public V applyIfPresent(K key, IBiFunction<? super K, ? super V, ? extends V> remappingFunction) { checkNotNull(key); checkNotNull(remappingFunction); int hash = hashOf(key); Segment<K, V> segment = segmentFor(hash); V v = segment.get(key, hash); if (v == null) { return null; } return segmentFor(hash).applyIfPresent(key, hash, remappingFunction); }
public UsernamePasswordCredentials(String username, String password) { super(username); checkNotNull(password); this.password = stringToBytes(password); }
public static boolean matchInterface(String address, String interfaceMask) { final AddressMatcher mask; try { mask = getAddressMatcher(interfaceMask); } catch (Exception e) { return false; } return mask.match(address); }
/** * It works on best effort basis. If multi-threaded calls involved it may evict all elements, but it's unlikely. */ private void evictMap(SampleableConcurrentHashMap<?, ?> map, int triggeringEvictionSize, int afterEvictionSize) { map.purgeStaleEntries(); int mapSize = map.size(); if (mapSize - triggeringEvictionSize >= 0) { for (SampleableConcurrentHashMap.SamplingEntry entry : map.getRandomSamples(mapSize - afterEvictionSize)) { map.remove(entry.getEntryKey()); } } }
public Map<String, String> phoneHome(Node hazelcastNode) { PhoneHomeParameterCreator parameterCreator = createParameters(hazelcastNode); String urlStr = BASE_PHONE_HOME_URL + parameterCreator.build(); fetchWebService(urlStr); return parameterCreator.getParameters(); }
/** * Gets the password. * * @return the password */ public String getPassword() { checkNotNull(password); return bytesToString(password); }
/** * {@inheritDoc} * * @throws NullPointerException if the specified key is null */ public boolean remove(Object key, Object value) { int hash = hashOf(key); if (value == null) { return false; } return segmentFor(hash).remove(key, hash, value, false) != null; }
final Object newKeyReference(K key, ReferenceType keyType, ReferenceQueue<Object> refQueue) { if (keyType == ReferenceType.WEAK) { return new WeakKeyReference<K>(key, hash, refQueue); } if (keyType == ReferenceType.SOFT) { return new SoftKeyReference<K>(key, hash, refQueue); } return key; }
final Object newValueReference(V value, ReferenceType valueType, ReferenceQueue<Object> refQueue) { if (valueType == ReferenceType.WEAK) { return new WeakValueReference<V>(value, keyRef, hash, refQueue); } if (valueType == ReferenceType.SOFT) { return new SoftValueReference<V>(value, keyRef, hash, refQueue); } return value; }
public PutFromLoadAllOperation(String name, List<Data> keyValueSequence) { super(name); checkFalse(isEmpty(keyValueSequence), "key-value sequence cannot be empty or null"); this.keyValueSequence = keyValueSequence; }
private static void checkIfAddressPartsAreValid(String[] addressParts, String address) { for (String part : addressParts) { if (!isValidIpAddressPart(part, true)) { throw new InvalidAddressException(address); } } }
@Override public V applyIfPresent(K key, IBiFunction<? super K, ? super V, ? extends V> remappingFunction) { checkNotNull(key); checkNotNull(remappingFunction); int hash = hashOf(key); Segment<K, V> segment = segmentFor(hash); V v = segment.get(key, hash); if (v == null) { return null; } return segmentFor(hash).applyIfPresent(key, hash, remappingFunction); }
/** * Sets the password. * * @param password the password to set */ public void setPassword(String password) { checkNotNull(password); this.password = stringToBytes(password); }
/** * Gets the password. * * @return the password */ public String getPassword() { checkNotNull(password); return bytesToString(password); }
/** * {@inheritDoc} * * @throws NullPointerException if the specified key is null */ public boolean remove(Object key, Object value) { int hash = hashOf(key); if (value == null) { return false; } return segmentFor(hash).remove(key, hash, value, false) != null; }
public boolean match(final String address) { try { return match(getAddressMatcher(address)); } catch (Exception e) { return false; } }
final Object newKeyReference(K key, ReferenceType keyType, ReferenceQueue<Object> refQueue) { if (keyType == ReferenceType.WEAK) { return new WeakKeyReference<K>(key, hash, refQueue); } if (keyType == ReferenceType.SOFT) { return new SoftKeyReference<K>(key, hash, refQueue); } return key; }
public boolean match(final String address) { try { return match(getAddressMatcher(address)); } catch (Exception e) { return false; } }