List of usage examples for com.google.common.base Predicates not
public static <T> Predicate<T> not(Predicate<T> predicate)
From source file:org.eclipse.sirius.diagram.sequence.ui.tool.internal.edit.validator.ISEComplexMoveValidator.java
private Collection<Range> getTitleZoneRanges(SequenceDiagram diagram) { Collection<Range> titleZones = Lists.newArrayList(); for (CombinedFragment unmovedCF : Iterables.filter(diagram.getAllCombinedFragments(), Predicates.not(Predicates.in(movedElements)))) { int titleZoneLowerBound = rangeFunction.apply(unmovedCF).getLowerBound(); int titleZoneUpperBound = rangeFunction.apply(unmovedCF.getFirstOperand()).getLowerBound(); titleZones.add(new Range(titleZoneLowerBound, titleZoneUpperBound)); }/* ww w . jav a 2s. c o m*/ return titleZones; }
From source file:org.apache.ambari.server.api.services.stackadvisor.StackAdvisorBlueprintProcessor.java
/** * Remove user defined properties from stack advisor output in case of it applies only on the stack defaults *//*from ww w . j a v a 2s . c o m*/ private BlueprintConfigurations filterBlueprintConfig(String configType, BlueprintConfigurations config, Map<String, Map<String, String>> userProvidedProperties, ClusterTopology topology) { if (topology.getConfigRecommendationStrategy() == ConfigRecommendationStrategy.ONLY_STACK_DEFAULTS_APPLY) { if (userProvidedProperties.containsKey(configType)) { BlueprintConfigurations newConfig = new BlueprintConfigurations(); Map<String, String> filteredProps = Maps.filterKeys(config.getProperties(), Predicates.not(Predicates.in(userProvidedProperties.get(configType).keySet()))); newConfig.setProperties(Maps.newHashMap(filteredProps)); if (config.getPropertyAttributes() != null) { Map<String, ValueAttributesInfo> filteredAttributes = Maps.filterKeys( config.getPropertyAttributes(), Predicates.not(Predicates.in(userProvidedProperties.get(configType).keySet()))); newConfig.setPropertyAttributes(Maps.newHashMap(filteredAttributes)); } return newConfig; } } return config; }
From source file:com.eucalyptus.compute.common.internal.network.NetworkGroup.java
public Iterable<NetworkRule> getIngressNetworkRules() { return Iterables.filter(getNetworkRules(), Predicates.not(NetworkRule.egress())); }
From source file:org.apache.brooklyn.core.mgmt.EntityManagementUtils.java
/** Modifies the child so it includes the inessential setup of its parent, * for use when unwrapping specific children, but a name or other item may have been set on the parent. * See {@link #WRAPPER_APP_MARKER}. */ private static void mergeWrapperParentSpecToChildEntity(EntitySpec<? extends Application> wrapperParent, EntitySpec<?> wrappedChild) { if (Strings.isNonEmpty(wrapperParent.getDisplayName())) { wrappedChild.displayName(wrapperParent.getDisplayName()); }// www . j a v a2 s. c o m wrappedChild.locations(wrapperParent.getLocations()); if (!wrapperParent.getParameters().isEmpty()) wrappedChild.parametersReplace(wrapperParent.getParameters()); // prefer the wrapper ID (change in 2016-01); see notes on the catalogItemIdIfNotNull method wrappedChild.catalogItemIdIfNotNull(wrapperParent.getCatalogItemId()); // NB: this clobber's child config wherever they conflict; might prefer to deeply merge maps etc // (or maybe even prevent the merge in these cases; // not sure there is a compelling reason to have config on a pure-wrapper parent) Map<ConfigKey<?>, Object> configWithoutWrapperMarker = Maps.filterKeys(wrapperParent.getConfig(), Predicates.not(Predicates.<ConfigKey<?>>equalTo(EntityManagementUtils.WRAPPER_APP_MARKER))); wrappedChild.configure(configWithoutWrapperMarker); wrappedChild.configure(wrapperParent.getFlags()); // copying tags to all entities may be something the caller wants to control, // e.g. if we're adding multiple, the caller might not want to copy the parent // (the BrooklynTags.YAML_SPEC tag will include the parents source including siblings), // but OTOH they might because otherwise the parent's tags might get lost. // also if we are unwrapping multiple registry references we will get the YAML_SPEC for each; // putting the parent's tags first however causes the preferred (outer) one to be retrieved first. wrappedChild.tagsReplace(MutableList.copyOf(wrapperParent.getTags()).appendAll(wrappedChild.getTags())); }
From source file:forge.card.BoosterGenerator.java
/** * This method also modifies passed parameter *//*from w w w . jav a 2 s . c o m*/ private static Predicate<PaperCard> buildExtraPredicate(List<String> operators) { List<Predicate<PaperCard>> conditions = new ArrayList<>(); Iterator<String> itOp = operators.iterator(); while (itOp.hasNext()) { String operator = itOp.next(); if (StringUtils.isEmpty(operator)) { itOp.remove(); continue; } if (operator.endsWith("s")) { operator = operator.substring(0, operator.length() - 1); } boolean invert = operator.charAt(0) == '!'; if (invert) { operator = operator.substring(1); } Predicate<PaperCard> toAdd = null; if (operator.equalsIgnoreCase(BoosterSlots.DUAL_FACED_CARD)) { toAdd = Predicates.compose(CardRulesPredicates.splitType(CardSplitType.Transform), PaperCard.FN_GET_RULES); } else if (operator.equalsIgnoreCase(BoosterSlots.LAND)) { toAdd = Predicates.compose(CardRulesPredicates.Presets.IS_LAND, PaperCard.FN_GET_RULES); } else if (operator.equalsIgnoreCase(BoosterSlots.BASIC_LAND)) { toAdd = IPaperCard.Predicates.Presets.IS_BASIC_LAND; } else if (operator.equalsIgnoreCase(BoosterSlots.TIME_SHIFTED)) { toAdd = IPaperCard.Predicates.Presets.IS_SPECIAL; } else if (operator.equalsIgnoreCase(BoosterSlots.SPECIAL)) { toAdd = IPaperCard.Predicates.Presets.IS_SPECIAL; } else if (operator.equalsIgnoreCase(BoosterSlots.MYTHIC)) { toAdd = IPaperCard.Predicates.Presets.IS_MYTHIC_RARE; } else if (operator.equalsIgnoreCase(BoosterSlots.RARE)) { toAdd = IPaperCard.Predicates.Presets.IS_RARE; } else if (operator.equalsIgnoreCase(BoosterSlots.UNCOMMON)) { toAdd = IPaperCard.Predicates.Presets.IS_UNCOMMON; } else if (operator.equalsIgnoreCase(BoosterSlots.COMMON)) { toAdd = IPaperCard.Predicates.Presets.IS_COMMON; } else if (operator.startsWith("name(")) { operator = StringUtils.strip(operator.substring(4), "() "); String[] cardNames = TextUtil.splitWithParenthesis(operator, ',', '"', '"'); toAdd = IPaperCard.Predicates.names(Lists.newArrayList(cardNames)); } else if (operator.startsWith("color(")) { operator = StringUtils.strip(operator.substring("color(".length() + 1), "()\" "); switch (operator.toLowerCase()) { case "black": toAdd = Presets.IS_BLACK; break; case "blue": toAdd = Presets.IS_BLUE; break; case "green": toAdd = Presets.IS_GREEN; break; case "red": toAdd = Presets.IS_RED; break; case "white": toAdd = Presets.IS_WHITE; break; case "colorless": toAdd = Presets.IS_COLORLESS; break; } } else if (operator.startsWith("fromSets(")) { operator = StringUtils.strip(operator.substring("fromSets(".length() + 1), "()\" "); String[] sets = operator.split(","); toAdd = IPaperCard.Predicates.printedInSets(sets); } else if (operator.startsWith("fromSheet(") && invert) { String sheetName = StringUtils.strip(operator.substring(9), "()\" "); Iterable<PaperCard> src = StaticData.instance().getPrintSheets().get(sheetName).toFlatList(); List<String> cardNames = Lists.newArrayList(); for (PaperCard card : src) { cardNames.add(card.getName()); } toAdd = IPaperCard.Predicates.names(Lists.newArrayList(cardNames)); } if (toAdd == null) { continue; } else { itOp.remove(); } if (invert) { toAdd = Predicates.not(toAdd); } conditions.add(toAdd); } if (conditions.isEmpty()) { return Predicates.alwaysTrue(); } return Predicates.and(conditions); }
From source file:org.eclipse.sirius.diagram.ui.tools.internal.actions.distribute.DistributeAction.java
@Override protected List<?> createOperationSet() { List<?> selection = getSelectedObjects(); if (selection.isEmpty() || !(selection.get(0) instanceof IGraphicalEditPart)) { selection = Collections.EMPTY_LIST; } else {//from w w w. ja v a 2 s . c om // Get the the top level selected edit parts selection = ToolUtilities.getSelectionWithoutDependants(selection); // Remove the connections selection = Lists.newArrayList( Iterables.filter(selection, Predicates.not(Predicates.instanceOf(ConnectionEditPart.class)))); if (selection.size() < 3) { selection = Collections.EMPTY_LIST; } else { EditPart parent = ((EditPart) selection.get(0)).getParent(); int sideOfFirstSelection = PositionConstants.NONE; if (selection.get(0) instanceof IBorderItemEditPart) { // If the first selected element is a border node sideOfFirstSelection = ((IBorderItemEditPart) selection.get(0)).getBorderItemLocator() .getCurrentSideOfParent(); // Check that the side corresponds to the action axis // (horizontal or vertical) if (!isHorizontalAxisAuthorizedForBorderNode(sideOfFirstSelection) && !isVerticalAxisAuthorizedForBorderNode(sideOfFirstSelection)) { selection = Collections.EMPTY_LIST; } } for (int i = 1; i < selection.size(); i++) { EditPart part = (EditPart) selection.get(i); if (part.getParent() != parent) { // All the selected shapes must have the same parent. selection = Collections.EMPTY_LIST; break; } else if (sideOfFirstSelection != PositionConstants.NONE && !isABorderNodeOnSameAxis(part, sideOfFirstSelection)) { // All the selected border nodes must have the same // axis. selection = Collections.EMPTY_LIST; break; } else if (part instanceof IGraphicalEditPart) { EditPartQuery containerLayoutQuery = new EditPartQuery((IGraphicalEditPart) part); if (!containerLayoutQuery.isFreeFormContainerChildrenPresentation()) { // List item and elements inside compartment can not // be distribute selection = Collections.EMPTY_LIST; break; } } } } } return selection; }
From source file:clocker.docker.location.DockerContainerLocation.java
@Override public int copyTo(final Map<String, ?> props, final InputStream src, final String destination) { Map<String, ?> nonPortProps = Maps.filterKeys(props, Predicates.not(Predicates.containsPattern("port"))); boolean entitySsh = Boolean.TRUE.equals(entity.config().get(DockerContainer.DOCKER_USE_SSH)); boolean dockerSsh = Boolean.TRUE.equals(getOwner().config().get(DockerContainer.DOCKER_USE_SSH)); if (entitySsh && dockerSsh) { return super.copyTo(nonPortProps, src, destination); } else {/*from w w w.jav a 2 s . co m*/ try { String tmp = Os.mergePaths("/tmp", Joiner.on('-').join(dockerContainer.getId(), Urls.getBasename(destination), Strings.makeRandomId(4))); hostMachine.copyTo(nonPortProps, src, tmp); copyFile(tmp, destination); src.close(); return 0; } catch (IOException ioe) { throw Exceptions.propagate(ioe); } } }
From source file:org.apache.druid.server.coordinator.CostBalancerStrategy.java
protected double computeCost(final DataSegment proposalSegment, final ServerHolder server, final boolean includeCurrentServer) { final long proposalSegmentSize = proposalSegment.getSize(); // (optional) Don't include server if it is already serving segment if (!includeCurrentServer && server.isServingSegment(proposalSegment)) { return Double.POSITIVE_INFINITY; }//from w w w.ja va2 s . c o m // Don't calculate cost if the server doesn't have enough space or is loading the segment if (proposalSegmentSize > server.getAvailableSize() || server.isLoadingSegment(proposalSegment)) { return Double.POSITIVE_INFINITY; } // The contribution to the total cost of a given server by proposing to move the segment to that server is... double cost = 0d; // the sum of the costs of other (exclusive of the proposalSegment) segments on the server cost += computeJointSegmentsCost(proposalSegment, Iterables.filter( server.getServer().getSegments().values(), Predicates.not(Predicates.equalTo(proposalSegment)))); // plus the costs of segments that will be loaded cost += computeJointSegmentsCost(proposalSegment, server.getPeon().getSegmentsToLoad()); // minus the costs of segments that are marked to be dropped cost -= computeJointSegmentsCost(proposalSegment, server.getPeon().getSegmentsMarkedToDrop()); return cost; }
From source file:com.android.monkeyrunner.JythonUtils.java
/** * build a jython doc-string for a class from the annotation and the fields * contained within the class/*from w ww . ja va2 s . c o m*/ * * @param doc the annotation * @param clz the class to be documented * @return the doc-string */ private static String buildClassDoc(MonkeyRunnerExported doc, Class<?> clz) { // Below the class doc, we need to document all the documented field this class contains Collection<Field> annotatedFields = Collections2.filter(Arrays.asList(clz.getFields()), SHOULD_BE_DOCUMENTED); Collection<Field> staticFields = Collections2.filter(annotatedFields, IS_FIELD_STATIC); Collection<Field> nonStaticFields = Collections2.filter(annotatedFields, Predicates.not(IS_FIELD_STATIC)); StringBuilder sb = new StringBuilder(); for (String line : splitString(doc.doc(), 80)) { sb.append(line).append("\n"); } if (staticFields.size() > 0) { sb.append("\nClass Fields: \n"); for (Field f : staticFields) { sb.append(buildFieldDoc(f)); } } if (nonStaticFields.size() > 0) { sb.append("\n\nFields: \n"); for (Field f : nonStaticFields) { sb.append(buildFieldDoc(f)); } } return sb.toString(); }
From source file:edu.udo.scaffoldhunter.view.util.TooltipManager.java
private void appendAccumulatedProperties(Structure structure, DefaultFormBuilder propertyPanelBuilder) { ToolTipPropertyConfigurationEntry entry; if (structure instanceof Scaffold) { propertyPanelBuilder.appendSeparator(_("Tooltip.PropertyTitles.AccumulatedMolecule")); propertyPanelBuilder.nextLine(); } else {// ww w . j a va 2 s .co m return; } String propValue; String accSubtree; for (PropertyDefinition propDef : Iterables.filter(sortedProperties, Predicates.not(SHPredicates.IS_SCAFFOLD_PROPDEF))) { propValue = null; accSubtree = null; if (propDef.isStringProperty()) { continue; } else { entry = propertyConfigurations.get(propDef); propValue = DBExceptionHandler.callDBManager(db, new GetAccDBFunction(propDef, entry.getAccumulationFunction(), (Scaffold) structure, entry.isAccumulationWithSubtree())); } if (propValue == null && showUndefinedProperties) { propValue = _("Tooltip.Property.Undefined"); } if (propValue != null) { accSubtree = entry.isAccumulationWithSubtree() ? _("Model.SubtreeCumulative") : _("Model.Cumulative"); JLabel propertyName = new JLabel(); propertyName.setText(String.format("<html><b>%s</b><br>(<i>%s, %s)</i></html>", propDef.getTitle(), entry.getAccumulationFunction().toString(), accSubtree)); if (!propDef.getDescription().isEmpty()) { propertyName.setToolTipText(propDef.getDescription()); } propertyPanelBuilder.append(propertyName, new HyperlinkedLabel(propValue)); propertyPanelBuilder.nextLine(); } } }