List of usage examples for com.google.common.base Predicates not
public static <T> Predicate<T> not(Predicate<T> predicate)
From source file:com.palantir.atlasdb.transaction.impl.SnapshotTransaction.java
@Override public Map<Cell, byte[]> getIgnoringLocalWrites(String tableName, Set<Cell> cells) { checkGetPreconditions(tableName);//w ww . jav a2 s.com if (Iterables.isEmpty(cells)) { return ImmutableMap.of(); } Map<Cell, byte[]> result = getFromKeyValueService(tableName, cells); return Maps.filterValues(result, Predicates.not(Value.IS_EMPTY)); }
From source file:org.opentestsystem.authoring.testauth.validation.PublishingRecordValidationHelper.java
private List<ObjectError> checkItemInformation(final PublishingRecord publishingRecord, final String assessmentId, final List<Segment> segmentList) { final BindingResult bindingResult = new BeanPropertyBindingResult(publishingRecord, OBJECT_NAME); final List<Segment> fixedFormSegmentList = Lists .newArrayList(Iterables.filter(segmentList, FIXEDFORM_SEGMENT_FILTER)); final List<Segment> adaptiveSegmentList = Lists .newArrayList(Iterables.filter(segmentList, Predicates.not(FIXEDFORM_SEGMENT_FILTER))); if (fixedFormSegmentList.size() > 0) { final List<Form> formList = this.formService.getFormsByAssessmentId(assessmentId); for (final Form form : formList) { final List<FormPartition> formPartitionList = this.formPartitionService .getFormPartitionsByFormId(form.getId()); for (final FormPartition formPartition : formPartitionList) { final List<Item> itemList = this.itemService.getItemsByFormPartitionId(formPartition.getId()); if (CollectionUtils.isEmpty(itemList)) { bindingResult.addError(new ObjectError(OBJECT_NAME, paramArray("publishingRecord.formPartition.items.required"), paramArray(formPartition.getName()), "publishingRecord.formPartition.items.required")); }/* w w w . ja v a 2s . co m*/ final List<ValidationResult<FormPartition>> validationResultList = this.formService .validateForms(assessmentId); if (!CollectionUtils.isEmpty(validationResultList)) { for (final ObjectError error : Iterables.transform( Iterables.filter(validationResultList, VALIDATION_RESULT_ERROR_LEVEL_FILTER), VALIDATION_RESULT_OERROR_XFORMER.getInstance("Form"))) { bindingResult.addError(error); } } } } } if (adaptiveSegmentList.size() > 0) { for (final Segment segment : adaptiveSegmentList) { final List<Item> itemList = this.itemService.getItemsBySegmentId(segment.getId()); if (CollectionUtils.isEmpty(itemList)) { bindingResult.addError( new ObjectError(OBJECT_NAME, paramArray("publishingRecord.segment.items.required"), paramArray(segment.getLabel()), "publishingRecord.segment.items.required")); } } final List<ValidationResult<Segment>> validationResultList = this.itemService .validateItemPools(assessmentId); if (!CollectionUtils.isEmpty(validationResultList)) { for (final ObjectError error : Iterables.transform( Iterables.filter(validationResultList, VALIDATION_RESULT_ERROR_LEVEL_FILTER), VALIDATION_RESULT_OERROR_XFORMER.getInstance("Item Pool"))) { bindingResult.addError(error); } } } return bindingResult.getAllErrors(); }
From source file:com.google.devtools.build.lib.rules.java.JavaTargetAttributes.java
/** * Returns the classpath artifacts needed in a deploy jar for this target. * * This excludes the artifacts made available by jars in the deployment * environment.//w ww . j a v a 2 s . c om */ public Iterable<Artifact> getRuntimeClassPathForArchive() { Iterable<Artifact> runtimeClasspath = getRuntimeClassPath(); if (getExcludedArtifacts().isEmpty()) { return runtimeClasspath; } else { return Iterables.filter(runtimeClasspath, Predicates.not(Predicates.in(getExcludedArtifacts().toSet()))); } }
From source file:org.eclipse.sirius.diagram.ui.tools.internal.layout.PinnedElementsHandler.java
/** * Resolve all the overlaps concerning the given fixed edit part. This * method may also resolve overlaps concerning other fixed parts in the * process, but will at least resolve all the (solvable) ones concerning the * specified part. After successful execution of this method, the only parts * overlapping <code>fixedPart</code>, if any, are also fixed parts, and * thus are unsolvable overlaps./*from w w w .ja v a 2s . c o m*/ * * @param fixedPart * the fixed edit part to consider. */ private void resolveOverlaps(final IGraphicalEditPart fixedPart) { final Set<IGraphicalEditPart> solvableOverlaps = Sets.filter(findOverlappingParts(fixedPart), Predicates.not(isPinned)); final Map<Direction, SortedSet<IGraphicalEditPart>> groupedOverlaps = groupByDirection(fixedPart, solvableOverlaps); for (Entry<Direction, SortedSet<IGraphicalEditPart>> group : groupedOverlaps.entrySet()) { // For a same group, we kept the movedPositions to allow a complete // rollback to move again several parts in same time Map<IGraphicalEditPart, Point> previousMovedPositionsBefore = Maps.newHashMap(); for (IGraphicalEditPart part : group.getValue()) { assert overlaps(fixedPart, part); previousMovedPositionsBefore = moveAside(Collections.singleton(part), Collections.singleton(fixedPart), group.getKey(), previousMovedPositionsBefore); assert !overlaps(fixedPart, part); } } assert Collections2.filter(findOverlappingParts(fixedPart), Predicates.not(isPinned)) .isEmpty() : Messages.PinnedElementsHandler_remainOverlapsMsg; }
From source file:com.palantir.atlasdb.transaction.impl.SerializableTransaction.java
private NavigableMap<Cell, byte[]> getReadsInRange(String table, Entry<RangeRequest, byte[]> e, RangeRequest range) {/* w ww . j a va2 s. c o m*/ NavigableMap<Cell, byte[]> reads = getReadsForTable(table); if (range.getStartInclusive().length != 0) { reads = reads.tailMap(Cells.createSmallestCellForRow(range.getStartInclusive()), true); } if (range.getEndExclusive().length != 0) { reads = reads.headMap(Cells.createSmallestCellForRow(range.getEndExclusive()), false); } ConcurrentNavigableMap<Cell, byte[]> writes = writesByTable.get(table); if (writes != null) { reads = Maps.filterKeys(reads, Predicates.not(Predicates.in(writes.keySet()))); } return reads; }
From source file:com.google.devtools.build.lib.rules.objc.ProtobufSupport.java
private Iterable<Artifact> getProtoSourceFilesForCompilation(Iterable<Artifact> outputProtoFiles) { Iterable<Artifact> filteredOutputs = Iterables.filter(outputProtoFiles, Predicates.not(Predicates.in(dylibHandledProtos))); return getGeneratedProtoOutputs(filteredOutputs, SOURCE_SUFFIX); }
From source file:com.android.build.gradle.tasks.PackageAndroidArtifact.java
/** * Obtains all changed inputs of a given input set. Given a set of files mapped to their * changed status, this method returns a list of changes computed as follows: * * <ol>/*from w w w . ja v a2 s . c o m*/ * <li>Changed inputs are split into deleted and non-deleted inputs. This separation is * needed because deleted inputs may no longer be mappable to any {@link InputSet} just * by looking at the file path, without using {@link KnownFilesSaveData}. * <li>Deleted inputs are filtered through {@link KnownFilesSaveData} to get only those * whose input set matches {@code inputSet}. * <li>Non-deleted inputs are processed through * {@link IncrementalRelativeFileSets#makeFromBaseFiles(Collection, Map, FileCacheByPath)} * to obtain the incremental file changes. * <li>The results of processed deleted and non-deleted are merged and returned. * </ol> * * @param changedInputs all changed inputs * @param saveData the save data with all input sets from last run * @param inputSet the input set to filter * @param baseFiles the base files of the input set * @param cacheByPath where to cache files * @return the status of all relative files in the input set */ @NonNull private ImmutableMap<RelativeFile, FileStatus> getChangedInputs(@NonNull Map<File, FileStatus> changedInputs, @NonNull KnownFilesSaveData saveData, @NonNull InputSet inputSet, @NonNull Collection<File> baseFiles, @NonNull FileCacheByPath cacheByPath) throws IOException { /* * Figure out changes to deleted files. */ Set<File> deletedFiles = Maps.filterValues(changedInputs, Predicates.equalTo(FileStatus.REMOVED)).keySet(); Set<RelativeFile> deletedRelativeFiles = saveData.find(deletedFiles, inputSet); /* * Figure out changes to non-deleted files. */ Map<File, FileStatus> nonDeletedFiles = Maps.filterValues(changedInputs, Predicates.not(Predicates.equalTo(FileStatus.REMOVED))); Map<RelativeFile, FileStatus> nonDeletedRelativeFiles = IncrementalRelativeFileSets .makeFromBaseFiles(baseFiles, nonDeletedFiles, cacheByPath); /* * Merge everything. */ return new ImmutableMap.Builder<RelativeFile, FileStatus>() .putAll(Maps.asMap(deletedRelativeFiles, Functions.constant(FileStatus.REMOVED))) .putAll(nonDeletedRelativeFiles).build(); }
From source file:com.google.devtools.build.lib.rules.objc.ObjcProvider.java
/** Returns the list of .a files required for linking that arise from objc libraries. */ ImmutableList<Artifact> getObjcLibraries() { // JRE libraries must be ordered after all regular objc libraries. NestedSet<Artifact> jreLibs = get(JRE_LIBRARY); return ImmutableList.<Artifact>builder() .addAll(Iterables.filter(get(LIBRARY), Predicates.not(Predicates.in(jreLibs.toSet())))) .addAll(jreLibs).build();/*from w w w . j a v a 2s. c o m*/ }
From source file:com.google.devtools.build.lib.rules.objc.CompilationSupport.java
/** * Registers an action to create an archive artifact by fully (statically) linking all transitive * dependencies of this rule *except* for dependencies given in {@code avoidsDeps}. * * @param objcProvider provides all compiling and linking information to create this artifact * @param outputArchive the output artifact for this action * @param avoidsDeps list of providers with dependencies that should not be linked into the output * artifact//from w ww . j a v a 2 s . co m */ public CompilationSupport registerFullyLinkActionWithAvoids(ObjcProvider objcProvider, Artifact outputArchive, Iterable<ObjcProvider> avoidsDeps) throws InterruptedException { ImmutableSet.Builder<Artifact> avoidsDepsArtifacts = ImmutableSet.builder(); for (ObjcProvider avoidsProvider : avoidsDeps) { avoidsDepsArtifacts.addAll(avoidsProvider.getObjcLibraries()) .addAll(avoidsProvider.get(IMPORTED_LIBRARY)).addAll(avoidsProvider.getCcLibraries()); } ImmutableList<Artifact> depsArtifacts = ImmutableList.<Artifact>builder() .addAll(objcProvider.getObjcLibraries()).addAll(objcProvider.get(IMPORTED_LIBRARY)) .addAll(objcProvider.getCcLibraries()).build(); Iterable<Artifact> inputArtifacts = Iterables.filter(depsArtifacts, Predicates.not(Predicates.in(avoidsDepsArtifacts.build()))); return registerFullyLinkAction(objcProvider, inputArtifacts, outputArchive); }
From source file:org.trancecode.xproc.PipelineParser.java
private static Step addImplicitInputPort(final Step step) { if (STEPS_WITH_IMPLICIT_INPUT_PORT.contains(step.getType())) { final Iterable<Port> inputPorts = Iterables.filter(step.getInputPorts(false), Predicates.not( Predicates.compose(Predicates.equalTo(XProcPorts.XPATH_CONTEXT), PortFunctions.getPortName()))); if (Iterables.isEmpty(inputPorts)) { final Port port = Port.newInputPort(step.getName(), XProcPorts.SOURCE, step.getLocation()) .setPrimary(true);//w w w . j av a 2 s.c o m LOG.trace(" add implicit input port: {}", port); return step.declarePort(port); } } return step; }