List of usage examples for java.util List isEmpty
boolean isEmpty();
From source file:com.ms.scombiz.solr.utils.BaseSolrQueryConvert.java
protected static SolrQuery setQuery(List<String> params, SearchQuery searchQuery) { SolrQuery solrQuery = new SolrQuery(); String query = null;/*w ww . j a va 2s . c o m*/ if (params.isEmpty()) { query = ("*:*"); } else { query = StringUtils.join(params, " AND "); } solrQuery.setQuery(query); solrQuery.setStart(searchQuery.getStart()); solrQuery.setRows(searchQuery.getRows()); if (StringUtils.isNotBlank(searchQuery.getSortFiled())) { solrQuery.addSort(searchQuery.getSortFiled(), searchQuery.getOrderBy()); } return solrQuery; }
From source file:fr.dutra.confluence2wordpress.util.CollectionUtils.java
public static List<String> split(String str, String sep) { if (StringUtils.isBlank(str)) { return null; }//from www. j a va 2s . co m Splitter splitter = Splitter.on(sep).trimResults().omitEmptyStrings(); List<String> list = new ArrayList<String>(); for (String token : splitter.split(str)) { list.add(token); } if (list.isEmpty()) { return null; } return list; }
From source file:io.wcm.dam.assetservice.impl.AssetRequestParser.java
/** * Reads asset requests from URL. If requests using the new suffix-based approach are provided those are returned. * Otherwise requests defined via URL parameters are parsed and returned. * If no parameters are given at all one single un-parameterized request for the dam asset is generated. * @param assetPath Asset path/* w ww .ja va 2 s .c om*/ * @param request Request * @return List of asset requests */ public static List<AssetRequest> getAssetRequests(String assetPath, SlingHttpServletRequest request) { List<AssetRequest> requests = getAssetRequestsFromSuffix(assetPath, request); if (requests.isEmpty()) { requests = getAssetRequestsFromUrlParams(assetPath, request); } if (requests.isEmpty()) { requests.add(new AssetRequest(assetPath, null, 0, 0)); } return requests; }
From source file:org.avidj.zuul.client.ZuulRestClient.java
private static String lockPath(List<String> path) { if (path.isEmpty()) { return ""; }/*from w ww. ja v a2s .co m*/ StringBuilder string = new StringBuilder(path.get(0)); for (int i = 1, n = path.size(); i < n; i++) { string.append("/").append(path.get(i)); } return string.toString(); }
From source file:gobblin.source.extractor.extract.kafka.workunit.packer.KafkaAvgRecordTimeBasedWorkUnitSizeEstimator.java
/** * Calculate the geometric mean of a {@link List} of double numbers. Numbers smaller than {@link #EPS} will be * treated as {@link #EPS}.//from w w w.j ava 2s . c o m */ private static double geometricMean(List<Double> numbers) { Preconditions.checkArgument(!numbers.isEmpty()); double[] numberArray = new double[numbers.size()]; for (int i = 0; i < numbers.size(); i++) { numberArray[i] = Math.max(numbers.get(i), EPS); } return GEOMETRIC_MEAN.evaluate(numberArray, 0, numberArray.length); }
From source file:org.fede.util.Util.java
private static BigDecimal avg(List<BigDecimal> list) { if (list.isEmpty()) { return BigDecimal.ZERO; }/* www. ja v a2s . co m*/ return list.stream().reduce(BigDecimal.ZERO, (left, right) -> left.add(right)) .setScale(7, RoundingMode.HALF_UP).divide(new BigDecimal(list.size()), MathContext.DECIMAL32); }
From source file:be.fedict.eid.dss.spi.utils.XAdESSignatureTimeStampValidation.java
/** * Checks the time-stamp tokens' digital signatures. * //w w w .j a va 2 s . c o m * @param signatureTimeStamp * @param signatureElement * @return * @throws XAdESValidationException */ public static List<TimeStampToken> verify(XAdESTimeStampType signatureTimeStamp, Element signatureElement) throws XAdESValidationException { LOG.debug("validate SignatureTimeStamp..."); List<TimeStampToken> timeStampTokens = XAdESUtils.getTimeStampTokens(signatureTimeStamp); if (timeStampTokens.isEmpty()) { LOG.error("No timestamp tokens present in SignatureTimeStamp"); throw new XAdESValidationException("No timestamp tokens present in SignatureTimeStamp"); } // 2. take ds:SignatureValue element NodeList signatureValueNodeList = signatureElement.getElementsByTagNameNS(XMLSignature.XMLNS, "SignatureValue"); if (0 == signatureValueNodeList.getLength()) { LOG.error("no XML signature valuefound"); throw new XAdESValidationException("no XML signature valuefound"); } // 3. canonicalize using CanonicalizationMethod if any, else take dsig's TimeStampDigestInput digestInput = new TimeStampDigestInput( signatureTimeStamp.getCanonicalizationMethod().getAlgorithm()); digestInput.addNode(signatureValueNodeList.item(0)); for (TimeStampToken timeStampToken : timeStampTokens) { // 1. verify signature in timestamp token XAdESUtils.verifyTimeStampTokenSignature(timeStampToken); // 4. for-each timestamp token, compute digest and compare XAdESUtils.verifyTimeStampTokenDigest(timeStampToken, digestInput); } return timeStampTokens; }
From source file:com.igormaznitsa.jute.Utils.java
public static int getMaxLineWidth(final List<String> str) { int max = 0;// w ww.j av a 2 s .com if (str != null && !str.isEmpty()) { for (final String s : str) { if (s != null && s.length() > max) { max = s.length(); } } } return max; }
From source file:com.ms.commons.test.tool.exportdata.DatabasePropertiesLoader.java
public static List<DatabaseConfigItem> getDatabaseConfigItems() { File fn = new File(System.getProperty("user.home") + ".frameworktest_db_config.properties"); if (!fn.exists()) { throwNoConfigException(fn);//from w w w. ja v a 2s . co m } Properties properties = loadProperties(fn); List<String> dbConfs = StrUtil.splitStringToList(properties.getProperty("intltest.conns"), ','); if (dbConfs.isEmpty()) { throwNoConfigException(fn); } List<DatabaseConfigItem> itemList = new ArrayList<DatabaseConfigItem>(); for (String dbConfName : dbConfs) { itemList.add(getDatabaseConfigItem(properties, dbConfName)); } return itemList; }
From source file:de.oth.keycloak.InitKeycloakServer.java
private static void addUserGroups(RealmResource rRes, List<UserGroupConfig> userGroupList) { if (userGroupList == null || userGroupList.isEmpty()) { return;//from w ww . j ava2 s . c o m } GroupsResource groupsResource = rRes.groups(); for (UserGroupConfig userGroup : userGroupList) { String name = userGroup.getName(); GroupResource groupRes = KeycloakAccess.getGroupFromRealm(rRes, name); if (groupRes == null) { groupRes = KeycloakAccess.addGroupToRealm(rRes, name); } List<String> groupRealmRoles = userGroup.getRealmRoles(); if (groupRealmRoles != null) { KeycloakAccess.addMissedGroupRealmRoles(rRes, groupRes, groupRealmRoles); } List<AppRoleConfig> groupAppRoles = userGroup.getAppRoles(); if (groupAppRoles != null) { for (AppRoleConfig appRole : groupAppRoles) { String appName = appRole.getApp(); String roleName = appRole.getRole(); KeycloakAccess.addMissedGroupClientRole(rRes, groupRes, appName, roleName); } } } }