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:nc.noumea.mairie.appock.services.impl.ArticleCatalogueServiceImpl.java

@Override
public ArticleCatalogue findArticleCataloguePlusRecentParReference(String reference, Catalogue catalogue) {
    List<ArticleCatalogue> listeArticleCatalogueAvecReference = articleCatalogueRepository
            .findAllByReference(reference);
    if (CollectionUtils.isEmpty(listeArticleCatalogueAvecReference)) {
        return null;
    }/*from   w  ww .  j  a  va 2s  . c  om*/

    for (ArticleCatalogue articleCatalogue : listeArticleCatalogueAvecReference) {
        AppockUtil.chargeElement(articleCatalogue.getSousFamille());
        AppockUtil.chargeElement(articleCatalogue.getSousFamille().getFamille());

        // Si la rfrence a t trouve dans le catalogue actif c'est la plus rcente, on la renvoie
        if (articleCatalogue.getSousFamille().getFamille().getCatalogue().equals(catalogue)) {
            return articleCatalogue;
        }
    }

    // Sinon, pas d'importance, on renvoie le premier qu'on trouve, a fera l'affaire
    return listeArticleCatalogueAvecReference.get(0);
}

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

@Override
public void setChannelEnabled(Set<String> channelIds, boolean enabled) {
    if (CollectionUtils.isEmpty(channelIds)) {
        channelIds = channelController.getChannelIds();
    }/*from w ww  .  j  a v a 2 s .  c  o  m*/
    try {
        channelController.setChannelEnabled(redactChannelIds(channelIds), context, enabled);
    } catch (ControllerException e) {
        throw new MirthApiException(e);
    }
}

From source file:it.gulch.linuxday.android.fragments.EventDetailsFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_event_details, container, false);

    holder = new ViewHolder();
    holder.inflater = inflater;/*  ww w  . ja  v a 2s  .co m*/

    ((TextView) view.findViewById(R.id.title)).setText(event.getTitle());
    TextView textView = (TextView) view.findViewById(R.id.subtitle);
    String text = event.getSubtitle();
    if (TextUtils.isEmpty(text)) {
        textView.setVisibility(View.GONE);
    } else {
        textView.setText(text);
    }

    MovementMethod linkMovementMethod = LinkMovementMethod.getInstance();

    // Set the persons summary text first; replace it with the clickable text when the loader completes
    holder.personsTextView = (TextView) view.findViewById(R.id.persons);
    String personsSummary = "";
    if (CollectionUtils.isEmpty(event.getPeople())) {
        holder.personsTextView.setVisibility(View.GONE);
    } else {
        personsSummary = StringUtils.join(event.getPeople(), ", ");
        holder.personsTextView.setText(personsSummary);
        holder.personsTextView.setMovementMethod(linkMovementMethod);
        holder.personsTextView.setVisibility(View.VISIBLE);
    }

    ((TextView) view.findViewById(R.id.track)).setText(event.getTrack().getTitle());
    Date startTime = event.getStartDate();
    Date endTime = event.getEndDate();
    text = String.format("%1$s, %2$s  %3$s", event.getTrack().getDay().getName(),
            (startTime != null) ? TIME_DATE_FORMAT.format(startTime) : "?",
            (endTime != null) ? TIME_DATE_FORMAT.format(endTime) : "?");
    ((TextView) view.findViewById(R.id.time)).setText(text);
    final String roomName = event.getTrack().getRoom().getName();
    TextView roomTextView = (TextView) view.findViewById(R.id.room);
    Spannable roomText = new SpannableString(String.format("%1$s", roomName));
    //      final int roomImageResId = getResources()
    //            .getIdentifier(StringUtils.roomNameToResourceName(roomName), "drawable",
    //                        getActivity().getPackageName());
    //      // If the room image exists, make the room text clickable to display it
    //      if(roomImageResId != 0) {
    //         roomText.setSpan(new UnderlineSpan(), 0, roomText.length(), Spannable.SPAN_EXCLUSIVE_EXCLUSIVE);
    //         roomTextView.setOnClickListener(new View.OnClickListener()
    //         {
    //
    //            @Override
    //            public void onClick(View view)
    //            {
    //               RoomImageDialogFragment.newInstance(roomName, roomImageResId).show(getFragmentManager());
    //            }
    //         });
    //         roomTextView.setFocusable(true);
    //      }
    roomTextView.setText(roomText);

    textView = (TextView) view.findViewById(R.id.abstract_text);
    text = event.getEventAbstract();
    if (TextUtils.isEmpty(text)) {
        textView.setVisibility(View.GONE);
    } else {
        String strippedText = StringUtils.stripEnd(Html.fromHtml(text).toString(), " \n");
        textView.setText(strippedText);
        textView.setMovementMethod(linkMovementMethod);
    }
    textView = (TextView) view.findViewById(R.id.description);
    text = event.getDescription();
    if (TextUtils.isEmpty(text)) {
        textView.setVisibility(View.GONE);
    } else {
        String strippedText = StringUtils.stripEnd(Html.fromHtml(text).toString(), " \n");
        textView.setText(strippedText);
        textView.setMovementMethod(linkMovementMethod);
    }

    holder.linksContainer = (ViewGroup) view.findViewById(R.id.links_container);
    return view;
}

From source file:com.movies.entities.Movie.java

public List<Actor> getActorsList() {
    if (CollectionUtils.isEmpty(actorsList) && CollectionUtils.isNotEmpty(actors)) {
        actorsList = new ArrayList<>(actors);
    }/* www .ja va2s. c  o m*/
    return actorsList;
}

From source file:io.cloudslang.lang.compiler.validator.PreCompileValidatorImpl.java

@Override
public List<Map<String, Map<String, Object>>> validateWorkflowRawData(ParsedSlang parsedSlang,
        Object workflowRawData, String executableName, List<RuntimeException> errors) {
    if (workflowRawData == null) {
        workflowRawData = new ArrayList<>();
        errors.add(new RuntimeException("Error compiling " + parsedSlang.getName() + ". Flow: " + executableName
                + " has no workflow property"));
    }/* w w w .j  ava 2s .c  o  m*/
    List<Map<String, Map<String, Object>>> workFlowRawData;
    try {
        //noinspection unchecked
        workFlowRawData = (List<Map<String, Map<String, Object>>>) workflowRawData;
    } catch (ClassCastException ex) {
        workFlowRawData = new ArrayList<>();
        errors.add(new RuntimeException("Flow: '" + executableName
                + "' syntax is illegal.\nBelow 'workflow' property there should be a list of steps and not a map"));
    }
    if (CollectionUtils.isEmpty(workFlowRawData)) {
        errors.add(new RuntimeException("Error compiling source '" + parsedSlang.getName() + "'. Flow: '"
                + executableName + "' has no workflow data"));
    }
    for (Map<String, Map<String, Object>> step : workFlowRawData) {
        if (step.size() > 1) {
            errors.add(new RuntimeException("Error compiling source '" + parsedSlang.getName() + "'.\nFlow: '"
                    + executableName + "' has steps with keyword on the same indentation as the step name "
                    + "or there is no space between step name and hyphen."));
        }
    }

    return workFlowRawData;
}

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

private List<String> getDependenciesIfEmpty(List<String> dependencies, File file) {
    if (CollectionUtils.isEmpty(dependencies)) {
        dependencies = new ArrayList<>();
        //app.home is the basedir property we set in our executables
        String appHome = System.getProperty("app.home", "");
        String contentRoot = appHome + File.separator + "content";
        File contentRootDir = new File(contentRoot);
        if (StringUtils.isNotEmpty(appHome) && contentRootDir.exists() && contentRootDir.isDirectory()) {
            dependencies.add(contentRoot);
        } else {/*from   ww w .  j a  va2 s .  c om*/
            //default behavior is taking the parent dir if not running from our executables
            dependencies.add(file.getParent());
        }
    }
    return dependencies;
}

From source file:com.epam.catgenome.dao.vcf.VcfFileDao.java

@Transactional(propagation = Propagation.MANDATORY)
public List<VcfFile> loadVcfFiles(List<Long> ids) {
    if (CollectionUtils.isEmpty(ids)) {
        return Collections.emptyList();
    }// ww w . j  av a  2s.c o  m

    long listId = daoHelper.createTempLongList(ids);
    List<BiologicalDataItem> files = getJdbcTemplate().query(loadVcfFilesQuery,
            BiologicalDataItemDao.BiologicalDataItemParameters.getRowMapper(), listId);
    daoHelper.clearTempList(listId);

    return files.stream().map(i -> (VcfFile) i).collect(Collectors.toList());
}

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

/**
 * Instantiates a new <code>SelectImpl</code> object.
 *
 * @author paouelle//from w  w w  .j  a v a2  s. c o  m
 *
 * @param  context the non-<code>null</code> class info context for the POJO
 *         associated with this statement
 * @param  table the non-<code>null</code> table to select from
 * @param  columnNames the selected columns
 * @param  countOrAllSelected <code>true</code> if the special COUNT() or *
 *         has been selected
 * @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 the table or any of the referenced
 *         columns are not defined by the POJO
 */
@SuppressWarnings({ "cast", "unchecked", "rawtypes" })
SelectImpl(ClassInfoImpl<T>.Context context, String table, List<Object> columnNames, boolean countOrAllSelected,
        StatementManagerImpl mgr, StatementBridge bridge) {
    super((Class<ObjectSet<T>>) (Class) ObjectSet.class, context, mgr, bridge);
    this.table = (TableInfoImpl<T>) context.getClassInfo().getTable(table);
    this.columnNames = columnNames;
    this.countOrAllSelected = countOrAllSelected;
    this.where = new WhereImpl<>(this);
    org.apache.commons.lang3.Validate.isTrue(!(!countOrAllSelected && CollectionUtils.isEmpty(columnNames)),
            "must select at least one column");
    if (columnNames != null) {
        this.table.validateColumns(columnNames);
    }
}

From source file:fr.landel.utils.commons.CastUtilsTest.java

/**
 * Check cast list//ww w.j  a v  a 2  s.  c  om
 */
@Test
public void testGetQueue() {

    Queue<String> queue = new LinkedList<>();
    queue.add("value1");
    queue.add(null);
    queue.add("value2");

    assertTrue(CollectionUtils.isEmpty(CastUtils.getLinkedListAsQueue(null, String.class)));
    assertTrue(CollectionUtils.isEmpty(CastUtils.getLinkedTransferQueue(null, String.class)));
    assertTrue(CollectionUtils.isEmpty(CastUtils.getPriorityQueue(null, String.class)));
    assertTrue(CollectionUtils.isEmpty(CastUtils.getLinkedBlockingQueue(null, String.class)));
    assertTrue(CollectionUtils.isEmpty(CastUtils.getPriorityBlockingQueue(null, String.class)));
    assertTrue(CollectionUtils.isEmpty(CastUtils.getArrayBlockingQueue(null, String.class, queue.size())));

    Queue<String> result = CastUtils.getLinkedListAsQueue(queue, String.class);
    assertEquals("value1", result.poll());
    assertNull(result.poll());
    assertEquals("value2", result.poll());

    result = CastUtils.getLinkedTransferQueue(queue, String.class);
    assertEquals("value1", result.poll());
    assertEquals("value2", result.poll());

    result = CastUtils.getPriorityQueue(queue, String.class);
    assertEquals("value1", result.poll());
    assertEquals("value2", result.poll());

    result = CastUtils.getLinkedBlockingQueue(queue, String.class);
    assertEquals("value1", result.poll());
    assertEquals("value2", result.poll());

    result = CastUtils.getPriorityBlockingQueue(queue, String.class);
    assertEquals("value1", result.poll());
    assertEquals("value2", result.poll());

    result = CastUtils.getArrayBlockingQueue(queue, String.class, queue.size());
    assertEquals("value1", result.poll());
    assertEquals("value2", result.poll());

    assertEquals(0, CastUtils.getLinkedListAsQueue(12, String.class).size());

    Queue<Integer> queue2 = new LinkedList<>();
    queue2.add(2);
    assertEquals(0, CastUtils.getLinkedListAsQueue(queue2, String.class).size());
}

From source file:com.movies.entities.Movie.java

public List<Director> getDirectorsList() {
    if (CollectionUtils.isEmpty(directorsList) && CollectionUtils.isNotEmpty(directors)) {
        directorsList = new ArrayList<>(directors);
    }/*from   www .  ja  v a  2s  .com*/
    return directorsList;
}