Revert "Consistent naming style for enum"

This reverts commit 4feafc4a52.
This commit is contained in:
Norman Maurer 2015-08-28 20:49:38 +02:00
parent d3dcc7f658
commit 407d5ccdcf
4 changed files with 10 additions and 10 deletions

View File

@ -27,10 +27,10 @@ public interface IpFilterRule {
boolean matches(InetSocketAddress remoteAddress); boolean matches(InetSocketAddress remoteAddress);
/** /**
* @return This method should return {@link IpFilterRuleType#Accept} if all * @return This method should return {@link IpFilterRuleType#ACCEPT} if all
* {@link IpFilterRule#matches(InetSocketAddress)} for which {@link #matches(InetSocketAddress)} * {@link IpFilterRule#matches(InetSocketAddress)} for which {@link #matches(InetSocketAddress)}
* returns true should the accepted. If you want to exclude all of those IP addresses then * returns true should the accepted. If you want to exclude all of those IP addresses then
* {@link IpFilterRuleType#Reject} should be returned. * {@link IpFilterRuleType#REJECT} should be returned.
*/ */
IpFilterRuleType ruleType(); IpFilterRuleType ruleType();
} }

View File

@ -19,6 +19,6 @@ package io.netty.handler.ipfilter;
* Used in {@link IpFilterRule} to decide if a matching IP Address should be allowed or denied to connect. * Used in {@link IpFilterRule} to decide if a matching IP Address should be allowed or denied to connect.
*/ */
public enum IpFilterRuleType { public enum IpFilterRuleType {
Accept, ACCEPT,
Reject REJECT
} }

View File

@ -51,7 +51,7 @@ public class RuleBasedIpFilter extends AbstractRemoteAddressFilter<InetSocketAdd
} }
if (rule.matches(remoteAddress)) { if (rule.matches(remoteAddress)) {
return rule.ruleType() == IpFilterRuleType.Accept; return rule.ruleType() == IpFilterRuleType.ACCEPT;
} }
} }

View File

@ -31,7 +31,7 @@ public class IpSubnetFilterTest {
@Test @Test
public void testIpv4DefaultRoute() { public void testIpv4DefaultRoute() {
IpSubnetFilterRule rule = new IpSubnetFilterRule("0.0.0.0", 0, IpFilterRuleType.Accept); IpSubnetFilterRule rule = new IpSubnetFilterRule("0.0.0.0", 0, IpFilterRuleType.ACCEPT);
Assert.assertTrue(rule.matches(newSockAddress("91.114.240.43"))); Assert.assertTrue(rule.matches(newSockAddress("91.114.240.43")));
Assert.assertTrue(rule.matches(newSockAddress("10.0.0.3"))); Assert.assertTrue(rule.matches(newSockAddress("10.0.0.3")));
Assert.assertTrue(rule.matches(newSockAddress("192.168.93.2"))); Assert.assertTrue(rule.matches(newSockAddress("192.168.93.2")));
@ -39,13 +39,13 @@ public class IpSubnetFilterTest {
@Test @Test
public void testIp4SubnetFilterRule() throws Exception { public void testIp4SubnetFilterRule() throws Exception {
IpSubnetFilterRule rule = new IpSubnetFilterRule("192.168.56.1", 24, IpFilterRuleType.Accept); IpSubnetFilterRule rule = new IpSubnetFilterRule("192.168.56.1", 24, IpFilterRuleType.ACCEPT);
for (int i = 0; i <= 255; i++) { for (int i = 0; i <= 255; i++) {
Assert.assertTrue(rule.matches(newSockAddress(String.format("192.168.56.%d", i)))); Assert.assertTrue(rule.matches(newSockAddress(String.format("192.168.56.%d", i))));
} }
Assert.assertFalse(rule.matches(newSockAddress("192.168.57.1"))); Assert.assertFalse(rule.matches(newSockAddress("192.168.57.1")));
rule = new IpSubnetFilterRule("91.114.240.1", 23, IpFilterRuleType.Accept); rule = new IpSubnetFilterRule("91.114.240.1", 23, IpFilterRuleType.ACCEPT);
Assert.assertTrue(rule.matches(newSockAddress("91.114.240.43"))); Assert.assertTrue(rule.matches(newSockAddress("91.114.240.43")));
Assert.assertTrue(rule.matches(newSockAddress("91.114.240.255"))); Assert.assertTrue(rule.matches(newSockAddress("91.114.240.255")));
Assert.assertTrue(rule.matches(newSockAddress("91.114.241.193"))); Assert.assertTrue(rule.matches(newSockAddress("91.114.241.193")));
@ -57,7 +57,7 @@ public class IpSubnetFilterTest {
public void testIp6SubnetFilterRule() { public void testIp6SubnetFilterRule() {
IpSubnetFilterRule rule; IpSubnetFilterRule rule;
rule = new IpSubnetFilterRule("2001:db8:abcd:0000::", 52, IpFilterRuleType.Accept); rule = new IpSubnetFilterRule("2001:db8:abcd:0000::", 52, IpFilterRuleType.ACCEPT);
Assert.assertTrue(rule.matches(newSockAddress("2001:db8:abcd:0000::1"))); Assert.assertTrue(rule.matches(newSockAddress("2001:db8:abcd:0000::1")));
Assert.assertTrue(rule.matches(newSockAddress("2001:db8:abcd:0fff:ffff:ffff:ffff:ffff"))); Assert.assertTrue(rule.matches(newSockAddress("2001:db8:abcd:0fff:ffff:ffff:ffff:ffff")));
Assert.assertFalse(rule.matches(newSockAddress("2001:db8:abcd:1000::"))); Assert.assertFalse(rule.matches(newSockAddress("2001:db8:abcd:1000::")));
@ -73,7 +73,7 @@ public class IpSubnetFilterTest {
@Override @Override
public IpFilterRuleType ruleType() { public IpFilterRuleType ruleType() {
return IpFilterRuleType.Reject; return IpFilterRuleType.REJECT;
} }
}; };