All Downloads are FREE. Search and download functionalities are using the official Maven repository.

io.vlingo.actors.Routing Maven / Gradle / Ivy

Go to download

Type safe Actor Model toolkit for reactive concurrency and resiliency using Java and other JVM languages.

There is a newer version: 1.7.5
Show newest version
// Copyright © 2012-2018 Vaughn Vernon. All rights reserved.
//
// This Source Code Form is subject to the terms of the
// Mozilla Public License, v. 2.0. If a copy of the MPL
// was not distributed with this file, You can obtain
// one at https://mozilla.org/MPL/2.0/.
package io.vlingo.actors;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Set;
/**
 * Routing is an ordered sequence of {@link Routee routees} that
 * was computed by way of some routing strategy and whose elements
 * will be the target of a message forwarded by a {@link Router}.
 */
public class Routing

{ public static Routing with(final Routee routee) { if (routee == null) throw new IllegalArgumentException("routee may not be null"); return new Routing(Arrays.asList(routee)); } public static Routing with(final List> routees) { if (routees == null || routees.isEmpty()) throw new IllegalArgumentException("routees may not be null or empty"); return new Routing(routees); } public static Routing with(final Set> routees) { if (routees == null || routees.isEmpty()) throw new IllegalArgumentException("routees may not be null or empty"); return new Routing(routees); } private final List> routees; Routing() { super(); this.routees = new ArrayList<>(); } Routing(final List> routees) { super(); this.routees = routees; } Routing(final Set> routees) { this(new ArrayList<>(routees)); } public Routee

first() { return routees.get(0); } public List> routees() { return Collections.unmodifiableList(routees); } public boolean isEmpty() { return routees.isEmpty(); } @Override public String toString() { return "Routing[routees=" + Arrays.toString(routees.toArray()) + "]"; } public void validate() { if (routees.isEmpty()) throw new IllegalStateException("routees may not be empty"); } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy