Deprecate NoopAutoCloseable for removal
[controller.git] / opendaylight / md-sal / sal-common-util / src / main / java / org / opendaylight / controller / sal / common / util / Arguments.java
1 /*
2  * Copyright (c) 2013 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.controller.sal.common.util;
9
10 public final class Arguments {
11
12     private Arguments() {
13         throw new UnsupportedOperationException("Utility class");
14     }
15
16     /**
17      * Checks if value is instance of provided class.
18      *
19      * @param value Value to check
20      * @param type Type to check
21      * @return Reference which was checked
22      */
23     @SuppressWarnings("unchecked")
24     public static <T> T checkInstanceOf(Object value, Class<T> type) {
25         if (!type.isInstance(value)) {
26             throw new IllegalArgumentException(String.format("Value %s is not of type %s", value, type));
27         }
28         return (T) value;
29     }
30 }

©2013 OpenDaylight, A Linux Foundation Collaborative Project. All Rights Reserved.
OpenDaylight is a registered trademark of The OpenDaylight Project, Inc.
Linux Foundation and OpenDaylight are registered trademarks of the Linux Foundation.
Linux is a registered trademark of Linus Torvalds.