Example usage for org.apache.commons.collections4 ListUtils sum

List of usage examples for org.apache.commons.collections4 ListUtils sum

Introduction

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

Prototype

public static <E> List<E> sum(final List<? extends E> list1, final List<? extends E> list2) 

Source Link

Document

Returns the sum of the given lists.

Usage

From source file:appsgate.lig.eude.interpreter.langage.nodes.NodeLists.java

/**
 * Method that compute the combination of the two lists depending on the
 * operator/*  w  w  w .  ja v a2 s  .  co  m*/
 */
private void computeResult() {
    switch (op) {
    case UNION:
        result = ListUtils.sum(leftList.getElements(), rightList.getElements());
        break;
    case INTERSECTION:
        result = ListUtils.intersection(leftList.getElements(), rightList.getElements());
        break;
    case NOT_IN:
        result = ListUtils.subtract(leftList.getElements(), rightList.getElements());
        break;
    default:
        LOGGER.warn("Unknown operator");
    }
}

From source file:org.apache.syncope.client.console.wizards.any.ConnObjectPanel.java

public ConnObjectPanel(final String id, final Pair<ConnObjectTO, ConnObjectTO> connObjectTOs,
        final boolean view) {
    super(id);// ww w  . j av  a  2 s. c  o m

    final IModel<List<String>> formProps = new LoadableDetachableModel<List<String>>() {

        private static final long serialVersionUID = 5275935387613157437L;

        @Override
        protected List<String> load() {
            List<AttrTO> right = new ArrayList<>(
                    connObjectTOs == null || connObjectTOs.getRight() == null ? Collections.<AttrTO>emptyList()
                            : connObjectTOs.getRight().getAttrs());

            List<AttrTO> left = new ArrayList<>(
                    connObjectTOs == null || connObjectTOs.getLeft() == null ? Collections.<AttrTO>emptyList()
                            : connObjectTOs.getLeft().getAttrs());

            final List<String> schemas = ListUtils.sum(
                    right.stream().map(AttrTO::getSchema).collect(Collectors.toList()),
                    left.stream().map(AttrTO::getSchema).collect(Collectors.toList()));

            Collections.sort(schemas);

            return schemas;
        }
    };

    final Map<String, AttrTO> beforeProfile = connObjectTOs == null || connObjectTOs.getLeft() == null ? null
            : EntityTOUtils.buildAttrMap(connObjectTOs.getLeft().getAttrs());
    final Map<String, AttrTO> afterProfile = connObjectTOs == null || connObjectTOs.getRight() == null ? null
            : EntityTOUtils.buildAttrMap(connObjectTOs.getRight().getAttrs());

    final ListView<String> propView = new ListView<String>("propView", formProps) {

        private static final long serialVersionUID = 3109256773218160485L;

        @Override
        protected void populateItem(final ListItem<String> item) {
            final String prop = item.getModelObject();

            final Fragment valueFragment;
            final AttrTO before = beforeProfile == null ? null : beforeProfile.get(prop);
            final AttrTO after = afterProfile == null ? null : afterProfile.get(prop);

            valueFragment = new Fragment("value", "doubleValue", ConnObjectPanel.this);

            Panel oldAttribute = getValuePanel("oldAttribute", prop, before);
            oldAttribute.setOutputMarkupPlaceholderTag(true);
            oldAttribute.setVisible(!view);
            valueFragment.add(oldAttribute);

            valueFragment.add(getValuePanel("newAttribute", prop, after));

            if (before == null || after == null
                    || (CollectionUtils.isNotEmpty(after.getValues())
                            && CollectionUtils.isEmpty(before.getValues()))
                    || (CollectionUtils.isEmpty(after.getValues())
                            && CollectionUtils.isNotEmpty(before.getValues()))
                    || (CollectionUtils.isNotEmpty(after.getValues())
                            && CollectionUtils.isNotEmpty(before.getValues())
                            && after.getValues().size() != before.getValues().size())
                    || (CollectionUtils.isNotEmpty(after.getValues())
                            && CollectionUtils.isNotEmpty(before.getValues())
                            && !after.getValues().equals(before.getValues()))) {

                valueFragment.add(new Behavior() {

                    private static final long serialVersionUID = 3109256773218160485L;

                    @Override
                    public void onComponentTag(final Component component, final ComponentTag tag) {
                        tag.put("class", "highlight");
                    }
                });
            }
            item.add(valueFragment);
        }
    };
    add(propView);
}