Example usage for org.apache.commons.collections4 IterableUtils find

List of usage examples for org.apache.commons.collections4 IterableUtils find

Introduction

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

Prototype

public static <E> E find(final Iterable<E> iterable, final Predicate<? super E> predicate) 

Source Link

Document

Finds the first element in the given iterable which matches the given predicate.

Usage

From source file:org.apache.syncope.core.persistence.jpa.entity.group.JPAGroup.java

@Override
public ADynGroupMembership getADynMembership(final AnyType anyType) {
    return IterableUtils.find(aDynMemberships, new Predicate<ADynGroupMembership>() {

        @Override/*w  ww.  ja  v a 2 s  .  c o  m*/
        public boolean evaluate(final ADynGroupMembership dynGroupMembership) {
            return anyType != null && anyType.equals(dynGroupMembership.getAnyType());
        }
    });
}

From source file:org.apache.syncope.core.persistence.jpa.entity.group.JPAGroup.java

@Override
public TypeExtension getTypeExtension(final AnyType anyType) {
    return IterableUtils.find(typeExtensions, new Predicate<TypeExtension>() {

        @Override//from   ww w.  j ava 2  s  .  c o  m
        public boolean evaluate(final TypeExtension typeExtension) {
            return typeExtension.getAnyType().equals(anyType);
        }
    });
}

From source file:org.apache.syncope.core.persistence.jpa.entity.JPANotification.java

@Override
public AnyAbout getAbout(final AnyType anyType) {
    return IterableUtils.find(abouts, new Predicate<AnyAbout>() {

        @Override//from   w ww.jav a 2  s.c o m
        public boolean evaluate(final AnyAbout about) {
            return anyType != null && anyType.equals(about.getAnyType());
        }
    });
}

From source file:org.apache.syncope.core.persistence.jpa.entity.resource.JPAMapping.java

@Override
public MappingItem getConnObjectKeyItem() {
    return IterableUtils.find(getItems(), new Predicate<MappingItem>() {

        @Override//from   ww w  . j a v  a2 s .c om
        public boolean evaluate(final MappingItem item) {
            return item.isConnObjectKey();
        }
    });
}

From source file:org.apache.syncope.core.persistence.jpa.entity.task.JPAPullTask.java

@Override
public AnyTemplatePullTask getTemplate(final AnyType anyType) {
    return IterableUtils.find(templates, new Predicate<AnyTemplate>() {

        @Override/*from   ww w  . j  a v  a  2s . co m*/
        public boolean evaluate(final AnyTemplate template) {
            return anyType != null && anyType.equals(template.getAnyType());
        }
    });
}

From source file:org.apache.syncope.core.persistence.jpa.entity.task.JPAPushTask.java

@Override
public PushTaskAnyFilter getFilter(final AnyType anyType) {
    return IterableUtils.find(filters, new Predicate<PushTaskAnyFilter>() {

        @Override/*w w w. ja v a2 s .com*/
        public boolean evaluate(final PushTaskAnyFilter filter) {
            return anyType != null && anyType.equals(filter.getAnyType());
        }
    });
}

From source file:org.apache.syncope.core.provisioning.java.propagation.DBPasswordPropagationActions.java

private String getCipherAlgorithm(final ConnInstance connInstance) {
    ConnConfProperty cipherAlgorithm = IterableUtils.find(connInstance.getConf(),
            new Predicate<ConnConfProperty>() {

                @Override//from  w  w  w. ja  v  a 2 s.c om
                public boolean evaluate(final ConnConfProperty property) {
                    return "cipherAlgorithm".equals(property.getSchema().getName())
                            && property.getValues() != null && !property.getValues().isEmpty();
                }
            });

    return cipherAlgorithm == null ? CLEARTEXT : (String) cipherAlgorithm.getValues().get(0);
}

From source file:org.apache.syncope.core.provisioning.java.propagation.DefaultPropagationReporter.java

@Override
public void onPriorityResourceFailure(final String failingResource, final Collection<PropagationTask> tasks) {
    LOG.debug("Propagation error: {} priority resource failed to propagate", failingResource);

    final PropagationTask propagationTask = IterableUtils.find(tasks, new Predicate<PropagationTask>() {

        @Override/*from  w  w  w  .j a v  a2s. co m*/
        public boolean evaluate(final PropagationTask task) {
            return task.getResource().getKey().equals(failingResource);
        }
    });

    if (propagationTask == null) {
        LOG.error("Could not find {} for {}", PropagationTask.class.getName(), failingResource);
    } else {
        PropagationStatus status = new PropagationStatus();
        status.setResource(propagationTask.getResource().getKey());
        status.setStatus(PropagationTaskExecStatus.FAILURE);
        status.setFailureReason(
                "Propagation error: " + failingResource + " priority resource failed to propagate.");
        add(status);
    }
}

From source file:org.apache.syncope.core.provisioning.java.propagation.LDAPPasswordPropagationActions.java

private String getCipherAlgorithm(final ConnInstance connInstance) {
    ConnConfProperty cipherAlgorithm = IterableUtils.find(connInstance.getConf(),
            new Predicate<ConnConfProperty>() {

                @Override/*from  w  w  w.  j  a v a  2 s.  c  o m*/
                public boolean evaluate(final ConnConfProperty property) {
                    return "passwordHashAlgorithm".equals(property.getSchema().getName())
                            && property.getValues() != null && !property.getValues().isEmpty();
                }
            });

    return cipherAlgorithm == null ? CLEARTEXT : (String) cipherAlgorithm.getValues().get(0);
}

From source file:org.apache.syncope.core.provisioning.java.pushpull.LDAPMembershipPullActions.java

/**
 * Allows easy subclassing for the ConnId AD connector bundle.
 *
 * @param connector A Connector instance to query for the groupMemberAttribute property name
 * @return the name of the attribute used to keep track of group memberships
 *//*from  w  ww . j  a  va2 s. c o  m*/
protected String getGroupMembershipAttrName(final Connector connector) {
    ConnConfProperty groupMembership = IterableUtils.find(connector.getConnInstance().getConf(),
            new Predicate<ConnConfProperty>() {

                @Override
                public boolean evaluate(final ConnConfProperty property) {
                    return "groupMemberAttribute".equals(property.getSchema().getName())
                            && property.getValues() != null && !property.getValues().isEmpty();
                }
            });

    return groupMembership == null ? "uniquemember" : (String) groupMembership.getValues().get(0);
}