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

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

Introduction

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

Prototype

public static boolean isEqualList(final Collection<?> list1, final Collection<?> list2) 

Source Link

Document

Tests two lists for value-equality as per the equality contract in java.util.List#equals(java.lang.Object) .

Usage

From source file:com.romeikat.datamessie.core.base.query.entity.EntityWithIdQueryTest.java

@Test
public void addIdRestriction() {
    final int maxId = 10000;
    final List<Long> ids = collectionUtil.createLongList(2, maxId);

    final EntityWithIdQuery<BarEntityWithId> query = new EntityWithIdQuery<>(BarEntityWithId.class);
    query.addIdRestriction(ids);//from  ww  w .ja v a2  s  .c om
    query.addOrder(Order.asc("name"));

    final List<BarEntityWithId> objects = query.listObjects(sessionProvider.getStatelessSession());
    final List<String> names = getNames(objects);
    final List<String> expected = Arrays.asList("BarEntityWithId2", "BarEntityWithId3", "BarEntityWithId4");
    assertTrue(ListUtils.isEqualList(expected, names));

    dbSetupTracker.skipNextLaunch();
}

From source file:org.apache.metron.stellar.dsl.functions.EncodingFunctionsTest.java

@Test
public void testSupportedEncodingsList() throws Exception {
    Object ret = run("GET_SUPPORTED_ENCODINGS()", new HashMap());
    Assert.assertTrue(ret instanceof List);
    List<String> list = (List<String>) ret;
    List<String> expected = new ArrayList<>(Arrays.asList("BASE32", "BASE32HEX", "BASE64", "BINARY", "HEX"));
    Assert.assertTrue(ListUtils.isEqualList(expected, list));
}

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

public <T extends AnyTO> AuxClasses(final AnyWrapper<T> modelObject, final List<String> anyTypeClasses) {
    super();//  w w  w  .j ava2 s  . c  o m
    setOutputMarkupId(true);

    List<AnyTypeClassTO> allAnyTypeClasses = new AnyTypeClassRestClient().list();

    List<String> choices = new ArrayList<>();
    for (AnyTypeClassTO aux : allAnyTypeClasses) {
        if (!anyTypeClasses.contains(aux.getKey())) {
            choices.add(aux.getKey());
        }
    }
    Collections.sort(choices);
    add(new AjaxPalettePanel.Builder<String>().setAllowOrder(true)
            .build("auxClasses", new PropertyModel<List<String>>(modelObject.getInnerObject(), "auxClasses"),
                    new ListModel<>(choices))
            .hideLabel().setOutputMarkupId(true));

    // ------------------
    // insert changed label if needed
    // ------------------
    if (modelObject instanceof UserWrapper && UserWrapper.class.cast(modelObject).getPreviousUserTO() != null
            && !ListUtils.isEqualList(modelObject.getInnerObject().getAuxClasses(),
                    UserWrapper.class.cast(modelObject).getPreviousUserTO().getAuxClasses())) {
        add(new LabelInfo("changed", StringUtils.EMPTY));
    } else {
        add(new Label("changed", StringUtils.EMPTY));
    }
    // ------------------
}

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

public <T extends AnyTO> Groups(final AnyWrapper<T> modelObject, final boolean templateMode) {
    super();/*w  w w.j  a va  2s.c o m*/
    this.templateMode = templateMode;

    this.anyTO = modelObject.getInnerObject();

    groupsModel = new GroupsModel();

    // -----------------------------------------------------------------
    // Pre-Authorizations
    // -----------------------------------------------------------------
    ActionPermissions permissions = new ActionPermissions();
    setMetaData(MetaDataRoleAuthorizationStrategy.ACTION_PERMISSIONS, permissions);
    permissions.authorizeAll(RENDER);
    // -----------------------------------------------------------------

    setOutputMarkupId(true);

    WebMarkupContainer groupsContainer = new WebMarkupContainer("groupsContainer");
    groupsContainer.setOutputMarkupId(true);
    groupsContainer.setOutputMarkupPlaceholderTag(true);
    add(groupsContainer);

    WebMarkupContainer dyngroupsContainer = new WebMarkupContainer("dyngroupsContainer");
    dyngroupsContainer.setOutputMarkupId(true);
    dyngroupsContainer.setOutputMarkupPlaceholderTag(true);
    add(dyngroupsContainer);

    if (anyTO instanceof GroupTO) {
        groupsContainer.add(new Label("groups").setVisible(false));
        groupsContainer.setVisible(false);
        dyngroupsContainer.add(new Label("dyngroups").setVisible(false));
        dyngroupsContainer.setVisible(false);
    } else {
        AjaxPalettePanel.Builder<MembershipTO> builder = new AjaxPalettePanel.Builder<MembershipTO>()
                .setRenderer(new IChoiceRenderer<MembershipTO>() {

                    private static final long serialVersionUID = -3086661086073628855L;

                    @Override
                    public Object getDisplayValue(final MembershipTO object) {
                        return object.getGroupName();
                    }

                    @Override
                    public String getIdValue(final MembershipTO object, final int index) {
                        return object.getGroupName();
                    }

                    @Override
                    public MembershipTO getObject(final String id,
                            final IModel<? extends List<? extends MembershipTO>> choices) {

                        return choices.getObject().stream()
                                .filter(object -> id.equalsIgnoreCase(object.getGroupName())).findAny()
                                .orElse(null);
                    }
                });

        groupsContainer
                .add(builder.setAllowOrder(true).withFilter().build("groups", new ListModel<MembershipTO>() {

                    private static final long serialVersionUID = -2583290457773357445L;

                    @Override
                    public List<MembershipTO> getObject() {
                        return Groups.this.groupsModel.getMemberships();
                    }

                }, new AjaxPalettePanel.Builder.Query<MembershipTO>() {

                    private static final long serialVersionUID = -7223078772249308813L;

                    @Override
                    public List<MembershipTO> execute(final String filter) {
                        return (StringUtils.isEmpty(filter) || "*".equals(filter) ? groupsModel.getObject()
                                : groupRestClient.search(anyTO.getRealm(),
                                        SyncopeClient.getGroupSearchConditionBuilder().isAssignable().and()
                                                .is("name").equalTo(filter).query(),
                                        1, MAX_GROUP_LIST_CARDINALITY, new SortParam<>("name", true), null))
                                                .stream().map(input -> {

                                                    return new MembershipTO.Builder()
                                                            .group(input.getKey(), input.getName()).build();
                                                }).collect(Collectors.toList());
                    }
                }).hideLabel().setOutputMarkupId(true));

        dyngroupsContainer.add(new AjaxPalettePanel.Builder<String>().setAllowOrder(true)
                .build("dyngroups", new ListModel<String>() {

                    private static final long serialVersionUID = -2583290457773357445L;

                    @Override
                    public List<String> getObject() {
                        return Groups.this.groupsModel.getDynMemberships();
                    }

                }, new ListModel<>(
                        groupsModel.getObject().stream().map(GroupTO::getName).collect(Collectors.toList())))
                .hideLabel().setEnabled(false).setOutputMarkupId(true));

        // ---------------------------------
    }

    add(new AjaxPalettePanel.Builder<>()
            .build("dynrealms", new PropertyModel<>(anyTO, "dynRealms"),
                    new ListModel<>(allDynRealms.stream().map(EntityTO::getKey).collect(Collectors.toList())))
            .hideLabel().setEnabled(false).setOutputMarkupId(true));

    // ------------------
    // insert changed label if needed
    // ------------------
    if (modelObject instanceof UserWrapper && UserWrapper.class.cast(modelObject).getPreviousUserTO() != null
            && !ListUtils.isEqualList(UserWrapper.class.cast(modelObject).getInnerObject().getMemberships(),
                    UserWrapper.class.cast(modelObject).getPreviousUserTO().getMemberships())) {
        groupsContainer.add(new LabelInfo("changed", StringUtils.EMPTY));
    } else {
        groupsContainer.add(new Label("changed", StringUtils.EMPTY));
    }
    // ------------------
}

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

public Relationships(final AnyWrapper<?> modelObject, final PageReference pageRef) {
    super();//from  ww w  .  j  ava  2s. com
    add(new Label("title", new ResourceModel("any.relationships")));

    if (modelObject instanceof UserWrapper && UserWrapper.class.cast(modelObject).getPreviousUserTO() != null
            && !ListUtils.isEqualList(UserWrapper.class.cast(modelObject).getInnerObject().getRelationships(),
                    UserWrapper.class.cast(modelObject).getPreviousUserTO().getRelationships())) {
        add(new LabelInfo("changed", StringUtils.EMPTY));
    } else {
        add(new Label("changed", StringUtils.EMPTY));
    }

    this.anyTO = modelObject.getInnerObject();
    this.pageRef = pageRef;

    // ------------------------
    // Existing relationships
    // ------------------------
    add(getViewFragment().setRenderBodyOnly(true));
    // ------------------------ 
}

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

public <T extends AnyTO> Roles(final AnyWrapper<?> modelObject) {
    if (!(modelObject.getInnerObject() instanceof UserTO)) {
        throw new IllegalStateException("Invalid instance " + modelObject.getInnerObject());
    }/*from w  ww  . ja v a 2  s .c o m*/

    if (UserWrapper.class.cast(modelObject).getPreviousUserTO() != null
            && !ListUtils.isEqualList(UserWrapper.class.cast(modelObject).getInnerObject().getRoles(),
                    UserWrapper.class.cast(modelObject).getPreviousUserTO().getRoles())) {
        add(new LabelInfo("changed", StringUtils.EMPTY));
    } else {
        add(new Label("changed", StringUtils.EMPTY));
    }

    final UserTO entityTO = UserTO.class.cast(modelObject.getInnerObject());

    // -----------------------------------------------------------------
    // Pre-Authorizations
    // -----------------------------------------------------------------
    final ActionPermissions permissions = new ActionPermissions();
    setMetaData(MetaDataRoleAuthorizationStrategy.ACTION_PERMISSIONS, permissions);
    permissions.authorize(RENDER,
            new org.apache.wicket.authroles.authorization.strategies.role.Roles(StandardEntitlement.ROLE_LIST));
    // -----------------------------------------------------------------

    this.setOutputMarkupId(true);

    allRoles = SyncopeConsoleApplication.get().getSecuritySettings().getAuthorizationStrategy()
            .isActionAuthorized(this, RENDER)
                    ? new RoleRestClient().list().stream().map(EntityTO::getKey).collect(Collectors.toList())
                    : Collections.<String>emptyList();
    Collections.sort(allRoles);

    add(new AjaxPalettePanel.Builder<String>()
            .build("roles", new PropertyModel<List<String>>(entityTO, "roles"), new ListModel<>(allRoles))
            .hideLabel().setOutputMarkupId(true));

    add(new AjaxPalettePanel.Builder<String>()
            .build("dynroles", new PropertyModel<List<String>>(entityTO, "dynRoles"), new ListModel<>(allRoles))
            .hideLabel().setEnabled(false).setOutputMarkupId(true));
}

From source file:org.kuali.coeus.common.framework.compliance.core.SaveSpecialReviewEvent.java

@Override
public boolean equals(Object obj) {
    if (this == obj) {
        return true;
    }//w w w .  j a v a  2s.com
    if (obj == null) {
        return false;
    }
    if (getClass() != obj.getClass()) {
        return false;
    }
    SaveSpecialReviewEvent<?> other = (SaveSpecialReviewEvent<?>) obj;
    if (specialReviews == null) {
        if (other.specialReviews != null) {
            return false;
        }
    } else if (!ListUtils.isEqualList(specialReviews, other.specialReviews)) {
        return false;
    }
    return true;
}

From source file:org.midonet.cluster.data.neutron.Port.java

@Override
public final boolean equals(Object obj) {

    if (obj == this)
        return true;

    if (!(obj instanceof Port))
        return false;
    final Port other = (Port) obj;

    return Objects.equal(id, other.id) && Objects.equal(name, other.name)
            && Objects.equal(networkId, other.networkId) && Objects.equal(adminStateUp, other.adminStateUp)
            && Objects.equal(macAddress, other.macAddress) && Objects.equal(deviceId, other.deviceId)
            && Objects.equal(deviceOwner, other.deviceOwner) && Objects.equal(tenantId, other.tenantId)
            && Objects.equal(status, other.status) && ListUtils.isEqualList(fixedIps, other.fixedIps)
            && ListUtils.isEqualList(securityGroups, other.securityGroups);
}

From source file:org.midonet.cluster.data.neutron.SecurityGroup.java

@Override
public boolean equals(Object obj) {

    if (obj == this)
        return true;

    if (!(obj instanceof SecurityGroup))
        return false;
    final SecurityGroup other = (SecurityGroup) obj;

    return Objects.equal(id, other.id) && Objects.equal(name, other.name)
            && Objects.equal(description, other.description) && Objects.equal(tenantId, other.tenantId)
            && ListUtils.isEqualList(securityGroupRules, other.securityGroupRules);
}

From source file:org.midonet.cluster.data.neutron.Subnet.java

@Override
public boolean equals(Object obj) {

    if (obj == this)
        return true;

    if (!(obj instanceof Subnet))
        return false;
    final Subnet other = (Subnet) obj;

    return Objects.equal(id, other.id) && Objects.equal(name, other.name)
            && Objects.equal(ipVersion, other.ipVersion) && Objects.equal(networkId, other.networkId)
            && Objects.equal(cidr, other.cidr) && Objects.equal(gatewayIp, other.gatewayIp)
            && Objects.equal(tenantId, other.tenantId) && Objects.equal(enableDhcp, other.enableDhcp)
            && Objects.equal(shared, other.shared)
            && ListUtils.isEqualList(allocationPools, other.allocationPools)
            && ListUtils.isEqualList(dnsNameservers, other.dnsNameservers)
            && ListUtils.isEqualList(hostRoutes, other.hostRoutes);
}