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

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

Introduction

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

Prototype

public static boolean isNotEmpty(boolean[] array) 

Source Link

Document

Checks if an array of primitive booleans is not empty or not null.

Usage

From source file:com.vmware.bdd.service.resmgmt.sync.filter.VcResourceFilters.java

public VcResourceFilters addHostFilterByNetwork(String[] vcNetworkNames) {
    if (ArrayUtils.isNotEmpty(vcNetworkNames)) {
        getFilterList(VC_RESOURCE_TYPE.HOST).add(new HostFilterByNetwork(vcNetworkNames));
    } else {/*from   w ww. j  av  a2 s .c o  m*/
        LOGGER.warn("can't create an empty host by datastore filter!");
    }

    return this;
}

From source file:com.hp.autonomy.searchcomponents.hod.search.fields.HodSearchResultDeserializer.java

@Override
public HodSearchResult deserialize(final JsonParser jsonParser,
        final DeserializationContext deserializationContext) throws IOException {
    final FieldsInfo fieldsInfo = configService.getConfig().getFieldsInfo();
    final Map<String, FieldInfo<?>> fieldConfig = fieldsInfo.getFieldConfigByName();

    final JsonNode node = jsonParser.getCodec().readTree(jsonParser);

    final Map<String, FieldInfo<?>> fieldMap = new HashMap<>(fieldConfig.size());
    for (final FieldInfo<?> fieldInfo : fieldConfig.values()) {
        for (final String name : fieldInfo.getNames()) {
            final String[] stringValues = parseAsStringArray(node, name);

            if (ArrayUtils.isNotEmpty(stringValues)) {
                final List<Object> values = new ArrayList<>(stringValues.length);
                for (final String stringValue : stringValues) {
                    final Object value = fieldInfo.getType().parseValue(fieldInfo.getType().getType(),
                            stringValue);
                    values.add(value);//  w  w  w  .ja v a 2s . co m
                }

                fieldMap.put(fieldInfo.getId(), new FieldInfo<>(fieldInfo.getId(), Collections.singleton(name),
                        fieldInfo.getType(), values));
            }
        }
    }

    return new HodSearchResult.Builder().setReference(parseAsString(node, "reference"))
            .setIndex(parseAsString(node, "index")).setTitle(parseAsString(node, "title"))
            .setSummary(parseAsString(node, "summary")).setWeight(parseAsDouble(node, "weight"))
            .setFieldMap(fieldMap).setDate(parseAsDateFromArray(node, "date"))
            .setPromotionCategory(parsePromotionCategory(node, "promotion")).build();
}

From source file:de.hybris.platform.acceleratorfacades.urlencoder.impl.DefaultUrlEncoderFacade.java

@Deprecated
@Override/*from  w w w.j av a  2  s .  c  o  m*/
public UrlEncoderPatternData patternForUrlEncoding(final String uri, final String contextPath,
        final boolean newSession) {
    final List<UrlEncoderData> urlEncodingAttributes = variablesForUrlEncoding();
    final UrlEncoderPatternData patternData = new UrlEncoderPatternData();
    final String[] splitUrl = StringUtils.split(uri, "/");
    int splitUrlCounter = (ArrayUtils.isNotEmpty(splitUrl)
            && (StringUtils.remove(contextPath, "/").equals(splitUrl[0]))) ? 1 : 0;
    for (final UrlEncoderData urlEncoderData : urlEncodingAttributes) {
        boolean applicationDriven = false;
        if ((splitUrlCounter) < splitUrl.length) {
            String tempValue = splitUrl[splitUrlCounter];
            if (!isValid(urlEncoderData.getAttributeName(), tempValue)) {
                tempValue = urlEncoderData.getDefaultValue();
                if (LOG.isDebugEnabled()) {
                    LOG.debug("Encoding attributes are absent. Injecting default value :  [" + tempValue + "]");
                }
            }
            final UrlEncodingAttributeManager attributeManager = getUrlEncoderService()
                    .getUrlEncodingAttrManagerMap().get(urlEncoderData.getAttributeName());
            //Check if its driven by user and if so redirect
            if (!newSession && !StringUtils.equalsIgnoreCase(urlEncoderData.getCurrentValue(),
                    attributeManager.getCurrentValue())) {
                urlEncoderData.setCurrentValue(attributeManager.getCurrentValue());
                patternData.setRedirectRequired(true);
                applicationDriven = true;
            }
            if (!applicationDriven) {
                urlEncoderData.setCurrentValue(tempValue);
            }
            splitUrlCounter++;
        } else {
            break;
        }
    }
    patternData.setPattern(extractEncodingPattern(urlEncodingAttributes));

    return patternData;
}

From source file:eu.gentech.osgi.packagescanner.ExportPackageScanner.java

public ExportPackageScanner with(final ExportPackageScanningStrategy... strategies) {
    if (ArrayUtils.isNotEmpty(strategies)) {
        this.strategies.addAll(Arrays.asList(strategies));
    }//from w ww.  ja v a 2s.co  m
    return this;
}

From source file:net.shopxx.service.impl.MemberAttributeServiceImpl.java

@Transactional(readOnly = true)
public boolean isValid(MemberAttribute memberAttribute, String[] values) {
    Assert.notNull(memberAttribute);/*from  w w  w . j a v a 2s.c o  m*/
    Assert.notNull(memberAttribute.getType());

    String value = ArrayUtils.isNotEmpty(values) ? values[0].trim() : null;
    switch (memberAttribute.getType()) {
    case name:
    case address:
    case zipCode:
    case phone:
    case mobile:
    case text:
        if (memberAttribute.getIsRequired() && StringUtils.isEmpty(value)) {
            return false;
        }
        if (StringUtils.isNotEmpty(memberAttribute.getPattern()) && StringUtils.isNotEmpty(value)
                && !Pattern.compile(memberAttribute.getPattern()).matcher(value).matches()) {
            return false;
        }
        break;
    case gender:
        if (memberAttribute.getIsRequired() && StringUtils.isEmpty(value)) {
            return false;
        }
        if (StringUtils.isNotEmpty(value)) {
            try {
                Member.Gender.valueOf(value);
            } catch (IllegalArgumentException e) {
                return false;
            }
        }
        break;
    case birth:
        if (memberAttribute.getIsRequired() && StringUtils.isEmpty(value)) {
            return false;
        }
        if (StringUtils.isNotEmpty(value)) {
            try {
                DateUtils.parseDate(value, CommonAttributes.DATE_PATTERNS);
            } catch (ParseException e) {
                return false;
            }
        }
        break;
    case area:
        Long id = NumberUtils.toLong(value, -1L);
        Area area = areaDao.find(id);
        if (memberAttribute.getIsRequired() && area == null) {
            return false;
        }
        break;
    case select:
        if (memberAttribute.getIsRequired() && StringUtils.isEmpty(value)) {
            return false;
        }
        if (CollectionUtils.isEmpty(memberAttribute.getOptions())) {
            return false;
        }
        if (StringUtils.isNotEmpty(value) && !memberAttribute.getOptions().contains(value)) {
            return false;
        }
        break;
    case checkbox:
        if (memberAttribute.getIsRequired() && ArrayUtils.isEmpty(values)) {
            return false;
        }
        if (CollectionUtils.isEmpty(memberAttribute.getOptions())) {
            return false;
        }
        if (ArrayUtils.isNotEmpty(values) && !memberAttribute.getOptions().containsAll(Arrays.asList(values))) {
            return false;
        }
        break;
    }
    return true;
}

From source file:cn.loveapple.client.android.bbt.listener.VisibilityOnCheckedChangeListener.java

/**
 * {@inheritDoc}// w  w  w .j  a va 2s .  co m
 */
@Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
    if (isChecked) {
        if (visibility == INVISIBLE) {
            if (ArrayUtils.isNotEmpty(visibleList)) {
                for (ViewVisibilityHelper helper : visibleList) {
                    if (helper.isView()) {
                        setVisibleList(target, helper.getView());
                    } else {
                        setInvisibleList(target, helper.getView());
                    }
                }
            }
            if (ArrayUtils.isNotEmpty(hiddenList)) {
                for (ViewVisibilityHelper helper : hiddenList) {
                    setInvisibleList(target, helper.getView());
                }
            }
        } else {
            if (ArrayUtils.isNotEmpty(visibleList)) {
                for (ViewVisibilityHelper helper : visibleList) {
                    if (helper.isView()) {
                        setVisibleList(target, helper.getView());
                    } else {
                        setGoneList(target, helper.getView());
                    }
                }
            }
            if (ArrayUtils.isNotEmpty(hiddenList)) {
                for (ViewVisibilityHelper helper : hiddenList) {
                    setGoneList(target, helper.getView());
                }
            }
        }
    } else {
        if (visibility == INVISIBLE) {
            if (ArrayUtils.isNotEmpty(visibleList)) {
                for (ViewVisibilityHelper helper : visibleList) {
                    setInvisibleList(target, helper.getView());
                }
            }
            if (ArrayUtils.isNotEmpty(hiddenList)) {
                for (ViewVisibilityHelper helper : hiddenList) {
                    if (helper.isView()) {
                        setVisibleList(target, helper.getView());
                    } else {
                        setGoneList(target, helper.getView());
                    }
                }
            }
        } else {
            if (ArrayUtils.isNotEmpty(visibleList)) {
                for (ViewVisibilityHelper helper : visibleList) {
                    setGoneList(target, helper.getView());
                }
            }
            if (ArrayUtils.isNotEmpty(hiddenList)) {
                for (ViewVisibilityHelper helper : hiddenList) {
                    if (helper.isView()) {
                        setVisibleList(target, helper.getView());
                    } else {
                        setGoneList(target, helper.getView());
                    }
                }
            }
        }
    }
}

From source file:de.pawlidi.openaletheia.base.model.User.java

public User toObject(final String userString) {
    if (StringUtils.isNotEmpty(userString)) {
        String[] values = StringUtils.split(userString, VALUE_SEPARATOR);
        if (ArrayUtils.isNotEmpty(values) && values.length >= 3) {
            uuid = values[0];//from   w  ww  .j  av a  2 s .  co m
            username = values[1];
            password = values[2];
        }
    }
    return this;
}

From source file:com.vmware.bdd.cli.auth.LoginClientImpl.java

/**
 *
 * attempt login by posting credentials to serengeti server
 *
 * @param serengetiURL https://host:8443/serengeti/api/
 * @param userName vc user name/*from  www  .  j a v a 2s . c o  m*/
 * @param password vc password
 * @throws IOException connection exception
 */
public LoginResponse login(final String serengetiURL, String userName, String password) throws IOException {
    String url = serengetiURL + Constants.REST_PATH_LOGIN;
    HttpPost loginPost = new HttpPost(url);

    NameValuePair[] loginCredentials = new NameValuePair[] { new BasicNameValuePair("j_username", userName),
            new BasicNameValuePair("j_password", password) };

    //handling non-ascii username and password. Encoding by Apache HTTP Client.
    HttpEntity requestEntity = new UrlEncodedFormEntity(Arrays.asList(loginCredentials),
            Charset.forName("UTF-8"));
    loginPost.setEntity(requestEntity);

    HttpResponse response;

    try {
        response = client1.execute(loginPost);

        LOGGER.debug("resp code is: " + response.getStatusLine());
        int responseCode = response.getStatusLine().getStatusCode();

        LoginResponse loginResponse;
        if (response.getStatusLine().getStatusCode() == HttpStatus.SC_OK) {
            //normal response
            String cookieValue = null;
            Header[] setCookieHeaders = response.getHeaders(SET_COOKIE_HEADER);

            if (ArrayUtils.isNotEmpty(setCookieHeaders)) {
                cookieValue = setCookieHeaders[0].getValue();

                if (StringUtils.isNotBlank(cookieValue) && cookieValue.contains(";")) {
                    cookieValue = cookieValue.split(";")[0];
                }
            }

            loginResponse = new LoginResponse(responseCode, cookieValue);
        } else {
            loginResponse = new LoginResponse(responseCode, null);
        }

        return loginResponse;
    } finally {
        loginPost.releaseConnection();
    }
}

From source file:com.adobe.acs.commons.replication.BrandPortalAgentFilter.java

@SuppressWarnings("squid:S3776")
protected List<Resource> getBrandPortalConfigs(Resource content) {
    if (content == null) {
        return Collections.emptyList();
    } else if (JcrConstants.JCR_CONTENT.equals(content.getName())) {
        content = content.getParent();//from  w  w  w .  j  a va 2  s. c  o m
    }

    final List<Resource> resources = new ArrayList<Resource>();
    final ResourceResolver resourceResolver = content.getResourceResolver();

    do {
        ValueMap properties = content.getValueMap();
        String[] configs = properties.get(PROP_MP_CONFIG, new String[] {});
        if (ArrayUtils.isNotEmpty(configs)) {
            if (log.isDebugEnabled()) {
                log.debug("Resolved Brand Portal configs [ {}@{} -> {} ]", content.getPath(), PROP_MP_CONFIG,
                        StringUtils.join(configs, ","));
            }

            for (final String config : configs) {
                Resource r = resourceResolver.getResource(config + "/" + JcrConstants.JCR_CONTENT);
                if (r != null) {
                    resources.add(r);
                }
            }

            break;
        }

        content = content.getParent();

    } while (content != null);

    return resources;
}

From source file:com.adobe.acs.commons.notifications.impl.InboxNotificationSenderImpl.java

private Task createTask(TaskManager taskManager, InboxNotification inboxNotification)
        throws TaskManagerException {

    Task newTask = taskManager.getTaskManagerFactory().newTask(NOTIFICATION_TASK_TYPE);

    newTask.setName(inboxNotification.getTitle());
    newTask.setContentPath(inboxNotification.getContentPath());
    newTask.setDescription(inboxNotification.getMessage());
    newTask.setInstructions(inboxNotification.getInstructions());
    newTask.setCurrentAssignee(inboxNotification.getAssignee());

    String[] notificationActions = inboxNotification.getNotificationActions();

    if (ArrayUtils.isNotEmpty(notificationActions)) {
        List<TaskAction> taskActions = createTaskActionsList(notificationActions, taskManager);
        newTask.setActions(taskActions);
    }/*from w  ww.  ja va2  s.c  o  m*/

    return newTask;
}