AbstractBootstrap.validate() should return reference to itself

This commit is contained in:
Norman Maurer 2013-02-08 07:48:47 +01:00
parent fa1b49de98
commit 1033bec4cd
3 changed files with 7 additions and 3 deletions

View File

@ -199,13 +199,15 @@ abstract class AbstractBootstrap<B extends AbstractBootstrap<?, C>, C extends Ch
* Validate all the parameters. Sub-classes may override this, but should
* call the super method in that case.
*/
public void validate() {
@SuppressWarnings("unchecked")
public B validate() {
if (group == null) {
throw new IllegalStateException("group not set");
}
if (channelFactory == null) {
throw new IllegalStateException("factory not set");
}
return (B) this;
}
/**

View File

@ -188,11 +188,12 @@ public final class Bootstrap extends AbstractBootstrap<Bootstrap, Channel> {
}
@Override
public void validate() {
public Bootstrap validate() {
super.validate();
if (handler() == null) {
throw new IllegalStateException("handler not set");
}
return this;
}
@Override

View File

@ -203,7 +203,7 @@ public final class ServerBootstrap extends AbstractBootstrap<ServerBootstrap, Se
}
@Override
public void validate() {
public ServerBootstrap validate() {
super.validate();
if (childHandler == null) {
throw new IllegalStateException("childHandler not set");
@ -212,6 +212,7 @@ public final class ServerBootstrap extends AbstractBootstrap<ServerBootstrap, Se
logger.warn("childGroup is not set. Using parentGroup instead.");
childGroup = group();
}
return this;
}
@SuppressWarnings("unchecked")