List of usage examples for com.google.common.collect ImmutableSet contains
boolean contains(Object o);
From source file:com.facebook.buck.apple.project_generator.ProjectGenerator.java
/** * Returns true if a target matches a set of unflavored targets or the main target. * * @param focusModules Set of unflavored targets. * @param buildTarget Target to test against the set of unflavored targets. * * @return {@code true} if the target is member of {@code focusModules}. *///from w ww .j a v a 2 s. c om public static boolean shouldIncludeBuildTargetIntoFocusedProject( ImmutableSet<UnflavoredBuildTarget> focusModules, BuildTarget buildTarget) { if (focusModules.isEmpty()) { return true; } return focusModules.contains(buildTarget.getUnflavoredBuildTarget()); }
From source file:com.facebook.buck.features.apple.project.WorkspaceAndProjectGenerator.java
private void generateProject(Map<Path, ProjectGenerator> projectGenerators, ListeningExecutorService listeningExecutorService, WorkspaceGenerator workspaceGenerator, ImmutableSet<BuildTarget> targetsInRequiredProjects, ImmutableSetMultimap.Builder<PBXProject, PBXTarget> generatedProjectToPbxTargetsBuilder, ImmutableMap.Builder<BuildTarget, PBXTarget> buildTargetToPbxTargetMapBuilder, ImmutableMap.Builder<PBXTarget, Path> targetToProjectPathMapBuilder) throws IOException, InterruptedException { ImmutableMultimap.Builder<Cell, BuildTarget> projectCellToBuildTargetsBuilder = ImmutableMultimap.builder(); for (TargetNode<?> targetNode : projectGraph.getNodes()) { BuildTarget buildTarget = targetNode.getBuildTarget(); projectCellToBuildTargetsBuilder.put(rootCell.getCell(buildTarget), buildTarget); }/*from w w w .j a v a 2s .c o m*/ ImmutableMultimap<Cell, BuildTarget> projectCellToBuildTargets = projectCellToBuildTargetsBuilder.build(); List<ListenableFuture<GenerationResult>> projectGeneratorFutures = new ArrayList<>(); for (Cell projectCell : projectCellToBuildTargets.keySet()) { ImmutableMultimap.Builder<Path, BuildTarget> projectDirectoryToBuildTargetsBuilder = ImmutableMultimap .builder(); ImmutableSet<BuildTarget> cellRules = ImmutableSet.copyOf(projectCellToBuildTargets.get(projectCell)); for (BuildTarget buildTarget : cellRules) { projectDirectoryToBuildTargetsBuilder.put(buildTarget.getBasePath(), buildTarget); } ImmutableMultimap<Path, BuildTarget> projectDirectoryToBuildTargets = projectDirectoryToBuildTargetsBuilder .build(); Path relativeTargetCell = rootCell.getRoot().relativize(projectCell.getRoot()); for (Path projectDirectory : projectDirectoryToBuildTargets.keySet()) { ImmutableSet<BuildTarget> rules = filterRulesForProjectDirectory(projectGraph, ImmutableSet.copyOf(projectDirectoryToBuildTargets.get(projectDirectory))); if (Sets.intersection(targetsInRequiredProjects, rules).isEmpty()) { continue; } boolean isMainProject = workspaceArguments.getSrcTarget().isPresent() && rules.contains(workspaceArguments.getSrcTarget().get()); projectGeneratorFutures.add(listeningExecutorService.submit(() -> { GenerationResult result = generateProjectForDirectory(projectGenerators, projectCell, projectDirectory, rules, isMainProject, targetsInRequiredProjects); // convert the projectPath to relative to the target cell here result = GenerationResult.of(relativeTargetCell.resolve(result.getProjectPath()), result.isProjectGenerated(), result.getRequiredBuildTargets(), result.getXcconfigPaths(), result.getFilesToCopyInXcode(), result.getBuildTargetToGeneratedTargetMap(), result.getGeneratedProjectToPbxTargets()); return result; })); } } List<GenerationResult> generationResults; try { generationResults = Futures.allAsList(projectGeneratorFutures).get(); } catch (ExecutionException e) { Throwables.throwIfInstanceOf(e.getCause(), IOException.class); Throwables.throwIfUnchecked(e.getCause()); throw new IllegalStateException("Unexpected exception: ", e); } for (GenerationResult result : generationResults) { if (!result.isProjectGenerated()) { continue; } workspaceGenerator.addFilePath(result.getProjectPath()); processGenerationResult(generatedProjectToPbxTargetsBuilder, buildTargetToPbxTargetMapBuilder, targetToProjectPathMapBuilder, result); } }
From source file:com.google.auto.value.processor.AutoValueProcessor.java
private void validateMethods(TypeElement type, ImmutableSet<ExecutableElement> abstractMethods, ImmutableSet<ExecutableElement> toBuilderMethods, ImmutableSet<ExecutableElement> propertyMethods, boolean extensionsPresent) { boolean ok = true; for (ExecutableElement method : abstractMethods) { if (propertyMethods.contains(method)) { ok &= checkReturnType(type, method); } else if (!toBuilderMethods.contains(method) && objectMethodToOverride(method) == ObjectMethodToOverride.NONE) { // This could reasonably be an error, were it not for an Eclipse bug in // ElementUtils.override that sometimes fails to recognize that one method overrides // another, and therefore leaves us with both an abstract method and the subclass method // that overrides it. This shows up in AutoValueTest.LukesBase for example. String message = "Abstract method is neither a property getter nor a Builder converter"; if (extensionsPresent) { message += ", and no extension consumed it"; }/* ww w. ja v a 2s . c om*/ errorReporter.reportWarning(message, method); } } if (!ok) { throw new AbortProcessingException(); } }
From source file:com.google.api.codegen.config.GapicMethodConfig.java
/** * Creates an instance of GapicMethodConfig based on MethodConfigProto, linking it up with the * provided method. On errors, null will be returned, and diagnostics are reported to the diag * collector./*from www .j a va 2 s. c om*/ */ @Nullable static GapicMethodConfig createMethodConfig(DiagCollector diagCollector, TargetLanguage language, MethodConfigProto methodConfigProto, Method method, ResourceNameMessageConfigs messageConfigs, ImmutableMap<String, ResourceNameConfig> resourceNameConfigs, ImmutableSet<String> retryCodesConfigNames, ImmutableSet<String> retryParamsConfigNames) { boolean error = false; ProtoMethodModel methodModel = new ProtoMethodModel(method); PageStreamingConfig pageStreaming = null; if (!PageStreamingConfigProto.getDefaultInstance().equals(methodConfigProto.getPageStreaming())) { pageStreaming = PageStreamingConfig.createPageStreaming(diagCollector, messageConfigs, resourceNameConfigs, methodConfigProto, methodModel); if (pageStreaming == null) { error = true; } } GrpcStreamingConfig grpcStreaming = null; if (isGrpcStreamingMethod(methodModel)) { if (PageStreamingConfigProto.getDefaultInstance().equals(methodConfigProto.getGrpcStreaming())) { grpcStreaming = GrpcStreamingConfig.createGrpcStreaming(diagCollector, method); } else { grpcStreaming = GrpcStreamingConfig.createGrpcStreaming(diagCollector, methodConfigProto.getGrpcStreaming(), method); if (grpcStreaming == null) { error = true; } } } ImmutableList<FlatteningConfig> flattening = null; if (!FlatteningConfigProto.getDefaultInstance().equals(methodConfigProto.getFlattening())) { flattening = createFlattening(diagCollector, messageConfigs, resourceNameConfigs, methodConfigProto, methodModel); if (flattening == null) { error = true; } } BatchingConfig batching = null; if (!BatchingConfigProto.getDefaultInstance().equals(methodConfigProto.getBatching())) { batching = BatchingConfig.createBatching(diagCollector, methodConfigProto.getBatching(), methodModel); if (batching == null) { error = true; } } String retryCodesName = methodConfigProto.getRetryCodesName(); if (!retryCodesName.isEmpty() && !retryCodesConfigNames.contains(retryCodesName)) { diagCollector.addDiag(Diag.error(SimpleLocation.TOPLEVEL, "Retry codes config used but not defined: '%s' (in method %s)", retryCodesName, methodModel.getFullName())); error = true; } String retryParamsName = methodConfigProto.getRetryParamsName(); if (!retryParamsConfigNames.isEmpty() && !retryParamsConfigNames.contains(retryParamsName)) { diagCollector.addDiag(Diag.error(SimpleLocation.TOPLEVEL, "Retry parameters config used but not defined: %s (in method %s)", retryParamsName, methodModel.getFullName())); error = true; } Duration timeout = Duration.ofMillis(methodConfigProto.getTimeoutMillis()); if (timeout.toMillis() <= 0) { diagCollector.addDiag(Diag.error(SimpleLocation.TOPLEVEL, "Default timeout not found or has invalid value (in method %s)", methodModel.getFullName())); error = true; } boolean hasRequestObjectMethod = methodConfigProto.getRequestObjectMethod(); if (hasRequestObjectMethod && method.getRequestStreaming()) { diagCollector.addDiag(Diag.error(SimpleLocation.TOPLEVEL, "request_object_method incompatible with streaming method %s", method.getFullName())); error = true; } ImmutableMap<String, String> fieldNamePatterns = ImmutableMap .copyOf(methodConfigProto.getFieldNamePatterns()); ResourceNameTreatment defaultResourceNameTreatment = methodConfigProto.getResourceNameTreatment(); if (defaultResourceNameTreatment == null || defaultResourceNameTreatment.equals(ResourceNameTreatment.UNSET_TREATMENT)) { defaultResourceNameTreatment = ResourceNameTreatment.NONE; } Iterable<FieldConfig> requiredFieldConfigs = createFieldNameConfigs(diagCollector, messageConfigs, defaultResourceNameTreatment, fieldNamePatterns, resourceNameConfigs, getRequiredFields(diagCollector, methodModel, methodConfigProto.getRequiredFieldsList())); Iterable<FieldConfig> optionalFieldConfigs = createFieldNameConfigs(diagCollector, messageConfigs, defaultResourceNameTreatment, fieldNamePatterns, resourceNameConfigs, getOptionalFields(methodModel, methodConfigProto.getRequiredFieldsList())); List<String> sampleCodeInitFields = new ArrayList<>(); sampleCodeInitFields.addAll(methodConfigProto.getSampleCodeInitFieldsList()); SampleSpec sampleSpec = new SampleSpec(methodConfigProto); String rerouteToGrpcInterface = Strings.emptyToNull(methodConfigProto.getRerouteToGrpcInterface()); VisibilityConfig visibility = VisibilityConfig.PUBLIC; ReleaseLevel releaseLevel = ReleaseLevel.GA; for (SurfaceTreatmentProto treatment : methodConfigProto.getSurfaceTreatmentsList()) { if (!treatment.getIncludeLanguagesList().contains(language.toString().toLowerCase())) { continue; } if (treatment.getVisibility() != VisibilityProto.UNSET_VISIBILITY) { visibility = VisibilityConfig.fromProto(treatment.getVisibility()); } if (treatment.getReleaseLevel() != ReleaseLevel.UNSET_RELEASE_LEVEL) { releaseLevel = treatment.getReleaseLevel(); } } LongRunningConfig longRunningConfig = null; if (!LongRunningConfigProto.getDefaultInstance().equals(methodConfigProto.getLongRunning())) { longRunningConfig = LongRunningConfig.createLongRunningConfig(method.getModel(), diagCollector, methodConfigProto.getLongRunning()); if (longRunningConfig == null) { error = true; } } List<String> headerRequestParams = ImmutableList.copyOf(methodConfigProto.getHeaderRequestParamsList()); if (error) { return null; } else { return new AutoValue_GapicMethodConfig(methodModel, pageStreaming, grpcStreaming, flattening, retryCodesName, retryParamsName, timeout, requiredFieldConfigs, optionalFieldConfigs, defaultResourceNameTreatment, batching, hasRequestObjectMethod, fieldNamePatterns, sampleCodeInitFields, sampleSpec, rerouteToGrpcInterface, visibility, releaseLevel, longRunningConfig, headerRequestParams); } }
From source file:com.google.auto.value.processor.AutoValueProcessor.java
/** * Returns all method annotations that should be imported in the generated class. Doesn't include * AutoValue itself (and its nested annotations), any @Inherited annotations, and anything that's * in excludedAnnotationsMap.//ww w .j a v a 2 s.com */ private Set<TypeMirror> allMethodAnnotationTypes(Iterable<ExecutableElement> methods, ImmutableSetMultimap<ExecutableElement, String> excludedAnnotationsMap) { Set<TypeMirror> annotationTypes = new TypeMirrorSet(); for (ExecutableElement method : methods) { ImmutableSet<String> excludedAnnotations = excludedAnnotationsMap.get(method); for (AnnotationMirror annotationMirror : method.getAnnotationMirrors()) { String annotationFqName = getAnnotationFqName(annotationMirror); if (excludedAnnotations.contains(annotationFqName)) { continue; } if (isAnnotationPresent(annotationMirror.getAnnotationType().asElement(), Inherited.class)) { continue; } if (AUTO_VALUE_CLASSNAME_PATTERN.matcher(annotationFqName).matches()) { continue; } annotationTypes.add(annotationMirror.getAnnotationType()); } for (AnnotationMirror annotationMirror : Java8Support.getAnnotationMirrors(method.getReturnType())) { annotationTypes.add(annotationMirror.getAnnotationType()); } } return annotationTypes; }
From source file:dagger.internal.codegen.writer.JavaWriter.java
public <A extends Appendable> A write(A appendable) throws IOException { if (!packageName.isEmpty()) { appendable.append("package ").append(packageName).append(";\n\n"); }/*from w w w.ja va 2 s . co m*/ // write imports ImmutableSet<ClassName> classNames = FluentIterable.from(typeWriters) .transformAndConcat(new Function<HasClassReferences, Set<ClassName>>() { @Override public Set<ClassName> apply(HasClassReferences input) { return input.referencedClasses(); } }).toSet(); ImmutableSortedSet<ClassName> importCandidates = ImmutableSortedSet.<ClassName>naturalOrder() .addAll(explicitImports).addAll(classNames).build(); ImmutableSet<ClassName> typeNames = FluentIterable.from(typeWriters) .transform(new Function<TypeWriter, ClassName>() { @Override public ClassName apply(TypeWriter input) { return input.name; } }).toSet(); ImmutableSet.Builder<String> declaredSimpleNamesBuilder = ImmutableSet.builder(); Deque<TypeWriter> declaredTypes = new ArrayDeque<>(typeWriters); while (!declaredTypes.isEmpty()) { TypeWriter currentType = declaredTypes.pop(); declaredSimpleNamesBuilder.add(currentType.name().simpleName()); declaredTypes.addAll(currentType.nestedTypeWriters); } ImmutableSet<String> declaredSimpleNames = declaredSimpleNamesBuilder.build(); BiMap<String, ClassName> importedClassIndex = HashBiMap.create(); for (ClassName className : importCandidates) { if (!(className.packageName().equals(packageName) && !className.enclosingClassName().isPresent()) && !(className.packageName().equals("java.lang") && className.enclosingSimpleNames().isEmpty()) && !typeNames.contains(className.topLevelClassName())) { Optional<ClassName> importCandidate = Optional.of(className); while (importCandidate.isPresent() && (importedClassIndex.containsKey(importCandidate.get().simpleName()) || declaredSimpleNames.contains(importCandidate.get().simpleName()))) { importCandidate = importCandidate.get().enclosingClassName(); } if (importCandidate.isPresent()) { appendable.append("import ").append(importCandidate.get().canonicalName()).append(";\n"); importedClassIndex.put(importCandidate.get().simpleName(), importCandidate.get()); } } } appendable.append('\n'); CompilationUnitContext context = new CompilationUnitContext(packageName, ImmutableSet.copyOf(importedClassIndex.values())); // write types for (TypeWriter typeWriter : typeWriters) { typeWriter.write(appendable, context.createSubcontext(typeNames)).append('\n'); } return appendable; }
From source file:dagger2.internal.codegen.writer.JavaWriter.java
public Appendable write(Appendable appendable) throws IOException { if (!packageName.isEmpty()) { appendable.append("package ").append(packageName).append(";\n\n"); }// w w w. j a v a2s . c om // write imports ImmutableSet<ClassName> classNames = FluentIterable.from(typeWriters) .transformAndConcat(new Function<HasClassReferences, Set<ClassName>>() { @Override public Set<ClassName> apply(HasClassReferences input) { return input.referencedClasses(); } }).toSet(); ImmutableSortedSet<ClassName> importCandidates = ImmutableSortedSet.<ClassName>naturalOrder() .addAll(explicitImports).addAll(classNames).build(); ImmutableSet<ClassName> typeNames = FluentIterable.from(typeWriters) .transform(new Function<TypeWriter, ClassName>() { @Override public ClassName apply(TypeWriter input) { return input.name; } }).toSet(); ImmutableSet.Builder<String> declaredSimpleNamesBuilder = ImmutableSet.builder(); Deque<TypeWriter> declaredTypes = Queues.newArrayDeque(typeWriters); while (!declaredTypes.isEmpty()) { TypeWriter currentType = declaredTypes.pop(); declaredSimpleNamesBuilder.add(currentType.name().simpleName()); declaredTypes.addAll(currentType.nestedTypeWriters); } ImmutableSet<String> declaredSimpleNames = declaredSimpleNamesBuilder.build(); BiMap<String, ClassName> importedClassIndex = HashBiMap.create(); for (ClassName className : importCandidates) { if (!(className.packageName().equals(packageName) && !className.enclosingClassName().isPresent()) && !(className.packageName().equals("java.lang") && className.enclosingSimpleNames().isEmpty()) && !typeNames.contains(className.topLevelClassName())) { Optional<ClassName> importCandidate = Optional.of(className); while (importCandidate.isPresent() && (importedClassIndex.containsKey(importCandidate.get().simpleName()) || declaredSimpleNames.contains(importCandidate.get().simpleName()))) { importCandidate = importCandidate.get().enclosingClassName(); } if (importCandidate.isPresent()) { appendable.append("import ").append(importCandidate.get().canonicalName()).append(";\n"); importedClassIndex.put(importCandidate.get().simpleName(), importCandidate.get()); } } } appendable.append('\n'); CompilationUnitContext context = new CompilationUnitContext(packageName, ImmutableSet.copyOf(importedClassIndex.values())); // write types for (TypeWriter typeWriter : typeWriters) { typeWriter.write(appendable, context.createSubcontext(typeNames)).append('\n'); } return appendable; }
From source file:com.ikanow.aleph2.management_db.services.DataBucketStatusCrudService.java
private static Collection<BasicMessageBean> validateUpdateCommand( UpdateComponent<DataBucketStatusBean> update) { final MethodNamingHelper<DataBucketStatusBean> helper = BeanTemplateUtils.from(DataBucketStatusBean.class); // There's a limited set of operations that are permitted: // - change the number of objects // - suspend or resume // - quarantine // - add/remove log or status messages final ImmutableSet<String> statusFields = ImmutableSet.<String>builder() .add(helper.field(DataBucketStatusBean::last_harvest_status_messages)) .add(helper.field(DataBucketStatusBean::last_enrichment_status_messages)) .add(helper.field(DataBucketStatusBean::last_storage_status_messages)).build(); final List<BasicMessageBean> errors = update.getAll().entries().stream() .map(kvtmp -> Patterns.match(kvtmp).<BasicMessageBean>andReturn() .when(kv -> helper.field(DataBucketStatusBean::num_objects).equals(kv.getKey()) && (kv.getValue()._1().equals(CrudUtils.UpdateOperator.set) || kv.getValue()._1().equals(CrudUtils.UpdateOperator.increment)) && (kv.getValue()._2() instanceof Number), __ -> { return null; })//w ww. java2 s .c o m .when(kv -> helper.field(DataBucketStatusBean::suspended).equals(kv.getKey()) && kv.getValue()._1().equals(CrudUtils.UpdateOperator.set) && (kv.getValue()._2() instanceof Boolean), __ -> { return null; }) .when(kv -> helper.field(DataBucketStatusBean::quarantined_until).equals(kv.getKey()) && ((kv.getValue()._1().equals(CrudUtils.UpdateOperator.set) && (kv.getValue()._2() instanceof Date)) || kv.getValue()._1().equals(CrudUtils.UpdateOperator.unset)), __ -> { return null; }) .when(kv -> statusFields.contains(kv.getKey().split("[.]")), __ -> { return null; }).otherwise(kv -> { return new BasicMessageBean(new Date(), // date false, // success IManagementDbService.CORE_MANAGEMENT_DB.get(), BucketActionMessage.UpdateBucketActionMessage.class.getSimpleName(), null, // message code ErrorUtils.get(ManagementDbErrorUtils.ILLEGAL_UPDATE_COMMAND, kv.getKey(), kv.getValue()._1()), null); // details })) .filter(errmsg -> errmsg != null).collect(Collectors.toList()); return errors; }
From source file:com.vmware.thinapp.manualmode.util.JobMonitorService.java
/** * Create a query spec using the given refresh rate, VM, * performance manager, and counter strings. The query will specify * performance counters for as many of the counter strings as were able to * be found. It is the caller's responsibility to verify that the metricId * array has the proper number of values. * * @param refreshRate// w w w .ja va2 s . c o m * @param vm * @param perfMgr * @param counters strings such as "cpu.usage.average", and "disk.usage.average" * @return the query if processing was successful, empty otherwise */ private static Option<PerfQuerySpec> createQuerySpec(Integer refreshRate, VirtualMachine vm, PerformanceManager perfMgr, Map<Integer, String> counterIdToName, Logger log, ImmutableSet<String> counters) { // Obtain all available performance metric IDs PerfMetricId[] perfMetricIds = null; try { perfMetricIds = perfMgr.queryAvailablePerfMetric(vm, null, null, refreshRate); } catch (RemoteException ex) { log.debug("Unable to obtain collection of available performance metris:", ex); return Option.empty(); } if (perfMetricIds == null) { log.debug("Unable to obtain collection of available performance metrics."); return Option.empty(); } log.debug("Obtained collection of available performance metrics with size={}", perfMetricIds.length); // Build a set of just the performance counter IDs and build a map from // these IDs to the associated PerfMetricId int[] perfCounterIds = new int[perfMetricIds.length]; Map<Integer, PerfMetricId> perfCounterIdToMetricId = new HashMap<Integer, PerfMetricId>(); for (int i = 0; i < perfMetricIds.length; i++) { PerfMetricId id = perfMetricIds[i]; perfCounterIds[i] = id.counterId; perfCounterIdToMetricId.put(id.counterId, perfMetricIds[i]); } // Get all performance counter info objects PerfCounterInfo[] perfCounterInfos = null; try { perfCounterInfos = perfMgr.queryPerfCounter(perfCounterIds); } catch (RemoteException ex) { log.debug("Unable to obtain collection of available performance counter infos:", ex); return Option.empty(); } if (perfCounterInfos == null) { log.debug("Unable to obtain collection of available performance counter infos."); return Option.empty(); } log.debug("Obtained collection of performance counter infos with size={}", perfCounterIds.length); // Now search for each of the given counter strings List<PerfMetricId> queryMetricIds = new ArrayList<PerfMetricId>(); for (PerfCounterInfo perfCounterInfo : perfCounterInfos) { String counter = createCounterString(perfCounterInfo); if (counters.contains(counter)) { PerfMetricId currMetricId = perfCounterIdToMetricId.get(perfCounterInfo.getKey()); if (currMetricId == null) { log.debug("Found matching perfCounterInfo but no metric ID: {}", counter, perfCounterInfo.getKey()); log.debug(prettyPrint(perfCounterInfo)); } else { if (!counterIdToName.containsKey(currMetricId.counterId)) { queryMetricIds.add(currMetricId); counterIdToName.put(currMetricId.counterId, counter); log.debug("Found matching perfCounterInfo: {}", counter); } else { log.debug("Found duplicate perfCounterInfo: {}", counter); } log.debug(prettyPrint(perfCounterInfo)); log.debug(prettyPrint(currMetricId)); } } } // Create the query spec using the counters we were able to find PerfQuerySpec qSpec = createPerfQuerySpec(vm, queryMetricIds.toArray(new PerfMetricId[queryMetricIds.size()]), refreshRate); return Option.apply(qSpec); }
From source file:com.facebook.buck.android.SplitZipStep.java
@VisibleForTesting Predicate<String> createRequiredInPrimaryZipPredicate(ExecutionContext context, ProguardTranslatorFactory translatorFactory, Supplier<ImmutableList<ClassNode>> classesSupplier) throws IOException { final Function<String, String> deobfuscate = translatorFactory.createDeobfuscationFunction(); final ImmutableSet<String> primaryDexClassNames = getRequiredPrimaryDexClassNames(context, translatorFactory, classesSupplier); final ClassNameFilter primaryDexFilter = ClassNameFilter .fromConfiguration(dexSplitMode.getPrimaryDexPatterns()); return new Predicate<String>() { @Override// ww w .j a va 2 s . c o m public boolean apply(String classFileName) { // This is a bit of a hack. DX automatically strips non-class assets from the primary // dex (because the output is classes.dex, which cannot contain assets), but not from // secondary dex jars (because the output is a jar that can contain assets), so we put // all assets in the primary jar to ensure that they get dropped. if (!classFileName.endsWith(".class")) { return true; } // Drop the ".class" suffix and deobfuscate the class name before we apply our checks. String internalClassName = Preconditions .checkNotNull(deobfuscate.apply(classFileName.replaceAll("\\.class$", ""))); if (primaryDexClassNames.contains(internalClassName)) { return true; } return primaryDexFilter.matches(internalClassName); } }; }