List of usage examples for java.util List isEmpty
boolean isEmpty();
From source file:com.haulmont.cuba.core.sys.jpql.Parser.java
private static void checkTreeForExceptions(String input, CommonTree tree) { TreeVisitor visitor = new TreeVisitor(); ErrorNodesFinder errorNodesFinder = new ErrorNodesFinder(); visitor.visit(tree, errorNodesFinder); List<ErrorRec> errors = errorNodesFinder.getErrorNodes().stream() .map(node -> new ErrorRec(node, "CommonErrorNode")).collect(Collectors.toList()); if (!errors.isEmpty()) { throw new JpqlSyntaxException( String.format("Errors found for input jpql:[%s]", StringUtils.strip(input)), errors); }/* ww w .j a v a 2 s .co m*/ }
From source file:grandroid.geo.Geocoder.java
public static String convertAddress(double lat, double lng, boolean nation, boolean city, boolean district, boolean street) throws Exception { List<Address> adds = getFromLocation(lat, lng, 1); if (adds == null || adds.isEmpty()) { throw new Exception("no address can be found"); } else {//from w w w. j av a 2 s .c o m Address add = adds.get(0); StringBuilder sb = new StringBuilder(); if (nation) { sb.append(add.getCountryName()); } if (city) { sb.append(add.getAdminArea()); } if (district) { sb.append(add.getLocality()); } if (street) { sb.append(add.getAddressLine(0)); } return sb.toString(); } }
From source file:com.wudaosoft.net.httpclient.ParameterRequestBuilder.java
public static HttpUriRequest build(RequestBuilder builder) { final HttpRequestBase result; URI uriNotNull = builder.getUri() != null ? builder.getUri() : URI.create("/"); Charset charset = builder.getCharset(); charset = charset != null ? charset : HTTP.DEF_CONTENT_CHARSET; String method = builder.getMethod(); List<NameValuePair> parameters = builder.getParameters(); HttpEntity entityCopy = builder.getEntity(); if (parameters != null && !parameters.isEmpty()) { if (entityCopy == null && (HttpPost.METHOD_NAME.equalsIgnoreCase(method) || HttpPut.METHOD_NAME.equalsIgnoreCase(method) || HttpPatch.METHOD_NAME.equalsIgnoreCase(method))) { entityCopy = new UrlEncodedFormEntity(parameters, charset); } else {//from w w w.j a va 2 s . c om try { uriNotNull = new URIBuilder(uriNotNull).setCharset(charset).addParameters(parameters).build(); } catch (final URISyntaxException ex) { // should never happen } } } if (entityCopy == null) { result = new InternalRequest(method); } else { final InternalEntityEclosingRequest request = new InternalEntityEclosingRequest(method); request.setEntity(entityCopy); result = request; } result.setProtocolVersion(builder.getVersion()); result.setURI(uriNotNull); // if (builder.headergroup != null) { // result.setHeaders(builder.headergroup.getAllHeaders()); // } result.setConfig(builder.getConfig()); return result; }
From source file:it.serverSystem.ClusterTest.java
private static String getPropertyValue(Orchestrator web, String property) { Settings.ValuesWsResponse response = ItUtils.newAdminWsClient(web).settingsService() .values(ValuesRequest.builder().setKeys(property).build()); List<Settings.Setting> settingsList = response.getSettingsList(); if (settingsList.isEmpty()) { return null; }/*w w w.j a va 2s . c o m*/ assertThat(settingsList).hasSize(1); return settingsList.iterator().next().getValue(); }
From source file:it.settings.SettingsTest.java
@CheckForNull private static Setting getSetting(String key, SettingsService settingsService) { ValuesWsResponse response = settingsService.values(ValuesRequest.builder().setKeys(key).build()); List<Settings.Setting> settings = response.getSettingsList(); return settings.isEmpty() ? null : settings.get(0); }
From source file:springfox.documentation.spring.web.scanners.ApiListingScanner.java
static String longestCommonPath(List<ApiDescription> apiDescriptions) { List<String> commons = newArrayList(); if (null == apiDescriptions || apiDescriptions.isEmpty()) { return null; }//from ww w. jav a2s . c om List<String> firstWords = urlParts(apiDescriptions.get(0)); for (int position = 0; position < firstWords.size(); position++) { String word = firstWords.get(position); boolean allContain = true; for (int i = 1; i < apiDescriptions.size(); i++) { List<String> words = urlParts(apiDescriptions.get(i)); if (words.size() < position + 1 || !words.get(position).equals(word)) { allContain = false; break; } } if (allContain) { commons.add(word); } } Joiner joiner = Joiner.on("/").skipNulls(); return "/" + joiner.join(commons); }
From source file:Main.java
/** * Checks if string representation corresponds to the collection. Parts of an expected collection should not contain * delimiter.// w ww . ja va 2 s.com */ public static boolean isStringPermutationOfCollection(String input, Collection<String> expected, String delimeter, int trimFromStart, int trimFromEnd) { input = input.substring(trimFromStart, input.length() - trimFromEnd); List<String> parts = new ArrayList<>(Arrays.asList(input.split(Pattern.quote(delimeter)))); for (String part : expected) { if (parts.contains(part)) { parts.remove(part); } } return parts.isEmpty(); }
From source file:com.izforge.izpack.panels.target.TargetPanelHelper.java
/** * Returns the installation path for the specified platform name. * <p/>// ww w . j a v a 2s . c om * This looks for a variable named {@code TargetPanel.dir.<platform name>}. If none is found, it searches the * parent platforms, in a breadth-first manner. * * @param installData the installation data * @param name the platform name * @return the default path, or {@code null} if none is found */ private static String getTargetPanelDir(InstallData installData, Platform.Name name) { String path = null; List<Platform.Name> queue = new ArrayList<Platform.Name>(); queue.add(name); while (!queue.isEmpty()) { name = queue.remove(0); path = installData.getVariable(PREFIX + name.toString().toLowerCase()); if (path != null) { break; } Collections.addAll(queue, name.getParents()); } return path; }
From source file:com.espertech.esper.core.start.EPStatementStartMethodHelperPrevious.java
private static void handlePrevious(List<ExprPreviousNode> previousRequests, Object previousNodeGetter, Map<ExprPreviousNode, ExprPreviousEvalStrategy> strategies) { if (previousRequests.isEmpty()) { return;/*from www . j a v a2 s . c o m*/ } RandomAccessByIndexGetter randomAccessGetter = null; RelativeAccessByEventNIndexMap relativeAccessGetter = null; if (previousNodeGetter instanceof RandomAccessByIndexGetter) { randomAccessGetter = (RandomAccessByIndexGetter) previousNodeGetter; } else if (previousNodeGetter instanceof RelativeAccessByEventNIndexMap) { relativeAccessGetter = (RelativeAccessByEventNIndexMap) previousNodeGetter; } else { throw new RuntimeException("Unexpected 'previous' handler: " + previousNodeGetter); } for (ExprPreviousNode previousNode : previousRequests) { int streamNumber = previousNode.getStreamNumber(); PreviousType previousType = previousNode.getPreviousType(); ExprPreviousEvalStrategy evaluator; if (previousType == PreviousType.PREVWINDOW) { evaluator = new ExprPreviousEvalStrategyWindow(streamNumber, previousNode.getChildNodes()[1].getExprEvaluator(), previousNode.getResultType().getComponentType(), randomAccessGetter, relativeAccessGetter); } else if (previousType == PreviousType.PREVCOUNT) { evaluator = new ExprPreviousEvalStrategyCount(streamNumber, randomAccessGetter, relativeAccessGetter); } else { evaluator = new ExprPreviousEvalStrategyPrev(streamNumber, previousNode.getChildNodes()[0].getExprEvaluator(), previousNode.getChildNodes()[1].getExprEvaluator(), randomAccessGetter, relativeAccessGetter, previousNode.isConstantIndex(), previousNode.getConstantIndexNumber(), previousType == PreviousType.PREVTAIL); } strategies.put(previousNode, evaluator); } }
From source file:ibeam.maven.plugins.Tools.java
/** * Implementation of the isNullOrEmpty check for the Lists. * /*from w w w .j a v a2 s.c o m*/ * @param list * @return true if the given List is null or is an empty List, false otherwise. */ public static boolean isNullOrEmpty(final List<?> list) { return list == null || list.isEmpty(); }