Example usage for java.lang Class isLocalClass

List of usage examples for java.lang Class isLocalClass

Introduction

In this page you can find the example usage for java.lang Class isLocalClass.

Prototype

public boolean isLocalClass() 

Source Link

Document

Returns true if and only if the underlying class is a local class.

Usage

From source file:Main.java

public static void main(String[] args) {

    Main c = new Main();
    Class cls = c.getClass();

    boolean retval = cls.isLocalClass();
    System.out.println(retval);//from ww w. j av a  2s. c om
}

From source file:Main.java

public static void main(String[] args) {

    Main c = new Main();
    Class cls = c.getClass();

    // returns true if and only if this class is a local class
    boolean retval = cls.isLocalClass();
    System.out.println(retval);//from www  .j  av  a 2 s. c o m
}

From source file:io.github.pellse.decorator.util.reflection.ReflectionUtils.java

public static boolean isNestedClass(Class<?> clazz) {
    return clazz.isMemberClass() || clazz.isLocalClass() || clazz.isAnonymousClass();
}

From source file:com.edmunds.autotest.ClassUtil.java

public static boolean isStandardClass(Class cls) {
    return !(((cls.getModifiers() & Modifier.ABSTRACT) > 0) || cls.isInterface() || cls.isMemberClass()
            || cls.isLocalClass() || cls.isSynthetic());
}

From source file:org.assertj.assertions.generator.util.ClassUtil.java

/**
 * @param loadedClass//ww w . ja va  2s.co  m
 * @return
 */
private static boolean isClassCandidateToAssertionsGeneration(Class<?> loadedClass) {
    return loadedClass != null && isPublic(loadedClass.getModifiers()) && !loadedClass.isAnonymousClass()
            && !loadedClass.isLocalClass();
}

From source file:org.springframework.jdbc.core.JdbcOperationsUtils.java

public static final void validatePropertyValue(String id, String propName, Object propValue,
        ConversionService converter) {//from  w  w w  .ja v a2s.  c  o m
    if (StringUtils.isEmpty(propName)) {
        throw new IllegalStateException("validatePropertyValue(" + id + ") no property name");
    }

    if (propValue == null) {
        throw new IllegalStateException("validatePropertyValue(" + id + ")[" + propName + "] no value");
    }

    if (!(propValue instanceof Serializable)) {
        throw new IllegalStateException("validatePropertyValue(" + id + ")[" + propName + "] not serializable");
    }

    Class<?> propType = resolveEffectivePropertyType(propValue);
    if (Date.class.isAssignableFrom(propType) || Calendar.class.isAssignableFrom(propType)) {
        return; // Date(s) have a special handling
    }

    if (propType == Class.class) {
        Class<?> valueClass = (Class<?>) propValue;
        if (Proxy.isProxyClass(valueClass)) {
            throw new IllegalStateException("validatePropertyValue(" + id + ")[" + propName + "] proxies N/A");
        }

        if (valueClass.isAnonymousClass()) {
            throw new IllegalStateException("validatePropertyValue(" + id + ")[" + propName + "]"
                    + " anonymous classes N/A: " + valueClass.getName());
        }

        if (valueClass.isLocalClass()) {
            throw new IllegalStateException("validatePropertyValue(" + id + ")[" + propName + "]"
                    + " local classes N/A: " + valueClass.getName());
        }

        if (valueClass.isArray()) {
            throw new IllegalStateException("validatePropertyValue(" + id + ")[" + propName + "]"
                    + " array classes N/A: " + valueClass.getName());
        }

        int mods = valueClass.getModifiers();
        if (!Modifier.isPublic(mods)) {
            throw new IllegalStateException("validatePropertyValue(" + id + ")[" + propName + "]"
                    + " non-public classes N/A: " + valueClass.getName());
        }
    }

    if (!converter.canConvert(String.class, propType)) {
        throw new IllegalStateException("validatePropertyValue(" + id + ")[" + propName + "]"
                + " cannot convert a string to a " + propType.getSimpleName());
    }
}

From source file:com.feilong.core.lang.ClassUtilTest.java

/**
 *  class info map for LOGGER.//from w w  w. jav a  2  s .c om
 *
 * @param klass
 *            the klass
 * @return  <code>klass</code> nullempty, {@link Collections#emptyMap()}<br>
 */
public static Map<String, Object> getClassInfoMapForLog(Class<?> klass) {
    if (isNullOrEmpty(klass)) {
        return Collections.emptyMap();
    }

    Map<String, Object> map = new LinkedHashMap<String, Object>();

    map.put("clz.getCanonicalName()", klass.getCanonicalName());//"com.feilong.core.date.DatePattern"
    map.put("clz.getName()", klass.getName());//"com.feilong.core.date.DatePattern"
    map.put("clz.getSimpleName()", klass.getSimpleName());//"DatePattern"

    map.put("clz.getComponentType()", klass.getComponentType());
    // ?"". ,voidboolean?byte?char?short?int?long?float  double?.
    map.put("clz.isPrimitive()", klass.isPrimitive());

    // ?"".,.
    map.put("clz.isLocalClass()", klass.isLocalClass());
    // ?"?".?,?,?"""??".
    map.put("clz.isMemberClass()", klass.isMemberClass());

    //isSynthetic()?Class?"??".java??false,?true.,JVM???,java??"??"?
    map.put("clz.isSynthetic()", klass.isSynthetic());
    map.put("clz.isArray()", klass.isArray());
    map.put("clz.isAnnotation()", klass.isAnnotation());

    //??true.
    map.put("clz.isAnonymousClass()", klass.isAnonymousClass());
    map.put("clz.isEnum()", klass.isEnum());

    return map;
}

From source file:de.alpharogroup.lang.ClassExtensions.java

/**
 * Gets the {@link ClassType} from the given class.
 *
 * @param clazz/*  ww  w.j ava 2s  .  c om*/
 *            The class.
 * @return the {@link ClassType} from the given class.
 */
public static ClassType getClassType(final Class<?> clazz) {
    if (clazz.isArray()) {
        return ClassType.ARRAY;
    }
    if (isCollection(clazz)) {
        return ClassType.COLLECTION;
    }
    if (isMap(clazz)) {
        return ClassType.MAP;
    }
    if (clazz.isLocalClass()) {
        return ClassType.LOCAL;
    }
    if (clazz.isMemberClass()) {
        return ClassType.MEMBER;
    }
    if (clazz.isPrimitive()) {
        return ClassType.PRIMITIVE;
    }
    if (clazz.isAnnotation()) {
        return ClassType.ANNOTATION;
    }
    if (clazz.isEnum()) {
        return ClassType.ENUM;
    }
    if (clazz.isInterface()) {
        return ClassType.INTERFACE;
    }
    if (clazz.isSynthetic()) {
        return ClassType.SYNTHETIC;
    }
    if (clazz.isAnonymousClass()) {
        return ClassType.ANONYMOUS;
    }
    return ClassType.DEFAULT;
}

From source file:com.discovery.darchrow.lang.ClassUtil.java

/**
 *  class info map for LOGGER./*from  www  . ja  va2  s  .c  o m*/
 *
 * @param klass
 *            the clz
 * @return the map for log
 */
public static Map<String, Object> getClassInfoMapForLog(Class<?> klass) {
    if (Validator.isNullOrEmpty(klass)) {
        return null;
    }

    Map<String, Object> map = new LinkedHashMap<String, Object>();

    map.put("clz.getCanonicalName()", klass.getCanonicalName());//"com.feilong.core.date.DatePattern"
    map.put("clz.getName()", klass.getName());//"com.feilong.core.date.DatePattern"
    map.put("clz.getSimpleName()", klass.getSimpleName());//"DatePattern"

    map.put("clz.getComponentType()", klass.getComponentType());
    // ?? voidboolean?byte?char?short?int?long?float  double?
    map.put("clz.isPrimitive()", klass.isPrimitive());

    // ??,
    map.put("clz.isLocalClass()", klass.isLocalClass());
    // ????,??????
    map.put("clz.isMemberClass()", klass.isMemberClass());

    //isSynthetic()?Class????java??false?trueJVM???java??????
    map.put("clz.isSynthetic()", klass.isSynthetic());
    map.put("clz.isArray()", klass.isArray());
    map.put("clz.isAnnotation()", klass.isAnnotation());

    //??true
    map.put("clz.isAnonymousClass()", klass.isAnonymousClass());
    map.put("clz.isEnum()", klass.isEnum());

    return map;
}

From source file:adalid.core.XS1.java

private static boolean isRestrictedFieldType(Class<?> fieldType) {
    int modifiers = fieldType.getModifiers();
    boolean b = fieldType.isPrimitive();
    b |= Modifier.isAbstract(modifiers) || !Modifier.isPublic(modifiers);
    b |= fieldType.isAnnotation();/*w  w  w.jav a2 s  . co m*/
    b |= fieldType.isAnonymousClass();
    b |= fieldType.isArray();
    b |= fieldType.isEnum();
    b |= fieldType.isLocalClass();
    b |= fieldType.isInterface();
    return b;
}