Skip to content
Snippets Groups Projects
Commit 7ee28984 authored by ribeaudc's avatar ribeaudc
Browse files

change: - Another 'abbreviate' method.

SVN: 4630
parent 97b84212
No related branches found
No related tags found
No related merge requests found
......@@ -20,7 +20,6 @@ import java.util.Arrays;
import java.util.Collection;
import java.util.Iterator;
/**
* Some convenience methods/utilities around {@link Collection}.
*
......@@ -89,7 +88,22 @@ public final class CollectionUtils
public final static <T> String abbreviate(final Collection<T> collection, final int maxLength,
final CollectionStyle style)
{
return abbreviate(collection, maxLength, true, ToStringDefaultConverter.getInstance(), style);
return abbreviate(collection, maxLength, ToStringDefaultConverter.getInstance(), style);
}
/**
* Abbreviates a given <code>Collection</code>.
* <p>
* By default it shows the number of items left.
* </p>
*
* @param maxLength the maximum number of items that should be shown. If <code>-1</code> then all items will be
* displayed.
*/
public final static <T> String abbreviate(final Collection<T> collection, final int maxLength,
final IToStringConverter<? super T> converter, final CollectionStyle style)
{
return abbreviate(collection, maxLength, true, converter, style);
}
/**
......
......@@ -31,17 +31,21 @@ public final class ToStringDefaultConverter implements IToStringConverter<Object
// This is a singleton.
}
public String toString(Object value)
{
return value.toString();
}
/**
* @return The instance of the {@link ToStringDefaultConverter}.
*/
public static ToStringDefaultConverter getInstance()
public final static ToStringDefaultConverter getInstance()
{
return instance;
}
//
// IToStringConverter
//
public final String toString(final Object value)
{
return value.toString();
}
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment