Example usage for org.apache.commons.collections4 CollectionUtils isNotEmpty

List of usage examples for org.apache.commons.collections4 CollectionUtils isNotEmpty

Introduction

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

Prototype

public static boolean isNotEmpty(final Collection<?> coll) 

Source Link

Document

Null-safe check if the specified collection is not empty.

Usage

From source file:badminton.common.Util.CollectionUtil.java

/**
 * ???/*  ww  w .ja  v a2  s.  co m*/
 *
 * @param collection
 * @return true:?,false:??
 */
public static boolean isNotEmpty(final Collection<?> collection) {
    return CollectionUtils.isNotEmpty(collection);
}

From source file:com.movies.util.MovieUtil.java

public static boolean okToSave(Movie movie) {
    return movie != null && StringUtils.isNotBlank(movie.getTitle())
            && CollectionUtils.isNotEmpty(movie.getDirectors()) && CollectionUtils.isNotEmpty(movie.getActors())
            && CollectionUtils.isNotEmpty(movie.getGenres());
}

From source file:com.mirth.connect.util.ChannelDependencyGraph.java

public ChannelDependencyGraph(Set<ChannelDependency> dependencies) throws ChannelDependencyException {
    if (CollectionUtils.isNotEmpty(dependencies)) {
        for (ChannelDependency dependency : dependencies) {
            addDependency(dependency);//from   www. j  av  a 2 s . c o  m
        }
    }
}

From source file:com.goodhuddle.huddle.repository.BlogPostSpecification.java

public static Specification<BlogPost> search(final Huddle huddle, final SearchBlogPostRequest request) {
    return new Specification<BlogPost>() {
        @Override/*from ww w . ja  v  a 2  s. co  m*/
        public Predicate toPredicate(Root<BlogPost> blogPost, CriteriaQuery<?> query, CriteriaBuilder builder) {

            Predicate conjunction = builder.conjunction();
            conjunction.getExpressions().add(builder.equal(blogPost.get("huddle"), huddle));

            if (StringUtils.isNotBlank(request.getPhrase())) {
                String phrase = "%" + request.getPhrase().toLowerCase() + "%";
                conjunction.getExpressions()
                        .add(builder.like(builder.lower(blogPost.<String>get("title")), phrase));
            }

            if (CollectionUtils.isNotEmpty(request.getBlogIds())) {
                Join<Object, Object> blog = blogPost.join("blog");
                conjunction.getExpressions().add(builder.in(blog.get("id")).value(request.getBlogIds()));
            }

            if (!request.isIncludeUnpublished()) {
                conjunction.getExpressions()
                        .add(builder.lessThan((Expression) blogPost.get("publishedOn"), new DateTime()));
            }

            return conjunction;
        }
    };
}

From source file:cop.raml.utils.javadoc.MethodJavaDoc.java

@NotNull
public static MethodJavaDoc create(List<String> doc) {
    return CollectionUtils.isNotEmpty(doc) ? new MethodJavaDoc(doc) : NULL;
}

From source file:io.cloudslang.lang.compiler.modeller.transformers.AbstractInOutForTransformer.java

protected Accumulator extractFunctionData(Serializable value) {
    String expression = ExpressionUtils.extractExpression(value);
    Set<String> systemPropertyDependencies = new HashSet<>();
    Set<ScriptFunction> functionDependencies = new HashSet<>();
    if (expression != null) {
        systemPropertyDependencies = ExpressionUtils.extractSystemProperties(expression);
        if (CollectionUtils.isNotEmpty(systemPropertyDependencies)) {
            functionDependencies.add(ScriptFunction.GET_SYSTEM_PROPERTY);
        }/*from  w ww. j a  v a 2 s  . c  o m*/
        boolean getFunctionFound = ExpressionUtils.matchGetFunction(expression);
        if (getFunctionFound) {
            functionDependencies.add(ScriptFunction.GET);
        }
        boolean checkEmptyFunctionFound = ExpressionUtils.matchCheckEmptyFunction(expression);
        if (checkEmptyFunctionFound) {
            functionDependencies.add(ScriptFunction.CHECK_EMPTY);
        }
    }
    return new Accumulator(functionDependencies, systemPropertyDependencies);
}

From source file:co.runrightfast.vertx.core.protobuf.MessageConversions.java

static VerticleDeployment toVerticleDeployment(@NonNull final RunRightFastVerticleDeployment deployment,
        @NonNull final Set<String> deploymentIds) {
    final VerticleDeployment.Builder builder = VerticleDeployment.newBuilder()
            .setVerticleClass(deployment.getVerticleClass().getName())
            .setVerticleId(toVerticleId(deployment.getRunRightFastVerticleId()))
            .setDeploymentOptions(toDeploymentOptions(deployment.getDeploymentOptions()));

    final Set<RunRightFastHealthCheck> healthChecks = deployment.getHealthChecks();
    if (CollectionUtils.isNotEmpty(healthChecks)) {
        healthChecks.stream().map(healthCheck -> toHealthCheck(healthCheck, builder.getVerticleId()))
                .forEach(builder::addHealthChecks);
    }/*from  w w w. j  av  a 2s  .  c  om*/

    if (CollectionUtils.isNotEmpty(deploymentIds)) {
        builder.addAllDeploymentIds(deploymentIds);
    }

    return builder.build();
}

From source file:io.github.swagger2markup.internal.utils.ParameterUtils.java

/**
 * Retrieves the type of a parameter, or otherwise null
 *
 * @param parameter the parameter//  w w  w .ja v a 2  s.c om
 * @param definitionDocumentResolver the defintion document resolver
 * @return the type of the parameter, or otherwise null
 */
public static Type getType(Parameter parameter, Map<String, Model> definitions,
        Function<String, String> definitionDocumentResolver) {
    Validate.notNull(parameter, "parameter must not be null!");
    Type type = null;

    if (parameter instanceof BodyParameter) {
        BodyParameter bodyParameter = (BodyParameter) parameter;
        Model model = bodyParameter.getSchema();

        if (model != null) {
            type = ModelUtils.getType(model, definitions, definitionDocumentResolver);
        } else {
            type = new BasicType("string", null);
        }

    } else if (parameter instanceof AbstractSerializableParameter) {
        AbstractSerializableParameter serializableParameter = (AbstractSerializableParameter) parameter;
        @SuppressWarnings("unchecked")
        List<String> enums = serializableParameter.getEnum();

        if (CollectionUtils.isNotEmpty(enums)) {
            type = new EnumType(null, enums);
        } else {
            type = new BasicType(serializableParameter.getType(), null, serializableParameter.getFormat());
        }
        if (serializableParameter.getType().equals("array")) {
            String collectionFormat = serializableParameter.getCollectionFormat();

            type = new ArrayType(null,
                    PropertyUtils.getType(serializableParameter.getItems(), definitionDocumentResolver),
                    collectionFormat);
        }
    } else if (parameter instanceof RefParameter) {
        String refName = ((RefParameter) parameter).getSimpleRef();

        type = new RefType(definitionDocumentResolver.apply(refName),
                new ObjectType(refName, null /* FIXME, not used for now */));
    }
    return type;
}

From source file:co.rsk.validators.RemascValidationRule.java

@Override
public boolean isValid(Block block) {
    List<Transaction> txs = block.getTransactionsList();
    boolean result = CollectionUtils.isNotEmpty(txs) && (txs.get(txs.size() - 1) instanceof RemascTransaction);
    if (!result) {
        logger.error("Remasc tx not found in block");
        panicProcessor.panic("invalidremasctx", "Remasc tx not found in block");
    }/* w ww .j  a  v a2s.  co m*/
    return result;
}

From source file:io.cloudslang.lang.compiler.modeller.transformers.AbstractTransformer.java

protected void validateKeySet(Set<String> keySet, Set<String> mandatoryKeys, Set<String> optionalKeys) {
    Validate.notNull(keySet);//from   w  w  w .  j  a v  a2s. c  om
    Validate.notNull(mandatoryKeys);
    Validate.notNull(optionalKeys);

    Set<String> missingKeys = new HashSet<>(mandatoryKeys);
    missingKeys.removeAll(keySet);
    if (CollectionUtils.isNotEmpty(missingKeys)) {
        throw new RuntimeException(MISSING_KEYS_ERROR_MESSAGE_PREFIX + missingKeys.toString());
    }

    Set<String> invalidKeys = new HashSet<>(keySet);
    invalidKeys.removeAll(mandatoryKeys);
    invalidKeys.removeAll(optionalKeys);
    if (CollectionUtils.isNotEmpty(invalidKeys)) {
        throw new RuntimeException(
                INVALID_KEYS_ERROR_MESSAGE_PREFIX + invalidKeys.toString() + INVALID_KEYS_ERROR_MESSAGE_SUFFIX);
    }
}