ref: Removes MuxServerSocketChannel#assertIsNotNull

Uses the equivalent Objects#requireNonNull instead.
This commit is contained in:
Boris Grozev 2017-03-23 15:56:49 -05:00
parent 6401fcd436
commit 7a78b72d5b
4 changed files with 13 additions and 30 deletions

View File

@ -19,6 +19,8 @@ package org.ice4j.socket.jdk8;
import java.io.*; import java.io.*;
import java.net.*; import java.net.*;
import java.util.*;
import org.ice4j.socket.*; import org.ice4j.socket.*;
/** /**
@ -48,7 +50,7 @@ class MuxServerSocket
throws IOException throws IOException
{ {
super( super(
MuxServerSocketChannel.assertIsNotNull(delegate, "delegate"), Objects.requireNonNull(delegate, "delegate"),
MuxServerSocketChannel.assertIsNotNull(channel, "channel")); Objects.requireNonNull(channel, "channel"));
} }
} }

View File

@ -32,27 +32,6 @@ import org.ice4j.socket.*;
public class MuxServerSocketChannel public class MuxServerSocketChannel
extends DelegatingServerSocketChannel<MuxingServerSocketChannel> extends DelegatingServerSocketChannel<MuxingServerSocketChannel>
{ {
/**
* Asserts that <tt>t</tt> is not <tt>null</tt> by throwing a
* <tt>NullPointerException</tt> if it is.
*
* @param t the <tt>Object</tt> to assert that it is not <tt>null</tt>
* @param message the (detail) message of the <tt>NullPointerException</tt>
* to be thrown if <tt>t</tt> is <tt>null</tt>
* @param <T> the type of <tt>t</tt>
* @return <tt>t</tt>
* @throws NullPointerException if <tt>t</tt> is <tt>null</tt>. The (detail)
* message of the <tt>NullPointerException</tt> is <tt>message</tt>
*/
public static <T> T assertIsNotNull(T t, String message)
throws NullPointerException
{
if (t == null)
throw new NullPointerException(message);
else
return t;
}
/** /**
* Opens and binds a new {@code MuxServerSocketChannel} instance. If there * Opens and binds a new {@code MuxServerSocketChannel} instance. If there
* are other (existing) {@code MuxServerSocketChannel} open and bound on the * are other (existing) {@code MuxServerSocketChannel} open and bound on the
@ -128,9 +107,9 @@ public class MuxServerSocketChannel
MuxingServerSocketChannel delegate, MuxingServerSocketChannel delegate,
DatagramPacketFilter filter) DatagramPacketFilter filter)
{ {
super(assertIsNotNull(delegate, "delegate")); super(Objects.requireNonNull(delegate, "delegate"));
this.filter = assertIsNotNull(filter, "filter"); this.filter = Objects.requireNonNull(filter, "filter");
} }
/** /**

View File

@ -19,6 +19,8 @@ package org.ice4j.socket.jdk8;
import java.io.*; import java.io.*;
import java.net.*; import java.net.*;
import java.util.*;
import org.ice4j.socket.*; import org.ice4j.socket.*;
/** /**
@ -48,7 +50,7 @@ class MuxingServerSocket
throws IOException throws IOException
{ {
super( super(
MuxServerSocketChannel.assertIsNotNull(delegate, "delegate"), Objects.requireNonNull(delegate, "delegate"),
MuxServerSocketChannel.assertIsNotNull(channel, "channel")); Objects.requireNonNull(channel, "channel"));
} }
} }

View File

@ -281,7 +281,7 @@ class MuxingServerSocketChannel
// as possible though because it does not make sense to bind a // as possible though because it does not make sense to bind a
// ServerSocketChannel and initialize a new MuxingServerSocketChannel // ServerSocketChannel and initialize a new MuxingServerSocketChannel
// instance otherwise. // instance otherwise.
MuxServerSocketChannel.assertIsNotNull(filter, "filter"); Objects.requireNonNull(filter, "filter");
MuxingServerSocketChannel muxingChannel; MuxingServerSocketChannel muxingChannel;
@ -641,7 +641,7 @@ class MuxingServerSocketChannel
public MuxingServerSocketChannel(ServerSocketChannel delegate) public MuxingServerSocketChannel(ServerSocketChannel delegate)
throws IOException throws IOException
{ {
super(MuxServerSocketChannel.assertIsNotNull(delegate, "delegate")); super(Objects.requireNonNull(delegate, "delegate"));
// If at least one MuxServerSocketChannel is configured as non-blocking, // If at least one MuxServerSocketChannel is configured as non-blocking,
// then MuxingServerSocketChannel (i.e. delegate) has to be configured // then MuxingServerSocketChannel (i.e. delegate) has to be configured
@ -732,7 +732,7 @@ class MuxingServerSocketChannel
// MuxServerSocketChannels) have no priorities. It cannot be a catch all // MuxServerSocketChannels) have no priorities. It cannot be a catch all
// because a SocketChannel (i.e. Socket) may be accepted by a single // because a SocketChannel (i.e. Socket) may be accepted by a single
// MuxServerSocketChannel only. // MuxServerSocketChannel only.
MuxServerSocketChannel.assertIsNotNull(filter, "filter"); Objects.requireNonNull(filter, "filter");
MuxServerSocketChannel channel; MuxServerSocketChannel channel;