Java Class Field Convert To fieldToString(String name, Object value)

Here you can find the source of fieldToString(String name, Object value)

Description

Returns a string that allows a field value pair to be added to a debug string.

License

Open Source License

Declaration

public static String fieldToString(String name, Object value) 

Method Source Code

//package com.java2s;

public class Main {
    /**/*from  w w w  . j av  a 2 s .  c  o m*/
     * Returns a string that allows a field value pair to be added to a debug
     * string.
     */
    public static String fieldToString(String name, Object value) {
        return fieldToString(name, value, false);
    }

    /**
     * Returns a string that allows a field value pair to be added to a debug
     * string.
     */
    public static String fieldToString(String name, Object value, boolean firstParameter) {
        if (value == null) {
            return "";
        }
        if (firstParameter) {
            return String.format("%s=%s", name, value);
        }
        return String.format(", %s=%s", name, value);
    }
}

Related

  1. fieldToColumnName(String name)
  2. fieldToGetMethod(String fieldName)
  3. fieldToProperty(String field)
  4. fieldToPropertyName(String name)
  5. fieldToValue(byte[] buffer, int offset, int length)