package org.beanmaker.util;

import java.util.ArrayList;
import java.util.Collections;
import java.util.List;

public class Names {

    public static <B extends NamedDbBean> List<String> getList(final List<B> beans) {
        final List<String> names = new ArrayList<String>();

        for (B bean: beans)
            names.add(bean.getDisplayName());

        return names;
    }

    public static <B extends NamedDbBean> List<String> getSortedList(final List<B> beans) {
        final List<String> names = getList(beans);
        Collections.sort(names);
        return names;
    }

    public static <B extends MultiLingualNamedDbBean> List<String> getList(
            final List<B> beans,
            final DbBeanLanguage dbBeanLanguage)
    {
        final List<String> names = new ArrayList<String>();

        for (B bean: beans)
            names.add(bean.getDisplayName(dbBeanLanguage));

        return names;
    }

    public static <B extends MultiLingualNamedDbBean> List<String> getSortedList(
            final List<B> beans,
            final DbBeanLanguage dbBeanLanguage)
    {
        final List<String> names = getList(beans, dbBeanLanguage);
        Collections.sort(names);
        return names;
    }

    public static <B extends DbBeanMultilingual> List<String> getListFromMultilingualBeans(
            final List<B> beans,
            final DbBeanLanguage dbBeanLanguage)
    {
        final List<String> names = new ArrayList<String>();

        for (B bean: beans)
            names.add(bean.getLabel(dbBeanLanguage));

        return names;
    }

    public static <B extends DbBeanMultilingual> List<String> getSortedListFromMultilingualBeans(
            final List<B> beans,
            final DbBeanLanguage dbBeanLanguage)
    {
        final List<String> names = getListFromMultilingualBeans(beans, dbBeanLanguage);
        Collections.sort(names);
        return names;
    }
}

@@ -50,16 +50,45 @@
 ayList;%0A
+import java.util.Collection;%0A
 import j
@@ -109,16 +109,16 @@
 ctions;%0A
-
 import j
@@ -216,36 +216,42 @@
 %3E getList(final 
-List
+Collection
 %3CB%3E beans) %7B%0A   
@@ -483,28 +483,34 @@
 dList(final 
-List
+Collection
 %3CB%3E beans) %7B
@@ -709,36 +709,42 @@
           final 
-List
+Collection
 %3CB%3E beans,%0A     
@@ -1064,36 +1064,42 @@
           final 
-List
+Collection
 %3CB%3E beans,%0A     
@@ -1379,36 +1379,42 @@
           final 
-List
+Collection
 %3CB%3E beans,%0A     
@@ -1752,20 +1752,26 @@
   final 
-List
+Collection
 %3CB%3E bean

Replace List by Collection for more flexibility