diff --git a/common/source/java/ch/systemsx/cisd/common/collections/CollectionUtils.java b/common/source/java/ch/systemsx/cisd/common/collections/CollectionUtils.java index 99c1bea7b8c21d524e32a4885464b19860a424fd..90be85907b17d17340d6e87cff5670ffb210fc08 100644 --- a/common/source/java/ch/systemsx/cisd/common/collections/CollectionUtils.java +++ b/common/source/java/ch/systemsx/cisd/common/collections/CollectionUtils.java @@ -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); } /** diff --git a/common/source/java/ch/systemsx/cisd/common/collections/ToStringDefaultConverter.java b/common/source/java/ch/systemsx/cisd/common/collections/ToStringDefaultConverter.java index f4d8c64dcaa0ea04af75654ca2034c3a4d35b9e1..4d0eed326aeaf0de75538317d0cc5f62d44cd76b 100644 --- a/common/source/java/ch/systemsx/cisd/common/collections/ToStringDefaultConverter.java +++ b/common/source/java/ch/systemsx/cisd/common/collections/ToStringDefaultConverter.java @@ -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(); + } + }