Example usage for com.liferay.portal.kernel.util ListUtil exists

List of usage examples for com.liferay.portal.kernel.util ListUtil exists

Introduction

In this page you can find the example usage for com.liferay.portal.kernel.util ListUtil exists.

Prototype

public static <E> boolean exists(List<? extends E> list, Predicate<E> predicate) 

Source Link

Usage

From source file:com.liferay.dynamic.data.mapping.model.impl.DDMStructureImpl.java

License:Open Source License

@Override
public String getUnambiguousName(List<DDMStructure> structures, long groupId, final Locale locale)
        throws PortalException {

    if (getGroupId() == groupId) {
        return getName(locale);
    }//from   w w w.  j av  a  2  s . co m

    boolean hasAmbiguousName = ListUtil.exists(structures, new PredicateFilter<DDMStructure>() {

        @Override
        public boolean filter(DDMStructure structure) {
            if (structure.getStructureId() == getStructureId()) {
                return false;
            }

            String name = structure.getName(locale);

            if (name.equals(getName(locale))) {
                return true;
            }

            return false;
        }

    });

    if (hasAmbiguousName) {
        Group group = GroupLocalServiceUtil.getGroup(getGroupId());

        return group.getUnambiguousName(getName(locale), locale);
    }

    return getName(locale);
}