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 Type
    Method
    Description
    static <E extends Enum<E> & SessionVersion>
    E
    fromVersion(E[] values, int version, String label)
    Resolves the given numeric version to its corresponding enum constant.
    int
    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

      static <E extends Enum<E> & SessionVersion> E fromVersion(E[] values, int version, String label)
      Resolves the given numeric version to its corresponding enum constant.
      Type Parameters:
      E - the enum type, which must also implement SessionVersion
      Parameters:
      values - the enum constants to search (typically E.values())
      version - the numeric version to match
      label - 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