Java Code Examples for com.google.common.collect.SetMultimap#keySet()

The following examples show how to use com.google.common.collect.SetMultimap#keySet() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FullMessageEntityValidator.java    From sailfish-core with Apache License 2.0 6 votes vote down vote up
private void checkUniqueness(List<DictionaryValidationError> errors, IMessageStructure message) {

        SetMultimap<String, String> duplicates = HashMultimap.create();

        checkFields(message, duplicates);

        if (!duplicates.isEmpty()) {
            for (String fieldName : duplicates.keySet()) {
                if (duplicates.get(fieldName).size() > 1) {
                    StringBuilder error = new StringBuilder(
                            String.format("Field <strong>[%s]</strong> in <strong>[%s]</strong> message duplicated in ",
                                    fieldName, message.getName()));
                    for (Iterator<String> i = duplicates.get(fieldName).iterator(); i.hasNext();) {
                        error.append(String.format("<strong>[%s]</strong>", i.next()));
                        if (i.hasNext()) {
                            error.append(", ");
                        }
                    }
                    errors.add(new DictionaryValidationError(message.getName(), fieldName, error.toString(),
                            DictionaryValidationErrorLevel.MESSAGE, DictionaryValidationErrorType.ERR_DUPLICATE_NAME));
                }
            }
        }
    }
 
Example 2
Source File: WhitelistBlacklist.java    From incubator-gobblin with Apache License 2.0 6 votes vote down vote up
private static boolean multimapContains(SetMultimap<Pattern, Pattern> multimap, String database,
    Optional<String> table, boolean blacklist) {
  for (Pattern dbPattern : multimap.keySet()) {
    if (dbPattern.matcher(database).matches()) {
      if (!table.isPresent()) {
        // if we are only matching database
        return !blacklist || multimap.get(dbPattern).contains(ALL_TABLES);
      }

      for (Pattern tablePattern : multimap.get(dbPattern)) {
        if (tablePattern.matcher(table.get()).matches()) {
          return true;
        }
      }
    }
  }

  return false;
}
 
Example 3
Source File: FunctionFeed.java    From brooklyn-server with Apache License 2.0 6 votes vote down vote up
@SuppressWarnings({ "unchecked", "rawtypes" })
@Override
protected void preStart() {
    SetMultimap<FunctionPollIdentifier, FunctionPollConfig<?, ?>> polls = getConfig(POLLS);
    for (final FunctionPollIdentifier pollInfo : polls.keySet()) {
        Set<FunctionPollConfig<?,?>> configs = polls.get(pollInfo);
        long minPeriod = Integer.MAX_VALUE;
        Set<AttributePollHandler<?>> handlers = Sets.newLinkedHashSet();

        for (FunctionPollConfig<?,?> config : configs) {
            handlers.add(new AttributePollHandler(config, entity, this));
            if (config.getPeriod() > 0) minPeriod = Math.min(minPeriod, config.getPeriod());
        }
        
        getPoller().scheduleAtFixedRate(
                (Callable)pollInfo.job,
                new DelegatingPollHandler(handlers), 
                minPeriod);
    }
}
 
Example 4
Source File: BaggageImpl.java    From tracing-framework with BSD 3-Clause "New" or "Revised" License 6 votes vote down vote up
/** Constructs a {@link BaggageMessage} protobuf message with the contents of this baggage. If this baggage is
 * empty, returns null */
BaggageMessage buildMessage() {
    // Call baggage handlers
    Handlers.preSerialize(this);
    
    // Construct message
    BaggageMessage.Builder b = BaggageMessage.newBuilder();
    for (ByteString namespace : contents.keySet()) {
        SetMultimap<ByteString, ByteString> namespaceData = contents.get(namespace);

        // Namespace should not exist if it has no data
        if (namespaceData.isEmpty()) {
            continue;
        }

        // Construct the namespace data message
        NamespaceData.Builder nb = b.addNamespaceBuilder().setKey(namespace);
        for (ByteString key : namespaceData.keySet()) {
            nb.addBagBuilder().setKey(key).addAllValue(namespaceData.get(key));
        }
    }

    // Return null if the baggage message is empty
    return b.getNamespaceCount() == 0 ? null : b.build();
}
 
Example 5
Source File: HtmlReport.java    From sailfish-core with Apache License 2.0 6 votes vote down vote up
private void writeReportKnownBugsTable(SetMultimap<String, BugDescription> allKnownBugsMap, SetMultimap<String, BugDescription> reproducedBugsMap, Writer reportWriter) throws IOException, TemplateException {
    if(allKnownBugsMap.isEmpty()) {
        return;
    }

    ReportTable table = new ReportTable(KNOWN_BUGS_TABLE_NAME, Arrays.asList("Test Case", BUG_CATEGORY_COLUMN_NAME, REPRODUCED_COLUMN_NAME, NOT_REPRODUCED_COLUMN_NAME));

    for(String testCaseDescription : allKnownBugsMap.keySet()) {
        Set<BugDescription> allKnownBugs = allKnownBugsMap.get(testCaseDescription);
        Set<BugDescription> reproducedBugs = reproducedBugsMap.get(testCaseDescription);

        List<Map<String, String>> rows = fillKnowBugTable(allKnownBugs, reproducedBugs);
        if (!rows.isEmpty()) {
            rows.get(0).put("Test Case", testCaseDescription);
            table.addRows(rows);
        }
    }

    writeTable(reportWriter, StatusType.NA, table, 4);
}
 
Example 6
Source File: Environment.java    From sqlitemagic with Apache License 2.0 5 votes vote down vote up
@NonNull
public Set<ExecutableElement> getLocalAndInheritedMethods(TypeElement type, ConditionCallback<ExecutableElement> includeMethodCallback) {
  SetMultimap<String, ExecutableElement> methodMap = LinkedHashMultimap.create();
  getLocalAndInheritedMethods(getPackage(type), type, methodMap, includeMethodCallback);
  // Find methods that are overridden. We do this using `Elements.overrides`, which means
  // that it is inherently a quadratic operation, since we have to compare every method against
  // every other method. We reduce the performance impact by (a) grouping methods by name, since
  // a method cannot override another method with a different name, and (b) making sure that
  // methods in ancestor types precede those in descendant types, which means we only have to
  // check a method against the ones that follow it in that order.
  Set<ExecutableElement> overridden = new LinkedHashSet<>();
  final Elements elementUtils = this.elementUtils;
  for (String methodName : methodMap.keySet()) {
    List<ExecutableElement> methodList = ImmutableList.copyOf(methodMap.get(methodName));
    for (int i = 0; i < methodList.size(); i++) {
      ExecutableElement methodI = methodList.get(i);
      for (int j = i + 1; j < methodList.size(); j++) {
        ExecutableElement methodJ = methodList.get(j);
        if (elementUtils.overrides(methodJ, methodI, type)) {
          overridden.add(methodI);
        }
      }
    }
  }
  Set<ExecutableElement> methods = new LinkedHashSet<>(methodMap.values());
  methods.removeAll(overridden);
  return methods;
}
 
Example 7
Source File: ShellFeed.java    From brooklyn-server with Apache License 2.0 5 votes vote down vote up
@Override
protected void preStart() {
    SetMultimap<ShellPollIdentifier, ShellPollConfig<?>> polls = getConfig(POLLS);
    
    for (final ShellPollIdentifier pollInfo : polls.keySet()) {
        Set<ShellPollConfig<?>> configs = polls.get(pollInfo);
        long minPeriod = Integer.MAX_VALUE;
        Set<AttributePollHandler<? super SshPollValue>> handlers = Sets.newLinkedHashSet();

        for (ShellPollConfig<?> config : configs) {
            handlers.add(new AttributePollHandler<SshPollValue>(config, entity, this));
            if (config.getPeriod() > 0) minPeriod = Math.min(minPeriod, config.getPeriod());
        }

        final ProcessTaskFactory<?> taskFactory = newTaskFactory(pollInfo.command, pollInfo.env, pollInfo.dir, 
                pollInfo.input, pollInfo.context, pollInfo.timeout);
        final ExecutionContext executionContext = getExecutionContext();

        getPoller().scheduleAtFixedRate(
                new Callable<SshPollValue>() {
                    @Override public SshPollValue call() throws Exception {
                        ProcessTaskWrapper<?> taskWrapper = taskFactory.newTask();
                        executionContext.submit(taskWrapper);
                        taskWrapper.block();
                        Optional<Integer> exitCode = Optional.fromNullable(taskWrapper.getExitCode());
                        return new SshPollValue(null, exitCode.or(-1), taskWrapper.getStdout(), taskWrapper.getStderr());
                    }}, 
                new DelegatingPollHandler<SshPollValue>(handlers), 
                minPeriod);
    }
}
 
Example 8
Source File: VpcCfgReconstruction.java    From jakstab with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Fold ART into a map from VPC locations to sets of abstract states, and
 * then flatten the state sets into single abstract states by joining.
 * 
 * @return a map from VPC locations to the join of all abstract states at 
 * that VPC location
 */
private Map<Location, AbstractState> flattenArtOntoVpcLocations() {

	SetMultimap<Location, AbstractState> vpcSensitiveReached = HashMultimap.create();
	
	Deque<AbstractState> worklist = new LinkedList<AbstractState>();
	worklist.add(art.getRoot());
	Set<AbstractState> visited = new HashSet<AbstractState>();
	visited.add(art.getRoot());
	
	while (!worklist.isEmpty()) {
		AbstractState headState = worklist.removeFirst();
		if (isVpcStateBot(headState))
			continue;
		
		BasedNumberElement vpcVal = getVPC(headState);
		VpcLocation headVpcLoc = new VpcLocation(vpcVal, (RTLLabel)headState.getLocation());

		vpcSensitiveReached.put(headVpcLoc, headState);

		Set<Pair<CFAEdge, AbstractState>> successors = art.getChildren(headState);
		for (Pair<CFAEdge, AbstractState> sPair : successors) {
			AbstractState nextState = sPair.getRight();
			
			if (!visited.contains(nextState)) {
				visited.add(nextState);
				worklist.add(nextState);
			}
		}
	}
	
	Map<Location, AbstractState> constants = new HashMap<Location, AbstractState>();
	for (Location l : vpcSensitiveReached.keySet()) {
		constants.put(l, Lattices.joinAll(vpcSensitiveReached.get(l)));
	}
	
	return constants;
}
 
Example 9
Source File: MoreElements.java    From auto-parcel with Apache License 2.0 5 votes vote down vote up
/**
 * Returns the set of all non-private methods from {@code type}, including methods that it
 * inherits from its ancestors. Inherited methods that are overridden are not included in the
 * result. So if {@code type} defines {@code public String toString()}, the returned set will
 * contain that method, but not the {@code toString()} method defined by {@code Object}.
 * <p/>
 * <p>The returned set may contain more than one method with the same signature, if
 * {@code type} inherits those methods from different ancestors. For example, if it
 * inherits from unrelated interfaces {@code One} and {@code Two} which each define
 * {@code void foo();}, and if it does not itself override the {@code foo()} method,
 * then both {@code One.foo()} and {@code Two.foo()} will be in the returned set.
 *
 * @param type         the type whose own and inherited methods are to be returned
 * @param elementUtils an {@link Elements} object, typically returned by
 *                     {@link javax.annotation.processing.AbstractProcessor#processingEnv processingEnv}<!--
 *                     -->.{@link javax.annotation.processing.ProcessingEnvironment.getElementUtils()
 *                     getElementUtils()}
 */
public static ImmutableSet<ExecutableElement> getLocalAndInheritedMethods(
        TypeElement type, Elements elementUtils) {

    SetMultimap<String, ExecutableElement> methodMap = LinkedHashMultimap.create();
    getLocalAndInheritedMethods(getPackage(type), type, methodMap);
    // Find methods that are overridden. We do this using `Elements.overrides`, which means
    // that it is inherently a quadratic operation, since we have to compare every method against
    // every other method. We reduce the performance impact by (a) grouping methods by name, since
    // a method cannot override another method with a different name, and (b) making sure that
    // methods in ancestor types precede those in descendant types, which means we only have to
    // check a method against the ones that follow it in that order.
    Set<ExecutableElement> overridden = new LinkedHashSet<ExecutableElement>();
    for (String methodName : methodMap.keySet()) {
        List<ExecutableElement> methodList = ImmutableList.copyOf(methodMap.get(methodName));
        for (int i = 0; i < methodList.size(); i++) {
            ExecutableElement methodI = methodList.get(i);
            for (int j = i + 1; j < methodList.size(); j++) {
                ExecutableElement methodJ = methodList.get(j);
                if (elementUtils.overrides(methodJ, methodI, type)) {
                    overridden.add(methodI);
                }
            }
        }
    }
    Set<ExecutableElement> methods = new LinkedHashSet<ExecutableElement>(methodMap.values());
    methods.removeAll(overridden);
    return ImmutableSet.copyOf(methods);
}
 
Example 10
Source File: BaggageImpl.java    From tracing-framework with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/** Returns a set view of the keys in the specified namespace that have 1 or more values assigned
 * 
 * @param namespace the namespace to look up
 * @return all the distinct keys under the given namespace with values assigned */
public Set<ByteString> keys(ByteString namespace) {
    if (namespace != null) {
        SetMultimap<ByteString, ByteString> namespaceData = contents.get(namespace);
        if (namespaceData != null) {
            return namespaceData.keySet();
        }
    }
    return Collections.emptySet();
}
 
Example 11
Source File: ObservableSetMultimapWrapper.java    From gef with Eclipse Public License 2.0 5 votes vote down vote up
@Override
public void clear() {
	SetMultimap<K, V> previousContents = delegateCopy();
	super.clear();
	if (!previousContents.isEmpty()) {
		List<ElementarySubChange<K, V>> elementaryChanges = new ArrayList<>();
		for (K key : previousContents.keySet()) {
			elementaryChanges.add(new ElementarySubChange<>(key,
					previousContents.get(key), Collections.<V> emptySet()));
		}
		helper.fireValueChangedEvent(
				new SetMultimapListenerHelper.AtomicChange<>(this,
						previousContents, elementaryChanges));
	}
}
 
Example 12
Source File: JmxFeed.java    From brooklyn-server with Apache License 2.0 4 votes vote down vote up
@Override
protected void preStart() {
    /*
     * All actions on the JmxHelper are done async (through the poller's threading) so we don't 
     * block on start/rebind if the entity is unreachable 
     * (without this we get a 120s pause in JmxHelper.connect restarting)
     */
    final SetMultimap<NotificationFilter, JmxNotificationSubscriptionConfig<?>> notificationSubscriptions = getConfig(NOTIFICATION_SUBSCRIPTIONS);
    final SetMultimap<List<?>, JmxOperationPollConfig<?>> operationPolls = getConfig(OPERATION_POLLS);
    final SetMultimap<String, JmxAttributePollConfig<?>> attributePolls = getConfig(ATTRIBUTE_POLLS);
    
    getPoller().submit(new Callable<Void>() {
           @Override public Void call() {
               getHelper().connect(getConfig(JMX_CONNECTION_TIMEOUT));
               return null;
           }
           @Override public String toString() { return "Connect JMX "+getHelper().getUrl(); }
       });
    
    for (final NotificationFilter filter : notificationSubscriptions.keySet()) {
        getPoller().submit(new Callable<Void>() {
            @Override public Void call() {
                // TODO Could config.getObjectName have wildcards? Is this code safe?
                Set<JmxNotificationSubscriptionConfig<?>> configs = notificationSubscriptions.get(filter);
                NotificationListener listener = registerNotificationListener(configs);
                ObjectName objectName = Iterables.get(configs, 0).getObjectName();
                notificationListeners.put(objectName, listener);
                return null;
            }
            @Override public String toString() { return "Register JMX notifications: "+notificationSubscriptions.get(filter); }
        });
    }
    
    // Setup polling of sensors
    for (final String jmxAttributeName : attributePolls.keys()) {
        registerAttributePoller(attributePolls.get(jmxAttributeName));
    }
    
    // Setup polling of operations
    for (final List<?> operationIdentifier : operationPolls.keys()) {
        registerOperationPoller(operationPolls.get(operationIdentifier));
    }
}
 
Example 13
Source File: HttpFeed.java    From brooklyn-server with Apache License 2.0 4 votes vote down vote up
@Override
protected void preStart() {
    SetMultimap<HttpPollIdentifier, HttpPollConfig<?>> polls = getConfig(POLLS);

    for (final HttpPollIdentifier pollInfo : polls.keySet()) {
        // Though HttpClients are thread safe and can take advantage of connection pooling
        // and authentication caching, the httpcomponents documentation says:
        //    "While HttpClient instances are thread safe and can be shared between multiple
        //     threads of execution, it is highly recommended that each thread maintains its
        //     own dedicated instance of HttpContext.
        //  http://hc.apache.org/httpcomponents-client-ga/tutorial/html/connmgmt.html

        Set<HttpPollConfig<?>> configs = polls.get(pollInfo);
        long minPeriod = Integer.MAX_VALUE;
        Set<AttributePollHandler<? super HttpToolResponse>> handlers = Sets.newLinkedHashSet();

        for (HttpPollConfig<?> config : configs) {
            handlers.add(new AttributePollHandler<HttpToolResponse>(config, entity, this));
            if (config.getPeriod() > 0) minPeriod = Math.min(minPeriod, config.getPeriod());
        }

        Callable<HttpToolResponse> pollJob;
        pollJob = new Callable<HttpToolResponse>() {
            @Override
            public HttpToolResponse call() throws Exception {
                if (log.isTraceEnabled()) log.trace("http polling for {} sensors at {}", entity, pollInfo);

                UsernamePassword creds = null;
                if (pollInfo.credentials.isPresent()) {
                    creds =  new UsernamePassword(
                            pollInfo.credentials.get().getUserPrincipal().getName(),
                            pollInfo.credentials.get().getPassword());
                }

                HttpResponse response =  pollInfo.httpExecutor.execute(new HttpRequest.Builder()
                        .headers(pollInfo.headers)
                        .uri(pollInfo.uriProvider.get())
                        .credentials(creds)
                        .method(pollInfo.method)
                        .body(pollInfo.body)
                        .config(HttpConfig.builder()
                                .trustSelfSigned(true)
                                .trustAll(true)
                                .laxRedirect(true)
                                .build())
                        .build());
                return createHttpToolRespose(response);
            }};
            getPoller().scheduleAtFixedRate(pollJob, new DelegatingPollHandler<HttpToolResponse>(handlers), minPeriod);
    }
}
 
Example 14
Source File: SetMultimapExpression.java    From gef with Eclipse Public License 2.0 4 votes vote down vote up
@Override
public Set<K> keySet() {
	final SetMultimap<K, V> setMultimap = get();
	return (setMultimap == null) ? EMPTY_SETMULTIMAP.keySet()
			: setMultimap.keySet();
}
 
Example 15
Source File: NullAway.java    From NullAway with MIT License 4 votes vote down vote up
/**
 * check that all @NonNull fields of the class are properly initialized
 *
 * @param tree the class
 * @param state visitor state
 */
private void checkFieldInitialization(ClassTree tree, VisitorState state) {
  FieldInitEntities entities = collectEntities(tree, state);
  Symbol.ClassSymbol classSymbol = ASTHelpers.getSymbol(tree);
  class2Entities.put(classSymbol, entities);
  // set of all non-null instance fields f such that *some* constructor does not initialize f
  Set<Symbol> notInitializedInConstructors;
  SetMultimap<MethodTree, Symbol> constructorInitInfo;
  if (entities.constructors().isEmpty()) {
    constructorInitInfo = null;
    notInitializedInConstructors = entities.nonnullInstanceFields();
  } else {
    constructorInitInfo = checkConstructorInitialization(entities, state);
    notInitializedInConstructors = ImmutableSet.copyOf(constructorInitInfo.values());
  }
  class2ConstructorUninit.putAll(classSymbol, notInitializedInConstructors);
  Set<Symbol> notInitializedAtAll =
      notAssignedInAnyInitializer(entities, notInitializedInConstructors, state);
  SetMultimap<Element, Element> errorFieldsForInitializer = LinkedHashMultimap.create();
  // non-null if we have a single initializer method
  Symbol.MethodSymbol singleInitializerMethod = null;
  if (entities.instanceInitializerMethods().size() == 1) {
    singleInitializerMethod =
        ASTHelpers.getSymbol(entities.instanceInitializerMethods().iterator().next());
  }
  for (Symbol uninitField : notInitializedAtAll) {
    if (errorBuilder.symbolHasSuppressWarningsAnnotation(
        uninitField, INITIALIZATION_CHECK_NAME)) {
      continue;
    }
    if (singleInitializerMethod != null) {
      // report it on the initializer
      errorFieldsForInitializer.put(singleInitializerMethod, uninitField);
    } else if (constructorInitInfo == null) {
      // report it on the field, except in the case where the class is externalInit and
      // we have no initializer methods
      if (!(isExternalInit(classSymbol) && entities.instanceInitializerMethods().isEmpty())) {
        errorBuilder.reportInitErrorOnField(
            uninitField, state, buildDescription(getTreesInstance(state).getTree(uninitField)));
      }
    } else {
      // report it on each constructor that does not initialize it
      for (MethodTree methodTree : constructorInitInfo.keySet()) {
        Set<Symbol> uninitFieldsForConstructor = constructorInitInfo.get(methodTree);
        if (uninitFieldsForConstructor.contains(uninitField)) {
          errorFieldsForInitializer.put(ASTHelpers.getSymbol(methodTree), uninitField);
        }
      }
    }
  }
  for (Element constructorElement : errorFieldsForInitializer.keySet()) {
    errorBuilder.reportInitializerError(
        (Symbol.MethodSymbol) constructorElement,
        errMsgForInitializer(errorFieldsForInitializer.get(constructorElement), state),
        state,
        buildDescription(getTreesInstance(state).getTree(constructorElement)));
  }
  // For static fields
  Set<Symbol> notInitializedStaticFields = notInitializedStatic(entities, state);
  for (Symbol uninitSField : notInitializedStaticFields) {
    // Always report it on the field for static fields (can't do @SuppressWarnings on a static
    // initialization block
    // anyways).
    errorBuilder.reportInitErrorOnField(
        uninitSField, state, buildDescription(getTreesInstance(state).getTree(uninitSField)));
  }
}
 
Example 16
Source File: LinkCollectionIntentFlowObjectiveCompiler.java    From onos with Apache License 2.0 4 votes vote down vote up
@Override
public List<Intent> compile(LinkCollectionIntent intent, List<Intent> installable) {

    SetMultimap<DeviceId, PortNumber> inputPorts = HashMultimap.create();
    SetMultimap<DeviceId, PortNumber> outputPorts = HashMultimap.create();
    Map<ConnectPoint, Identifier<?>> labels = ImmutableMap.of();

    Optional<EncapsulationConstraint> encapConstraint = this.getIntentEncapConstraint(intent);

    computePorts(intent, inputPorts, outputPorts);

    if (encapConstraint.isPresent()) {
        labels = labelAllocator.assignLabelToPorts(intent.links(),
                                                   intent.key(),
                                                   encapConstraint.get().encapType());
    }

    ImmutableList.Builder<Intent> intentList = ImmutableList.builder();
    if (this.isDomainProcessingEnabled(intent)) {
        intentList.addAll(this.getDomainIntents(intent, domainService));
    }

    List<Objective> objectives = new ArrayList<>();
    List<DeviceId> devices = new ArrayList<>();
    for (DeviceId deviceId : outputPorts.keySet()) {
        // add only objectives that are not inside of a domain
        if (LOCAL.equals(domainService.getDomain(deviceId))) {
            List<Objective> deviceObjectives =
                    createRules(intent,
                                deviceId,
                                inputPorts.get(deviceId),
                                outputPorts.get(deviceId),
                                labels);
            deviceObjectives.forEach(objective -> {
                objectives.add(objective);
                devices.add(deviceId);
            });
        }
    }
    // if any objectives have been created
    if (!objectives.isEmpty()) {
        intentList.add(new FlowObjectiveIntent(appId, intent.key(), devices,
                                               objectives,
                                               intent.resources(),
                                               intent.resourceGroup()));
    }
    return intentList.build();
}
 
Example 17
Source File: LinkCollectionIntentCompiler.java    From onos with Apache License 2.0 4 votes vote down vote up
@Override
public List<Intent> compile(LinkCollectionIntent intent, List<Intent> installable) {

    SetMultimap<DeviceId, PortNumber> inputPorts = HashMultimap.create();
    SetMultimap<DeviceId, PortNumber> outputPorts = HashMultimap.create();
    Map<ConnectPoint, Identifier<?>> labels = ImmutableMap.of();

    Optional<EncapsulationConstraint> encapConstraint = this.getIntentEncapConstraint(intent);

    computePorts(intent, inputPorts, outputPorts);

    if (encapConstraint.isPresent()) {
        labels = labelAllocator.assignLabelToPorts(intent.links(),
                                                   intent.key(),
                                                   encapConstraint.get().encapType());
    }

    ImmutableList.Builder<Intent> intentList = ImmutableList.builder();
    if (this.isDomainProcessingEnabled(intent)) {
        intentList.addAll(this.getDomainIntents(intent, domainService));
    }

    List<FlowRule> rules = new ArrayList<>();
    for (DeviceId deviceId : outputPorts.keySet()) {
        // add only flows that are not inside of a domain
        if (LOCAL.equals(domainService.getDomain(deviceId))) {
            rules.addAll(createRules(
                    intent,
                    deviceId,
                    inputPorts.get(deviceId),
                    outputPorts.get(deviceId),
                    labels)
            );
        }
    }
    // if any rules have been created
    if (!rules.isEmpty()) {
        intentList.add(new FlowRuleIntent(appId, intent.key(), rules,
                                          intent.resources(),
                                          PathIntent.ProtectionType.PRIMARY,
                             null));
    }
    return intentList.build();
}