reactor.event.registry.Registry Maven / Gradle / Ivy
/*
* Copyright (c) 2011-2013 GoPivotal, Inc. All Rights Reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package reactor.event.registry;
import java.util.List;
import reactor.event.selector.Selector;
/**
* Implementations of this interface manage a registry of objects that works sort of like a Map, except Registries don't
* use simple keys, they use {@link reactor.event.selector.Selector}s to map their objects.
*
* @param the type of objects that can be registered
*
* @author Jon Brisbin
* @author Andy Wilkinson
* @author Stephane Maldini
*/
public interface Registry extends Iterable> {
/**
* Assign the given {@link reactor.event.selector.Selector} with the given object.
*
* @param sel The left-hand side of the {@literal Selector} comparison check.
* @param obj The object to assign.
* @return {@literal this}
*/
Registration register(Selector sel, V obj);
/**
* Remove any objects matching this {@code key}. This will unregister all objects matching the given
* {@literal key}. There's no provision for removing only a specific object.
*
* @param key The key to be matched by the Selectors
* @return {@literal true} if any objects were unassigned, {@literal false} otherwise.
*/
boolean unregister(Object key);
/**
* Select {@link Registration}s whose {@link Selector} {@link Selector#matches(Object)} the given {@code key}.
*
* @param key The key for the Selectors to match
* @return A {@link List} of {@link Registration}s whose {@link Selector} matches the given key.
*/
List> select(Object key);
/**
* Clear the {@link Registry}, resetting its state and calling {@link Registration#cancel()} for any active {@link
* Registration}.
*/
void clear();
}