Example usage for org.apache.commons.collections4 CollectionUtils isEmpty

List of usage examples for org.apache.commons.collections4 CollectionUtils isEmpty

Introduction

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

Prototype

public static boolean isEmpty(final Collection<?> coll) 

Source Link

Document

Null-safe check if the specified collection is empty.

Usage

From source file:de.micromata.tpsb.doc.parser.FileInfo.java

public MethodInfo findMethodInfo(final String methodName, List<String> argTypes) {
    Collection<MethodInfo> methods = getAllMethodInfos(methodName);

    if (CollectionUtils.isEmpty(methods)) {
        return null;
    }//from ww  w.  j a v  a 2  s.  c om

    // Nur eine Methode mit identischem Namen
    if (methods.size() == 1) {
        return methods.iterator().next();
    }

    // Wenn die Parameter unterstzt werden, wird die Methode zurck
    // gegeben.
    for (MethodInfo methodInfo : methods) {
        if (methodInfo.matchArgTypes(argTypes)) {
            return methodInfo;
        }
    }
    return null;
}

From source file:com.mirth.connect.server.api.servlets.ChannelServlet.java

@Override
public void setChannelInitialState(Set<String> channelIds, DeployedState initialState) {
    if (CollectionUtils.isEmpty(channelIds)) {
        channelIds = channelController.getChannelIds();
    }//from w  w  w  .  ja  v  a 2  s . c  om
    try {
        channelController.setChannelInitialState(redactChannelIds(channelIds), context, initialState);
    } catch (ControllerException e) {
        throw new MirthApiException(e);
    }
}

From source file:co.rsk.net.discovery.PeerExplorerTest.java

@Test
public void handlePingMessage() throws Exception {
    List<String> nodes = new ArrayList<>();

    ECKey key2 = ECKey.fromPrivate(Hex.decode(KEY_2)).decompress();

    Node node = new Node(key2.getNodeId(), HOST_2, PORT_2);
    NodeDistanceTable distanceTable = new NodeDistanceTable(KademliaOptions.BINS, KademliaOptions.BUCKET_SIZE,
            node);//from w  w w. jav a 2 s. co  m
    PeerExplorer peerExplorer = new PeerExplorer(nodes, node, distanceTable, key2, TIMEOUT, REFRESH);

    Channel internalChannel = Mockito.mock(Channel.class);
    UDPTestChannel channel = new UDPTestChannel(internalChannel, peerExplorer);
    ChannelHandlerContext ctx = Mockito.mock(ChannelHandlerContext.class);
    peerExplorer.setUDPChannel(channel);

    Assert.assertTrue(CollectionUtils.isEmpty(peerExplorer.getNodes()));

    ECKey key1 = ECKey.fromPrivate(Hex.decode(KEY_1)).decompress();
    String check = UUID.randomUUID().toString();
    PingPeerMessage nodeMessage = PingPeerMessage.create(HOST_1, PORT_1, check, key1);
    DiscoveryEvent incomingPingEvent = new DiscoveryEvent(nodeMessage, new InetSocketAddress(HOST_1, PORT_1));

    //A message is received
    channel.channelRead0(ctx, incomingPingEvent);
    //As part of the ping response, a Ping and a Pong are sent to the sender.
    List<DiscoveryEvent> sentEvents = channel.getEventsWritten();
    Assert.assertEquals(2, sentEvents.size());
    DiscoveryEvent pongEvent = sentEvents.get(0);
    PongPeerMessage toSenderPong = (PongPeerMessage) pongEvent.getMessage();
    Assert.assertEquals(DiscoveryMessageType.PONG, toSenderPong.getMessageType());
    Assert.assertEquals(new InetSocketAddress(HOST_1, PORT_1), pongEvent.getAddress());

    DiscoveryEvent pingEvent = sentEvents.get(1);
    PingPeerMessage toSenderPing = (PingPeerMessage) pingEvent.getMessage();
    Assert.assertEquals(DiscoveryMessageType.PING, toSenderPing.getMessageType());
    Assert.assertEquals(new InetSocketAddress(HOST_1, PORT_1), pingEvent.getAddress());

    //After a pong returns from a node, when we receive a ping from that node, we only answer with a pong (no additional ping)
    PongPeerMessage pongResponseFromSender = PongPeerMessage.create(HOST_1, PORT_1, toSenderPing.getMessageId(),
            key1);
    DiscoveryEvent incomingPongEvent = new DiscoveryEvent(pongResponseFromSender,
            new InetSocketAddress(HOST_1, PORT_1));
    channel.channelRead0(ctx, incomingPongEvent);
    channel.clearEvents();
    channel.channelRead0(ctx, incomingPingEvent);
    sentEvents = channel.getEventsWritten();
    Assert.assertEquals(1, sentEvents.size());
    pongEvent = sentEvents.get(0);
    toSenderPong = (PongPeerMessage) pongEvent.getMessage();
    Assert.assertEquals(DiscoveryMessageType.PONG, toSenderPong.getMessageType());
    Assert.assertEquals(new InetSocketAddress(HOST_1, PORT_1), pongEvent.getAddress());
    Assert.assertEquals(NODE_ID_2, Hex.toHexString(toSenderPong.getKey().getNodeId()));
}

From source file:nc.noumea.mairie.appock.viewmodel.ListeDemandeACommanderViewModel.java

@Command
public void repasseATraiter() {
    if (CollectionUtils.isEmpty(selectedListeDemande)) {
        Messagebox.show(/*from   w  ww.j  a v  a 2  s  .  c o m*/
                "Vous devez slectionner au moins une demande pour pouvoir la repasser dans l'tat 'A traiter'",
                "Changement d'tat refus", Messagebox.OK, Messagebox.INFORMATION);
        return;
    }

    Messagebox.show("Voulez-vous repasser les demandes slectionnes dans l'tat 'A traiter' ?",
            "Confirmation", new Messagebox.Button[] { Messagebox.Button.YES, Messagebox.Button.NO },
            Messagebox.QUESTION, evt -> {
                if (evt.getName().equals("onYes")) {
                    demandeService.repasseATraiter(selectedListeDemande);
                    rechargeOngletListeReferentAchat();
                    showNotificationStandard("Demandes repasss dans l'tat 'A traiter'");
                }
            });
}

From source file:io.cloudslang.lang.cli.utils.CompilerHelperImpl.java

private Map<String, Value> loadMapsFromFiles(List<File> files, String[] extensions, String directory) {
    Collection<File> fileCollection;
    if (CollectionUtils.isEmpty(files)) {
        fileCollection = loadDefaultFiles(extensions, directory, false);
        if (CollectionUtils.isEmpty(fileCollection)) {
            return null;
        }/*from   ww  w.  j  a  v a2s .  co  m*/
    } else {
        fileCollection = files;
    }
    Map<String, Value> result = new HashMap<>();
    for (File inputFile : fileCollection) {
        logger.info("Loading file: " + inputFile);
        try {
            String inputsFileContent = SlangSource.fromFile(inputFile).getContent();
            Boolean emptyContent = true;
            if (StringUtils.isNotEmpty(inputsFileContent)) {
                @SuppressWarnings("unchecked")
                Map<String, ? extends Serializable> inputFileYamlContent = (Map<String, ? extends Serializable>) yaml
                        .load(inputsFileContent);
                if (MapUtils.isNotEmpty(inputFileYamlContent)) {
                    emptyContent = false;
                    result.putAll(
                            slangSourceService.convertInputFromMap(inputFileYamlContent, inputFile.getName()));
                }
            }
            if (emptyContent) {
                throw new RuntimeException(
                        "Inputs file: " + inputFile + " is empty or does not contain valid YAML content.");
            }
        } catch (RuntimeException ex) {
            logger.error("Error loading file: " + inputFile + ". Nested exception is: " + ex.getMessage(), ex);
            throw new RuntimeException(ex);
        }
    }
    return result;
}

From source file:nc.noumea.mairie.appock.viewmodel.EditStockReferentServiceViewModel.java

private void importerStockXlsx(Media media) {
    try {//from  w  w  w.j a  v  a  2  s  .  c  o  m
        List<String> warnings = StockSpreadsheetImporter.importFromXls(authHelper.getCurrentUser().getService(),
                stockService, media.getStreamData());
        if (!CollectionUtils.isEmpty(warnings)) {
            Messagebox.show( //
                    "Certaines rfrences ont t ignores :\n"
                            + warnings.stream().collect(Collectors.joining("\n - ", " - ", "")), //
                    "Attention", //
                    Messagebox.OK, //
                    Messagebox.EXCLAMATION);
        }
    } catch (Exception e) {
        log.error("An error accored during stock xlsx import : " + e.getMessage(), e);
        Messagebox.show("Une erreur s'est produite durant l'import Excel.", "Import chou", Messagebox.OK,
                Messagebox.ERROR);
        return;
    }
    showNotificationStandard("Inventaire import");
}

From source file:com.adguard.filter.rules.FilterRule.java

/**
 * Generic filter rules count as rules that:
 * <br/>/* w w  w.ja  v a 2s .c o  m*/
 * 1. Do not have a domain specified. "Hide this element on all domains"
 * <br/>
 * 2. Have only domain exceptions specified. "Hide this element on all domains except example.com"
 * <br/>
 * ~example.com##.ad
 * ||example.com^$third-party
 *
 * @return true if this rule is generic
 */
public boolean isGeneric() {
    return CollectionUtils.isEmpty(permittedDomains);
}

From source file:com.github.helenusdriver.driver.impl.DeleteImpl.java

/**
 * Instantiates a new <code>DeleteImpl</code> object.
 *
 * @author paouelle//from  w w  w.  j av a 2  s.co  m
 *
 * @param  context the non-<code>null</code> class info context associated
 *         with this statement
 * @param  tables the tables to delete from
 * @param  columnNames the columns names that should be deleted by the query
 * @param  allSelected <code>true</code> if the special COUNT() or *
 *         has been selected
 * @param  pkeys_override an optional map of primary key values to use instead
 *         of those provided by the POJO context
 * @param  mgr the non-<code>null</code> statement manager
 * @param  bridge the non-<code>null</code> statement bridge
 * @throws NullPointerException if <code>context</code> is <code>null</code>
 * @throws IllegalArgumentException if unable to compute the keyspace or table
 *         names based from the given object
 */
DeleteImpl(ClassInfoImpl<T>.Context context, String[] tables, List<Object> columnNames, boolean allSelected,
        Map<String, Object> pkeys_override, StatementManagerImpl mgr, StatementBridge bridge) {
    super(Void.class, context, mgr, bridge);
    if (tables != null) {
        for (final String table : tables) {
            if (table != null) {
                this.tables.add((TableInfoImpl<T>) context.getClassInfo().getTable(table));
            }
        }
    } else { // fallback to all
        this.tables.addAll(context.getClassInfo().getTables());
    }
    this.columnNames = columnNames;
    this.allSelected = allSelected;
    org.apache.commons.lang3.Validate.isTrue(!(!allSelected && CollectionUtils.isEmpty(columnNames)),
            "must select at least one column");
    this.where = new WhereImpl<>(this);
    this.usings = new OptionsImpl<>(this);
    this.pkeys_override = pkeys_override;
}

From source file:com.kumarvv.setl.core.Loader.java

/**
 * process and store return values from previous load
 *
 * @param load/*from  w  w w.j  a va2  s  . c o m*/
 * @param row
 * @param jrs
 * @return
 */
protected boolean processReturns(Load load, Row row, JdbcRowSet jrs) {
    if (load == null || row == null || jrs == null) {
        return false;
    }

    if (CollectionUtils.isEmpty(load.getReturns())) {
        return true;
    }

    for (String rc : load.getReturns()) {
        try {
            Object rcv = jrs.getObject(rc);
            row.getData().put("rc_" + load.getTable() + "_" + rc, rcv);
        } catch (SQLException sqle) {
            Logger.warn("return value error: " + sqle.getMessage());
            Logger.trace(sqle);
        }
    }
    return true;
}

From source file:com.romeikat.datamessie.core.base.util.DocumentsFilterSettings.java

public DocumentsFilterSettings restrictToDocumentIds(final Collection<Long> documentIds) {
    if (CollectionUtils.isEmpty(this.documentIds)) {
        this.documentIds = documentIds;
    }//from  w  w  w  . j  a  v  a 2  s . com

    else {
        this.documentIds.retainAll(documentIds);
    }

    return this;
}