List of usage examples for com.google.common.collect ImmutableSet contains
boolean contains(Object o);
From source file:com.facebook.buck.apple.AppleDescriptions.java
public static boolean flavorsDoNotAllowLinkerMapMode(BuildRuleParams params) { ImmutableSet<Flavor> flavors = params.getBuildTarget().getFlavors(); return flavors.contains(CxxCompilationDatabase.COMPILATION_DATABASE) || flavors.contains(CxxCompilationDatabase.UBER_COMPILATION_DATABASE) || flavors.contains(CxxDescriptionEnhancer.STATIC_FLAVOR) || flavors.contains(CxxDescriptionEnhancer.STATIC_PIC_FLAVOR) || flavors.contains(CxxDescriptionEnhancer.EXPORTED_HEADER_SYMLINK_TREE_FLAVOR) || flavors.contains(CxxDescriptionEnhancer.HEADER_SYMLINK_TREE_FLAVOR); }
From source file:com.google.auto.value.processor.AutoAnnotationProcessor.java
/** * Returns a map from the names of members with invariable hashCodes to the values of those * hashCodes.//from ww w . j a v a 2 s .co m */ private static ImmutableMap<String, Integer> invariableHashes(ImmutableMap<String, Member> members, ImmutableSet<String> parameters) { ImmutableMap.Builder<String, Integer> builder = ImmutableMap.builder(); for (String element : members.keySet()) { if (!parameters.contains(element)) { Member member = members.get(element); AnnotationValue annotationValue = member.method.getDefaultValue(); Optional<Integer> invariableHash = invariableHash(annotationValue); if (invariableHash.isPresent()) { builder.put(element, (element.hashCode() * 127) ^ invariableHash.get()); } } } return builder.build(); }
From source file:com.facebook.buck.distributed.DistBuildUtil.java
/** Checks whether the given targets match the Stampede project whitelist */ protected static boolean doTargetsMatchProjectWhitelist(ImmutableSet<String> buildTargets, ImmutableSet<String> projectWhitelist) { if (buildTargets.isEmpty()) { return false; }// w w w.ja v a2 s . c o m boolean mismatchFound = false; for (String buildTarget : buildTargets) { Pattern pattern = Pattern.compile(TARGET_TO_PROJECT_REGREX); Matcher matcher = pattern.matcher(buildTarget); if (matcher.find()) { // Check the project for the given target is whitelisted String projectForTarget = matcher.group(1); mismatchFound = !projectWhitelist.contains(projectForTarget); } else { mismatchFound = true; } if (mismatchFound) { break; } } return !mismatchFound; }
From source file:com.cloud.utils.ReflectUtil.java
private static List<String> flattenProperties(final Object target, final Class<?> clazz, final ImmutableSet<String> excludedProperties) { assert clazz != null; if (target == null) { return emptyList(); }// w w w.j ava 2s. co m assert clazz.isAssignableFrom(target.getClass()); try { final BeanInfo beanInfo = getBeanInfo(clazz); final PropertyDescriptor[] descriptors = beanInfo.getPropertyDescriptors(); final List<String> serializedProperties = new ArrayList<String>(); for (final PropertyDescriptor descriptor : descriptors) { if (excludedProperties.contains(descriptor.getName())) { continue; } serializedProperties.add(descriptor.getName()); final Object value = descriptor.getReadMethod().invoke(target); serializedProperties.add(value != null ? value.toString() : "null"); } return unmodifiableList(serializedProperties); } catch (IntrospectionException e) { s_logger.warn( "Ignored IntrospectionException when serializing class " + target.getClass().getCanonicalName(), e); } catch (IllegalArgumentException e) { s_logger.warn("Ignored IllegalArgumentException when serializing class " + target.getClass().getCanonicalName(), e); } catch (IllegalAccessException e) { s_logger.warn( "Ignored IllegalAccessException when serializing class " + target.getClass().getCanonicalName(), e); } catch (InvocationTargetException e) { s_logger.warn("Ignored InvocationTargetException when serializing class " + target.getClass().getCanonicalName(), e); } return emptyList(); }
From source file:org.opensingular.form.SFormUtil.java
public static String generateUserFriendlyName(String simpleName) { final Pattern lowerUpper = Pattern.compile("(.*?[a-z])([A-Z].*?)"); final Pattern prefixoSigla = Pattern.compile("([A-Z]+)([A-Z][a-z])"); final ImmutableSet<String> upperCaseSpecialCases = ImmutableSet.of("id", "url"); return StringUtils.capitalize(Arrays.asList(simpleName).stream() .map(s -> lowerUpper.matcher(s).replaceAll("$1-$2")) .map(s -> prefixoSigla.matcher(s).replaceAll("$1-$2")) .flatMap(s -> Arrays.asList(s.split("[-_]+")).stream()) .map(s -> (StringUtils.isAllUpperCase(s) ? s : StringUtils.uncapitalize(s))) .map(s -> upperCaseSpecialCases.contains(s) ? StringUtils.capitalize(s) : s).collect(joining(" "))); }
From source file:com.facebook.buck.features.rust.RustCompileUtils.java
/** * Given a list of sources, return the one which is the root based on the defaults and user * parameters.// w ww . java 2 s .c o m * * @param resolver SourcePathResolver for rule * @param crate Name of crate * @param defaults Default names for this rule (library, binary, etc) * @param sources List of sources * @return The matching source */ public static Optional<SourcePath> getCrateRoot(SourcePathResolver resolver, String crate, ImmutableSet<String> defaults, Stream<SourcePath> sources) { String crateName = String.format("%s.rs", crate); ImmutableList<SourcePath> res = sources.filter(src -> { String name = resolver.getRelativePath(src).getFileName().toString(); return defaults.contains(name) || name.equals(crateName); }).collect(ImmutableList.toImmutableList()); if (res.size() == 1) { return Optional.of(res.get(0)); } else { return Optional.empty(); } }
From source file:com.google.devtools.build.android.idlclass.IdlClass.java
/** * Unzip all the class files that correspond to idl processor- generated sources into the * temporary directory.//from w ww .j av a 2 s . co m */ private static void extractIdlClasses(Path classJar, Manifest manifest, Path tempDir, Set<Path> idlSources) throws IOException { ImmutableSet<String> prefixes = getIdlPrefixes(manifest, idlSources); try (JarFile jar = new JarFile(classJar.toFile())) { Enumeration<JarEntry> entries = jar.entries(); while (entries.hasMoreElements()) { JarEntry entry = entries.nextElement(); String name = entry.getName(); if (!name.endsWith(".class")) { continue; } String prefix = name.substring(0, name.length() - ".class".length()); int idx = prefix.indexOf('$'); if (idx > 0) { prefix = prefix.substring(0, idx); } if (prefixes.contains(prefix)) { Files.createDirectories(tempDir.resolve(name).getParent()); Files.copy(jar.getInputStream(entry), tempDir.resolve(name)); } } } }
From source file:com.google.polymer.JsRenamer.java
/** * Applies the rename map to the provided JavaScript abstract syntax tree. * @param renameMap A mapping from symbol to renamed symbol. * @param current The JavaScript abstract syntax tree to rename. Note that this method will mutate * |current| with the renames./* www . ja v a 2 s .c o m*/ * @param renameMode Variable renaming mode to use. * @return The renamed abstract syntax tree. */ private static Node renameNode(ImmutableMap<String, String> renameMap, Node current, ImmutableSet<RenameMode> renameMode) { int type = current.getType(); switch (type) { case CALL: if (isInObjectLit(current)) { renameCall(renameMap, current); } break; case GETPROP: if (renameMode.contains(RenameMode.RENAME_PROPERTIES)) { if (current.hasMoreThanOneChild()) { Node secondChild = current.getChildAtIndex(1); if (secondChild.isString()) { renamePolymerPropertyStringNode(renameMap, secondChild); } } } break; case NAME: if (renameMode.contains(RenameMode.RENAME_VARIABLES)) { renamePolymerPropertyStringNode(renameMap, current); } break; case OBJECTLIT: renameObjectLiteral(renameMap, current); break; case STRING_KEY: if (renameMode.contains(RenameMode.RENAME_PROPERTIES)) { renamePolymerPropertyStringNode(renameMap, current); } break; } for (Node child : current.children()) { renameNode(renameMap, child, renameMode); } return current; }
From source file:com.spectralogic.ds3autogen.c.helpers.StructHelper.java
/** * Determine if a Struct requires a custom parser. *///from www.j av a 2 s . c om public static boolean requiresNewCustomParser(final Struct struct, final Set<String> existingTypes, final ImmutableSet<String> enumNames) { for (final StructMember member : struct.getStructMembers()) { if (!member.getType().isPrimitive()) { if (member.getType().getTypeName().equals("ds3_str")) continue; // ds3_str is not an auto-generated API typeName. if (member.getType().getTypeName().equals("ds3_paging")) continue; // ds3_paging is not an auto-generated API typeName. if (existingTypes.contains(member.getType().getTypeName())) continue; if (enumNames.contains(member.getType().getTypeName())) continue; LOG.warn("Unknown type[" + member.getType().getTypeName() + "]"); return true; } } return false; }
From source file:org.apache.abdera2.activities.model.ASBase.java
public static Selector<Map.Entry<String, Object>> withFields(Iterable<String> names) { final ImmutableSet<String> list = ImmutableSet.copyOf(names); return new AbstractSelector<Map.Entry<String, Object>>() { public boolean select(Object item) { Map.Entry<String, Object> entry = (Entry<String, Object>) item; return list.contains(entry.getKey()); }/*from ww w .j a va2s . co m*/ }; }