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.net.*;
import java.util.*;
import org.ice4j.socket.*;
/**
@ -48,7 +50,7 @@ class MuxServerSocket
throws IOException
{
super(
MuxServerSocketChannel.assertIsNotNull(delegate, "delegate"),
MuxServerSocketChannel.assertIsNotNull(channel, "channel"));
Objects.requireNonNull(delegate, "delegate"),
Objects.requireNonNull(channel, "channel"));
}
}

View File

@ -32,27 +32,6 @@ import org.ice4j.socket.*;
public class MuxServerSocketChannel
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
* are other (existing) {@code MuxServerSocketChannel} open and bound on the
@ -128,9 +107,9 @@ public class MuxServerSocketChannel
MuxingServerSocketChannel delegate,
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.net.*;
import java.util.*;
import org.ice4j.socket.*;
/**
@ -48,7 +50,7 @@ class MuxingServerSocket
throws IOException
{
super(
MuxServerSocketChannel.assertIsNotNull(delegate, "delegate"),
MuxServerSocketChannel.assertIsNotNull(channel, "channel"));
Objects.requireNonNull(delegate, "delegate"),
Objects.requireNonNull(channel, "channel"));
}
}

View File

@ -281,7 +281,7 @@ class MuxingServerSocketChannel
// as possible though because it does not make sense to bind a
// ServerSocketChannel and initialize a new MuxingServerSocketChannel
// instance otherwise.
MuxServerSocketChannel.assertIsNotNull(filter, "filter");
Objects.requireNonNull(filter, "filter");
MuxingServerSocketChannel muxingChannel;
@ -641,7 +641,7 @@ class MuxingServerSocketChannel
public MuxingServerSocketChannel(ServerSocketChannel delegate)
throws IOException
{
super(MuxServerSocketChannel.assertIsNotNull(delegate, "delegate"));
super(Objects.requireNonNull(delegate, "delegate"));
// If at least one MuxServerSocketChannel is configured as non-blocking,
// 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
// because a SocketChannel (i.e. Socket) may be accepted by a single
// MuxServerSocketChannel only.
MuxServerSocketChannel.assertIsNotNull(filter, "filter");
Objects.requireNonNull(filter, "filter");
MuxServerSocketChannel channel;