Java Object to String toText(T t)

Here you can find the source of toText(T t)

Description

Converts an enum to basic text representation

License

Open Source License

Parameter

Parameter Description
t The enum value to convert
T The type of the enum to convert, used for type safety

Return

Returns the string representing the enum literal

Declaration

public static <T extends Enum<T>> String toText(T t) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**/*from  www.  ja  v  a  2  s  .co  m*/
     * Converts an enum to basic text representation
     *
     * @param t   The enum value to convert
     * @param <T> The type of the enum to convert, used for type safety
     * @return Returns the string representing the enum literal
     */
    public static <T extends Enum<T>> String toText(T t) {
        return t.toString().replaceAll("_+", " ").toLowerCase();
    }
}

Related

  1. toString(Object val)
  2. toString(Object value)
  3. toString(Object value)
  4. toString(Object value)
  5. toText(Object[] objs, String ch)