Interface SessionVersion
- All Known Implementing Classes:
MegolmSessionVersion, MessageType, OlmSessionVersion
public interface SessionVersion
Common interface for session version enums such as
OlmSessionVersion and
MegolmSessionVersion.
Provides a shared fromVersion(Enum[], int, String) utility that
resolves a numeric version to its corresponding enum constant, throwing
a ConversionException when no match is found.
- Author:
- François HERBRETEAU
-
Method Summary
Modifier and TypeMethodDescriptionstatic <E extends Enum<E> & SessionVersion>
EfromVersion(E[] values, int version, String label) Resolves the given numeric version to its corresponding enum constant.intvalue()Returns the numeric value of this session version.
-
Method Details
-
value
int value()Returns the numeric value of this session version.- Returns:
- the version number (1 for V1, 2 for V2)
-
fromVersion
Resolves the given numeric version to its corresponding enum constant.- Type Parameters:
E- the enum type, which must also implementSessionVersion- Parameters:
values- the enum constants to search (typicallyE.values())version- the numeric version to matchlabel- a human-readable label used in the error message if no match is found (e.g."version"or"message type")- Returns:
- the enum constant whose
value()matches the given version - Throws:
ConversionException- if no constant matches the given version
-