Example usage for com.google.common.collect Sets difference

List of usage examples for com.google.common.collect Sets difference

Introduction

In this page you can find the example usage for com.google.common.collect Sets difference.

Prototype

public static <E> SetView<E> difference(final Set<E> set1, final Set<?> set2) 

Source Link

Document

Returns an unmodifiable view of the difference of two sets.

Usage

From source file:com.linecorp.armeria.server.http.auth.OAuth1aToken.java

private OAuth1aToken(Map<String, String> params) {
    // Map builder with default version value.
    ImmutableMap.Builder<String, String> builder = ImmutableMap.builder();

    for (Entry<String, String> param : params.entrySet()) {
        String key = param.getKey();
        String value = param.getValue();

        // Empty values are ignored.
        if (!Strings.isNullOrEmpty(value)) {
            String lowerCased = key.toLowerCase(Locale.US);
            if (DEFINED_PARAM_KEYS.contains(lowerCased)) {
                // If given parameter is defined by Oauth1a protocol, add with lower-cased key.
                builder.put(lowerCased, value);
            } else {
                // Otherwise, just add.
                builder.put(key, value);
            }/*  w w w .  ja v  a 2s  .  co  m*/
        }
    }

    this.params = builder.build();

    if (!this.params.keySet().containsAll(REQUIRED_PARAM_KEYS)) {
        Set<String> missing = Sets.difference(REQUIRED_PARAM_KEYS, this.params.keySet());
        throw new IllegalArgumentException("Missing OAuth1a parameter exists: " + missing);
    }

    try {
        Long.parseLong(this.params.get(OAUTH_TIMESTAMP));
    } catch (NumberFormatException e) {
        throw new IllegalArgumentException(
                "Illegal " + OAUTH_TIMESTAMP + " value: " + this.params.get(OAUTH_TIMESTAMP));
    }
}

From source file:io.druid.segment.QueryableIndexIndexableAdapter.java

@Override
public Indexed<String> getMetricNames() {
    final Set<String> columns = Sets.newLinkedHashSet(input.getColumnNames());
    final HashSet<String> dimensions = Sets.newHashSet(getDimensionNames());

    return new ListIndexed<>(Lists.newArrayList(Sets.difference(columns, dimensions)), String.class);
}

From source file:no.ssb.vtl.script.expressions.FunctionExpression.java

@VisibleForTesting
static Map<String, VTLExpression> mergeArguments(VTLFunction.Signature signature, List<VTLExpression> arguments,
        Map<String, VTLExpression> namedArguments) {

    // Check unnamed arguments count.
    checkArgument(arguments.size() <= signature.size(), TOO_MANY_ARGUMENTS, signature.size(), arguments.size());

    ImmutableMap.Builder<String, VTLExpression> builder = ImmutableMap.builder();

    // Match the list with the signature names.
    Iterator<String> namesIterator = signature.keySet().iterator();
    for (VTLExpression argument : arguments) {
        builder.put(namesIterator.next(), argument);
    }//from   ww w .j a  va2 s .c  o  m

    // Check for duplicates
    Set<String> duplicates = Sets.intersection(namedArguments.keySet(), builder.build().keySet());
    checkArgument(duplicates.isEmpty(), DUPLICATE_ARGUMENTS, String.join(", ", duplicates));

    ImmutableMap<String, VTLExpression> computedArguments = builder.putAll(namedArguments).build();

    // Check for unknown arguments.
    Set<String> unknown = Sets.difference(computedArguments.keySet(), signature.keySet());
    checkArgument(unknown.isEmpty(), UNKNOWN_ARGUMENTS, String.join(", ", unknown));

    // Check for missing arguments
    Set<String> required = Maps.filterValues(signature, VTLFunction.Argument::isRequired).keySet();
    Set<String> missing = Sets.difference(required, computedArguments.keySet());
    checkArgument(missing.isEmpty(), MISSING_ARGUMENTS, String.join(", ", missing));

    return computedArguments;
}

From source file:org.eclipse.sirius.business.internal.session.danalysis.MovidaSupport.java

void registryChanged(final org.eclipse.sirius.business.internal.movida.registry.ViewpointRegistry registry,
        Set<URI> removed, Set<URI> added, Set<URI> changed) {
    TransactionalEditingDomain transactionalEditingDomain = session.getTransactionalEditingDomain();
    Set<URI> selected = Sets.newHashSet(
            Iterables.transform(session.getSelectedViewpoints(false), new Function<Viewpoint, URI>() {
                public URI apply(Viewpoint from) {
                    return new ViewpointQuery(from).getViewpointURI().get();
                }/*from ww  w.  j a v  a 2s . c  o  m*/
            }));
    final SetView<URI> unavailable = Sets.intersection(selected, removed);
    if (!unavailable.isEmpty()) {
        deselectMissingViewpoints(unavailable);
    }
    Set<URI> resourcesLoaded = vsmResources;
    Set<URI> resourcesRequired = new VSMResolver(registry).resolve(selected);
    Set<URI> resourcesChanged = Sets
            .newHashSet(Iterables.transform(Sets.intersection(changed, selected), new Function<URI, URI>() {
                public URI apply(URI logicalURI) {
                    return registry.getProvider(logicalURI).get();
                };
            }));
    for (URI uri : Sets.difference(resourcesLoaded, resourcesRequired)) {
        // The resource was loaded but is not required anymore.
        // Unload & remove.
        Resource vsm = transactionalEditingDomain.getResourceSet().getResource(uri, false);
        new ViewpointResourceOperations(vsm).unloadAndResetProxyURIs();
        transactionalEditingDomain.getResourceSet().getResources().remove(vsm);
    }
    for (URI uri : resourcesChanged) {
        // The resource is loaded and still required, but its content
        // has changed: unload it.
        Resource vsm = transactionalEditingDomain.getResourceSet().getResource(uri, false);
        if (vsm != null) {
            new ViewpointResourceOperations(vsm).unloadAndResetProxyURIs();
        }
    }
    for (URI uri : Sets.difference(resourcesRequired, resourcesLoaded)) {
        transactionalEditingDomain.getResourceSet().getResource(uri, true);
    }
    for (DAnalysis analysis : session.allAnalyses()) {
        EcoreUtil.resolveAll(analysis);
    }
    vsmResources = resourcesRequired;
    transactionalEditingDomain.getCommandStack().execute(new RecordingCommand(transactionalEditingDomain) {
        @Override
        protected void doExecute() {
            for (DView view : session.getSelectedViews()) {
                for (DRepresentation representation : view.getAllRepresentations()) {
                    DialectManager.INSTANCE.refreshEffectiveRepresentationDescription(representation,
                            new NullProgressMonitor());
                }
            }
        }
    });
}

From source file:com.zulily.omicron.sla.Policy.java

/**
 * Evaluates a list of jobs against the logic of this SLA
 *
 * @param jobs The jobs to evaluate/*from  ww  w .  j ava2  s  .  c  o m*/
 * @return A collection of ACTIONABLE alerts from the result
 */
public List<Alert> evaluate(final Iterable<Job> jobs) {

    checkNotNull(jobs, "jobs");

    final List<Alert> result = new ArrayList<>();

    final Set<Long> activeJobIds = new HashSet<>();

    for (Job job : jobs) {

        if (!job.isActive()) {
            // Inactive indicates that the schedule was removed or changed
            // writing log info is noise
            continue;
        }

        if (isDisabled(job)) {
            info("SLA {0} disabled for line {1}", getName(),
                    String.valueOf(job.getCrontabExpression().getLineNumber()));
            continue;
        }

        if (isDowntime(job)) {
            info("Currently in SLA downtime for line {0}",
                    String.valueOf(job.getCrontabExpression().getLineNumber()));
            continue;
        }

        activeJobIds.add(job.getJobId());

        final Alert alert = generateAlert(job);

        if (alert.getAlertStatus() == AlertStatus.NotApplicable) {
            continue;
        }

        AlertLogEntry logEntry = lastAlertLog.get(job.getJobId());

        if (logEntry != null) {

            // Do not alert multiple times for success
            if (alert.getAlertStatus() == AlertStatus.Success && logEntry.getStatus() == AlertStatus.Success) {
                continue;
            }

            // Do not repeat alerts within the threshold
            if (alert.getAlertStatus() == AlertStatus.Failure && delayRepeat(logEntry, job)) {
                continue;
            }

        } else if (alert.getAlertStatus() != AlertStatus.Failure) {
            continue;
        }

        lastAlertLog.put(job.getJobId(), new AlertLogEntry(job.getJobId(), alert.getAlertStatus()));

        result.add(alert);

    }

    // Remove alerts for inactive jobs
    final ImmutableSet<Long> inactiveAlertJobIds = ImmutableSet
            .copyOf(Sets.difference(lastAlertLog.keySet(), activeJobIds));

    inactiveAlertJobIds.forEach(lastAlertLog::remove);

    return result;
}

From source file:org.apache.beam.runners.direct.SideInputContainer.java

/**
 * Return a view of this {@link SideInputContainer} that contains only the views in the
 * provided argument. The returned {@link SideInputContainer} is unmodifiable without
 * casting, but will change as this {@link SideInputContainer} is modified.
 *///from  w  ww .j  av a  2 s  .co m
public ReadyCheckingSideInputReader createReaderForViews(Collection<PCollectionView<?>> newContainedViews) {
    if (!containedViews.containsAll(newContainedViews)) {
        Set<PCollectionView<?>> currentlyContained = ImmutableSet.copyOf(containedViews);
        Set<PCollectionView<?>> newRequested = ImmutableSet.copyOf(newContainedViews);
        throw new IllegalArgumentException("Can't create a SideInputReader with unknown views "
                + Sets.difference(newRequested, currentlyContained));
    }
    return new SideInputContainerSideInputReader(newContainedViews);
}

From source file:com.jivesoftware.os.tasmo.model.ViewBinding.java

private void validate() {
    Set<String> ensurePathIdsAreUnique = new HashSet<>();
    Set<Integer> ensurePathIdHashCodesAreUnique = new HashSet<>();
    Set<String> rootClassNames = new HashSet<>();

    for (ModelPath modelPath : modelPaths) {
        if (modelPath == null) {
            throw new IllegalStateException("null viewValueBindings are not supported.");
        }//from   w  ww  .j  a v a2  s.  c  o  m
        String pathId = modelPath.getId();

        if (ensurePathIdsAreUnique.contains(pathId)) {
            throw new IllegalStateException(
                    "There are two occurances of ViewValueBinding using the same pathId:" + pathId + ".");
        }
        ensurePathIdsAreUnique.add(pathId);

        if (ensurePathIdHashCodesAreUnique.contains(pathId.hashCode())) {
            throw new IllegalStateException("The following pathId:" + pathId
                    + " .hashCode() collides with another pathId. Consider yourself lucky this check is here. This is incredible rare.");
        }
        ensurePathIdHashCodesAreUnique.add(pathId.hashCode());

        List<ModelPathStep> members = modelPath.getPathMembers();
        ModelPathStep leafStep = members.get(members.size() - 1);
        if (leafStep.getFieldNames().contains(ReservedFields.DELETED)) {
            throw new IllegalStateException(
                    "Model path " + pathId + " attempts to bind to the '" + ReservedFields.DELETED + "' field");
        }

        if (!leafStep.getStepType().equals(ModelPathStepType.value)) {
            throw new IllegalStateException("Model path " + pathId + " does not end with a value step");
        }

        Set<String> pathRootClasses = modelPath.getRootClassNames();

        if (rootClassNames.isEmpty()) {
            rootClassNames.addAll(pathRootClasses);
        } else if (Sets.difference(rootClassNames, pathRootClasses).size() > 0
                || Sets.difference(pathRootClasses, rootClassNames).size() > 0) {
            throw new IllegalStateException(
                    "all paths must pivot on the same root classNames:" + rootClassNames + " " + this);
        }
    }
}

From source file:com.wrmsr.wava.transform.Outlining.java

public static OutlinedFunction outlineFunction(Function function, Node node, Name outlinedName,
        Index externalRetControl, Index externalRetValue, LocalAnalysis loa, ControlTransferAnalysis cfa,
        ValueTypeAnalysis vta, Map<Node, Optional<Node>> parentsByNode, Map<Name, Node> nodesByName) {
    final List<Index> allLocals;
    final List<Index> spilledOutLocalPuts;
    final List<Index> spilledInLocalGets;
    {// w  w  w .  j a  v a 2s  . co  m
        ImSet<Index> entryLocalGets = loa.get(node).getLocalGets();
        ImSet<Index> entryLocalPuts = loa.get(node).getLocalPuts();

        ImSet<Index> nonEntryLocalGets = LocalAnalysis.EMPTY_LOCALS;
        ImSet<Index> nonEntryLocalPuts = LocalAnalysis.EMPTY_LOCALS;
        Optional<Node> cur = Optional.of(node);
        while (true) {
            Optional<Node> next = requireNonNull(parentsByNode.get(cur.get()));
            if (!next.isPresent()) {
                break;
            }
            for (Node sibling : next.get().getChildren()) {
                if (sibling == cur.get()) {
                    continue;
                }
                nonEntryLocalGets = nonEntryLocalGets.union(loa.get(sibling).getLocalGets());
                nonEntryLocalPuts = nonEntryLocalPuts.union(loa.get(sibling).getLocalPuts());
            }
            cur = next;
        }

        Set<Index> entryLocals = Sets.union(entryLocalGets, entryLocalPuts);
        Set<Index> nonEntryLocals = Sets.union(nonEntryLocalGets, nonEntryLocalPuts);
        Set<Index> entryOnlyLocals = Sets.difference(entryLocals, nonEntryLocals);

        Set<Index> spilledOutLocalPutsSet = Sets.intersection(entryLocalPuts, nonEntryLocalGets);
        spilledOutLocalPuts = spilledOutLocalPutsSet.stream().sorted().collect(toImmutableList());
        spilledInLocalGets = Sets.intersection(nonEntryLocalPuts, entryLocalGets).stream()
                .filter(i -> !spilledOutLocalPutsSet.contains(i)).sorted().collect(toImmutableList());

        List<Index> entryOnlyLocalList = entryOnlyLocals.stream().sorted().collect(toImmutableList());
        checkState(
                Sets.intersection(ImmutableSet.copyOf(spilledInLocalGets), ImmutableSet.copyOf(entryOnlyLocals))
                        .isEmpty());

        allLocals = ImmutableList.<Index>builder().addAll(spilledOutLocalPuts).addAll(spilledInLocalGets)
                .addAll(entryOnlyLocalList).build();
    }

    Map<Index, Index> localTranslationMap = enumerate(allLocals.stream())
            .collect(toImmutableMap(i -> i.getItem(), i -> Index.of(i.getIndex())));

    ControlTransferAnalysis.Entry maxCfa = cfa.get(node);
    List<ControlTransferAnalysis.Target> targets = ImmutableList.copyOf(maxCfa.getTargets());
    Map<ControlTransferAnalysis.Target, Name> targetNameMap = enumerate(targets.stream())
            .collect(toImmutableMap(i -> i.getItem(), i -> Name.of("_epilog$" + i.getIndex())));

    ImmutableMap.Builder<ControlTransferAnalysis.Target, Type> targetTypesBuilder = ImmutableMap.builder();
    for (ControlTransferAnalysis.Target target : targets) {
        if (target.equals(ControlTransferAnalysis.Target.RETURN)) {
            targetTypesBuilder.put(ControlTransferAnalysis.Target.RETURN, function.getResult());
        } else if (target instanceof ControlTransferAnalysis.NameTarget) {
            Name name = ((ControlTransferAnalysis.NameTarget) target).getName();
            Type type = vta.get(nodesByName.get(name)).getType();
            targetTypesBuilder.put(target, type);
        } else {
            throw new IllegalStateException();
        }
    }
    Map<ControlTransferAnalysis.Target, Type> targetTypes = targetTypesBuilder.build();

    Node outlinedBody = node.accept(new Visitor<Void, Node>() {
        @Override
        protected Node visitNode(Node node, Void context) {
            return reconstructNode(node,
                    node.getChildren().stream().map(child -> child.accept(this, context)).iterator());
        }

        @Override
        public Node visitBreak(Break node, Void context) {
            ControlTransferAnalysis.Target target = ControlTransferAnalysis.Target.of(node.getTarget());
            if (targetNameMap.containsKey(target)) {
                return new Break(targetNameMap.get(ControlTransferAnalysis.Target.of(node.getTarget())),
                        node.getValue().accept(this, context));
            } else {
                return super.visitBreak(node, context);
            }
        }

        @Override
        public Node visitBreakTable(BreakTable node, Void context) {
            return super.visitBreakTable(node, context);
        }

        @Override
        public Node visitGetLocal(GetLocal node, Void context) {
            return new GetLocal(localTranslationMap.get(node.getIndex()), node.getType());
        }

        @Override
        public Node visitReturn(Return node, Void context) {
            return new Break(targetNameMap.get(ControlTransferAnalysis.Target.RETURN),
                    node.getValue().accept(this, context));
        }

        @Override
        public Node visitSetLocal(SetLocal node, Void context) {
            return new SetLocal(localTranslationMap.get(node.getIndex()), node.getType(),
                    node.getValue().accept(this, context));
        }
    }, null);

    Index internalRetControl = Index.of(allLocals.size());
    Index internalRetValue = Index.of(allLocals.size() + 1);

    ValueTypeAnalysis.Entry maxVta = vta.get(node);
    if (maxCfa.getExecution() == ControlTransferAnalysis.Execution.FALLTHROUGH) {
        if (maxVta.getType() != Type.NONE) {
            outlinedBody = new Block(ImmutableList.of(
                    new SetLocal(internalRetValue, Type.I64, packI64(outlinedBody, maxVta.getType())),
                    new Break(Name.of("_epilog$"), new Nop())));
        } else {
            outlinedBody = new Block(ImmutableList.of(outlinedBody, new Break(Name.of("_epilog$"), new Nop())));
        }
    }

    for (int i = 0; i < targets.size(); ++i) {
        ControlTransferAnalysis.Target target = targets.get(i);
        Name name = targetNameMap.get(target);
        Type type = targetTypes.get(target);

        outlinedBody = new Label(name, outlinedBody);

        switch (type) {
        case NONE:
            break;
        case I32:
        case I64:
        case F32:
        case F64:
            outlinedBody = new SetLocal(internalRetValue, Type.I64, packI64(outlinedBody, type));
            break;
        default:
            throw new IllegalStateException();
        }

        outlinedBody = new Block(ImmutableList.of(new Block(ImmutableList.of(outlinedBody,
                new SetLocal(internalRetControl, Type.I32, new Const(Literal.of(i))),
                new Break(Name.of("_epilog$"), new Nop())))));
    }

    Node returnValueSpiller = new Call(new Call.HostTarget(HostOp.SpillPut, Optional.empty()),
            HostOp.SpillPut.getSignature(),
            ImmutableList.of(new Const(Literal.of(0)), new GetLocal(internalRetValue, Type.I64)));

    List<Node> localSpillers = enumerate(spilledOutLocalPuts.stream()).map(i -> {
        Type type = function.getLocals().getLocal(i.getItem()).getType();
        return new Call(new Call.HostTarget(HostOp.SpillPut, Optional.empty()), HostOp.SpillPut.getSignature(),
                ImmutableList.of(new Const(Literal.of(i.getIndex() + 1)),
                        packI64(new GetLocal(localTranslationMap.get(i.getItem()), type), type)));
    }).collect(toImmutableList());

    outlinedBody = new Block(ImmutableList.of(
            new Label(Name.of("_epilog$"), outlinedBody), new Block(Stream
                    .concat(Stream.of(returnValueSpiller), localSpillers.stream()).collect(toImmutableList())),
            new Return(new GetLocal(internalRetControl, Type.I32))));

    List<Local> localList = ImmutableList.<Local>builder().addAll(allLocals.stream().map(l -> {
        Local o = function.getLocals().getLocal(l);
        return new Local(o.getName(), localTranslationMap.get(l), o.getType());
    }).iterator()).add(new Local(Name.of("_internal$control"), internalRetControl, Type.I32))
            .add(new Local(Name.of("_internal$value"), internalRetValue, Type.I64)).build();

    int argCount = spilledOutLocalPuts.size() + spilledInLocalGets.size();

    Function outlinedFunction = new Function(outlinedName, Type.I32, argCount, new Locals(localList),
            outlinedBody);

    Node outlinedCall = new SetLocal(externalRetControl, Type.I32,
            new Call(new Call.DirectTarget(outlinedName), outlinedFunction.getSignature(),
                    Stream.concat(spilledOutLocalPuts.stream(), spilledInLocalGets.stream())
                            .map(i -> new GetLocal(i, function.getLocals().getLocal(i).getType()))
                            .collect(toImmutableList())));

    Node returnValueUnspiller = new SetLocal(externalRetValue, Type.I64,
            new Call(new Call.HostTarget(HostOp.SpillGet, Optional.empty()), HostOp.SpillGet.getSignature(),
                    ImmutableList.of(new Const(Literal.of(0)))));

    List<Node> localUnspillers = enumerate(spilledOutLocalPuts.stream()).map(i -> {
        Type type = function.getLocals().getLocal(i.getItem()).getType();
        return new SetLocal(i.getItem(), type,
                unpackI64(new Call(new Call.HostTarget(HostOp.SpillGet, Optional.empty()),
                        HostOp.SpillGet.getSignature(),
                        ImmutableList.of(new Const(Literal.of(i.getIndex() + 1)))), type));
    }).collect(toImmutableList());

    Node controlSwitch = new Switch(new GetLocal(externalRetControl, Type.I32),
            Stream.concat(enumerate(targets.stream()).map(i -> {
                if (i.getItem().equals(ControlTransferAnalysis.Target.RETURN)) {
                    return new Switch.Entry(ImmutableList.of(Switch.Value.of(i.getIndex() + 1)), new Return(
                            unpackI64(new GetLocal(externalRetValue, Type.I64), function.getResult())));
                } else if (i.getItem() instanceof ControlTransferAnalysis.NameTarget) {
                    Name name = ((ControlTransferAnalysis.NameTarget) i.getItem()).getName();
                    Type type = vta.get(nodesByName.get(name)).getType();
                    Node value = type != Type.NONE
                            ? unpackI64(new GetLocal(externalRetValue, Type.I64), function.getResult())
                            : new Nop();
                    return new Switch.Entry(ImmutableList.of(Switch.Value.of(i.getIndex() + 1)),
                            new Break(name, value));
                } else {
                    throw new IllegalStateException();
                }
            }), Stream.concat(
                    Stream.of(new Switch.Entry(ImmutableList.of(Switch.Value.DEFAULT), new Unreachable())),
                    maxCfa.getExecution() == ControlTransferAnalysis.Execution.FALLTHROUGH
                            ? Stream.of(new Switch.Entry(ImmutableList.of(Switch.Value.of(0)), new Nop()))
                            : Stream.empty()))
                    .collect(toImmutableList()));

    Node callsite = new Block(ImmutableList.<Node>builder().add(outlinedCall).add(returnValueUnspiller)
            .addAll(localUnspillers).add(controlSwitch)
            .add(maxCfa.getExecution() == ControlTransferAnalysis.Execution.FALLTHROUGH
                    ? unpackI64(new GetLocal(externalRetControl, Type.I64), maxVta.getType())
                    : new Nop())
            .build());

    return new OutlinedFunction(callsite, outlinedFunction);
}

From source file:org.opendaylight.controller.config.yang.netconf.mdsal.notification.BaseCapabilityChangeNotificationPublisher.java

private NetconfCapabilityChange computeCapabilitycChange(
        AsyncDataChangeEvent<InstanceIdentifier<?>, DataObject> change) {
    final NetconfCapabilityChangeBuilder netconfCapabilityChangeBuilder = new NetconfCapabilityChangeBuilder();
    netconfCapabilityChangeBuilder.setChangedBy(
            new ChangedByBuilder().setServerOrUser(new ServerBuilder().setServer(true).build()).build());

    if (!change.getCreatedData().isEmpty()) {
        final InstanceIdentifier capabilitiesIdentifier = InstanceIdentifier.create(NetconfState.class)
                .child(Capabilities.class).builder().build();
        Preconditions/*from  w  w w  .jav a2  s  .  c  o  m*/
                .checkArgument(change.getCreatedData().get(capabilitiesIdentifier) instanceof Capabilities);
        netconfCapabilityChangeBuilder.setAddedCapability(
                ((Capabilities) change.getCreatedData().get(capabilitiesIdentifier)).getCapability());
        netconfCapabilityChangeBuilder.setDeletedCapability(Collections.<Uri>emptyList());
    } else {
        Preconditions.checkArgument(change.getUpdatedSubtree() instanceof Capabilities);
        final Set<Uri> currentState = Sets
                .newHashSet(((Capabilities) change.getUpdatedSubtree()).getCapability());
        final Set<Uri> previousState = Sets
                .newHashSet(((Capabilities) change.getOriginalSubtree()).getCapability());

        netconfCapabilityChangeBuilder
                .setAddedCapability(Lists.newArrayList(Sets.difference(currentState, previousState)));
        netconfCapabilityChangeBuilder
                .setDeletedCapability(Lists.newArrayList(Sets.difference(previousState, currentState)));
    }

    // TODO modified should be computed ... but why ?
    netconfCapabilityChangeBuilder.setModifiedCapability(Collections.<Uri>emptyList());
    return netconfCapabilityChangeBuilder.build();
}

From source file:org.gradle.internal.component.AmbiguousConfigurationSelectionException.java

static void formatConfiguration(StringBuilder sb, AttributeContainer fromConfigurationAttributes,
        AttributesSchema consumerSchema, List<ConfigurationMetadata> matches, Set<String> requestedAttributes,
        int maxConfLength, final String conf) {
    Optional<ConfigurationMetadata> match = Iterables.tryFind(matches, new Predicate<ConfigurationMetadata>() {
        @Override//from   w w  w.j a v  a 2  s.  c o  m
        public boolean apply(ConfigurationMetadata input) {
            return conf.equals(input.getName());
        }
    });
    if (match.isPresent()) {
        AttributeContainer producerAttributes = match.get().getAttributes();
        Set<Attribute<?>> targetAttributes = producerAttributes.keySet();
        Set<String> targetAttributeNames = Sets
                .newTreeSet(Iterables.transform(targetAttributes, ATTRIBUTE_NAME));
        Set<Attribute<?>> allAttributes = Sets.union(fromConfigurationAttributes.keySet(),
                producerAttributes.keySet());
        Set<String> commonAttributes = Sets.intersection(requestedAttributes, targetAttributeNames);
        Set<String> consumerOnlyAttributes = Sets.difference(requestedAttributes, targetAttributeNames);
        sb.append("   ").append("- Configuration '").append(StringUtils.rightPad(conf + "'", maxConfLength + 1))
                .append(" :");
        List<Attribute<?>> sortedAttributes = Ordering.usingToString().sortedCopy(allAttributes);
        List<String> values = new ArrayList<String>(sortedAttributes.size());
        formatAttributes(sb, fromConfigurationAttributes, consumerSchema, producerAttributes, commonAttributes,
                consumerOnlyAttributes, sortedAttributes, values);
    }
}