package org.beanmaker.util;

public class Ids {

    public static String getProtectionCodeFromParameterName(final String parameterName) {
        return getProtectionCodeFromParameterName(parameterName, "_");
    }

    public static String getProtectionCodeFromParameterName(final String parameterName, final String separatorRegex) {
        final String[] elements = parameterName.split(separatorRegex);
        if (elements.length < 2)
            throw new IllegalArgumentException("Could not separate id/code from name based on regex: "
                    + separatorRegex);

        return elements[elements.length - 1];
    }

    public static long getIdFromParameterName(final String parameterName) {
        return Long.valueOf(getProtectionCodeFromParameterName(parameterName));
    }

    public static long getIdFromParameterName(final String parameterName, final String separatorRegex) {
        return Long.valueOf(getProtectionCodeFromParameterName(parameterName, separatorRegex));
    }
}

@@ -22,16 +22,94 @@
 .util;%0A%0A
+import java.util.Collection;%0Aimport java.util.HashSet;%0Aimport java.util.Set;%0A%0A
 public c
@@ -1076,11 +1076,248 @@
 );%0A    %7D
+%0A%0A    public static Set%3CLong%3E getIdSet(final Collection%3CDbBeanInterface%3E beans) %7B%0A        final Set%3CLong%3E set = new HashSet%3CLong%3E();%0A%0A        for (DbBeanInterface bean: beans)%0A            set.add(bean.getId());%0A%0A        return set;%0A    %7D
 %0A%7D%0A

Add function that takes a Collection of beans and returns a Set of ids