/*
 * Copyright (C) 2008 Herve Quiroz
 *
 * This library is free software; you can redistribute it and/or modify it under
 * the terms of the GNU Lesser General Public License as published by the Free
 * Software Foundation; either version 2.1 of the License, or (at your option)
 * any later version.
 * 
 * This library is distributed in the hope that it will be useful, but WITHOUT
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
 * details.
 * 
 * You should have received a copy of the GNU Lesser General Public License
 * along with this library; if not, write to the Free Software Foundation, Inc.,
 * 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA 
 *
 * $Id$
 */
package org.trancecode.lang;

import com.google.common.base.Preconditions;
import com.google.common.collect.Iterators;

import java.util.Iterator;

import org.trancecode.base.TcPreconditions;
import org.trancecode.collection.TcIterables;

/**
 * Utility methods related to {@link String} objects.
 * 
 * @author Herve Quiroz
 */
public final class TcStrings
{
    /**
     * Splits this string around matches of the given separator sequence.
     * 
     * @param separatorSequence
     *            the separator (not a regular expression).
     */
    public static Iterable<String> split(final String string, final String separatorSequence)
    {
        Preconditions.checkNotNull(string);
        TcPreconditions.checkNotEmpty(separatorSequence);

        return new Iterable<String>()
        {
            @Override
            public Iterator<String> iterator()
            {
                if (string.isEmpty())
                {
                    return Iterators.singletonIterator(string);
                }

                final int index = string.indexOf(separatorSequence);
                if (index < 0)
                {
                    return Iterators.singletonIterator(string);
                }

                final String after = string.substring(index + separatorSequence.length());
                return TcIterables.prepend(split(after, separatorSequence), string.substring(0, index)).iterator();
            }
        };
    }

    private TcStrings()
    {
        // No instantiation
    }
}

@@ -933,16 +933,95 @@
 rator;%0A%0A
+import org.trancecode.api.Nullable;%0Aimport org.trancecode.api.ReturnsNullable;%0A
 import o
@@ -2323,24 +2323,231 @@
   %7D;%0A    %7D%0A%0A
+    @ReturnsNullable%0A    public static String toString(@Nullable final Object object)%0A    %7B%0A        if (object != null)%0A        %7B%0A            return object.toString();%0A        %7D%0A%0A        return null;%0A    %7D%0A%0A
     private 

Add TcStrings.toString()