blob: c7a5c88437cfbae86cde2becaf7fca6e7361da46 [file] [log] [blame]
/*
* Copyright 2005 The Apache Software Foundation.
*
* Licensed under the Apache License, Version 2.0 (the "License")
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.apache.jcs.yajcache.util;
import java.math.BigDecimal;
import java.math.BigInteger;
import org.apache.jcs.yajcache.lang.annotation.*;
/**
*
* @author Hanson Char
*/
// @CopyRightApache
// http://www.netbeans.org/issues/show_bug.cgi?id=53704
public enum ClassUtils {
inst;
/**
* Returns true if instances of the given class is known to be immutable;
* false if we don't know.
*/
public boolean isImmutable(@NonNullable Class t) {
return t == String.class
|| t.isPrimitive()
|| t == Boolean.class
|| t == Byte.class
|| t == Character.class
|| t == Short.class
|| t == Integer.class
|| t == Long.class
|| t == Float.class
|| t == Double.class
|| t == BigInteger.class
|| t == BigDecimal.class
|| t.isEnum()
;
}
public boolean isImmutable(@NonNullable Object obj) {
return this.isImmutable(obj.getClass());
}
}