net.minestom.server.adventure.ComponentHolder Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of minestom-snapshots Show documentation
Show all versions of minestom-snapshots Show documentation
1.20.4 Lightweight Minecraft server
package net.minestom.server.adventure;
import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.NotNull;
import java.util.Collection;
import java.util.function.Consumer;
import java.util.function.UnaryOperator;
/**
* Represents an object that holds some amount of components.
*
* @param the holding class
*/
public interface ComponentHolder {
/**
* Gets the components held by this object.
*
* @return the components
*/
@NotNull Collection components();
/**
* Returns a copy of this object. For each component this object holds, the operator
* is applied to the copy before returning.
*
* @param operator the operator
* @return the copy
*/
@NotNull T copyWithOperator(@NotNull UnaryOperator operator);
/**
* Visits each component held by this object.
*
* @param visitor the visitor
*/
default void visitComponents(@NotNull Consumer visitor) {
for (Component component : this.components()) {
visitor.accept(component);
}
}
}