List of usage examples for java.util Set contains
boolean contains(Object o);
From source file:com.github.javarch.jsf.tags.security.SpringSecurityELLibrary.java
/** * Method that checks if <b>none</b> of the given roles is hold by the user. * Returns <code>true</code> if no roles are given, or none of the given roles match the users roles. * Returns <code>false</code> on the first matching role. * * @param notGrantedRoles a comma seperated list of roles * @return true if none of the given roles is granted to the current user, false otherwise *//*from w ww . j a va2s . co m*/ public static boolean ifNotGranted(final String notGrantedRoles) { Set<String> parsedAuthorities = parseAuthorities(notGrantedRoles); if (parsedAuthorities.isEmpty()) return true; GrantedAuthority[] authorities = getUserAuthorities(); for (GrantedAuthority authority : authorities) { if (parsedAuthorities.contains(authority.getAuthority())) return false; } return true; }
From source file:adalid.util.i18n.Merger.java
private static Properties merge(File bundle, Properties baseProperties, Properties localeProperties) { Properties properties = new SortedProperties(); Set<String> baseNames = baseProperties.stringPropertyNames(); Set<String> localeNames = localeProperties.stringPropertyNames(); String baseValue, localeValue, newValue; int newProperties = 0; int oldProperties = 0; int translationRequired = 0; for (String name : baseNames) { if (localeNames.contains(name)) { } else {/*from w ww . j a va 2s. c o m*/ newProperties++; } baseValue = baseProperties.getProperty(name); localeValue = localeProperties.getProperty(name); boolean noTranslationRequired = noTranslationRequired(baseValue); if (noTranslationRequired || isNotTranslated(localeValue)) { if (noTranslationRequired) { newValue = baseValue; } else { newValue = TRAN_REQD + baseValue; translationRequired++; } properties.setProperty(name, newValue); } else { properties.setProperty(name, localeValue); } } for (String name : localeNames) { if (baseNames.contains(name)) { } else { oldProperties++; } } if (newProperties > 0) { logger.warn(NEW_VALUE + " " + bundle.getName() + " = " + newProperties); } if (oldProperties > 0) { logger.warn(OLD_VALUE + " " + bundle.getName() + " = " + oldProperties); } if (translationRequired > 0) { logger.warn(TRAN_REQD + " " + bundle.getName() + " = " + translationRequired); } return properties; }
From source file:com.cloudbees.plugins.credentials.cli.BaseCredentialsCLICommand.java
protected static Credentials getCredentialsById(CredentialsStore store, Domain domain, String id) { List<Credentials> credentialsList = store.getCredentials(domain); Set<String> ids = new HashSet<String>(credentialsList.size()); Credentials existing = null;//from ww w. j a v a 2s . c o m int index = 0; for (Credentials c : credentialsList) { String cid; if (c instanceof IdCredentials) { cid = ((IdCredentials) c).getId(); } else { while (ids.contains("index-" + index)) { index++; } cid = "index-" + index; index++; } if (id.equals(cid)) { existing = c; break; } ids.add(cid); } return existing; }
From source file:com.kurtraschke.nyctrtproxy.model.NyctTripId.java
public static NyctTripId buildFromTripDescriptor(GtfsRealtime.TripDescriptorOrBuilder td, Set<String> reverseDirectionsRoutes) { NyctTripId id = buildFromString(td.getTripId()); if (id != null) { if (td.hasRouteId()) { id.routeId = td.getRouteId(); }/*w w w . ja va2s. c o m*/ if (reverseDirectionsRoutes.contains(id.routeId)) { id.directionId = id.directionId.equals("N") ? "S" : "N"; } } return id; }
From source file:de.vandermeer.skb.commons.Predicates.java
/** * Returns a predicate that evaluates to true if the set contains strings starting with a given character sequence. * @param nodes set of strings as base/*from ww w.j a va2 s. c om*/ * @return predicate that returns true if set contains strings starting with it, false otherwise */ final public static Predicate<StrBuilder> CONTAINS_STRINGS_STARTING_WITH(final Set<String> nodes) { return new Predicate<StrBuilder>() { @Override public boolean test(final StrBuilder fqpn) { if (fqpn == null) { return false; } String key = fqpn.toString(); if (!nodes.contains(key)) { return false; } Set<String> tail = new TreeSet<String>(nodes).tailSet(key, false); if (tail.size() == 0) { return false; } String child = tail.iterator().next(); if (child.startsWith(key)) { return true; } return false; } }; }
From source file:com.qpark.maven.plugin.flowmapper.AbstractGenerator.java
public static final void addImport(final String fqName, final Set<String> imports, final Set<String> importClasses) { final int index = fqName.lastIndexOf('.'); if (index > 0) { final String simpleName = fqName.substring(index + 1, fqName.length()); if (!importClasses.contains(simpleName) && !fqName.startsWith("java.lang")) { imports.add(fqName);/*from w ww .j av a 2s . co m*/ importClasses.add(simpleName); } } }
From source file:de.kapsi.net.daap.DaapUtil.java
/** * Creates and returns an unique session ID * /*from www .j a v a 2 s. c o m*/ * @param knownIDs all known session IDs * @return a uniquie session id */ public static Integer createSessionId(Set knownIDs) { Integer sessionId = null; while (sessionId == null || knownIDs.contains(sessionId)) { int tmp = generator.nextInt(); if (tmp == 0) { continue; } else if (tmp < 0) { tmp = -tmp; } sessionId = new Integer(tmp); } return sessionId; }
From source file:com.netflix.nicobar.core.utils.__JDKPaths.java
static void processClassPathItem(final String classPath, final Set<String> jarSet, final Set<String> pathSet) { if (classPath == null) return;//from ww w . java2s . c om int s = 0, e; do { e = classPath.indexOf(File.pathSeparatorChar, s); String item = e == -1 ? classPath.substring(s) : classPath.substring(s, e); if (jarSet != null && !jarSet.contains(item)) { final File file = new File(item); if (file.isDirectory()) { processDirectory0(pathSet, file); } else { try { processJar(pathSet, file); } catch (IOException ex) { // NOPMD } } } s = e + 1; } while (e != -1); }
From source file:fr.openwide.nuxeo.utils.document.DocumentUtils.java
/** * Returns true if and only if the "to" doctype is a supertype of "from" * //from w w w .j ava 2s .co m * @param from target type * @param to queried supertype * @return true if to is a supertype of from */ public static boolean isAssignable(String from, String to) { if (from.equals(to)) { return true; } TypeManager typeManager; try { typeManager = Framework.getService(TypeManager.class); } catch (Exception e) { throw new RuntimeException("Unable to get TypeManager", e); } Set<String> superTypes = new HashSet<String>(); Collections.addAll(superTypes, typeManager.getSuperTypes(from)); return superTypes.contains(to); }
From source file:com.wolvereness.overmapped.lib.WellOrdered.java
private static <T> boolean handleTokens(final T token, final Map<T, Collection<T>> map, final Set<T> in) { final Iterator<T> it = getIterator(token, map); if (it == null) return true; while (it.hasNext()) { if (in.contains(it.next())) return false; // Short the search for next time it.remove();//from w ww . j a va 2 s .com } // Short the search further for next time as collection is empty map.remove(token); return true; }