List of usage examples for java.util Set isEmpty
boolean isEmpty();
From source file:com.enonic.cms.core.search.builder.ContentIndexDataFieldValueSetFactory.java
private static void addDateFieldValue(ContentIndexDataElement element, final Set<ContentIndexDataFieldAndValue> contentIndexDataFieldAndValues) { final Set<Date> elementDateTimeValues = element.getDateTimeValues(); if (elementDateTimeValues != null && !elementDateTimeValues.isEmpty()) { contentIndexDataFieldAndValues.add(new ContentIndexDataFieldAndValue( element.getFieldBaseName() + INDEX_FIELD_TYPE_SEPARATOR + DATE_FIELD_POSTFIX, elementDateTimeValues)); }// w w w .j a v a 2 s . c o m }
From source file:com.parse.ParseRESTQueryCommand.java
static <T extends ParseObject> Map<String, String> encode(ParseQuery.State<T> state, boolean count) { ParseEncoder encoder = PointerEncoder.get(); HashMap<String, String> parameters = new HashMap<>(); List<String> order = state.order(); if (!order.isEmpty()) { parameters.put("order", ParseTextUtils.join(",", order)); }/*from w w w. ja v a 2 s . c o m*/ ParseQuery.QueryConstraints conditions = state.constraints(); if (!conditions.isEmpty()) { JSONObject encodedConditions = (JSONObject) encoder.encode(conditions); parameters.put("where", encodedConditions.toString()); } // This is nullable since we allow unset selectedKeys as well as no selectedKeys Set<String> selectedKeys = state.selectedKeys(); if (selectedKeys != null) { parameters.put("keys", ParseTextUtils.join(",", selectedKeys)); } Set<String> includeds = state.includes(); if (!includeds.isEmpty()) { parameters.put("include", ParseTextUtils.join(",", includeds)); } if (count) { parameters.put("count", Integer.toString(1)); } else { int limit = state.limit(); if (limit >= 0) { parameters.put("limit", Integer.toString(limit)); } int skip = state.skip(); if (skip > 0) { parameters.put("skip", Integer.toString(skip)); } } Map<String, Object> extraOptions = state.extraOptions(); for (Map.Entry<String, Object> entry : extraOptions.entrySet()) { Object encodedExtraOptions = encoder.encode(entry.getValue()); parameters.put(entry.getKey(), encodedExtraOptions.toString()); } if (state.isTracingEnabled()) { parameters.put("trace", Integer.toString(1)); } return parameters; }
From source file:Main.java
/** * This method returns a new HashSet which is the intersection of the two Set parameters, based on {@link Object#equals(Object) equality} * of their elements./* w w w . j a va2s. co m*/ * Any references in the resultant set will be to elements within set1. * * @return a new HashSet whose values represent the intersection of the two Sets. */ public static <T> Set<T> intersect(Set<? extends T> set1, Set<? extends T> set2) { if (set1 == null || set1.isEmpty() || set2 == null || set2.isEmpty()) { return Collections.emptySet(); } Set<T> result = new HashSet<T>(); result.addAll(set1); result.retainAll(set2); return result; }
From source file:com.jrummyapps.busybox.utils.Utils.java
public static List<String> getBusyBoxApplets() { BusyBox busyBox = BusyBox.getInstance(); Set<String> applets = busyBox.getApplets(); if (applets.isEmpty()) { String json = readRaw(R.raw.busybox_applets); try {/* w w w . ja v a2s . co m*/ JSONObject jsonObject = new JSONObject(json); for (Iterator<String> iterator = jsonObject.keys(); iterator.hasNext();) { applets.add(iterator.next()); } } catch (Exception ignored) { } } return new ArrayList<>(applets); }
From source file:com.kalessil.phpStorm.phpInspectionsEA.inspectors.security.rsaStrategies.OpensslRsaOraclePaddingStrategy.java
static private boolean isTargetCall(@NotNull FunctionReference reference) { boolean result = false; if (reference.getNameNode() == null) { final PsiElement name = reference.getFirstPsiChild(); if (name != null) { final Set<PsiElement> nameVariants = PossibleValuesDiscoveryUtil.discover(name); if (!nameVariants.isEmpty()) { for (final PsiElement variant : nameVariants) { if (variant instanceof StringLiteralExpression) { final String content = ((StringLiteralExpression) variant).getContents(); if (functions.contains(StringUtils.strip(content, "\\"))) { result = true; break; }/* w ww.j a v a2 s . c om*/ } } nameVariants.clear(); } } } else { result = functions.contains(reference.getName()); } return result; }
From source file:com.kalessil.phpStorm.phpInspectionsEA.inspectors.security.rsaStrategies.OpensslRsaOraclePaddingStrategy.java
static public boolean apply(@NotNull ProblemsHolder holder, @NotNull FunctionReference reference) { boolean result = false; final PsiElement[] arguments = reference.getParameters(); if (arguments.length == 3 && isTargetCall(reference)) { holder.registerProblem(reference, message); result = true;//www. ja v a 2s . c om } else if (arguments.length == 4 && isTargetCall(reference)) { final Set<PsiElement> modeVariants = PossibleValuesDiscoveryUtil.discover(arguments[3]); if (!modeVariants.isEmpty()) { for (final PsiElement variant : modeVariants) { if (variant instanceof ConstantReference) { final String constantName = ((ConstantReference) variant).getName(); if (constantName != null && constantName.equals("OPENSSL_PKCS1_PADDING")) { holder.registerProblem(reference, message); result = true; break; } } } modeVariants.clear(); } } return result; }
From source file:de.shadowhunt.sonar.plugins.ignorecode.batch.IgnoreIssueFilter.java
static boolean match(final Issue issue, final IssuePattern pattern) { final boolean isMatchingResource = matchResource(issue.componentKey(), pattern.getResourcePattern()); if (!isMatchingResource) { return false; }/*from ww w .jav a 2 s . c om*/ final boolean isMatchingRule = matchRule(issue.ruleKey(), pattern.getRulePattern()); if (!isMatchingRule) { return false; } final Set<Integer> lines = pattern.getLines(); if (lines.isEmpty()) { return true; // empty is any line } return lines.contains(issue.line()); }
From source file:Main.java
/** * @param orig//from ww w .j a v a 2s . co m * if null, return intersect */ public static Set<? extends Object> intersectSet(Set<? extends Object> orig, Set<? extends Object> intersect) { if (orig == null) return intersect; if (intersect == null || orig.isEmpty()) return Collections.emptySet(); Set<Object> set = new HashSet<Object>(orig.size()); for (Object p : orig) { if (intersect.contains(p)) set.add(p); } return set; }
From source file:eu.scidipes.toolkits.palibrary.utils.zip.ZipUtils.java
/** * Zips one or more {@link ByteArrayZipEntry} objects together and returns the archive as a base64-encoded * <code>String</code>//www .java 2 s. c o m * * @param entries * @return a base64-encoded <code>String</code> which is the zip archive of the passed entries * * @throws IOException * in the event of an exception writing to the zip output stream * @throws IllegalArgumentException * if passed entries is null or empty */ public static String byteArrayZipEntriesToBase64(final Set<? extends ByteArrayZipEntry> entries) throws IOException { if (entries == null || entries.isEmpty()) { throw new IllegalArgumentException("entries cannot be null or empty"); } final ByteArrayOutputStream bos = new ByteArrayOutputStream(); try (final ZipOutputStream zos = new ZipOutputStream(bos)) { for (final ByteArrayZipEntry entry : entries) { zos.putNextEntry(entry.getZipEntry()); IOUtils.write(entry.getBytes(), zos); zos.closeEntry(); } } return Base64.encodeBase64String(bos.toByteArray()); }
From source file:com.vrem.util.EnumUtils.java
public static <T extends Enum> Set<T> find(@NonNull Class<T> enumType, @NonNull Set<String> ordinals, @NonNull T defaultValue) {//from w w w . ja v a2 s . c om Set<T> results = new HashSet<>(CollectionUtils.collect(ordinals, new ToEnum<>(enumType, defaultValue))); return results.isEmpty() ? values(enumType) : results; }