Java Code Examples for org.apache.commons.collections.CollectionUtils#sizeIsEmpty()
The following examples show how to use
org.apache.commons.collections.CollectionUtils#sizeIsEmpty() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ServiceREST.java From ranger with Apache License 2.0 | 6 votes |
private void processServiceMapping(Map<String, String> servicesMappingMap, List<String> sourceServices, List<String> destinationServices) { if (!CollectionUtils.sizeIsEmpty(servicesMappingMap)) { for (Entry<String, String> map : servicesMappingMap.entrySet()) { String sourceServiceName = null; String destinationServiceName = null; if (StringUtils.isNotEmpty(map.getKey().trim()) && StringUtils.isNotEmpty(map.getValue().trim())) { sourceServiceName = map.getKey().trim(); destinationServiceName = map.getValue().trim(); } else { LOG.error("Source service or destination service name is not provided!!"); throw restErrorUtil .createRESTException("Source service or destonation service name is not provided!!"); } if (StringUtils.isNotEmpty(sourceServiceName) && StringUtils.isNotEmpty(destinationServiceName)) { sourceServices.add(sourceServiceName); destinationServices.add(destinationServiceName); } } } }
Example 2
Source File: MultiColumnComparator.java From rice with Educational Community License v2.0 | 6 votes |
/** * Compare the field values by computing the two string values and comparing them based on the * sort type. * * @param columnSort the comparison metadata (which column number, which direction, what type of * sort) * @param protoField the prototype Field for the column being sorted * @param index1 the index of the first modelCollection element for comparison * @param index2 the index of the second modelCollection element for comparison * @return 0 if the two elements are considered equal, a positive integer if the element at * index1 is considered greater, else a negative integer */ private int compareFieldStringValues(ColumnSort columnSort, Field protoField, Integer index1, Integer index2) { final int sortResult; final String fieldValue1; final String fieldValue2; if (!CollectionUtils.sizeIsEmpty(protoField.getPropertyExpressions())) { // We have to evaluate expressions fieldValue1 = calculateFieldValue(protoField, index1, columnSort.getColumnIndex()); fieldValue2 = calculateFieldValue(protoField, index2, columnSort.getColumnIndex()); } else { fieldValue1 = KRADUtils.getSimpleFieldValue(modelCollection.get(index1), protoField); fieldValue2 = KRADUtils.getSimpleFieldValue(modelCollection.get(index2), protoField); } sortResult = columnTypeCompare(fieldValue1, fieldValue2, columnSort.getSortType()); return sortResult; }
Example 3
Source File: LocationActor.java From sunbird-lms-service with MIT License | 5 votes |
public Set<String> getValidatedRelatedLocationSet(List<Location> locationList) { Set<Location> locationSet = new HashSet<>(); for (Location requestedLocation : locationList) { Set<Location> parentLocnSet = getParentLocations(requestedLocation); if (CollectionUtils.sizeIsEmpty(locationSet)) { locationSet.addAll(parentLocnSet); } else { for (Location currentLocation : parentLocnSet) { String type = currentLocation.getType(); locationSet .stream() .forEach( location -> { if (type.equalsIgnoreCase(location.getType()) && !(currentLocation.getId().equals(location.getId()))) { throw new ProjectCommonException( ResponseCode.conflictingOrgLocations.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.conflictingOrgLocations.getErrorMessage(), requestedLocation.getCode(), location.getCode(), type), ResponseCode.CLIENT_ERROR.getResponseCode()); } }); locationSet.add(currentLocation); } } } return locationSet.stream().map(Location::getId).collect(Collectors.toSet()); }
Example 4
Source File: LocationRequestValidator.java From sunbird-lms-service with MIT License | 5 votes |
/** * This method will validate the location hierarchy and return the locationIds list. * * @param actorRef Actor reference. * @param locationList List of location. * @return Set of locationId. */ public Set<String> getValidatedLocationSet(ActorRef actorRef, List<Location> locationList) { Set<Location> locationSet = new HashSet<>(); for (Location requestedLocation : locationList) { Set<Location> parentLocnSet = getParentLocations(actorRef, requestedLocation); if (CollectionUtils.sizeIsEmpty(locationSet)) { locationSet.addAll(parentLocnSet); } else { for (Location currentLocation : parentLocnSet) { String type = currentLocation.getType(); locationSet .stream() .forEach( location -> { if (type.equalsIgnoreCase(location.getType()) && !(currentLocation.getId().equals(location.getId()))) { throw new ProjectCommonException( ResponseCode.conflictingOrgLocations.getErrorCode(), ProjectUtil.formatMessage( ResponseCode.conflictingOrgLocations.getErrorMessage(), requestedLocation.getCode(), location.getCode(), type), ResponseCode.CLIENT_ERROR.getResponseCode()); } }); locationSet.add(currentLocation); } } } return locationSet.stream().map(Location::getId).collect(Collectors.toSet()); }
Example 5
Source File: ServiceREST.java From ranger with Apache License 2.0 | 5 votes |
private List<RangerPolicy> getPoliciesFromProvidedJson(RangerExportPolicyList rangerExportPolicyList) { List<RangerPolicy> policies = null; if (rangerExportPolicyList != null && !CollectionUtils.sizeIsEmpty(rangerExportPolicyList.getPolicies())) { policies = rangerExportPolicyList.getPolicies(); } else { LOG.error("Provided json file does not contain any policy!!"); throw restErrorUtil.createRESTException("Provided json file does not contain any policy!!"); } return policies; }
Example 6
Source File: ServiceREST.java From ranger with Apache License 2.0 | 5 votes |
private void getServiceNameList(HttpServletRequest request, List<String> serviceNameList) { SearchFilter filter = searchUtil.getSearchFilter(request,policyService.sortFields); String serviceType = null; List<String> serviceTypeList = null; if (StringUtils.isNotEmpty(request.getParameter(PARAM_SERVICE_TYPE))){ serviceType = request.getParameter(PARAM_SERVICE_TYPE); } if(StringUtils.isNotEmpty(serviceType)){ serviceTypeList = new ArrayList<String>(Arrays.asList(serviceType.split(","))); } List<RangerService> rangerServiceList = null; List<RangerService> rangerServiceLists = new ArrayList<RangerService>(); if (CollectionUtils.isNotEmpty(serviceTypeList)){ for (String s : serviceTypeList) { filter.removeParam(PARAM_SERVICE_TYPE); filter.setParam(PARAM_SERVICE_TYPE, s.trim()); rangerServiceList = getServices(filter); rangerServiceLists.addAll(rangerServiceList); } } if(!CollectionUtils.sizeIsEmpty(rangerServiceLists)){ for(RangerService rService : rangerServiceLists){ if (StringUtils.isNotEmpty(rService.getName())){ serviceNameList.add(rService.getName()); } } } }
Example 7
Source File: ServiceREST.java From ranger with Apache License 2.0 | 5 votes |
private void processZoneMapping(Map<String, String> zoneMappingMap, List<String> sourceZones, List<String> destinationZones) { if (!CollectionUtils.sizeIsEmpty(zoneMappingMap)) { for (Entry<String, String> map : zoneMappingMap.entrySet()) { String sourceZoneName = null; String destinationZoneName = null; if (StringUtils.isNotEmpty(map.getKey().trim()) || StringUtils.isNotEmpty(map.getValue().trim())) { // zone to zone // zone to unzone // unzone to zone sourceZoneName = map.getKey().trim(); destinationZoneName = map.getValue().trim(); LOG.info("sourceZoneName =" + sourceZoneName + "destinationZoneName = " + destinationZoneName); } else if (StringUtils.isEmpty(map.getKey().trim()) && StringUtils.isEmpty(map.getValue().trim())) { LOG.info("Unzone to unzone policies import"); } else { LOG.error("Source zone or destination zone name is not provided!!"); throw restErrorUtil.createRESTException("Source zone or destination zone name is not provided!!"); } if (StringUtils.isNotEmpty(sourceZoneName) || StringUtils.isNotEmpty(destinationZoneName)) { sourceZones.add(sourceZoneName); destinationZones.add(destinationZoneName); } } } }
Example 8
Source File: ReturnEmptyListIterator.java From levelup-java-examples with Apache License 2.0 | 5 votes |
/** * Used for exception example */ @SuppressWarnings({ "unchecked", "unused" }) private void return_empty_list_iterator_apache_commons_exception () { DomainObject domain = null; // dao populate domain ListIterator<String> strings; if (domain != null && !CollectionUtils.sizeIsEmpty(domain.getStrings())) { strings = domain.getStrings(); } else { strings = EmptyListIterator.INSTANCE; } //... }
Example 9
Source File: ReturnEmptyIterator.java From levelup-java-examples with Apache License 2.0 | 5 votes |
/** * Used for exception example */ @SuppressWarnings({ "unchecked", "unused" }) private void return_empty_iterator_apache_commons_exception () { DomainObject domain = null; // dao populate domain Iterator<String> strings; if (domain != null && !CollectionUtils.sizeIsEmpty(domain.getStrings())) { strings = domain.getStrings(); } else { strings = EmptyIterator.INSTANCE; } //... }