@@ -1303,9 +1303,7 @@ private WriteThroughEntry(final K k, final V v) {
13031303 */
13041304 @ Override
13051305 public V setValue (final V value ) {
1306- if (value == null ) {
1307- throw new NullPointerException ();
1308- }
1306+ Objects .requireNonNull (value , "value" );
13091307 final V v = super .setValue (value );
13101308 ConcurrentReferenceHashMap .this .put (getKey (), value );
13111309 return v ;
@@ -1553,9 +1551,7 @@ public boolean containsKey(final Object key) {
15531551 */
15541552 @ Override
15551553 public boolean containsValue (final Object value ) {
1556- if (value == null ) {
1557- throw new NullPointerException ();
1558- }
1554+ Objects .requireNonNull (value , "value" );
15591555 // See explanation of modCount use above
15601556 final Segment <K , V >[] segments = this .segments ;
15611557 final int [] mc = new int [segments .length ];
@@ -1715,9 +1711,8 @@ public void purgeStaleEntries() {
17151711 */
17161712 @ Override
17171713 public V put (final K key , final V value ) {
1718- if (key == null || value == null ) {
1719- throw new NullPointerException ();
1720- }
1714+ Objects .requireNonNull (key , "key" );
1715+ Objects .requireNonNull (value , "value" );
17211716 final int hash = hashOf (key );
17221717 return segmentFor (hash ).put (key , hash , value , null , false );
17231718 }
@@ -1743,9 +1738,7 @@ public void putAll(final Map<? extends K, ? extends V> m) {
17431738 */
17441739 @ Override
17451740 public V putIfAbsent (final K key , final V value ) {
1746- if (value == null ) {
1747- throw new NullPointerException ();
1748- }
1741+ Objects .requireNonNull (value , "value" );
17491742 final int hash = hashOf (key );
17501743 return segmentFor (hash ).put (key , hash , value , null , true );
17511744 }
@@ -1785,9 +1778,7 @@ public boolean remove(final Object key, final Object value) {
17851778 */
17861779 @ Override
17871780 public V replace (final K key , final V value ) {
1788- if (value == null ) {
1789- throw new NullPointerException ();
1790- }
1781+ Objects .requireNonNull (value , "value" );
17911782 final int hash = hashOf (key );
17921783 return segmentFor (hash ).replace (key , hash , value );
17931784 }
@@ -1799,9 +1790,8 @@ public V replace(final K key, final V value) {
17991790 */
18001791 @ Override
18011792 public boolean replace (final K key , final V oldValue , final V newValue ) {
1802- if (oldValue == null || newValue == null ) {
1803- throw new NullPointerException ();
1804- }
1793+ Objects .requireNonNull (oldValue , "oldValue" );
1794+ Objects .requireNonNull (newValue , "newValue" );
18051795 final int hash = hashOf (key );
18061796 return segmentFor (hash ).replace (key , hash , oldValue , newValue );
18071797 }
0 commit comments