Fix class references of its subclass issue
Motivation: Realization of `AbstractTrafficShapingHandler.userDefinedWritabilityIndex()` has references to subclasses. In addition, one of the subclasses overriding it, but the other does not. Modifications: Add overriding to the second subclass. Remove references to subclasses from parent class. Result: More consistent and clean code (OOP-stylish).
This commit is contained in:
parent
bb37e592f8
commit
73f40afca9
@ -143,13 +143,7 @@ public abstract class AbstractTrafficShapingHandler extends ChannelDuplexHandler
|
|||||||
* {@value #GLOBALCHANNEL_DEFAULT_USER_DEFINED_WRITABILITY_INDEX}.
|
* {@value #GLOBALCHANNEL_DEFAULT_USER_DEFINED_WRITABILITY_INDEX}.
|
||||||
*/
|
*/
|
||||||
protected int userDefinedWritabilityIndex() {
|
protected int userDefinedWritabilityIndex() {
|
||||||
if (this instanceof GlobalChannelTrafficShapingHandler) {
|
return CHANNEL_DEFAULT_USER_DEFINED_WRITABILITY_INDEX;
|
||||||
return GLOBALCHANNEL_DEFAULT_USER_DEFINED_WRITABILITY_INDEX;
|
|
||||||
} else if (this instanceof GlobalTrafficShapingHandler) {
|
|
||||||
return GLOBAL_DEFAULT_USER_DEFINED_WRITABILITY_INDEX;
|
|
||||||
} else {
|
|
||||||
return CHANNEL_DEFAULT_USER_DEFINED_WRITABILITY_INDEX;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -111,6 +111,11 @@ public class GlobalTrafficShapingHandler extends AbstractTrafficShapingHandler {
|
|||||||
tc.start();
|
tc.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected int userDefinedWritabilityIndex() {
|
||||||
|
return AbstractTrafficShapingHandler.GLOBAL_DEFAULT_USER_DEFINED_WRITABILITY_INDEX;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Create a new instance.
|
* Create a new instance.
|
||||||
*
|
*
|
||||||
|
Loading…
Reference in New Issue
Block a user