Example usage for java.lang.reflect ParameterizedType getTypeName

List of usage examples for java.lang.reflect ParameterizedType getTypeName

Introduction

In this page you can find the example usage for java.lang.reflect ParameterizedType getTypeName.

Prototype

default String getTypeName() 

Source Link

Document

Returns a string describing this type, including information about any type parameters.

Usage

From source file:org.datalorax.populace.core.util.TypeUtils.java

/**
 * Returns an abbreviated generic name for logging purposes.  Package names are abbreviated to a single character.
 * Generic info is included.//w w w  .j a v a2  s.com
 *
 * @param type the type whose name should be abbreviated.
 * @return the abbreviated class name
 */
public static String abbreviatedName(final Type type) {
    if (type instanceof Class) {
        return abbreviatedName(((Class<?>) type).getName());
    }

    if (type instanceof ParameterizedType) {
        final ParameterizedType pt = (ParameterizedType) type;
        return abbreviatedName(pt.getTypeName());
    }

    throw new IllegalArgumentException("Type not supported: " + type);
}