All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.alachisoft.ncache.client.util.ClientEnumUtil Maven / Gradle / Ivy

There is a newer version: 5.3.0
Show newest version
package com.alachisoft.ncache.client.util;

import Alachisoft.NCache.Caching.Util.Log;
import com.alachisoft.ncache.client.*;
import com.alachisoft.ncache.client.internal.caching.CacheItemRemovedReason;
import com.alachisoft.ncache.runtime.caching.DeliveryOption;
import com.alachisoft.ncache.runtime.caching.messaging.DeliveryMode;
import com.alachisoft.ncache.runtime.caching.messaging.TopicSearchOptions;
import com.alachisoft.ncache.runtime.events.EventType;
import com.google.protobuf.Internal;

import java.util.EnumSet;
import java.util.List;

public class ClientEnumUtil {

    public static IsolationLevel getIsolationLevel(Integer value) {
        return IsolationLevel.forValue((value));
    }

    public static int getIsolationLevelValue(IsolationLevel options) {
        return options.getValue();
    }

    public static CacheStatusNotificationType getCacheStatusNotificationType(String value) {
        return CacheStatusNotificationType.valueOf(value);
    }

    public static String getCacheStatusNotificationTypeValue(CacheStatusNotificationType type) {
        return type.name().toString();
    }

    public static DeliveryMode getDeliveryMode(String mode) {
        return DeliveryMode.valueOf(mode);
    }

    public static String getDeliveryModeValue(DeliveryMode mode) {
        return mode.name().toString();
    }

    public static DeliveryOption getDeliveryOption(Integer option) {
        return DeliveryOption.forValue(option);
    }

    public static String getDeliveryOptionValue(DeliveryOption option) {
        return option.name().toString();
    }

    public static CacheItemRemovedReason getCacheItemRemovedReason(Integer value) {
        return CacheItemRemovedReason.forValue(value);
    }

    public static String getCacheItemRemovedReasonValue(CacheItemRemovedReason reason) {
        return reason.name().toString();
    }

    public static LogLevel getLogLevel(Integer value) {
        return LogLevel.forValue(value);
    }

    public static int getLogLevelValue(LogLevel level) {
        return level.getValue();
    }
    public static EnumSet EnumSetCacheStatus(List types) throws Exception {
        java.util.EnumSet _eventType = null;
        for (CacheStatusNotificationType type : types) {
            switch (type) {
                case CacheStopped:
                    _eventType = EnumSet.of(CacheStatusNotificationType.CacheStopped);
                    break;
                case MemberJoined:
                    _eventType = EnumSet.of(CacheStatusNotificationType.MemberJoined);
                    break;
                case MemberLeft:
                    _eventType = EnumSet.of(CacheStatusNotificationType.MemberLeft);
                    break;
                case ALL:
                    _eventType = EnumSet.of(CacheStatusNotificationType.ALL);
                    break;

                default:
                    throw new Exception(type + " no action is defined for this type.");
            }
        }

        return _eventType;
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy