Split Restconf implementations (draft02 and RFC) - move
[netconf.git] / restconf / restconf-nb-bierman02 / src / main / java / org / opendaylight / restconf / restful / utils / ResolveEnumUtil.java
1 /*
2  * Copyright (c) 2016 Cisco Systems, Inc. and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package org.opendaylight.restconf.restful.utils;
9
10 /**
11  * Common util class for resolve enum from String.
12  *
13  * @deprecated move to splitted module restconf-nb-rfc8040
14  */
15 @Deprecated
16 public final class ResolveEnumUtil {
17
18     private ResolveEnumUtil() {
19         throw new UnsupportedOperationException("Util class");
20     }
21
22     /**
23      * Resolve specific type of enum by value.
24      *
25      * @param clazz
26      *             enum
27      * @param value
28      *             string of enum
29      * @return - enum
30      */
31     public static <T> T resolveEnum(final Class<T> clazz, final String value) {
32         for (final T t : clazz.getEnumConstants()) {
33             if (((Enum<?>) t).name().equals(value)) {
34                 return t;
35             }
36         }
37         return null;
38     }
39 }