Example usage for org.apache.commons.collections4 IterableUtils find

List of usage examples for org.apache.commons.collections4 IterableUtils find

Introduction

In this page you can find the example usage for org.apache.commons.collections4 IterableUtils find.

Prototype

public static <E> E find(final Iterable<E> iterable, final Predicate<? super E> predicate) 

Source Link

Document

Finds the first element in the given iterable which matches the given predicate.

Usage

From source file:com.haulmont.cuba.web.jmx.JmxConnectionHelper.java

@Nullable
protected static ObjectName getObjectName(final MBeanServerConnection connection, final Class objectClass)
        throws IOException {

    Set<ObjectName> names = connection.queryNames(null, null);
    return IterableUtils.find(names, o -> {
        MBeanInfo info;//from  w  w w .j  a  va2 s .  c  om
        try {
            info = connection.getMBeanInfo(o);
        } catch (InstanceNotFoundException | UnmarshalException e) {
            return false;
        } catch (Exception e) {
            throw new JmxControlException(e);
        }
        return Objects.equals(objectClass.getName(), info.getClassName());
    });
}

From source file:it.infn.ct.futuregateway.apiserver.inframanager.Utilities.java

/**
 * Retrieves the parameter value from a list.
 * If the parameter has multiple definition, and so multiple values, the
 * first occurrence is returned.// ww  w. j a v  a  2s.  c  o  m
 *
 * @param params The parameter list
 * @param name Parameter name
 * @return Parameter value or null is not present
 */
public static String getParamterValue(final List<Params> params, final String name) {
    Params tmpParam = IterableUtils.find(params, new Predicate<Params>() {
        @Override
        public boolean evaluate(final Params t) {
            return t.getName().equals(name);
        }
    });
    if (tmpParam != null) {
        return tmpParam.getValue();
    }
    return null;
}

From source file:com.vrem.wifianalyzer.wifi.model.Security.java

public static Security findOne(String capabilities) {
    Security result = IterableUtils.find(EnumUtils.values(Security.class),
            new SecurityPredicate(findAll(capabilities)));
    return result == null ? Security.NONE : result;
}

From source file:com.haulmont.cuba.web.jmx.JmxConnectionHelper.java

protected static ObjectName getObjectName(final MBeanServerConnection connection, final String remoteContext,
        final Class objectClass) throws IOException {
    Set<ObjectName> names = connection.queryNames(null, null);
    return IterableUtils.find(names, o -> {
        if (!Objects.equals(remoteContext, o.getDomain())) {
            return false;
        }/*from   ww  w .j  ava 2  s . c  o m*/

        MBeanInfo info;
        try {
            info = connection.getMBeanInfo(o);
        } catch (Exception e) {
            throw new JmxControlException(e);
        }
        return Objects.equals(objectClass.getName(), info.getClassName());
    });
}

From source file:it.infn.ct.futuregateway.apiserver.inframanager.Utilities.java

/**
 * Retrieves the parameter value from a list.
 * If the parameter has multiple definition, and so multiple values, the
 * first occurrence is returned.// ww  w .j  ava 2  s .  com
 *
 * @param params The parameter list
 * @param name Parameter name
 * @param defaultValue Default value if the parameter is not defined
 * @return Parameter value or null is not present
 */
public static String getParamterValue(final List<Params> params, final String name, final String defaultValue) {
    Params tmpParam = IterableUtils.find(params, new Predicate<Params>() {
        @Override
        public boolean evaluate(final Params t) {
            return t.getName().equals(name);
        }
    });
    if (tmpParam != null) {
        return tmpParam.getValue();
    }
    return defaultValue;
}

From source file:com.vrem.wifianalyzer.wifi.filter.adapter.FilterAdapter.java

public boolean isActive() {
    return IterableUtils.find(getFilterAdapters(isAccessPoints()), new ActivePredicate()) != null;
}

From source file:com.vrem.wifianalyzer.wifi.model.WiFiData.java

@NonNull
public WiFiDetail getConnection() {
    WiFiDetail wiFiDetail = IterableUtils.find(wiFiDetails, new ConnectionPredicate());
    return wiFiDetail == null ? WiFiDetail.EMPTY : copyWiFiDetail(wiFiDetail);
}

From source file:com.vrem.wifianalyzer.wifi.graphutils.SeriesCache.java

WiFiDetail find(@NonNull Series series) {
    return IterableUtils.find(cache.keySet(), new FindPredicate(series));
}

From source file:com.vrem.wifianalyzer.wifi.band.WiFiChannelsGHZ5.java

@Override
public Pair<WiFiChannel, WiFiChannel> getWiFiChannelPairFirst(String countryCode) {
    Pair<WiFiChannel, WiFiChannel> found = null;
    if (StringUtils.isNotBlank(countryCode)) {
        found = IterableUtils.find(getWiFiChannelPairs(), new WiFiChannelPredicate(countryCode));
    }//from w w  w .j av  a 2 s.c  om
    return found == null ? SET1 : found;
}

From source file:com.vrem.wifianalyzer.wifi.band.WiFiChannels.java

public WiFiChannel getWiFiChannelByFrequency(int frequency) {
    Pair<WiFiChannel, WiFiChannel> found = null;
    if (isInRange(frequency)) {
        found = IterableUtils.find(wiFiChannelPairs, new FrequencyPredicate(frequency));
    }/*from w  w w. j av  a  2  s  .c o  m*/
    return found == null ? WiFiChannel.UNKNOWN : getWiFiChannel(frequency, found);
}