package com.charlesdream.office.shared.enums;

import com.charlesdream.office.BaseEnum;

import java.util.EnumSet;
import java.util.HashMap;
import java.util.Map;

/**
 * Specifies the intensity of light used on a shape.
 * <p>
 *
 * @author Charles Cui on 5/5/2016.
 * @since 1.0
 */
public enum MsoPresetLightingSoftness implements BaseEnum {

    /**
     * Bright light.
     *
     * @since 1.0
     */
    msoLightingBright(3),

    /**
     * Dim light.
     *
     * @since 1.0
     */
    msoLightingDim(1),

    /**
     * Normal light.
     *
     * @since 1.0
     */
    msoLightingNormal(2),

    /**
     * Not supported.
     *
     * @since 1.0
     */
    msoPresetLightingSoftnessMixed(-2);


    private static final Map<Integer, MsoPresetLightingSoftness> lookup;

    static {
        lookup = new HashMap<>();

        for (MsoPresetLightingSoftness e : EnumSet.allOf(MsoPresetLightingSoftness.class)) {
            lookup.put(e.value(), e);
        }
    }


    private final int value;

    MsoPresetLightingSoftness(int value) {
        this.value = value;
    }


    /**
     * Find the enum type by its value.
     *
     * @param value The enum value.
     * @return The enum type, or null if this enum value does not exists.
     * @since 1.0
     */
    public static MsoPresetLightingSoftness find(int value) {
        MsoPresetLightingSoftness result = lookup.get(value);

        return result;
    }

    /**
     * Find the enum type by its value, with the default value.
     *
     * @param value        The enum value.
     * @param defaultValue The default return value if the enum value does not exists.
     * @return The enum type, or the default value if this enum value does not exists.
     * @since 1.0
     */
    public static MsoPresetLightingSoftness find(int value, MsoPresetLightingSoftness defaultValue) {
        MsoPresetLightingSoftness result = MsoPresetLightingSoftness.find(value);

        if (result == null) {
            result = defaultValue;
        }

        return result;
    }

    /**
     * Get the value of a enum type.
     *
     * @return The value of a enum type.
     * @since 1.0
     */
    public int value() {
        return this.value;
    }
}
