package com.bt.openlink.type;

import java.util.Optional;

import javax.annotation.Nonnull;
import javax.annotation.Nullable;

/**
 * List of recommended feature types.<br>
 * Reference: Openlink Specification xep-xxx-openlink_15-12, section 4.5.2
 */
public enum FeatureType {

    MESSAGE_WAITING("MessageWaiting"),
    MICROPHONE_GAIN("MicrophoneGain"),
    MICROPHONE_MUTE("MicrophoneMute"),
    RINGER_STATUS("RingerStatus"),
    SPEAKER_MUTE("SpeakerMute"),
    SPEED_DIAL("SpeedDial"),
    GROUP_INTERCOM("GroupIntercom"),
    SPEAKER_CHANNEL("SpeakerChannel"),
    VOICE_MESSAGE("VoiceMessage"),
    VOICE_MESSAGE_PLAYLIST("VoiceMessagePlaylist"),
    VOICE_RECORDER("VoiceRecorder"),
    VOICE_BRIDGE("VoiceBridge"),
    PRIVACY("Privacy"),
    HANDSET("Handset"),
    DO_NOT_DISTURN("DoNotDisturb"),
    CALL_FORWARD("CallForward"),
    CALL_BACK("CallBack"),
    CONFERENCE("Conference"),
    MEDIA_STREAM("MediaStream"),
    DEVICE_KEYS("DeviceKeys");

    @Nonnull private final String id;

    FeatureType(@Nonnull final String id) {
        this.id = id;
    }

    @Nonnull
    public String getId() {
        return id;
    }

    @Nonnull
    public static Optional<FeatureType> from(@Nullable final String value) {
        for (final FeatureType featureType : FeatureType.values()) {
            if (featureType.id.equalsIgnoreCase(value)) {
                return Optional.of(featureType);
            }
        }
        return Optional.empty();
    }

}

@@ -240,16 +240,110 @@
 on 4.5.2
+%3Cbr%3E%0A * Note; FeatureType.HEADSET is not part of the spec. Refer to bt-openlink-extensions%3Cbr%3E
 %0A */%0Apub
@@ -857,24 +857,48 @@
 %22Handset%22),%0A
+    HEADSET(%22Headset%22),%0A
     DO_NOT_D

Add support for a headset feature.