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

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

Introduction

In this page you can find the example usage for org.apache.commons.collections 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:exercise.cpc.app.MainCli.java

private void addList(ChessPiece[] word, List<List<ChessPiece>> piecesList) {
    List<ChessPiece> pieces = new ArrayList<ChessPiece>();
    pieces.addAll(Arrays.asList(word));
    boolean notExists = true;
    for (List<ChessPiece> listOfPieces : piecesList) {
        if (ListUtils.isEqualList(listOfPieces, pieces)) {
            notExists = false;//from   ww  w  . j  a va2  s.  co m
            break;
        }
    }
    if (notExists) {
        piecesList.add(pieces);
    }
}

From source file:com.ebay.cloud.cms.entmgr.entity.impl.EntityFieldTargetMerger.java

private List<?> mergeTargetContent(List<?> giveValues, List<?> foundValues, AtomicBoolean hasChange) {
    List<?> result = null;/*  w  ww  .  j  a  v  a  2  s.  c o m*/
    if (pull) {
        result = ListUtils.subtract(foundValues, giveValues);
    } else {
        result = ListUtils.sum(foundValues, giveValues);
    }
    hasChange.set(!ListUtils.isEqualList(result, foundValues));
    return result;
}

From source file:gov.nih.nci.caarray.services.external.v1_0.data.impl.DataServiceBean.java

private boolean allDesignElementListsAreConsistent(List<gov.nih.nci.caarray.domain.data.DataSet> dataSets) {
    final DesignElementList firstList = dataSets.get(0).getDesignElementList();
    for (int i = 1; i < dataSets.size(); i++) {
        final DesignElementList nextList = dataSets.get(i).getDesignElementList();
        if (!ListUtils.isEqualList(firstList.getDesignElements(), nextList.getDesignElements())) {
            return false;
        }/*from w ww .j  a v a  2  s  .c o m*/
    }
    return true;
}

From source file:com.vmware.photon.controller.apife.entities.DeploymentEntity.java

@Override
public boolean equals(Object o) {
    if (!super.equals(o)) {
        return false;
    }/*  w  w w  .j a va 2s  . c o m*/

    DeploymentEntity other = (DeploymentEntity) o;
    return Objects.equals(this.getSyslogEndpoint(), other.getSyslogEndpoint())
            && Objects.equals(this.getStatsEnabled(), other.getStatsEnabled())
            && Objects.equals(this.getStatsStoreEndpoint(), other.getStatsStoreEndpoint())
            && Objects.equals(this.getStatsStorePort(), other.getStatsStorePort())
            && Objects.equals(this.getStatsStoreType(), other.getStatsStoreType())
            && Objects.equals(this.getAuthEnabled(), other.getAuthEnabled())
            && Objects.equals(this.getOauthEndpoint(), other.getOauthEndpoint())
            && Objects.equals(this.getOauthPort(), other.getOauthPort())
            && Objects.equals(this.getOauthTenant(), other.getOauthTenant())
            && Objects.equals(this.getOauthUsername(), other.getOauthUsername())
            && Objects.equals(this.getOauthPassword(), other.getOauthPassword())
            && ListUtils.isEqualList(this.getOauthSecurityGroups(), other.getOauthSecurityGroups())
            && Objects.equals(this.getVirtualNetworkEnabled(), other.getVirtualNetworkEnabled())
            && Objects.equals(this.getNetworkManagerAddress(), other.getNetworkManagerAddress())
            && Objects.equals(this.getNetworkManagerUsername(), other.getNetworkManagerUsername())
            && Objects.equals(this.getNetworkManagerPassword(), other.getNetworkManagerPassword())
            && Objects.equals(this.getNtpEndpoint(), other.getNtpEndpoint())
            && Objects.equals(this.getImageDatastores(), other.getImageDatastores())
            && Objects.equals(this.getUseImageDatastoreForVms(), other.getUseImageDatastoreForVms())
            && Objects.equals(this.getLoadBalancerEnabled(), other.getLoadBalancerEnabled())
            && Objects.equals(this.getLoadBalancerAddress(), other.getLoadBalancerAddress())
            && Objects.equals(this.getMigrationProgress(), other.getMigrationProgress())
            && Objects.equals(this.getVibsUploaded(), other.getVibsUploaded())
            && Objects.equals(this.getVibsUploading(), other.getVibsUploading());
}

From source file:com.vmware.photon.controller.apife.backends.ProjectSqlBackendTest.java

@Test
public void testUpdateSecurityGroupsSuccess() throws Exception {
    final String projectId = entityFactory.createProject(tenantId, tenantTicketId, "p1",
            new QuotaLineItemEntity("vm", 10, QuotaUnit.COUNT),
            new QuotaLineItemEntity("disk", 200, QuotaUnit.GB));

    String[] securityGroups = { "adminGroup1", "adminGroup2" };
    TaskEntity taskEntity = backend.setSecurityGroups(projectId, Arrays.asList(securityGroups));

    flushSession();//from w ww.ja  v a 2s. c o m

    List<SecurityGroupEntity> updatedSecurityGroups = projectDao.findById(projectId).get().getSecurityGroups();
    List<SecurityGroupEntity> securityGroupsWithInherited = Arrays.asList(securityGroups).stream()
            .map(g -> new SecurityGroupEntity(g, false)).collect(Collectors.toList());
    assertThat(ListUtils.isEqualList(updatedSecurityGroups, securityGroupsWithInherited), is(true));

    taskEntity = taskDao.findById(taskEntity.getId()).get();
    Assert.assertThat(taskEntity.getEntityId(), notNullValue());
    Assert.assertThat(taskEntity.getState(), is(TaskEntity.State.COMPLETED));
    Assert.assertThat(taskEntity.getEntityKind(), is(Project.KIND));
    assertThat(taskEntity.getSteps().size(), is(1));

    StepEntity stepEntity = taskEntity.getSteps().get(0);
    assertThat(stepEntity.getState(), is(StepEntity.State.COMPLETED));
    assertThat(stepEntity.getWarnings().size(), is(0));
}

From source file:com.vmware.photon.controller.api.frontend.entities.DeploymentEntity.java

@Override
public boolean equals(Object o) {
    if (!super.equals(o)) {
        return false;
    }/*from   w w w . j a v  a2  s. com*/

    DeploymentEntity other = (DeploymentEntity) o;
    return Objects.equals(this.getSyslogEndpoint(), other.getSyslogEndpoint())
            && Objects.equals(this.getStatsEnabled(), other.getStatsEnabled())
            && Objects.equals(this.getStatsStoreEndpoint(), other.getStatsStoreEndpoint())
            && Objects.equals(this.getStatsStorePort(), other.getStatsStorePort())
            && Objects.equals(this.getStatsStoreType(), other.getStatsStoreType())
            && Objects.equals(this.getAuthEnabled(), other.getAuthEnabled())
            && Objects.equals(this.getOauthEndpoint(), other.getOauthEndpoint())
            && Objects.equals(this.getOauthPort(), other.getOauthPort())
            && Objects.equals(this.getOauthTenant(), other.getOauthTenant())
            && Objects.equals(this.getOauthUsername(), other.getOauthUsername())
            && Objects.equals(this.getOauthPassword(), other.getOauthPassword())
            && ListUtils.isEqualList(this.getOauthSecurityGroups(), other.getOauthSecurityGroups())
            && Objects.equals(this.getSdnEnabled(), other.getSdnEnabled())
            && Objects.equals(this.getNetworkManagerAddress(), other.getNetworkManagerAddress())
            && Objects.equals(this.getNetworkManagerUsername(), other.getNetworkManagerUsername())
            && Objects.equals(this.getNetworkManagerPassword(), other.getNetworkManagerPassword())
            && Objects.equals(this.getNetworkZoneId(), other.getNetworkZoneId())
            && Objects.equals(this.getNetworkTopRouterId(), other.getNetworkTopRouterId())
            && Objects.equals(this.getIpRange(), other.getIpRange())
            && Objects.equals(this.getFloatingIpRange(), other.getFloatingIpRange())
            && Objects.equals(this.getFloatingAddressSpaceSubnetId(), other.getFloatingAddressSpaceSubnetId())
            && Objects.equals(this.getNtpEndpoint(), other.getNtpEndpoint())
            && Objects.equals(this.getImageDatastores(), other.getImageDatastores())
            && Objects.equals(this.getUseImageDatastoreForVms(), other.getUseImageDatastoreForVms())
            && Objects.equals(this.getLoadBalancerEnabled(), other.getLoadBalancerEnabled())
            && Objects.equals(this.getLoadBalancerAddress(), other.getLoadBalancerAddress())
            && Objects.equals(this.getMigrationProgress(), other.getMigrationProgress())
            && Objects.equals(this.getVibsUploaded(), other.getVibsUploaded())
            && Objects.equals(this.getVibsUploading(), other.getVibsUploading());
}

From source file:com.vmware.photon.controller.apife.backends.TenantSqlBackendTest.java

@Test
public void testReadSecurityGroups() throws Exception {
    TenantEntity tenantEntity = entityFactory.createTenant("t1");
    String tenantId = tenantEntity.getId();

    String[] securityGroups = { "adminGroup1", "adminGroup2" };
    TaskEntity taskEntity = backend.prepareSetSecurityGroups(tenantId, Arrays.asList(securityGroups));

    flushSession();//  ww  w . j  a va  2  s . c om

    TenantEntity found = tenantDao.findById(tenantId).get();
    SecurityGroupEntity inheritedSecurityGroup = new SecurityGroupEntity("adminGroup3", true);
    found.getSecurityGroups().add(inheritedSecurityGroup);
    tenantDao.update(found);

    List<SecurityGroup> expectedSecurityGroups = ImmutableList.of(new SecurityGroup("adminGroup1", false),
            new SecurityGroup("adminGroup2", false), new SecurityGroup("adminGroup3", true));
    List<SecurityGroup> returnedSecurityGroups = backend.getApiRepresentation(tenantId).getSecurityGroups();
    assertThat(returnedSecurityGroups.size(), is(3));
    assertThat(ListUtils.isEqualList(expectedSecurityGroups, returnedSecurityGroups), is(true));
}

From source file:com.vmware.photon.controller.apife.backends.ProjectSqlBackendTest.java

@Test
public void testUpdateSecurityGroupsWarning() throws Exception {
    final String projectId = entityFactory.createProject(tenantId, tenantTicketId, "p1",
            new QuotaLineItemEntity("vm", 10, QuotaUnit.COUNT),
            new QuotaLineItemEntity("disk", 200, QuotaUnit.GB));

    ProjectEntity projectEntity = projectDao.findById(projectId).get();
    List<SecurityGroupEntity> currSecurityGroups = projectEntity.getSecurityGroups();
    assertThat(currSecurityGroups.isEmpty(), is(true));

    currSecurityGroups.add(new SecurityGroupEntity("adminGroup1", true));
    projectDao.update(projectEntity);//from w  ww  .java 2 s  .com
    flushSession();

    String[] securityGroups = { "adminGroup1", "adminGroup2" };
    TaskEntity taskEntity = backend.setSecurityGroups(projectId, Arrays.asList(securityGroups));
    flushSession();

    List<SecurityGroupEntity> expectedSecurityGroups = new ArrayList<>();
    expectedSecurityGroups.add(new SecurityGroupEntity("adminGroup1", true));
    expectedSecurityGroups.add(new SecurityGroupEntity("adminGroup2", false));

    List<SecurityGroupEntity> updatedSecurityGroups = projectDao.findById(projectId).get().getSecurityGroups();
    assertThat(ListUtils.isEqualList(updatedSecurityGroups, expectedSecurityGroups), is(true));

    taskEntity = taskDao.findById(taskEntity.getId()).get();
    Assert.assertThat(taskEntity.getEntityId(), notNullValue());
    Assert.assertThat(taskEntity.getState(), is(TaskEntity.State.COMPLETED));
    Assert.assertThat(taskEntity.getEntityKind(), is(Project.KIND));
    assertThat(taskEntity.getSteps().size(), is(1));

    StepEntity stepEntity = taskEntity.getSteps().get(0);
    assertThat(stepEntity.getState(), is(StepEntity.State.COMPLETED));
    assertThat(stepEntity.getWarnings().size(), is(1));
    Assert.assertThat(stepEntity.getWarnings().get(0).getCode(), is("SecurityGroupsAlreadyInherited"));
    Assert.assertThat(stepEntity.getWarnings().get(0).getMessage(),
            is("Security groups [adminGroup1] were not set as they had been inherited from parents"));
}

From source file:com.thinkbiganalytics.feedmgr.service.feed.DefaultFeedManagerFeedService.java

private void saveFeed(final FeedMetadata feed) {
    if (StringUtils.isBlank(feed.getId())) {
        feed.setIsNew(true);/*  ww w  . j  a  va  2  s  . c  o  m*/
    }
    metadataAccess.commit(() -> {
        Stopwatch stopwatch = Stopwatch.createStarted();
        List<? extends HadoopSecurityGroup> previousSavedSecurityGroups = null;
        // Store the old security groups before saving beccause we need to compare afterward
        if (feed.isNew()) {
            Feed existing = feedProvider.findBySystemName(feed.getCategory().getSystemName(),
                    feed.getSystemFeedName());
            // Since we know this is expected to be new check if the category/feed name combo is already being used.
            if (existing != null) {
                throw new DuplicateFeedNameException(feed.getCategoryName(), feed.getFeedName());
            }
        } else {
            Feed previousStateBeforeSaving = feedProvider.findById(feedProvider.resolveId(feed.getId()));
            Map<String, String> userProperties = previousStateBeforeSaving.getUserProperties();
            previousSavedSecurityGroups = previousStateBeforeSaving.getSecurityGroups();
        }

        //if this is the first time saving this feed create a new one
        Feed domainFeed = feedModelTransform.feedToDomain(feed);

        if (domainFeed.getState() == null) {
            domainFeed.setState(Feed.State.ENABLED);
        }
        stopwatch.stop();
        log.debug("Time to transform the feed to a domain object for saving: {} ms",
                stopwatch.elapsed(TimeUnit.MILLISECONDS));
        stopwatch.reset();

        //initially save the feed
        if (feed.isNew()) {
            stopwatch.start();
            domainFeed = feedProvider.update(domainFeed);
            stopwatch.stop();
            log.debug("Time to save the New feed: {} ms", stopwatch.elapsed(TimeUnit.MILLISECONDS));
            stopwatch.reset();
        }

        final String domainId = domainFeed.getId().toString();
        final String feedName = FeedNameUtil.fullName(domainFeed.getCategory().getSystemName(),
                domainFeed.getName());

        // Build preconditions
        stopwatch.start();
        assignFeedDependencies(feed, domainFeed);
        stopwatch.stop();
        log.debug("Time to assignFeedDependencies: {} ms", stopwatch.elapsed(TimeUnit.MILLISECONDS));
        stopwatch.reset();

        //Assign the datasources
        stopwatch.start();
        assignFeedDatasources(feed, domainFeed);
        stopwatch.stop();
        log.debug("Time to assignFeedDatasources: {} ms", stopwatch.elapsed(TimeUnit.MILLISECONDS));
        stopwatch.reset();

        stopwatch.start();
        boolean isStream = feed.getRegisteredTemplate() != null ? feed.getRegisteredTemplate().isStream()
                : false;
        Long timeBetweenBatchJobs = feed.getRegisteredTemplate() != null
                ? feed.getRegisteredTemplate().getTimeBetweenStartingBatchJobs()
                : 0L;
        //sync the feed information to ops manager
        metadataAccess.commit(() -> opsManagerFeedProvider.save(opsManagerFeedProvider.resolveId(domainId),
                feedName, isStream, timeBetweenBatchJobs));

        stopwatch.stop();
        log.debug("Time to sync feed data with Operations Manager: {} ms",
                stopwatch.elapsed(TimeUnit.MILLISECONDS));
        stopwatch.reset();

        // Update hadoop security group polices if the groups changed
        if (!feed.isNew()
                && !ListUtils.isEqualList(previousSavedSecurityGroups, domainFeed.getSecurityGroups())) {
            stopwatch.start();
            List<? extends HadoopSecurityGroup> securityGroups = domainFeed.getSecurityGroups();
            List<String> groupsAsCommaList = securityGroups.stream().map(group -> group.getName())
                    .collect(Collectors.toList());
            hadoopAuthorizationService.updateSecurityGroupsForAllPolicies(feed.getSystemCategoryName(),
                    feed.getSystemFeedName(), groupsAsCommaList, domainFeed.getProperties());
            stopwatch.stop();
            log.debug("Time to update hadoop security groups: {} ms", stopwatch.elapsed(TimeUnit.MILLISECONDS));
            stopwatch.reset();
        }

        // Update Hive metastore
        stopwatch.start();
        final boolean hasHiveDestination = domainFeed.getDestinations().stream()
                .map(FeedDestination::getDatasource).filter(DerivedDatasource.class::isInstance)
                .map(DerivedDatasource.class::cast)
                .anyMatch(datasource -> "HiveDatasource".equals(datasource.getDatasourceType()));
        if (hasHiveDestination) {
            try {
                feedHiveTableService.updateColumnDescriptions(feed);
            } catch (final DataAccessException e) {
                log.warn("Failed to update column descriptions for feed: {}",
                        feed.getCategoryAndFeedDisplayName(), e);
            }
        }
        stopwatch.stop();
        log.debug("Time to update hive metastore: {} ms", stopwatch.elapsed(TimeUnit.MILLISECONDS));
        stopwatch.reset();

        // Update Kylo metastore
        stopwatch.start();
        domainFeed = feedProvider.update(domainFeed);
        stopwatch.stop();
        log.debug("Time to call feedProvider.update: {} ms", stopwatch.elapsed(TimeUnit.MILLISECONDS));
        stopwatch.reset();
    }, (e) -> {
        if (feed.isNew() && StringUtils.isNotBlank(feed.getId())) {
            //Rollback ops Manager insert if it is newly created
            metadataAccess.commit(() -> {
                opsManagerFeedProvider.delete(opsManagerFeedProvider.resolveId(feed.getId()));
            });
        }
    });

}

From source file:com.mirth.connect.connectors.http.HttpReceiver.java

private boolean parametersEqual(Map<String, List<String>> params1, Map<String, List<String>> params2) {
    if (!params1.keySet().equals(params2.keySet())) {
        return false;
    }//from  www.j  ava  2  s  .  co m

    for (Entry<String, List<String>> entry : params1.entrySet()) {
        if (!ListUtils.isEqualList(entry.getValue(), params2.get(entry.getKey()))) {
            return false;
        }
    }

    return true;
}