/** * Returns the default option from the given list of select options, * or <code>null</code> in case there is no default option in the given list.<p> * * If an element found in the given list is not of type * <code>{@link CmsSelectWidgetOption}</code>, this is ignored.<p> * * @param options the list of select options to get the default from * * @return the default option from the given list of select options, or <code>null</code> in case there is no default option */ public static CmsSelectWidgetOption getDefaultOption(List<CmsSelectWidgetOption> options) { if ((options == null) || (options.size() == 0)) { return null; } for (int i = 0; i < options.size(); i++) { Object o = options.get(i); if (o instanceof CmsSelectWidgetOption) { CmsSelectWidgetOption option = (CmsSelectWidgetOption)o; if (option.isDefault()) { return option; } } } return null; }
/** * Returns the default option from the given list of select options, * or <code>null</code> in case there is no default option in the given list.<p> * * If an element found in the given list is not of type * <code>{@link CmsSelectWidgetOption}</code>, this is ignored.<p> * * @param options the list of select options to get the default from * * @return the default option from the given list of select options, or <code>null</code> in case there is no default option */ public static CmsSelectWidgetOption getDefaultOption(List options) { if ((options == null) || (options.size() == 0)) { return null; } for (int i = 0; i < options.size(); i++) { Object o = options.get(i); if (o instanceof CmsSelectWidgetOption) { CmsSelectWidgetOption option = (CmsSelectWidgetOption)o; if (option.isDefault()) { return option; } } } return null; }
/** * Returns a list of default options from the given list of select options.<p> * * If an element found in the given list is not of type * <code>{@link CmsSelectWidgetOption}</code>, this is ignored.<p> * * @param options the list of select options to get the default from * * @return a list of <code>{@link CmsSelectWidgetOption}</code> objects */ public static List<CmsSelectWidgetOption> getDefaultOptions(List<CmsSelectWidgetOption> options) { List<CmsSelectWidgetOption> defaults = new ArrayList<CmsSelectWidgetOption>(); if ((options == null) || (options.size() == 0)) { return defaults; } for (int i = 0; i < options.size(); i++) { Object o = options.get(i); if (o instanceof CmsSelectWidgetOption) { CmsSelectWidgetOption option = (CmsSelectWidgetOption)o; if (option.isDefault()) { defaults.add(option); } } } return defaults; }
/** * Returns a list of default options from the given list of select options.<p> * * If an element found in the given list is not of type * <code>{@link CmsSelectWidgetOption}</code>, this is ignored.<p> * * @param options the list of select options to get the default from * * @return a list of <code>{@link CmsSelectWidgetOption}</code> objects */ public static List getDefaultOptions(List options) { List defaults = new ArrayList(); if ((options == null) || (options.size() == 0)) { return defaults; } for (int i = 0; i < options.size(); i++) { Object o = options.get(i); if (o instanceof CmsSelectWidgetOption) { CmsSelectWidgetOption option = (CmsSelectWidgetOption)o; if (option.isDefault()) { defaults.add(option); } } } return defaults; }