Example usage for java.util List isEmpty

List of usage examples for java.util List isEmpty

Introduction

In this page you can find the example usage for java.util List isEmpty.

Prototype

boolean isEmpty();

Source Link

Document

Returns true if this list contains no elements.

Usage

From source file:net.sourceforge.fenixedu.presentationTier.backBeans.coordinator.ListStudentThesis.java

private static List run(String degreeCurricularPlanID) throws FenixServiceException {

    DegreeCurricularPlan degreeCurricularPlan = FenixFramework.getDomainObject(degreeCurricularPlanID);

    List masterDegreeThesisDataVersions = degreeCurricularPlan.readActiveMasterDegreeThesisDataVersions();

    if (masterDegreeThesisDataVersions == null || masterDegreeThesisDataVersions.isEmpty()) {
        throw new NonExistingServiceException("error.exception.masterDegree.nonExistingMasterDegreeThesis");
    }//from w  w w  . ja v  a  2s. c o m

    CollectionUtils.transform(masterDegreeThesisDataVersions, new Transformer() {
        @Override
        public Object transform(Object arg0) {
            MasterDegreeThesisDataVersion masterDegreeThesisDataVersion = (MasterDegreeThesisDataVersion) arg0;
            return InfoMasterDegreeThesisDataVersionWithGuidersAndRespAndThesis
                    .newInfoFromDomain(masterDegreeThesisDataVersion);
        }
    });

    return masterDegreeThesisDataVersions;
}

From source file:Main.java

public static <T> List<List<T>> innerJoin(List<T> l1, List<T> l2, BiFunction<T, T, T> function) {
    if (l1 == null || l2 == null) {
        throw new NullPointerException("inner join arrays must not be null");
    }//from   w  w w .ja  va2  s.c o m

    if (l1.isEmpty() && l2.isEmpty()) {
        return Collections.emptyList();
    } else if (l1.isEmpty()) {
        return Collections.singletonList(l2);
    } else if (l2.isEmpty()) {
        return Collections.singletonList(l1);
    }

    List<List<T>> result = new ArrayList<>(l1.size() * l2.size());
    l1.stream().forEach(t1 -> {
        List<T> l = new ArrayList<>();
        l2.stream().forEach(t2 -> l.add(function.apply(t1, t2)));
        result.add(l);
    });
    return result;
}

From source file:com.clustercontrol.accesscontrol.factory.LoginUserSelector.java

/**
 * ??<BR>//from w  w  w  . j  a  va 2 s  .c  o  m
 * 
 * @return ?
 * @throws UserNotFound
 * @throws HinemosUnknown
 */
public static ArrayList<UserInfo> getUserInfoList() {
    m_log.debug("getting all user...");

    // ?
    List<UserInfo> users = QueryUtil.getAllShowUser();

    m_log.debug("successful in getting all user.");

    if (users == null || users.isEmpty()) {
        return new ArrayList<>();
    } else {
        return new ArrayList<UserInfo>(users);
    }
}

From source file:com.hybris.mobile.app.commerce.helper.ProductHelper.java

/**
 * Fill Spinner list with arraylist of variantMatrixElement
 *
 * @param context/*from   w  ww.  j  a  v a  2s  .  co m*/
 * @param spinner
 * @param variants
 * @param position
 */
public static void populateSpinner(Context context, Spinner spinner, List<VariantOption> variants,
        int position) {
    if (spinner != null && variants != null && !variants.isEmpty()) {
        VariantAdapter mVariantAdapter = new VariantAdapter(context, R.layout.item_product_variant, variants);
        spinner.setAdapter(mVariantAdapter);
        spinner.setPrompt(context.getString(R.string.choose_variant,
                ((List<VariantOptionQualifier>) variants.get(0).getVariantOptionQualifiers()).get(0)
                        .getName()));
        spinner.setVisibility(View.VISIBLE);
        spinner.setSelection(position < variants.size() ? position : 0);
    }
}

From source file:com.tealcube.minecraft.bukkit.mythicdrops.utils.SocketGemUtil.java

public static Material getRandomSocketGemMaterial() {
    List<Material> materialDatas = MythicDropsPlugin.getInstance().getSockettingSettings()
            .getSocketGemMaterials();//from  w  w  w .  java 2 s.com
    if (materialDatas == null || materialDatas.isEmpty()) {
        return null;
    }
    return materialDatas.get(RandomUtils.nextInt(materialDatas.size()));
}

From source file:jp.ikedam.jenkins.plugins.extensible_choice_parameter.utility.TextareaStringListUtility.java

/**
 * Returns a list of string parsed from a input of textarea.
 * /*from   w w w. jav a  2s .  co m*/
 * @param choiceListText the input of a textarea
 * @return a list of string.
 */
public static List<String> stringListFromTextarea(String choiceListText) {
    List<String> stringList = (choiceListText != null) ? Arrays.asList(choiceListText.split("\\r?\\n", -1))
            : new ArrayList<String>(0);
    if (!stringList.isEmpty() && StringUtils.isEmpty(stringList.get(stringList.size() - 1))) {
        // The last empty line will be ignored.
        // The list object returned from asList() does not support remove,
        // so use subList().
        stringList = stringList.subList(0, stringList.size() - 1);
    }

    return stringList;
}

From source file:grandroid.geo.Geocoder.java

public static String convertAddress(double lat, double lng) throws Exception {
    List<Address> adds = getFromLocation(lat, lng, 1);
    if (adds == null || adds.isEmpty()) {
        throw new Exception("no address can be found");
    } else {//from   www  .  ja  va  2  s. com
        Address add = adds.get(0);
        if (add.getFeatureName() == null) {
            return add.getAdminArea() + add.getLocality() + add.getAddressLine(0);
        } else {
            return add.getFeatureName();
        }
    }
}

From source file:com.doculibre.constellio.plugins.PluginFactory.java

private static <P extends ConstellioPlugin> P getPlugin(Class<P> pluginClass, boolean onlyDefault) {
    List<P> matches = getPlugins(pluginClass, onlyDefault);
    return !matches.isEmpty() ? matches.get(0) : null;
}

From source file:com.hybris.mobile.app.commerce.helper.ProductHelper.java

/**
 * Use variantValueCategory code to find the default variant value with the category code
 *
 * @return default variant position//from  w w  w.  ja v a2s  .  co  m
 */
public static int findVariantPosition(List<VariantOption> options, VariantOption selected) {
    int position = 0;
    if (options != null && !options.isEmpty() && selected != null) {
        for (VariantOption variantOption : options) {
            if (StringUtils.equals(variantOption.getCode(), selected.getCode())) {
                return position;
            }
            position++;
        }
    }
    return position;
}

From source file:Main.java

public static <T> List<T> innerJoin(List<List<T>> list, BiFunction<T, T, T> function) {
    if (list == null || function == null) {
        throw new NullPointerException("list or function must not be null");
    }// w ww  .j  a  v  a 2 s.com
    if (list.isEmpty()) {
        return Collections.emptyList();
    }
    if (list.size() == 1) {
        return list.get(0);
    }

    List<List<T>> result = innerJoin(list.get(0), list.get(1), function);
    if (list.size() == 2) {
        return merge(result);
    } else {
        for (int i = 2; i < list.size(); i++) {
            List<T> l1 = list.get(i);
            List<List<T>> temp = new ArrayList<>();
            result.stream().forEach(l -> temp.addAll(innerJoin(l, l1, function)));
            result = temp;
        }
        return merge(result);
    }
}