/** * Returns a pair with the left and right reversed. * @return */ public Pair<W, V> getReversed() { return create(rhSide, lhSide); }
public void markNumResultsNotDeleted(int resultsInBatch) { numNotDeleted += resultsInBatch; AssertUtils.assertAndLog(log, numNotDeleted <= numReturned, "NotDeleted is bigger than the number of results we returned."); }
/** * Returns a new <code>Pair</code> instance * with the given left-side and right-side objects. */ public static <V, W> Pair<V, W> create(V v, W w) { return new Pair<V, W>(v, w); }
public SoftCache(int initialSize) { cacheEntries = createCache(initialSize); setName("SoftCache"); SoftCache.registerForCleanup(this); }
public static void assertAndLog(Logger log, boolean cheapTest, String msg) { if (!cheapTest) { assertAndLogWithException(log, false, msg, getDebuggingException()); } }
/** * Creates a new Mutable with a null value to start with. */ public static <T> Mutable<T> newMutable() { return newMutable(null); } }
/** * Make sure to get a unique name on this object before trying to register this cache with JMX. * If it doens't have a unique name, then it won't be registered correctly. */ public void registerMBean() { registerMBean(getStatBeanName()); }
/** * Constructs a new <code>MutuallyExclusiveSetLock</code> that will * lock the objects in the order determined by <code>comparator</code>. * @param fair when <code>true</code>, the class favors granting access to the * longest-waiting thread when there is any contention. * When <code>false</code>, no access order is guaranteed. * @param comparator a <code>java.util.Comparator</code> to use in determining lock order. */ public static <T> MutuallyExclusiveSetLock<T> createWithComparator(boolean fair, Comparator<? super T> comparator) { return new MutuallyExclusiveSetLock<T>(fair, comparator); }
/** * Unlocks the objects acquired from locking. * This method should always be in a try/finally block immediately after the lock. * If you try to unlock from another thread, no objects are unlocked. * @see #lockOnObjects(Iterable) */ public void unlock() { setLock.unlock(this); } }
public VersionedType<T> getVersionedValue() { return delegate.get(); } }
private VersionedType<Long> constantNumber() { return VersionedType.of(1L, 0); } }
@Override public void write(int b) throws IOException { ensureCapacity(outputPos); bytes[outputPos++] = (byte) b; }
/** * Type-inferred factory method for {@link Mutable} */ public static <T> Mutable<T> newMutable(T val) { return new Mutable<T>(val); }
@Override public synchronized boolean containsKey(K key) { V val = get(key); return (val != null); }
/** * Returns a new <code>Pair</code> with the right hand side set to the passed value. */ public <T> Pair<V, T> withRhSide(T newRhSide) { return Pair.create(lhSide, newRhSide); }
/** * Return a new <code>Pair</code> with the left hand side set to the passed value. */ public <T> Pair<T, W> withLhSide(T newLhSide) { return Pair.create(newLhSide, rhSide); }