diff --git a/src/main/java/org/ice4j/ice/harvest/AbstractCandidateHarvester.java b/src/main/java/org/ice4j/ice/harvest/AbstractCandidateHarvester.java new file mode 100644 index 0000000..854273b --- /dev/null +++ b/src/main/java/org/ice4j/ice/harvest/AbstractCandidateHarvester.java @@ -0,0 +1,51 @@ +/* + * ice4j, the OpenSource Java Solution for NAT and Firewall Traversal. + * + * Copyright @ 2015 Atlassian Pty Ltd + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + */ +package org.ice4j.ice.harvest; + +/** + * An abstract partial implementation of {@link CandidateHarvester}. + * + * @author Emil Ivov + * @author Lyubomir Marinov + * @author Boris Grozev + */ +public abstract class AbstractCandidateHarvester + implements CandidateHarvester +{ + /** + * Manages statistics about harvesting time. + */ + private HarvestStatistics harvestStatistics = new HarvestStatistics(); + + /** + * {@inheritDoc} + */ + public HarvestStatistics getHarvestStatistics() + { + return harvestStatistics; + } + + /** + * {@inheritDoc} + * @return + */ + public boolean isHostHarvester() + { + return false; + } +} diff --git a/src/main/java/org/ice4j/ice/harvest/CandidateHarvester.java b/src/main/java/org/ice4j/ice/harvest/CandidateHarvester.java index 3528d00..46bb0a2 100644 --- a/src/main/java/org/ice4j/ice/harvest/CandidateHarvester.java +++ b/src/main/java/org/ice4j/ice/harvest/CandidateHarvester.java @@ -28,14 +28,10 @@ import org.ice4j.ice.*; * * @author Emil Ivov * @author Lyubomir Marinov + * @author Boris Grozev */ -public abstract class CandidateHarvester +public interface CandidateHarvester { - /** - * Manages statistics about harvesting time. - */ - private HarvestStatistics harvestStatistics = new HarvestStatistics(); - /** * Gathers all candidate addresses of the type that this * CandidateHarvester supports. The gathered candidate addresses @@ -52,7 +48,7 @@ public abstract class CandidateHarvester * as they are discovered, they should also be returned in order to make * sure that the gathering will be considered successful. */ - public abstract Collection harvest(Component component); + Collection harvest(Component component); /** * Returns the statistics describing how well the various harvests of this @@ -61,10 +57,7 @@ public abstract class CandidateHarvester * @return The {@link HarvestStatistics} describing this harvester's * harvests. */ - public HarvestStatistics getHarvestStatistics() - { - return harvestStatistics; - } + HarvestStatistics getHarvestStatistics(); /** * Returns true if this CandidateHarvester is to be @@ -77,8 +70,5 @@ public abstract class CandidateHarvester * @return true if this CandidateHarvester is a harvester * for host candidates. */ - public boolean isHostHarvester() - { - return false; - } + boolean isHostHarvester(); } diff --git a/src/main/java/org/ice4j/ice/harvest/MappingCandidateHarvester.java b/src/main/java/org/ice4j/ice/harvest/MappingCandidateHarvester.java index b2a8877..021d032 100644 --- a/src/main/java/org/ice4j/ice/harvest/MappingCandidateHarvester.java +++ b/src/main/java/org/ice4j/ice/harvest/MappingCandidateHarvester.java @@ -41,7 +41,7 @@ import java.util.*; * @author Emil Ivov */ public class MappingCandidateHarvester - extends CandidateHarvester + extends AbstractCandidateHarvester { /** * The addresses that we will use as a mask diff --git a/src/main/java/org/ice4j/ice/harvest/SinglePortUdpHarvester.java b/src/main/java/org/ice4j/ice/harvest/SinglePortUdpHarvester.java index 04d5965..c03f2ac 100644 --- a/src/main/java/org/ice4j/ice/harvest/SinglePortUdpHarvester.java +++ b/src/main/java/org/ice4j/ice/harvest/SinglePortUdpHarvester.java @@ -53,7 +53,7 @@ import java.util.logging.Logger; // Disambiguation * @author Boris Grozev */ public class SinglePortUdpHarvester - extends CandidateHarvester + extends AbstractCandidateHarvester { /** * Our class logger. diff --git a/src/main/java/org/ice4j/ice/harvest/StunCandidateHarvester.java b/src/main/java/org/ice4j/ice/harvest/StunCandidateHarvester.java index 3eaa624..33b21d1 100644 --- a/src/main/java/org/ice4j/ice/harvest/StunCandidateHarvester.java +++ b/src/main/java/org/ice4j/ice/harvest/StunCandidateHarvester.java @@ -36,7 +36,7 @@ import org.ice4j.stack.*; * @author Lyubomir Marinov */ public class StunCandidateHarvester - extends CandidateHarvester + extends AbstractCandidateHarvester { /** diff --git a/src/main/java/org/ice4j/ice/harvest/TcpHarvester.java b/src/main/java/org/ice4j/ice/harvest/TcpHarvester.java index fea4e97..4c6cf2d 100644 --- a/src/main/java/org/ice4j/ice/harvest/TcpHarvester.java +++ b/src/main/java/org/ice4j/ice/harvest/TcpHarvester.java @@ -46,7 +46,7 @@ import org.ice4j.socket.*; * @author Lyubomir Marinov */ public class TcpHarvester - extends CandidateHarvester + extends AbstractCandidateHarvester { /** * Our class logger. diff --git a/src/main/java/org/ice4j/ice/harvest/UPNPHarvester.java b/src/main/java/org/ice4j/ice/harvest/UPNPHarvester.java index 6fe0d5a..a838445 100644 --- a/src/main/java/org/ice4j/ice/harvest/UPNPHarvester.java +++ b/src/main/java/org/ice4j/ice/harvest/UPNPHarvester.java @@ -34,7 +34,7 @@ import org.bitlet.weupnp.*; * @author Sebastien Vincent */ public class UPNPHarvester - extends CandidateHarvester + extends AbstractCandidateHarvester { /** * The logger.