From 4d0a1c92596e67c3deb6cc321c30164af40c3ece Mon Sep 17 00:00:00 2001 From: nathan Date: Sat, 15 Aug 2020 13:22:43 +0200 Subject: [PATCH] Converted to kotlin --- .../{IpFilterRule.java => IpFilterRule.kt} | 16 ++++++++-------- ...IpFilterRuleType.java => IpFilterRuleType.kt} | 9 ++++----- .../network/ipFilter/IpSubnetFilterRule.kt | 7 ++++--- 3 files changed, 16 insertions(+), 16 deletions(-) rename src/dorkbox/network/ipFilter/{IpFilterRule.java => IpFilterRule.kt} (68%) rename src/dorkbox/network/ipFilter/{IpFilterRuleType.java => IpFilterRuleType.kt} (76%) diff --git a/src/dorkbox/network/ipFilter/IpFilterRule.java b/src/dorkbox/network/ipFilter/IpFilterRule.kt similarity index 68% rename from src/dorkbox/network/ipFilter/IpFilterRule.java rename to src/dorkbox/network/ipFilter/IpFilterRule.kt index 2089c046..5aeff31c 100644 --- a/src/dorkbox/network/ipFilter/IpFilterRule.java +++ b/src/dorkbox/network/ipFilter/IpFilterRule.kt @@ -13,24 +13,24 @@ * License for the specific language governing permissions and limitations * under the License. */ -package dorkbox.network.ipFilter; +package dorkbox.network.ipFilter -import java.net.InetSocketAddress; +import java.net.InetSocketAddress /** * Implement this interface to create new rules. */ -public interface IpFilterRule { +interface IpFilterRule { /** * @return This method should return true if remoteAddress is valid according to your criteria. False otherwise. */ - boolean matches(InetSocketAddress remoteAddress); + fun matches(remoteAddress: InetSocketAddress): Boolean /** - * @return This method should return {@link IpFilterRuleType#ACCEPT} if all - * {@link IpFilterRule#matches(InetSocketAddress)} for which {@link #matches(InetSocketAddress)} + * @return This method should return [IpFilterRuleType.ACCEPT] if all + * [IpFilterRule.matches] for which [.matches] * returns true should the accepted. If you want to exclude all of those IP addresses then - * {@link IpFilterRuleType#REJECT} should be returned. + * [IpFilterRuleType.REJECT] should be returned. */ - IpFilterRuleType ruleType(); + fun ruleType(): IpFilterRuleType } diff --git a/src/dorkbox/network/ipFilter/IpFilterRuleType.java b/src/dorkbox/network/ipFilter/IpFilterRuleType.kt similarity index 76% rename from src/dorkbox/network/ipFilter/IpFilterRuleType.java rename to src/dorkbox/network/ipFilter/IpFilterRuleType.kt index 9967417c..ae4ead34 100644 --- a/src/dorkbox/network/ipFilter/IpFilterRuleType.java +++ b/src/dorkbox/network/ipFilter/IpFilterRuleType.kt @@ -13,12 +13,11 @@ * License for the specific language governing permissions and limitations * under the License. */ -package dorkbox.network.ipFilter; +package dorkbox.network.ipFilter /** - * Used in {@link IpFilterRule} to decide if a matching IP Address should be allowed or denied to connect. + * Used in [IpFilterRule] to decide if a matching IP Address should be allowed or denied to connect. */ -public enum IpFilterRuleType { - ACCEPT, - REJECT +enum class IpFilterRuleType { + ACCEPT, REJECT } diff --git a/src/dorkbox/network/ipFilter/IpSubnetFilterRule.kt b/src/dorkbox/network/ipFilter/IpSubnetFilterRule.kt index 58e7cda9..f47d1848 100644 --- a/src/dorkbox/network/ipFilter/IpSubnetFilterRule.kt +++ b/src/dorkbox/network/ipFilter/IpSubnetFilterRule.kt @@ -21,8 +21,9 @@ import java.math.BigInteger import java.net.* /** - * Use this class to create rules for [RuleBasedIpFilter] that group IP addresses into subnets. - * Supports both, IPv4 and IPv6. + * Use this class to create rules that group IP addresses into subnets. + * + * Supports both IPv4 and IPv6. */ class IpSubnetFilterRule : IpFilterRule { companion object { @@ -70,7 +71,7 @@ class IpSubnetFilterRule : IpFilterRule { } private class FakeSubnetFilterRule() : IpFilterRule { - override fun matches(remoteAddress: InetSocketAddress?): Boolean { + override fun matches(remoteAddress: InetSocketAddress): Boolean { return true }