Example usage for org.apache.commons.lang ArrayUtils contains

List of usage examples for org.apache.commons.lang ArrayUtils contains

Introduction

In this page you can find the example usage for org.apache.commons.lang ArrayUtils contains.

Prototype

public static boolean contains(boolean[] array, boolean valueToFind) 

Source Link

Document

Checks if the value is in the given array.

Usage

From source file:com.vmware.identity.idm.client.TenantManagementTest.java

private void AssertClientCertPolicy(ClientCertPolicy certIn, ClientCertPolicy certOut) {
    Assert.assertEquals(certIn.revocationCheckEnabled(), certOut.revocationCheckEnabled());
    Assert.assertEquals(certIn.useCRLAsFailOver(), certOut.useCRLAsFailOver());
    Assert.assertEquals(certIn.sendOCSPNonce(), certOut.sendOCSPNonce());
    Assert.assertEquals(certIn.getOCSPUrl(), certOut.getOCSPUrl());
    Assert.assertEquals(certIn.getOCSPResponderSigningCert(), certOut.getOCSPResponderSigningCert());
    Assert.assertEquals(certIn.useCertCRL(), certOut.useCertCRL());
    Assert.assertEquals(certIn.getCRLUrl(), certOut.getCRLUrl());
    Assert.assertEquals(certIn.getCacheSize(), certOut.getCacheSize());
    if (certIn.get_siteOCSPList() != null) {
        Assert.assertTrue(certIn.get_siteOCSPList().equals(certOut.get_siteOCSPList()));
    }/*from w  w  w  .j  a  v a  2 s .  co m*/

    //OIDs
    if (certIn.getOIDs() == null) {
        Assert.assertNull(certOut.getOIDs());
    } else {
        Assert.assertNotNull(certOut.getOIDs());
        Assert.assertEquals(certIn.getOIDs().length, certOut.getOIDs().length);
        for (String s : certIn.getOIDs()) {
            Assert.assertTrue(ArrayUtils.contains(certOut.getOIDs(), s));
        }
    }

    //trusted CAs
    if (certIn.getTrustedCAs() == null || certIn.getTrustedCAs().length == 0) {
        Assert.assertNull(certOut.getTrustedCAs());
    } else {
        Assert.assertNotNull(certOut.getTrustedCAs());
        Assert.assertEquals(certIn.getTrustedCAs().length, certOut.getTrustedCAs().length);
        for (int i = 0; i < certIn.getTrustedCAs().length; i++) {
            Assert.assertEquals(certIn.getTrustedCAs()[i], certOut.getTrustedCAs()[i]);
        }
    }
}

From source file:net.sourceforge.vulcan.mailer.EmailPlugin.java

protected List<String> getEmailAddresses(ProjectStatusDto status, ProfileDto profile) {
    if (profile.isOnlyEmailChangeAuthors()) {
        ChangeLogDto changeLog = status.getChangeLog();
        if (changeLog == null) {
            return Collections.emptyList();
        }// w  w  w. j  ava  2  s . c om

        final Set<String> addresses = new LinkedHashSet<String>();
        final List<ChangeSetDto> changeSets = changeLog.getChangeSets();

        final Map<String, String> map = getChangeAuthorEmailMap();

        final String[] profileAddresses = profile.getEmailAddresses();
        for (ChangeSetDto changeSet : changeSets) {
            final String author = changeSet.getAuthorName().trim();
            if (!map.containsKey(author)) {
                continue;
            }
            final String address = map.get(author);
            if (ArrayUtils.contains(profileAddresses, address)) {
                addresses.add(address);
            }
        }
        return new ArrayList<String>(addresses);
    }
    return Arrays.asList(profile.getEmailAddresses());
}

From source file:net.unicon.sakora.impl.csv.CsvCommonHandlerService.java

public void setUserRemoveMode(String userRemoveMode) {
    if (ArrayUtils.contains(URM_VALIDS, userRemoveMode)) {
        this.userRemoveMode = userRemoveMode;
    } else {/*ww  w  .ja v a  2s. c o  m*/
        this.userRemoveMode = URM_DISABLE;
        log.warn("SakoraCSV userRemoveMode (" + userRemoveMode
                + ") is invalid: resetting to default (disable), must match one of these: "
                + ArrayUtils.toString(URM_VALIDS));
    }
}

From source file:net.unicon.sakora.impl.csv.CsvCommonHandlerService.java

/**
 * Allows the current setting to be overridden for the current sync run only
 * @param urm null clears the override, see {@link #userRemoveMode}
 *///from w w w. ja v a  2s  .  c o m
public void overrideUserRemoveMode(String urm) {
    if (ArrayUtils.contains(URM_VALIDS, userRemoveMode) || urm == null) {
        setCurrentSyncVar(USER_REMOVAL_MODE, urm);
        if (urm != null) {
            log.info("Overriding the " + USER_REMOVAL_MODE + " value of " + userRemoveMode + " with " + urm
                    + " for current sync: " + getCurrentSyncRunId());
        }
    } else {
        log.warn("SakoraCSV userRemoveMode override (" + urm
                + ") is invalid: ignoring the override, must match one of these: "
                + ArrayUtils.toString(URM_VALIDS));
    }
}

From source file:net.ymate.platform.core.beans.intercept.InterceptAnnoHelper.java

public static List<Class<? extends IInterceptor>> getBeforeIntercepts(Class<?> targetClass,
        Method targetMethod) {//from  w  w  w  .j av a2 s  .co m
    List<Class<? extends IInterceptor>> _classes = new ArrayList<Class<? extends IInterceptor>>();
    if (targetClass.isAnnotationPresent(Before.class)) {
        Before _before = targetClass.getAnnotation(Before.class);
        Clean _clean = getCleanIntercepts(targetMethod);
        //
        if (_clean != null && (_clean.type().equals(IInterceptor.CleanType.ALL)
                || _clean.type().equals(IInterceptor.CleanType.BEFORE))) {
            if (_clean.value().length > 0) {
                for (Class<? extends IInterceptor> _clazz : _before.value()) {
                    if (ArrayUtils.contains(_clean.value(), _clazz)) {
                        continue;
                    }
                    _classes.add(_clazz);
                }
            }
        } else {
            Collections.addAll(_classes, _before.value());
        }
    }
    //
    if (targetMethod.isAnnotationPresent(Before.class)) {
        Collections.addAll(_classes, targetMethod.getAnnotation(Before.class).value());
    }
    //
    return _classes;
}

From source file:net.ymate.platform.core.beans.intercept.InterceptAnnoHelper.java

public static List<Class<? extends IInterceptor>> getAfterIntercepts(Class<?> targetClass,
        Method targetMethod) {/* w w w .j ava 2 s  . c  o m*/
    List<Class<? extends IInterceptor>> _classes = new ArrayList<Class<? extends IInterceptor>>();
    if (targetClass.isAnnotationPresent(After.class)) {
        After _after = targetClass.getAnnotation(After.class);
        Clean _clean = getCleanIntercepts(targetMethod);
        //
        if (_clean != null && (_clean.type().equals(IInterceptor.CleanType.ALL)
                || _clean.type().equals(IInterceptor.CleanType.AFTER))) {
            if (_clean.value().length > 0) {
                for (Class<? extends IInterceptor> _clazz : _after.value()) {
                    if (ArrayUtils.contains(_clean.value(), _clazz)) {
                        continue;
                    }
                    _classes.add(_clazz);
                }
            }
        } else {
            Collections.addAll(_classes, _after.value());
        }
    }
    //
    if (targetMethod.isAnnotationPresent(After.class)) {
        Collections.addAll(_classes, targetMethod.getAnnotation(After.class).value());
    }
    //
    return _classes;
}

From source file:nl.intercommit.weaves.components.EnhancedSelect.java

private boolean isSelected(String clientValue) {
    if (multiple) {
        if (org.apache.commons.lang.StringUtils.isNotBlank(selectedClientValue)) {
            return ArrayUtils.contains(selectedClientValue.split(multiSeparator), clientValue);
        }/*from   www.ja v a2 s  . c  om*/
    }
    return TapestryInternalUtils.isEqual(clientValue, selectedClientValue);
}

From source file:nl.intercommit.weaves.mixins.Bootstrap.java

void afterRenderTemplate(MarkupWriter writer) {
    writer.getElement().getElement(new Predicate<Element>() {

        @Override/*  w w  w  . java 2 s .  c  o m*/
        public boolean accept(Element arg0) {

            final String elementName = arg0.getName();
            final String inputType = arg0.getAttribute("type");
            final String className = arg0.getAttribute("class");

            // quickly skip some non-styleable stuff
            if (ArrayUtils.contains(NON_STYLABLE, elementName)) {
                return false;
            }
            if (logger.isDebugEnabled()) {
                logger.debug("Styling element [" + elementName + "] with type [" + inputType + "] and class ["
                        + className + "] ");
            }
            // Use JAVA7 features.
            switch (elementName) {
            case "form": {
                arg0.addClassName(config.getElementClassMapping().get("form"));
                break;
            }
            case "dl": {
                arg0.addClassName("dl-horizontal");
                break;
            }
            case "label": {
                arg0.addClassName("control-label");
                if (StringUtils.contains(arg0.getContainer().getAttribute("class"), "form-group")) {
                    arg0.addClassName("col-lg-" + labelSize);
                }
                break;
            }
            case "input": {
                if (inputType != null) {
                    if ("text".equals(inputType)) {
                        arg0.addClassName("form-control"); // inputtext
                    } else if ("submit".equals(inputType)) {
                        arg0.addClassName("btn"); // submit
                    } else if ("password".equals(inputType)) {
                        arg0.addClassName("form-control"); // password
                    }
                } else {
                    arg0.addClassName("form-control"); // regular control
                }
                if (StringUtils.contains(arg0.getContainer().getAttribute("class"), "form-group")) {
                    arg0.wrap("div", "class", "col-lg-" + inputSize);
                }
                break;
            }
            case "select": {
                arg0.addClassName("form-control");
                if (StringUtils.contains(arg0.getContainer().getAttribute("class"), "form-group")) {
                    arg0.wrap("div", "class", "col-lg-" + inputSize);
                }
                break;
            }
            case "textarea": {
                arg0.addClassName("form-control");
                if (StringUtils.contains(arg0.getContainer().getAttribute("class"), "form-group")) {
                    arg0.wrap("div", "class", "col-lg-" + inputSize);
                }
                break;
            }
            case "div": {
                if ("t-beaneditor-row".equals(className)) {
                    arg0.addClassName("form-group");
                } else if ("t-error".equals(className)) {
                    arg0.addClassName("alert alert-danger");
                } else if ("input-group".equals(className)) {
                    arg0.addClassName("col-lg-" + inputSize);
                }
                break;
            }
            case "table": {
                arg0.addClassName("table");
                break;
            }
            }
            return false;
        }
    });

}

From source file:nl.strohalm.cyclos.services.customization.CustomFieldServiceImpl.java

public int remove(final Long... ids) {
    final CustomField.Nature[] allowed = { CustomField.Nature.AD, CustomField.Nature.MEMBER,
            CustomField.Nature.ADMIN, CustomField.Nature.LOAN_GROUP };
    for (final Long id : ids) {
        final CustomField field = load(id);
        if (!ArrayUtils.contains(allowed, field.getNature())) {
            throw new UnexpectedEntityException();
        }// w ww.ja  va  2s . c om
        cachedCustomFieldsByNature.remove(field.getNature());
    }
    return customFieldDao.delete(ids);
}

From source file:nl.strohalm.cyclos.utils.conversion.HtmlConverter.java

private static void removeBadNodes(final Document document) {
    final NodeList elements = document.getElementsByTagName("*");
    for (int i = 0; i < elements.getLength(); i++) {
        final Element element = (Element) elements.item(i);
        if (ArrayUtils.contains(BAD_TAGS, element.getTagName())) {
            element.getParentNode().removeChild(element);
        }//from w  ww.  j  av a 2s  . c  om
        final NamedNodeMap attributes = element.getAttributes();
        for (int j = 0; j < attributes.getLength(); j++) {
            final Attr attr = (Attr) attributes.item(j);
            if (attr.getNodeName().startsWith("on")) {
                // This is an event handler: remove it
                element.removeAttributeNode(attr);
            }
        }
    }
}