List of usage examples for org.apache.commons.collections4 CollectionUtils isNotEmpty
public static boolean isNotEmpty(final Collection<?> coll)
From source file:com.jkoolcloud.tnt4j.streams.inputs.ExcelSXSSFRowStream.java
@Override public void setProperties(Collection<Map.Entry<String, String>> props) { super.setProperties(props); if (CollectionUtils.isNotEmpty(props)) { for (Map.Entry<String, String> prop : props) { String name = prop.getKey(); String value = prop.getValue(); if (StreamProperties.PROP_FILENAME.equalsIgnoreCase(name)) { fileName = value;//from w w w . j a va 2s.c o m } else if (MsOfficeStreamProperties.PROP_SHEETS.equalsIgnoreCase(name)) { sheetName = value; if (StringUtils.isNotEmpty(sheetName)) { sheetNameMatcher = Pattern.compile(Utils.wildcardToRegex2(sheetName)); } } else if (StreamProperties.PROP_RANGE_TO_STREAM.equalsIgnoreCase(name)) { if (StringUtils.isNotEmpty(value)) { rangeValue = value; } } else if (MsOfficeStreamProperties.PROP_WORKBOOK_PASS.equalsIgnoreCase(name)) { if (StringUtils.isNotEmpty(value)) { wbPass = value; } } } } }
From source file:io.github.swagger2markup.internal.adapter.PropertyAdapter.java
/** * Retrieves the type and format of a property. * * @param definitionDocumentResolver the definition document resolver * @return the type of the property//from ww w . j ava 2 s . c om */ public Type getType(DocumentResolver definitionDocumentResolver) { Type type; if (property instanceof RefProperty) { RefProperty refProperty = (RefProperty) property; if (refProperty.getRefFormat() == RefFormat.RELATIVE) type = new ObjectType(refProperty.getTitle(), null); // FIXME : Workaround for https://github.com/swagger-api/swagger-parser/issues/177 else type = new RefType(definitionDocumentResolver.apply(refProperty.getSimpleRef()), new ObjectType(refProperty.getSimpleRef(), null /* FIXME, not used for now */)); } else if (property instanceof ArrayProperty) { ArrayProperty arrayProperty = (ArrayProperty) property; Property items = arrayProperty.getItems(); if (items == null) type = new ArrayType(arrayProperty.getTitle(), new ObjectType(null, null)); // FIXME : Workaround for Swagger parser issue with composed models (https://github.com/Swagger2Markup/swagger2markup/issues/150) else type = new ArrayType(arrayProperty.getTitle(), new PropertyAdapter(items).getType(definitionDocumentResolver)); } else if (property instanceof MapProperty) { MapProperty mapProperty = (MapProperty) property; Property additionalProperties = mapProperty.getAdditionalProperties(); if (additionalProperties == null) type = new MapType(mapProperty.getTitle(), new ObjectType(null, null)); // FIXME : Workaround for Swagger parser issue with composed models (https://github.com/Swagger2Markup/swagger2markup/issues/150) else type = new MapType(mapProperty.getTitle(), new PropertyAdapter(additionalProperties).getType(definitionDocumentResolver)); } else if (property instanceof StringProperty) { StringProperty stringProperty = (StringProperty) property; List<String> enums = stringProperty.getEnum(); if (CollectionUtils.isNotEmpty(enums)) { type = new EnumType(stringProperty.getTitle(), enums); } else if (isNotBlank(stringProperty.getFormat())) { type = new BasicType(stringProperty.getType(), stringProperty.getTitle(), stringProperty.getFormat()); } else { type = new BasicType(stringProperty.getType(), stringProperty.getTitle()); } } else if (property instanceof ObjectProperty) { type = new ObjectType(property.getTitle(), ((ObjectProperty) property).getProperties()); } else { if (isNotBlank(property.getFormat())) { type = new BasicType(property.getType(), property.getTitle(), property.getFormat()); } else { type = new BasicType(property.getType(), property.getTitle()); } } return type; }
From source file:com.baifendian.swordfish.dao.mapper.StreamingResultMapperProvider.java
/** * ???/* ww w . ja va 2s. com*/ * * @param parameter * @return */ public String findLatestDetailByProjectAndNames(Map<String, Object> parameter) { List<String> nameList = (List<String>) parameter.get("nameList"); String subSql = new SQL() { { SELECT("max(id)"); FROM(TABLE_NAME); WHERE("p.id=#{projectId}"); if (CollectionUtils.isNotEmpty(nameList)) { String names = "\"" + String.join("\", \"", nameList) + "\""; WHERE("s.name in (" + names + ")"); } GROUP_BY("streaming_id"); } }.toString(); return constructCommonDetailSQL().WHERE("r.id in " + "(" + subSql + ")").toString(); }
From source file:io.cloudslang.lang.compiler.SlangCompilerImpl.java
private CompilationModellingResult getCompilationModellingResult(SlangSource source, Set<SlangSource> path, PrecompileStrategy precompileStrategy, SensitivityLevel sensitivityLevel) { ExecutableModellingResult executableModellingResult = preCompileSource(source, precompileStrategy, sensitivityLevel);//from w ww .j a v a2s .com List<RuntimeException> errors = executableModellingResult.getErrors(); // we transform also all of the files in the given dependency sources to model objects Map<Executable, SlangSource> executablePairs = new HashMap<>(); executablePairs.put(executableModellingResult.getExecutable(), source); if (CollectionUtils.isNotEmpty(path)) { for (SlangSource currentSource : path) { ExecutableModellingResult result = preCompileSource(currentSource, precompileStrategy, sensitivityLevel); Executable preCompiledCurrentSource = result.getExecutable(); errors.addAll(result.getErrors()); List<RuntimeException> validatorErrors = compileValidator .validateNoDuplicateExecutables(preCompiledCurrentSource, currentSource, executablePairs); errors.addAll(validatorErrors); executablePairs.put(preCompiledCurrentSource, currentSource); } } CompilationModellingResult result = scoreCompiler.compileSource(executableModellingResult.getExecutable(), executablePairs.keySet()); errors.addAll(result.getErrors()); return new CompilationModellingResult(result.getCompilationArtifact(), errors); }
From source file:com.hp.autonomy.searchcomponents.idol.search.fields.FieldsParserImpl.java
private <T> T parseField(final Element node, final FieldInfo<T> fieldInfo, final Class<T> type) { final List<T> fields = parseFields(node, fieldInfo.getNames().get(0), fieldInfo.getType(), type); return CollectionUtils.isNotEmpty(fields) ? fields.get(0) : null; }
From source file:io.github.swagger2markup.internal.adapter.ParameterAdapter.java
/** * Retrieves the type of a parameter, or otherwise null * * @param definitionDocumentResolver the definition document resolver * @return the type of the parameter, or otherwise null *///from w ww . ja v a2 s .co m private Type getType(Map<String, Model> definitions, DocumentResolver 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", bodyParameter.getName()); } } else if (parameter instanceof AbstractSerializableParameter) { AbstractSerializableParameter serializableParameter = (AbstractSerializableParameter) parameter; @SuppressWarnings("unchecked") List<String> enums = serializableParameter.getEnum(); if (CollectionUtils.isNotEmpty(enums)) { type = new EnumType(serializableParameter.getName(), enums); } else { type = new BasicType(serializableParameter.getType(), serializableParameter.getName(), serializableParameter.getFormat()); } if (serializableParameter.getType().equals("array")) { String collectionFormat = serializableParameter.getCollectionFormat(); type = new ArrayType(serializableParameter.getName(), new PropertyAdapter(serializableParameter.getItems()).getType(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:at.gv.egiz.pdfas.lib.impl.signing.pdfbox.LTVEnabledPADESPDFBOXSigner.java
/** * Adds the DSS dictionary as specified in <a href= * "http://www.etsi.org/deliver/etsi_ts%5C102700_102799%5C10277804%5C01.01.02_60%5Cts_10277804v010102p.pdf">PAdES * ETSI TS 102 778-4 v1.1.2, Annex A, "LTV extensions"</a>. * * @param pdDocument/*w w w . jav a 2s . c o m*/ * The pdf document (required; must not be {@code null}). * @param ltvVerificationInfo * The certificate verification info data (required; must not be {@code null}). * @throws CertificateEncodingException * In case of an error encoding certificates. * @throws IOException * In case there was an error adding a pdf stream to the document. * @throws CRLException * In case there was an error encoding CRL data. */ private void addDSS(PDDocument pdDocument, CertificateVerificationData ltvVerificationInfo) throws CertificateEncodingException, IOException, CRLException { final COSName COSNAME_DSS = COSName.getPDFName("DSS"); PDDocumentCatalog root = Objects.requireNonNull(pdDocument).getDocumentCatalog(); COSDictionary dssDictionary = (COSDictionary) root.getCOSDictionary().getDictionaryObject(COSNAME_DSS); if (dssDictionary == null) { log.trace("Adding new DSS dictionary."); // add new DSS dictionary dssDictionary = new COSDictionary(); root.getCOSDictionary().setItem(COSNAME_DSS, dssDictionary); root.getCOSObject().setNeedToBeUpdate(true); } dssDictionary.setNeedToBeUpdate(true); // DSS/Certs addDSSCerts(pdDocument, dssDictionary, ltvVerificationInfo.getChainCerts()); // DSS/OCSPs if (CollectionUtils.isNotEmpty(ltvVerificationInfo.getEncodedOCSPResponses())) { addDSSOCSPs(pdDocument, dssDictionary, ltvVerificationInfo.getEncodedOCSPResponses()); } // DSS/CRLs if (CollectionUtils.isNotEmpty(ltvVerificationInfo.getCRLs())) { addDSSCRLs(pdDocument, dssDictionary, ltvVerificationInfo.getCRLs()); } }
From source file:com.jkoolcloud.tnt4j.streams.fields.ActivityInfo.java
/** * Applies the given value(s) for the specified field to the appropriate internal data field for reporting field to * the JKool Cloud./*from w w w . j a v a 2 s .c o m*/ * * @param field * field to apply * @param value * value to apply for this field, which could be an array of objects if value for field consists of * multiple locations * * @throws ParseException * if an error parsing the specified value based on the field definition (e.g. does not match defined * format, etc.) */ public void applyField(ActivityField field, Object value) throws ParseException { LOGGER.log(OpLevel.TRACE, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME, "ActivityInfo.applying.field"), field, value); Object[] values = Utils.makeArray(Utils.simplifyValue(value)); List<ActivityFieldLocator> locators = field.getLocators(); if (values != null && CollectionUtils.isNotEmpty(locators)) { if (locators.size() > 1 && locators.size() != values.length) { throw new ParseException(StreamsResources.getStringFormatted(StreamsResources.RESOURCE_BUNDLE_NAME, "ActivityInfo.failed.parsing", field), 0); } ActivityFieldLocator locator; Object fValue; List<Object> fvList = new ArrayList<>(locators.size()); for (int v = 0; v < values.length; v++) { locator = locators.size() == 1 ? locators.get(0) : locators.get(v); fValue = formatValue(field, locator, values[v]); if (fValue == null && locator.isOptional()) { continue; } fvList.add(fValue); } values = fvList.toArray(); if (field.isEnumeration() && values.length > 1) { throw new ParseException(StreamsResources.getStringFormatted(StreamsResources.RESOURCE_BUNDLE_NAME, "ActivityInfo.multiple.enum.values", field), 0); } } Object fieldValue = Utils.simplifyValue(values); if (fieldValue == null) { LOGGER.log(OpLevel.TRACE, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME, "ActivityInfo.field.value.null"), field); return; } LOGGER.log(OpLevel.TRACE, StreamsResources.getString(StreamsResources.RESOURCE_BUNDLE_NAME, "ActivityInfo.applying.field.value"), field, Utils.toString(fieldValue)); fieldValue = transform(field, fieldValue); fieldValue = filterFieldValue(field, fieldValue); if (!field.isTransparent()) { setFieldValue(field, fieldValue); } else { addActivityProperty(field.getFieldTypeName(), fieldValue, TRANSPARENT_PROP_TYPE); } }
From source file:com.adguard.filter.rules.FilterRule.java
/** * Checks if this rule is domain sensitive or not * * @return true if rule has permitted or restricted domains *//*from w ww .ja v a2s . c om*/ public boolean isDomainSensitive() { return CollectionUtils.isNotEmpty(permittedDomains) || CollectionUtils.isNotEmpty(restrictedDomains); }
From source file:io.cloudslang.lang.compiler.validator.CompileValidatorImpl.java
private List<RuntimeException> validateBreakSection(Flow parentFlow, Step step, Executable reference) { List<RuntimeException> errors = new ArrayList<>(); @SuppressWarnings("unchecked") // from BreakTransformer List<String> breakValues = (List<String>) step.getPostStepActionData().get(SlangTextualKeys.BREAK_KEY); if (isForLoop(step, breakValues)) { List<String> referenceResultNames = getResultNames(reference); Collection<String> nonExistingResults = ListUtils.subtract(breakValues, referenceResultNames); if (CollectionUtils.isNotEmpty(nonExistingResults)) { errors.add(new IllegalArgumentException( "Cannot compile flow '" + parentFlow.getId() + "' since in step '" + step.getName() + "' the results " + nonExistingResults + " declared in '" + SlangTextualKeys.BREAK_KEY + "' section are not declared in the dependency '" + reference.getId() + "' result section.")); }//from w w w. j av a 2 s .c o m } return errors; }