@Test public void testGetAndSet() throws Exception { int get = i1.getAndSet(100); assertEquals(0, get); assertEquals(100, i1.get()); try { i1.getAndSet(-1); } catch (IllegalArgumentException expected) { assertThat(expected.getMessage(), allOf(containsString("new value"), containsString("< 0"))); } }
public final int getAndSet(int newValue) { if (newValue < 0) { throw new IllegalArgumentException("new value " + newValue + " < 0"); } return indexUpdater.getAndSet(this, newValue) & Integer.MAX_VALUE; }
AtomicPositiveInteger extends Number { public final int getAndSet(int newValue) { if (newValue < 0) { throw new IllegalArgumentException("new value " + newValue + " < 0"); } return indexUpdater.getAndSet(this, newValue) & Integer.MAX_VALUE; } }
AtomicPositiveInteger extends Number { public final int getAndSet(int newValue) { if (newValue < 0) { throw new IllegalArgumentException("new value " + newValue + " < 0"); } return indexUpdater.getAndSet(this, newValue) & Integer.MAX_VALUE; } AtomicPositiveInteger();  AtomicPositiveInteger(int initialValue); }
AtomicPositiveInteger extends Number { public final int getAndSet(int newValue) { if (newValue < 0) { throw new IllegalArgumentException("new value " + newValue + " < 0"); } return indexUpdater.getAndSet(this, newValue) & Integer.MAX_VALUE; } AtomicPositiveInteger();  AtomicPositiveInteger(int initialValue); final int getAndIncrement(); final int getAndDecrement(); final int incrementAndGet(); final int decrementAndGet(); final int get(); final void set(int newValue); final int getAndSet(int newValue); final int getAndAdd(int delta); final int addAndGet(int delta); final boolean compareAndSet(int expect, int update); final boolean weakCompareAndSet(int expect, int update); @Override byte byteValue(); @Override short shortValue(); @Override int intValue(); @Override long longValue(); @Override float floatValue(); @Override double doubleValue(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj); }
AtomicPositiveInteger extends Number { public final int getAndSet(int newValue) { if (newValue < 0) { throw new IllegalArgumentException("new value " + newValue + " < 0"); } return indexUpdater.getAndSet(this, newValue) & Integer.MAX_VALUE; } AtomicPositiveInteger();  AtomicPositiveInteger(int initialValue); final int getAndIncrement(); final int getAndDecrement(); final int incrementAndGet(); final int decrementAndGet(); final int get(); final void set(int newValue); final int getAndSet(int newValue); final int getAndAdd(int delta); final int addAndGet(int delta); final boolean compareAndSet(int expect, int update); final boolean weakCompareAndSet(int expect, int update); @Override byte byteValue(); @Override short shortValue(); @Override int intValue(); @Override long longValue(); @Override float floatValue(); @Override double doubleValue(); @Override String toString(); @Override int hashCode(); @Override boolean equals(Object obj);  }