Java Collection Dump dumpList(Collection list)

Here you can find the source of dumpList(Collection list)

Description

dump List

License

Open Source License

Declaration

public static <T> String dumpList(Collection<T> list) 

Method Source Code

//package com.java2s;
/*******************************************************************************
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
 *
 * Copyright (c) 2013,2014 by Peter Pilgrim, Addiscombe, Surrey, XeNoNiQUe UK
 *
 * All rights reserved. This program and the accompanying materials
 * are made available under the terms of the GNU GPL v3.0
 * which accompanies this distribution, and is available at:
 * http://www.gnu.org/licenses/gpl-3.0.txt
 *
 * Developers://from  www  .  ja va  2 s  .  c o m
 * Peter Pilgrim -- design, development and implementation
 *               -- Blog: http://www.xenonique.co.uk/blog/
 *               -- Twitter: @peter_pilgrim
 *
 * Contributors:
 *
 *******************************************************************************/

import java.util.Collection;

public class Main {
    public static <T> String dumpList(Collection<T> list) {
        StringBuilder buf = new StringBuilder();
        if (list == null) {
            buf.append("null");
        } else {
            buf.append('[');
            int count = 0;
            for (T elem : list) {
                if (count > 0)
                    buf.append(',');
                if (elem == null) {
                    buf.append("null");
                } else {
                    buf.append(elem.getClass().getSimpleName() + '@');
                    buf.append(Integer.toHexString(System.identityHashCode(elem)));
                }
                count++;
            }
            buf.append(']');
        }
        return buf.toString();
    }
}

Related

  1. dumpCollection(Collection collection)
  2. dumpCollection(Object[] c, StringBuilder sb, int indent)
  3. dumpCollection(String msg, Collection c)
  4. dumpCollectionCollection(Collection c)
  5. dumpList(StringBuffer sb, Collection slist)
  6. dumpToString(Collection c, String separator)