Java Code Examples for org.apache.commons.lang3.ObjectUtils#toString()

The following examples show how to use org.apache.commons.lang3.ObjectUtils#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AptoideUtils.java    From aptoide-client with GNU General Public License v2.0 5 votes vote down vote up
/**
 * <p>Joins the elements of the provided {@code Iterator} into
 * a single String containing the provided elements.</p>
 *
 * <p>No delimiter is added before or after the list.
 * A {@code null} separator is the same as an empty String ("").</p>
 *
 * @param iterator  the {@code Iterator} of values to join together, may be null
 * @param separator  the separator character to use, null treated as ""
 * @return the joined String, {@code null} if null iterator input
 */
public static String join(final Iterator<?> iterator, final String separator) {

    // handle null, zero and one elements before building a buffer
    if (iterator == null) {
        return null;
    }
    if (!iterator.hasNext()) {
        return "";
    }
    final Object first = iterator.next();
    if (!iterator.hasNext()) {
        @SuppressWarnings( "deprecation" ) // ObjectUtils.toString(Object) has been deprecated in 3.2
        final String result = ObjectUtils.toString(first);
        return result;
    }

    // two or more elements
    final StringBuilder buf = new StringBuilder(256); // Java default is 16, probably too small
    if (first != null) {
        buf.append(first);
    }

    while (iterator.hasNext()) {
        if (separator != null) {
            buf.append(separator);
        }
        final Object obj = iterator.next();
        if (obj != null) {
            buf.append(obj);
        }
    }
    return buf.toString();
}
 
Example 2
Source File: StrBuilder.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Appends a iterable placing separators between each value, but
 * not before the first or after the last.
 * Appending a null iterable will have no effect.
 * Each object is appended using {@link #append(Object)}.
 *
 * @param iterable  the iterable to append
 * @param separator  the separator to use, null means no separator
 * @return this, to enable chaining
 */
public StrBuilder appendWithSeparators(Iterable<?> iterable, String separator) {
    if (iterable != null) {
        separator = ObjectUtils.toString(separator);
        Iterator<?> it = iterable.iterator();
        while (it.hasNext()) {
            append(it.next());
            if (it.hasNext()) {
                append(separator);
            }
        }
    }
    return this;
}
 
Example 3
Source File: StrBuilder.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Appends an iterator placing separators between each value, but
 * not before the first or after the last.
 * Appending a null iterator will have no effect.
 * Each object is appended using {@link #append(Object)}.
 *
 * @param it  the iterator to append
 * @param separator  the separator to use, null means no separator
 * @return this, to enable chaining
 */
public StrBuilder appendWithSeparators(final Iterator<?> it, String separator) {
    if (it != null) {
        separator = ObjectUtils.toString(separator);
        while (it.hasNext()) {
            append(it.next());
            if (it.hasNext()) {
                append(separator);
            }
        }
    }
    return this;
}
 
Example 4
Source File: StrBuilder.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Appends a iterable placing separators between each value, but
 * not before the first or after the last.
 * Appending a null iterable will have no effect.
 * Each object is appended using {@link #append(Object)}.
 *
 * @param iterable  the iterable to append
 * @param separator  the separator to use, null means no separator
 * @return this, to enable chaining
 */
public StrBuilder appendWithSeparators(final Iterable<?> iterable, String separator) {
    if (iterable != null) {
        separator = ObjectUtils.toString(separator);
        final Iterator<?> it = iterable.iterator();
        while (it.hasNext()) {
            append(it.next());
            if (it.hasNext()) {
                append(separator);
            }
        }
    }
    return this;
}
 
Example 5
Source File: StrBuilder.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Appends an array placing separators between each value, but
 * not before the first or after the last.
 * Appending a null array will have no effect.
 * Each object is appended using {@link #append(Object)}.
 *
 * @param array  the array to append
 * @param separator  the separator to use, null means no separator
 * @return this, to enable chaining
 */
public StrBuilder appendWithSeparators(final Object[] array, String separator) {
    if (array != null && array.length > 0) {
        separator = ObjectUtils.toString(separator);
        append(array[0]);
        for (int i = 1; i < array.length; i++) {
            append(separator);
            append(array[i]);
        }
    }
    return this;
}
 
Example 6
Source File: StrBuilder.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Appends an iterator placing separators between each value, but
 * not before the first or after the last.
 * Appending a null iterator will have no effect.
 * Each object is appended using {@link #append(Object)}.
 *
 * @param it  the iterator to append
 * @param separator  the separator to use, null means no separator
 * @return this, to enable chaining
 */
public StrBuilder appendWithSeparators(Iterator<?> it, String separator) {
    if (it != null) {
        separator = ObjectUtils.toString(separator);
        while (it.hasNext()) {
            append(it.next());
            if (it.hasNext()) {
                append(separator);
            }
        }
    }
    return this;
}
 
Example 7
Source File: StrBuilder.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Appends a iterable placing separators between each value, but
 * not before the first or after the last.
 * Appending a null iterable will have no effect.
 * Each object is appended using {@link #append(Object)}.
 *
 * @param iterable  the iterable to append
 * @param separator  the separator to use, null means no separator
 * @return this, to enable chaining
 */
public StrBuilder appendWithSeparators(Iterable<?> iterable, String separator) {
    if (iterable != null) {
        separator = ObjectUtils.toString(separator);
        Iterator<?> it = iterable.iterator();
        while (it.hasNext()) {
            append(it.next());
            if (it.hasNext()) {
                append(separator);
            }
        }
    }
    return this;
}
 
Example 8
Source File: StrBuilder.java    From astor with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Appends an array placing separators between each value, but
 * not before the first or after the last.
 * Appending a null array will have no effect.
 * Each object is appended using {@link #append(Object)}.
 *
 * @param array  the array to append
 * @param separator  the separator to use, null means no separator
 * @return this, to enable chaining
 */
public StrBuilder appendWithSeparators(Object[] array, String separator) {
    if (array != null && array.length > 0) {
        separator = ObjectUtils.toString(separator);
        append(array[0]);
        for (int i = 1; i < array.length; i++) {
            append(separator);
            append(array[i]);
        }
    }
    return this;
}
 
Example 9
Source File: StrBuilder.java    From scheduling with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Appends an iterator placing separators between each value, but
 * not before the first or after the last.
 * Appending a null iterator will have no effect.
 * Each object is appended using {@link #append(Object)}.
 *
 * @param it  the iterator to append
 * @param separator  the separator to use, null means no separator
 * @return this, to enable chaining
 */
public StrBuilder appendWithSeparators(final Iterator<?> it, final String separator) {
    if (it != null) {
        @SuppressWarnings("deprecation") // ObjectUtils.toString(Object) has been deprecated in 3.2
        final String sep = ObjectUtils.toString(separator);
        while (it.hasNext()) {
            append(it.next());
            if (it.hasNext()) {
                append(sep);
            }
        }
    }
    return this;
}
 
Example 10
Source File: StrBuilder.java    From scheduling with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Appends a iterable placing separators between each value, but
 * not before the first or after the last.
 * Appending a null iterable will have no effect.
 * Each object is appended using {@link #append(Object)}.
 *
 * @param iterable  the iterable to append
 * @param separator  the separator to use, null means no separator
 * @return this, to enable chaining
 */
public StrBuilder appendWithSeparators(final Iterable<?> iterable, final String separator) {
    if (iterable != null) {
        @SuppressWarnings("deprecation") // ObjectUtils.toString(Object) has been deprecated in 3.2
        final String sep = ObjectUtils.toString(separator);
        final Iterator<?> it = iterable.iterator();
        while (it.hasNext()) {
            append(it.next());
            if (it.hasNext()) {
                append(sep);
            }
        }
    }
    return this;
}
 
Example 11
Source File: UsersFormType.java    From activiti-in-action-codes with Apache License 2.0 4 votes vote down vote up
@Override
public String convertModelValueToFormValue(Object modelValue) {
    return ObjectUtils.toString(modelValue);
}
 
Example 12
Source File: UsersFormType.java    From activiti-in-action-codes with Apache License 2.0 4 votes vote down vote up
@Override
public String convertModelValueToFormValue(Object modelValue) {
    return ObjectUtils.toString(modelValue);
}
 
Example 13
Source File: Cvar.java    From riiablo with Apache License 2.0 4 votes vote down vote up
@Override
public String toString() {
  return ObjectUtils.toString(value);
}
 
Example 14
Source File: DoubleFormType.java    From activiti-in-action-codes with Apache License 2.0 4 votes vote down vote up
@Override
public String convertModelValueToFormValue(Object modelValue) {
    return ObjectUtils.toString(modelValue);
}
 
Example 15
Source File: UsersFormType.java    From activiti-in-action-codes with Apache License 2.0 4 votes vote down vote up
@Override
public String convertModelValueToFormValue(Object modelValue) {
    return ObjectUtils.toString(modelValue);
}
 
Example 16
Source File: DoubleFormType.java    From activiti-in-action-codes with Apache License 2.0 4 votes vote down vote up
@Override
public String convertModelValueToFormValue(Object modelValue) {
    return ObjectUtils.toString(modelValue);
}
 
Example 17
Source File: UsersFormType.java    From activiti-in-action-codes with Apache License 2.0 4 votes vote down vote up
@Override
public String convertModelValueToFormValue(Object modelValue) {
    return ObjectUtils.toString(modelValue);
}
 
Example 18
Source File: UsersFormType.java    From activiti-in-action-codes with Apache License 2.0 4 votes vote down vote up
@Override
public String convertModelValueToFormValue(Object modelValue) {
    return ObjectUtils.toString(modelValue);
}
 
Example 19
Source File: UsersFormType.java    From activiti-in-action-codes with Apache License 2.0 4 votes vote down vote up
@Override
public String convertModelValueToFormValue(Object modelValue) {
    return ObjectUtils.toString(modelValue);
}
 
Example 20
Source File: UsersFormType.java    From activiti-in-action-codes with Apache License 2.0 4 votes vote down vote up
@Override
public String convertModelValueToFormValue(Object modelValue) {
    return ObjectUtils.toString(modelValue);
}