List of usage examples for java.util Set isEmpty
boolean isEmpty();
From source file:net.dv8tion.jda.handle.ReadyHandler.java
public void onGuildInit(Guild guild) { Set<String> ids = guildIds.get(api); ids.remove(guild.getId());// w w w.j a va 2 s.c o m if (ids.isEmpty()) { finishReady(cachedJson.get(api)); } else if (ids.size() == chunkIds.get(api).size()) { sendChunks(); } }
From source file:net.groupbuy.controller.admin.ArticleCategoryController.java
/** * /* www. j a v a 2s .com*/ */ @RequestMapping(value = "/delete", method = RequestMethod.POST) public @ResponseBody Message delete(Long id) { ArticleCategory articleCategory = articleCategoryService.find(id); if (articleCategory == null) { return ERROR_MESSAGE; } Set<ArticleCategory> children = articleCategory.getChildren(); if (children != null && !children.isEmpty()) { return Message.error("admin.articleCategory.deleteExistChildrenNotAllowed"); } Set<Article> articles = articleCategory.getArticles(); if (articles != null && !articles.isEmpty()) { return Message.error("admin.articleCategory.deleteExistArticleNotAllowed"); } articleCategoryService.delete(id); return SUCCESS_MESSAGE; }
From source file:com.diversityarrays.kdxplore.trials.SampleGroupExportDialog.java
static public Set<Integer> getExcludedTraitIds(Component comp, String msgTitle, KdxploreDatabase kdxdb, SampleGroup sg) {/*from w w w. j a va 2 s .c om*/ Set<Integer> excludeTheseTraitIds = new HashSet<>(); try { Set<Integer> traitIds = collectTraitIdsFromSamples(kdxdb, sg); List<Trait> undecidableTraits = new ArrayList<>(); Set<Integer> missingTraitIds = new TreeSet<>(); Map<Integer, Trait> traitMap = kdxdb.getKDXploreKSmartDatabase().getTraitMap(); for (Integer traitId : traitIds) { Trait t = traitMap.get(traitId); if (t == null) { missingTraitIds.add(traitId); } else if (TraitLevel.UNDECIDABLE == t.getTraitLevel()) { undecidableTraits.add(t); } } if (!missingTraitIds.isEmpty()) { String msg = missingTraitIds.stream().map(i -> Integer.toString(i)) .collect(Collectors.joining(",")); MsgBox.error(comp, msg, "Missing Trait IDs"); return null; } if (!undecidableTraits.isEmpty()) { String msg = undecidableTraits.stream().map(Trait::getTraitName) .collect(Collectors.joining("\n", "Traits that are neither Plot nor Sub-Plot:\n", "\nDo you want to continue and Exclude samples for those Traits?")); if (JOptionPane.YES_OPTION != JOptionPane.showConfirmDialog(comp, msg, msgTitle, JOptionPane.YES_NO_OPTION, JOptionPane.WARNING_MESSAGE)) { return null; } Set<Integer> tmp = undecidableTraits.stream().map(Trait::getTraitId).collect(Collectors.toSet()); excludeTheseTraitIds.addAll(tmp); } } catch (IOException e) { MsgBox.error(comp, "Unable to read samples from database\n" + e.getMessage(), msgTitle); return null; } return excludeTheseTraitIds; }
From source file:com.greenline.hrs.admin.user.service.ManUserService.java
/** * /*from ww w .j a v a2 s .co m*/ * * @param uid * @return ?????null. */ public UserAuthInfo getUserAuthInfo(long uid) { UserAuthInfo userAuthInfo = new UserAuthInfo(String.valueOf(uid)); Set<Integer> groupIds = manUserGroupBiz.getGroupIdsByUid(uid); Set<Integer> roleIds = manGroupRoleBiz.getRoleIdsByGroupIds(groupIds); roleIds.addAll(manUserRoleBiz.getRoleIdsByUid(uid)); if (!roleIds.isEmpty()) { for (Integer roleId : roleIds) { userAuthInfo.addRole(roleId.toString()); } Set<Integer> permissionIds = manRoleResourceBiz.getResourceIdsByRoleIds(roleIds); Set<String> permissions = manResourceBiz.getPermissionByIds(permissionIds); userAuthInfo.setPermissions(permissions); } return userAuthInfo; }
From source file:ca.uhn.fhir.rest.method.ElementsParameter.java
@Override @SuppressWarnings({ "rawtypes", "unchecked" }) public Object translateQueryParametersIntoServerArgument(RequestDetails theRequest, BaseMethodBinding<?> theMethodBinding) throws InternalErrorException, InvalidRequestException { Set<String> value = getElementsValueOrNull(theRequest); if (value == null || value.isEmpty()) { return null; }/*from ww w . j a v a2s . c o m*/ if (myInnerCollectionType == null) { return StringUtils.join(value, ','); } try { Collection retVal = myInnerCollectionType.newInstance(); retVal.addAll(value); return retVal; } catch (InstantiationException e) { throw new InternalErrorException("Failed to instantiate " + myInnerCollectionType, e); } catch (IllegalAccessException e) { throw new InternalErrorException("Failed to instantiate " + myInnerCollectionType, e); } }
From source file:com.haulmont.cuba.core.global.filter.QueryFilter.java
protected boolean isActual(Condition condition, Set<String> params) { Set<ParameterInfo> declaredParams = condition.getParameters(); if (declaredParams.isEmpty()) return true; if (enableSessionParams) { Predicate<ParameterInfo> paramHasValue = paramInfo -> params.contains(paramInfo.getName()); if (condition.getConditions().isEmpty()) { // for leaf condition all parameters must have values return declaredParams.stream().allMatch(paramHasValue); } else {/*from ww w .j a va2s . c om*/ // for branch conditions at least some parameters must have values return declaredParams.stream().anyMatch(paramHasValue); } } else { // Return true only if declared params have values and there is at least one non-session parameter among them. // This is necessary to exclude generic filter conditions that contain only session parameters. Otherwise // there is no way to handle exclusion. Unfortunately this imposes the restriction on custom filters design: // condition with session-only parameters must be avoided, they must be coded as part of main query body or as // part of another condition. boolean found = false; for (ParameterInfo paramInfo : declaredParams) { if (params.contains(paramInfo.getName())) { found = found || !paramInfo.getType().equals(ParameterInfo.Type.SESSION); } } return found; } }
From source file:edu.umd.cs.marmoset.utilities.MarmosetUtilities.java
public static <T> Map<T, Boolean> setAsMap(final Set<T> set) { return new Map<T, Boolean>() { @Override/*from w w w .j a va 2s .co m*/ public void clear() { set.clear(); } @Override public boolean containsKey(Object arg0) { return set.contains(arg0); } @Override public boolean containsValue(Object arg0) { throw new UnsupportedOperationException(); } @Override public Set<java.util.Map.Entry<T, Boolean>> entrySet() { throw new UnsupportedOperationException(); } @Override public Boolean get(Object arg0) { return set.contains(arg0); } @Override public boolean isEmpty() { return set.isEmpty(); } @Override public Set<T> keySet() { return set; } @Override public Boolean put(T arg0, Boolean arg1) { Boolean result = set.contains(arg0); if (arg1) set.add(arg0); else set.remove(arg0); return result; } @Override public void putAll(Map<? extends T, ? extends Boolean> arg0) { throw new UnsupportedOperationException(); } @Override public Boolean remove(Object arg0) { Boolean result = set.contains(arg0); set.remove(arg0); return result; } @Override public int size() { return set.size(); } @Override public Collection<Boolean> values() { throw new UnsupportedOperationException(); } }; }
From source file:io.seldon.similarity.item.JdoItemSimilarityPeer.java
@Override public Map<Long, Double> getSimilarItems(long itemId, Set<Integer> dimensions, int max) { Collection<Object[]> results; Query query;/*from w ww.j a v a2 s . c o m*/ if (dimensions.isEmpty() || (dimensions.size() == 1 && dimensions.iterator().next() == Constants.DEFAULT_DIMENSION)) { String sql = "select isim.item_id2 as item_id,score from item_similarity isim where isim.item_id=? union select isim.item_id,score from item_similarity isim where isim.item_id2=? order by score desc"; if (max > 0) sql = sql + " limit " + max; query = getPM().newQuery("javax.jdo.query.SQL", sql); ArrayList<Object> args = new ArrayList<>(); args.add(itemId); args.add(itemId); results = (Collection<Object[]>) query.executeWithArray(args.toArray()); } else { String dimensionsStr = StringUtils.join(dimensions, ","); String sql = "select isim.item_id2 as item_id,score from item_similarity isim join item_map_enum ime on (isim.item_id2=ime.item_id) join dimension d on (ime.attr_id=d.attr_id and ime.value_id=d.value_id) where dim_id in (" + dimensionsStr + ") and isim.item_id=? union select isim.item_id,score from item_similarity isim join item_map_enum ime on (isim.item_id=ime.item_id) join dimension d on (ime.attr_id=d.attr_id and ime.value_id=d.value_id) where dim_id in (" + dimensionsStr + ") and isim.item_id2=? order by score desc"; if (max > 0) sql = sql + " limit " + max; query = getPM().newQuery("javax.jdo.query.SQL", sql); ArrayList<Object> args = new ArrayList<>(); args.add(itemId); args.add(itemId); results = (Collection<Object[]>) query.executeWithArray(args.toArray()); } Map<Long, Double> map = new HashMap<>(); for (Object[] res : results) { Long item = (Long) res[0]; Double score = (Double) res[1]; map.put(item, score); } query.closeAll(); return map; }
From source file:org.grails.datastore.mapping.redis.engine.RedisPropertyValueIndexer.java
private void deleteKeys(Set<String> toDelete) { if (toDelete != null && !toDelete.isEmpty()) { template.del(toDelete.toArray(new String[toDelete.size()])); }//from w w w . j av a 2 s . c o m }
From source file:org.openinfinity.web.controller.ProductController.java
@Log @AuditTrail(argumentStrategy = ArgumentStrategy.ALL) @RequestMapping(method = RequestMethod.POST) public @ResponseBody Map<String, ? extends Object> create(@Valid @RequestBody ProductModel productModel, HttpServletResponse response) {/* w w w . jav a2 s . c o m*/ Set<ConstraintViolation<ProductModel>> failures = validator.validate(productModel); if (failures.isEmpty()) { Product product = productService.create(productModel.getProduct()); return new ModelMap("id", product.getId()); } else { response.setStatus(HttpServletResponse.SC_BAD_REQUEST); return getValidationMessages(failures); } }