2 * Copyright (c) 2014 Cisco Systems, Inc. and others. All rights reserved.
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
8 package org.opendaylight.yangtools.util;
10 import static com.google.common.base.Preconditions.checkArgument;
12 import com.google.common.collect.ImmutableSet;
13 import java.math.BigDecimal;
14 import java.math.BigInteger;
15 import org.opendaylight.yangtools.concepts.Immutable;
16 import org.opendaylight.yangtools.concepts.Mutable;
18 @Deprecated(since = "7.0.9", forRemoval = true)
19 public final class Immutables {
20 private static final ImmutableSet<Class<?>> KNOWN_IMMUTABLES = ImmutableSet.of(
21 Integer.class, Short.class, BigDecimal.class, BigInteger.class, Byte.class, Character.class, Double.class,
22 Float.class, String.class, Boolean.class, Void.class);
24 private Immutables() {
29 * Determines if object is known to be immutable
31 * <p>Note: This method may return false to immutable objects which
32 * immutability is not known, was defined not using concepts term.
34 * @param obj Reference to check
35 * @return true if object is known to be immutable false otherwise.
37 public static boolean isImmutable(final Object obj) {
38 checkArgument(obj != null,"Object should not be null");
39 if (obj instanceof Mutable) {
41 } else if (obj instanceof Immutable || obj instanceof String || KNOWN_IMMUTABLES.contains(obj.getClass())) {