Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions src/main/java/com/vonage/client/video/ConnectionState.java
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonValue;
import com.vonage.client.Jsonable;

/**
* Represents the state of a connection in a Vonage Video session.
Expand All @@ -37,15 +38,16 @@ public enum ConnectionState {
*/
DISCONNECTED;

/**
* Convert a string to a ConnectionState enum.
*
* @param value The string to convert.
*
* @return The ConnectionState as an enum, or {@code null} if invalid.
*/
@JsonCreator
public static ConnectionState fromString(String state) {
if (state == null) return null;
try {
return ConnectionState.valueOf(state.toUpperCase());
}
catch (IllegalArgumentException ex) {
return null;
}
public static ConnectionState fromString(String value) {
return Jsonable.fromString(value, ConnectionState.class);
}

@JsonValue
Expand Down