From 945c0ccd6560cca64156a1b83039102040b99829 Mon Sep 17 00:00:00 2001 From: Lyubomir Marinov Date: Thu, 24 Mar 2016 16:17:27 -0500 Subject: [PATCH] Implements Agent#isOver() in IceProcessingState (like isEstablished()). --- src/main/java/org/ice4j/ice/Agent.java | 6 +++--- .../java/org/ice4j/ice/IceProcessingState.java | 16 ++++++++++++++++ 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/src/main/java/org/ice4j/ice/Agent.java b/src/main/java/org/ice4j/ice/Agent.java index eb62b6b..f993b67 100644 --- a/src/main/java/org/ice4j/ice/Agent.java +++ b/src/main/java/org/ice4j/ice/Agent.java @@ -681,9 +681,9 @@ public class Agent */ public boolean isOver() { - return state == IceProcessingState.COMPLETED - || state == IceProcessingState.TERMINATED - || state == IceProcessingState.FAILED; + IceProcessingState state = getState(); + + return (state != null) && state.isOver(); } /** diff --git a/src/main/java/org/ice4j/ice/IceProcessingState.java b/src/main/java/org/ice4j/ice/IceProcessingState.java index 3de46b9..53aeb6d 100644 --- a/src/main/java/org/ice4j/ice/IceProcessingState.java +++ b/src/main/java/org/ice4j/ice/IceProcessingState.java @@ -35,6 +35,7 @@ package org.ice4j.ice; * refer to with "Terminated". * * @author Emil Ivov + * @author Lyubomir Marinov */ public enum IceProcessingState { @@ -99,6 +100,21 @@ public enum IceProcessingState return stateName; } + /** + * Determines whether an {@link Agent} in this state has finished its ICE + * processing. + * + * @return {@code true} if an {@code Agent} in this state has finished its + * ICE processing; otherwise, {@code false} + */ + public boolean isOver() + { + return + COMPLETED.equals(this) + || FAILED.equals(this) + || TERMINATED.equals(this); + } + /** * Returns true iff the state is one in which a connection * has been established, that is either COMPLETED or