Example usage for java.lang Class getName

List of usage examples for java.lang Class getName

Introduction

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

Prototype

public String getName() 

Source Link

Document

Returns the name of the entity (class, interface, array class, primitive type, or void) represented by this Class object, as a String .

Usage

From source file:id.zelory.tanipedia.util.Utils.java

public static boolean isMyServiceRunning(Class<?> serviceClass, Context context) {
    ActivityManager manager = (ActivityManager) context.getSystemService(Context.ACTIVITY_SERVICE);
    for (ActivityManager.RunningServiceInfo service : manager.getRunningServices(Integer.MAX_VALUE)) {
        if (serviceClass.getName().equals(service.service.getClassName())) {
            return true;
        }/*from   ww w .  j a v a  2 s  .c  o  m*/
    }
    return false;
}

From source file:com.yukthi.utils.beans.PropertyMapper.java

/**
 * Called to check when property copy has to be done mismatching fields. Simple types like primitives, java core classes and arrays will be skipped.
 * @param type Type to be checked/*from  w  w  w. jav a  2 s . c  o m*/
 * @return
 */
private static boolean isIgnorableType(Class<?> type) {
    if (type.isPrimitive() || type.getName().startsWith("java") || type.isArray()) {
        return true;
    }

    return false;
}

From source file:com.yc.modules.utils.Reflections.java

public static Class<?> getUserClass(Object instance) {
    Assert.notNull(instance, "Instance must not be null");
    Class clazz = instance.getClass();
    if ((clazz != null) && clazz.getName().contains(CGLIB_CLASS_SEPARATOR)) {
        Class<?> superClass = clazz.getSuperclass();
        if ((superClass != null) && !Object.class.equals(superClass)) {
            return superClass;
        }//from  www.j a  va 2 s.  co m
    }
    return clazz;

}

From source file:io.rhiot.utils.Reflections.java

public static void runMain(Class<?> classWithMain, String... args) {
    try {/*  w  w  w. j  av  a2 s.  c o m*/
        Method mainMethod = classWithMain.getMethod("main", String[].class);
        if (mainMethod == null) {
            throw new IllegalArgumentException("No main method in class " + classWithMain.getName());
        }
        mainMethod.invoke(null, new Object[] { args });
    } catch (InvocationTargetException | NoSuchMethodException | IllegalAccessException e) {
        throw new RuntimeException(e);
    }
}

From source file:com.jlfex.hermes.common.utils.Reflections.java

@SuppressWarnings("rawtypes")
public static Class<?> getUserClass(Object instance) {
    Validate.notNull(instance, "Instance must not be null");
    Class clazz = instance.getClass();
    if ((clazz != null) && clazz.getName().contains(CGLIB_CLASS_SEPARATOR)) {
        Class<?> superClass = clazz.getSuperclass();
        if ((superClass != null) && !Object.class.equals(superClass)) {
            return superClass;
        }/*from www. j a v a 2s.c  o  m*/
    }
    return clazz;

}

From source file:cn.com.qiqi.order.utils.Reflections.java

@SuppressWarnings("rawtypes")
public static Class<?> getUserClass(Object instance) {
    Assert.notNull(instance, "Instance must not be null");
    Class clazz = instance.getClass();
    if (clazz != null && clazz.getName().contains(CGLIB_CLASS_SEPARATOR)) {
        Class<?> superClass = clazz.getSuperclass();
        if (superClass != null && !Object.class.equals(superClass)) {
            return superClass;
        }/*from  w  w w.  j a  v  a2s. c om*/
    }
    return clazz;

}

From source file:com.cprassoc.solr.auth.util.Utils.java

public static RequestHandler getRequestHandler(String className) {
    RequestHandler handler = null;/*from w w w  .  j  a  va2s. c o m*/
    try {
        // Create a new JavaClassLoader

        ClassLoader classLoader = Utils.class.getClassLoader();

        // Load the target class using its binary name

        Class loadedMyClass = classLoader.loadClass(className);

        System.out.println("Loaded class name: " + loadedMyClass.getName());

        // Create a new instance from the loaded class

        Constructor constructor = loadedMyClass.getConstructor();

        Object myClassObject = constructor.newInstance();
        handler = (RequestHandler) myClassObject;

    } catch (Exception e) {
        e.printStackTrace();
    }
    return handler;
}

From source file:com.cprassoc.solr.auth.util.Utils.java

public static Handler getHandler(String className) {
    Handler handler = null;/*from   w w w .  j a  va  2  s . c  o m*/
    try {
        // Create a new JavaClassLoader

        ClassLoader classLoader = Utils.class.getClassLoader();

        // Load the target class using its binary name

        Class loadedMyClass = classLoader.loadClass(className);

        System.out.println("Loaded class name: " + loadedMyClass.getName());

        // Create a new instance from the loaded class

        Constructor constructor = loadedMyClass.getConstructor();

        Object myClassObject = constructor.newInstance();
        handler = (Handler) myClassObject;

    } catch (Exception e) {
        e.printStackTrace();
    }
    return handler;
}

From source file:org.fusesource.meshkeeper.util.internal.IntrospectionSupport.java

public static String simpleName(Class<?> clazz) {
    String name = clazz.getName();
    int p = name.lastIndexOf(".");
    if (p >= 0) {
        name = name.substring(p + 1);/*from   ww  w  .  j  av  a  2s .c o m*/
    }
    return name;
}