// Path: sdk/src/main/java/com/punchthrough/bean/sdk/internal/exception/NoEnumFoundException.java
// public class NoEnumFoundException extends Exception {
//     public NoEnumFoundException(String detailMessage) {
//         super(detailMessage);
//     }
// }


import com.punchthrough.bean.sdk.internal.exception.NoEnumFoundException;
import java.util.EnumSet;
package com.punchthrough.bean.sdk.internal.utility;



/**
 * Utilities for parsing enums from raw values.
 */
public class EnumParse {

    /**
     * Denotes enums that provide a method "int getRawValue()" to get their unique int representation.
     */
    public static interface ParsableEnum {
        public int getRawValue();
    }

    /**
     * Retrieve the enum of a given type from a given raw value. Enums must implement the
     * {@link com.punchthrough.bean.sdk.internal.utility.EnumParse.ParsableEnum} interface to ensure they have
     * a {@link com.punchthrough.bean.sdk.internal.utility.EnumParse.ParsableEnum#getRawValue()} method.
     * <a href="http://stackoverflow.com/a/16406386/254187">Based on this StackOverflow answer.</a>
     *
     * @param enumClass The class of the enum type being parsed, e.g. <code>BeanState.class</code>
     * @param value     The raw int value of the enum to be retrieved
     * @param <T>       The enum type being parsed
     * @return          The enum value with the given raw value
     *
     * @throws com.punchthrough.bean.sdk.internal.exception.NoEnumFoundException if the given enum type has no enum value with a raw value
     *      matching the given value
     */
    public static <T extends Enum & ParsableEnum> T enumWithRawValue(Class<T> enumClass, int value)
// Path: sdk/src/main/java/com/punchthrough/bean/sdk/internal/exception/NoEnumFoundException.java
// public class NoEnumFoundException extends Exception {
//     public NoEnumFoundException(String detailMessage) {
//         super(detailMessage);
//     }
// }


// Path: sdk/src/main/java/com/punchthrough/bean/sdk/internal/utility/EnumParse.java
import com.punchthrough.bean.sdk.internal.exception.NoEnumFoundException;
import java.util.EnumSet;

package com.punchthrough.bean.sdk.internal.utility;



/**
 * Utilities for parsing enums from raw values.
 */
public class EnumParse {

    /**
     * Denotes enums that provide a method "int getRawValue()" to get their unique int representation.
     */
    public static interface ParsableEnum {
        public int getRawValue();
    }

    /**
     * Retrieve the enum of a given type from a given raw value. Enums must implement the
     * {@link com.punchthrough.bean.sdk.internal.utility.EnumParse.ParsableEnum} interface to ensure they have
     * a {@link com.punchthrough.bean.sdk.internal.utility.EnumParse.ParsableEnum#getRawValue()} method.
     * <a href="http://stackoverflow.com/a/16406386/254187">Based on this StackOverflow answer.</a>
     *
     * @param enumClass The class of the enum type being parsed, e.g. <code>BeanState.class</code>
     * @param value     The raw int value of the enum to be retrieved
     * @param <T>       The enum type being parsed
     * @return          The enum value with the given raw value
     *
     * @throws com.punchthrough.bean.sdk.internal.exception.NoEnumFoundException if the given enum type has no enum value with a raw value
     *      matching the given value
     */
    public static <T extends Enum & ParsableEnum> T enumWithRawValue(Class<T> enumClass, int value)
            throws NoEnumFoundException {