// Path: compiler/src/main/java/pl/edu/radomski/navigator/utils/tuple/Tuple.java
// public class Tuple {
// 
//     public static <T1, T2> Tuple2<T1, T2> make(T1 first, T2 second) {
//         return new Tuple2<>(first, second);
//     }
// 
//     public static <T1, T2, T3> Tuple3<T1, T2, T3> make(T1 first, T2 second, T3 third) {
//         return new Tuple3<>(first, second, third);
//     }
// 
//     public static <T1, T2, T3, T4> Tuple4<T1, T2, T3, T4> make(T1 first, T2 second, T3 third, T4 fourth) {
//         return new Tuple4<>(first, second, third, fourth);
//     }
// 
//     public static <T1, T2, T3, T4, T5> Tuple5<T1, T2, T3, T4, T5> make(T1 first, T2 second, T3 third, T4 fourth, T5 fifth) {
//         return new Tuple5<>(first, second, third, fourth, fifth);
//     }
// 
//     public static <T1, T2, T3, T4, T5, T6> Tuple6<T1, T2, T3, T4, T5, T6> make(T1 first, T2 second, T3 third, T4 fourth, T5 fifth, T6 sixth ) {
//         return new Tuple6<>(first, second, third, fourth, fifth, sixth);
//     }
// 
//     public static <T1, T2, T3, T4, T5, T6, T7> Tuple7<T1, T2, T3, T4, T5, T6, T7> make(T1 first, T2 second, T3 third, T4 fourth, T5 fifth, T6 sixth, T7 seventh) {
//         return new Tuple7<>(first, second, third, fourth, fifth, sixth, seventh);
//     }
// 
//     public static <T1, T2, T3, T4, T5, T6, T7, T8> Tuple8<T1, T2, T3, T4, T5, T6, T7, T8> make(T1 first, T2 second, T3 third, T4 fourth, T5 fifth, T6 sixth, T7 seventh, T8 eighth) {
//         return new Tuple8<>(first, second, third, fourth, fifth, sixth, seventh, eighth);
//     }
// 
//     public static <T1, T2, T3, T4, T5, T6, T7, T8, T9> Tuple9<T1, T2, T3, T4, T5, T6, T7, T8, T9> make(T1 first, T2 second, T3 third, T4 fourth, T5 fifth, T6 sixth, T7 seventh, T8 eighth, T9 nineth) {
//         return new Tuple9<>(first, second, third, fourth, fifth, sixth, seventh, eighth, nineth);
//     }
// 
//     private Tuple() {
//     }
// }
// 
// Path: compiler/src/main/java/pl/edu/radomski/navigator/utils/tuple/Tuple2.java
// public class Tuple2<T1, T2> extends Tuple1<T1> {
// 
//     public final T2 second;
// 
//     Tuple2(T1 first, T2 second) {
//         super(first);
//         this.second = second;
//     }
// }


import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import pl.edu.radomski.navigator.utils.tuple.Tuple;
import pl.edu.radomski.navigator.utils.tuple.Tuple2;
/*
 * Navigator
 * Copyright (C)  2015 Adam Radomski
 *
 * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
 * USA
 */

package pl.edu.radomski.navigator.utils;



/**
 * Created by adam on 8/25/15.
 */
public final class StringUtils {

    public static boolean isEmpty(String s) {
        return s == null || s.trim().length() == 0;
    }

    public static String longestCommonSubstring(List<String> values) {
        TreeMap<Integer, Tuple2<String, String>> map = new TreeMap<>();
        if (values.size() == 0) {
            return "";
        } else if (values.size() == 1) {
            return values.get(0);
        }

        for (int i = 0; i < values.size() - 1; i++) {
            for (int j = i + 1; j < values.size(); j++) {
                map.put(longestCommonSubstring(values.get(i), values.get(j)), Tuple.make(values.get(i), values.get(j)));
            }
        }

// Path: compiler/src/main/java/pl/edu/radomski/navigator/utils/tuple/Tuple.java
// public class Tuple {
// 
//     public static <T1, T2> Tuple2<T1, T2> make(T1 first, T2 second) {
//         return new Tuple2<>(first, second);
//     }
// 
//     public static <T1, T2, T3> Tuple3<T1, T2, T3> make(T1 first, T2 second, T3 third) {
//         return new Tuple3<>(first, second, third);
//     }
// 
//     public static <T1, T2, T3, T4> Tuple4<T1, T2, T3, T4> make(T1 first, T2 second, T3 third, T4 fourth) {
//         return new Tuple4<>(first, second, third, fourth);
//     }
// 
//     public static <T1, T2, T3, T4, T5> Tuple5<T1, T2, T3, T4, T5> make(T1 first, T2 second, T3 third, T4 fourth, T5 fifth) {
//         return new Tuple5<>(first, second, third, fourth, fifth);
//     }
// 
//     public static <T1, T2, T3, T4, T5, T6> Tuple6<T1, T2, T3, T4, T5, T6> make(T1 first, T2 second, T3 third, T4 fourth, T5 fifth, T6 sixth ) {
//         return new Tuple6<>(first, second, third, fourth, fifth, sixth);
//     }
// 
//     public static <T1, T2, T3, T4, T5, T6, T7> Tuple7<T1, T2, T3, T4, T5, T6, T7> make(T1 first, T2 second, T3 third, T4 fourth, T5 fifth, T6 sixth, T7 seventh) {
//         return new Tuple7<>(first, second, third, fourth, fifth, sixth, seventh);
//     }
// 
//     public static <T1, T2, T3, T4, T5, T6, T7, T8> Tuple8<T1, T2, T3, T4, T5, T6, T7, T8> make(T1 first, T2 second, T3 third, T4 fourth, T5 fifth, T6 sixth, T7 seventh, T8 eighth) {
//         return new Tuple8<>(first, second, third, fourth, fifth, sixth, seventh, eighth);
//     }
// 
//     public static <T1, T2, T3, T4, T5, T6, T7, T8, T9> Tuple9<T1, T2, T3, T4, T5, T6, T7, T8, T9> make(T1 first, T2 second, T3 third, T4 fourth, T5 fifth, T6 sixth, T7 seventh, T8 eighth, T9 nineth) {
//         return new Tuple9<>(first, second, third, fourth, fifth, sixth, seventh, eighth, nineth);
//     }
// 
//     private Tuple() {
//     }
// }
// 
// Path: compiler/src/main/java/pl/edu/radomski/navigator/utils/tuple/Tuple2.java
// public class Tuple2<T1, T2> extends Tuple1<T1> {
// 
//     public final T2 second;
// 
//     Tuple2(T1 first, T2 second) {
//         super(first);
//         this.second = second;
//     }
// }


// Path: compiler/src/main/java/pl/edu/radomski/navigator/utils/StringUtils.java
import java.util.List;
import java.util.Map;
import java.util.TreeMap;
import pl.edu.radomski.navigator.utils.tuple.Tuple;
import pl.edu.radomski.navigator.utils.tuple.Tuple2;

/*
 * Navigator
 * Copyright (C)  2015 Adam Radomski
 *
 * 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., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
 * USA
 */

package pl.edu.radomski.navigator.utils;



/**
 * Created by adam on 8/25/15.
 */
public final class StringUtils {

    public static boolean isEmpty(String s) {
        return s == null || s.trim().length() == 0;
    }

    public static String longestCommonSubstring(List<String> values) {
        TreeMap<Integer, Tuple2<String, String>> map = new TreeMap<>();
        if (values.size() == 0) {
            return "";
        } else if (values.size() == 1) {
            return values.get(0);
        }

        for (int i = 0; i < values.size() - 1; i++) {
            for (int j = i + 1; j < values.size(); j++) {
                map.put(longestCommonSubstring(values.get(i), values.get(j)), Tuple.make(values.get(i), values.get(j)));
            }
        }

        Map.Entry<Integer, Tuple2<String, String>> integerTuple2Entry = map.firstEntry();