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

net.dv8tion.jda.api.interactions.components.LayoutComponent Maven / Gradle / Ivy

Go to download

Java wrapper for the popular chat & VOIP service: Discord https://discord.com

There is a newer version: 5.1.0
Show newest version
/*
 * Copyright 2015 Austin Keener, Michael Ritter, Florian Spieß, and the JDA contributors
 *
 * 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 net.dv8tion.jda.api.interactions.components;

import net.dv8tion.jda.api.interactions.components.buttons.Button;
import net.dv8tion.jda.api.interactions.components.buttons.ButtonStyle;
import net.dv8tion.jda.api.utils.data.SerializableData;
import net.dv8tion.jda.internal.utils.Checks;

import javax.annotation.CheckReturnValue;
import javax.annotation.Nonnull;
import javax.annotation.Nullable;
import java.util.*;
import java.util.stream.Collectors;

/**
 * Represents a top-level layout used for {@link ItemComponent ItemComponents} such as {@link Button Buttons}.
 *
 * 

Components must always be contained within such a layout. * * @see ActionRow */ public interface LayoutComponent extends SerializableData, Iterable, Component { /** * List representation of this component layout. *
This list is modifiable. Note that empty layouts are not supported. * * @return {@link List} of components in this layout */ @Nonnull List getComponents(); @Override default boolean isMessageCompatible() { if (!getType().isMessageCompatible()) return false; return getComponents().stream().allMatch(ItemComponent::isMessageCompatible); } @Override default boolean isModalCompatible() { if (!getType().isModalCompatible()) return false; return getComponents().stream().allMatch(ItemComponent::isModalCompatible); } /** * Immutable filtered copy of {@link #getComponents()} elements which are {@link ActionComponent ActionComponents}. * * @return Immutable {@link List} copy of {@link ActionComponent ActionComponents} in this layout */ @Nonnull default List getActionComponents() { return getComponents().stream() .filter(ActionComponent.class::isInstance) .map(ActionComponent.class::cast) .collect(Collectors.toList()); } /** * List of buttons in this component layout. * * @return Immutable {@link List} of {@link Button Buttons} */ @Nonnull default List





© 2015 - 2024 Weber Informatics LLC | Privacy Policy