org.junit.jupiter.engine.extension.ExtensionRegistry Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of junit-jupiter-engine Show documentation
Show all versions of junit-jupiter-engine Show documentation
Module "junit-jupiter-engine" of JUnit 5.
/*
* Copyright 2015-2022 the original author or authors.
*
* All rights reserved. This program and the accompanying materials are
* made available under the terms of the Eclipse Public License v2.0 which
* accompanies this distribution and is available at
*
* https://www.eclipse.org/legal/epl-v20.html
*/
package org.junit.jupiter.engine.extension;
import static java.util.stream.Collectors.toCollection;
import static org.apiguardian.api.API.Status.INTERNAL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.stream.Stream;
import org.apiguardian.api.API;
import org.junit.jupiter.api.extension.Extension;
/**
* An {@code ExtensionRegistry} holds all registered extensions (i.e.
* instances of {@link Extension}) for a given
* {@link org.junit.platform.engine.support.hierarchical.Node}.
*
* @since 5.0
*/
@API(status = INTERNAL, since = "5.0")
public interface ExtensionRegistry {
/**
* Stream all {@code Extensions} of the specified type that are present
* in this registry or one of its ancestors.
*
* @param extensionType the type of {@link Extension} to stream
* @see #getReversedExtensions(Class)
* @see #getExtensions(Class)
*/
Stream stream(Class extensionType);
/**
* Get all {@code Extensions} of the specified type that are present
* in this registry or one of its ancestors.
*
* @param extensionType the type of {@link Extension} to get
* @see #getReversedExtensions(Class)
* @see #stream(Class)
*/
default List getExtensions(Class extensionType) {
return stream(extensionType).collect(toCollection(ArrayList::new));
}
/**
* Get all {@code Extensions} of the specified type that are present
* in this registry or one of its ancestors, in reverse order.
*
* @param extensionType the type of {@link Extension} to get
* @see #getExtensions(Class)
* @see #stream(Class)
*/
default List getReversedExtensions(Class extensionType) {
List extensions = getExtensions(extensionType);
Collections.reverse(extensions);
return extensions;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy