Module ultimategdbot.api
Interface ConfigEntry<T>
-
- Type Parameters:
T
- the type of value this entry can read and write
- All Known Implementing Classes:
BooleanConfigEntry
,GuildChannelConfigEntry
,GuildMemberConfigEntry
,GuildRoleConfigEntry
,IntegerConfigEntry
,LongConfigEntry
,StringConfigEntry
public interface ConfigEntry<T>
Represents a guild configuration entry. An entry is uniquely identified by a key, and may have a user-friendly description. An entry also supports reading and writing values in the field represented by this entry. Mutations performed via an entry are reflected to its parentGuildConfigurator
, and are expected to be thread-safe.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description <R> reactor.core.publisher.Mono<R>
accept(ConfigEntryVisitor<R> visitor)
Accepts a visitor to visit the concrete type of this config entry.String
getDisplayName()
Gets the display name of this entry.discord4j.rest.util.Snowflake
getGuildId()
Gets the ID of the guild this config entry is attached to.String
getKey()
Gets the unique key of this entry.reactor.core.publisher.Mono<T>
getValue()
Gets the current value of this entry.boolean
isReadOnly()
Tells whether this entry is read-only.reactor.core.publisher.Mono<Void>
setValue(T newValue)
Sets a new value for this entry.
-
-
-
Method Detail
-
getGuildId
discord4j.rest.util.Snowflake getGuildId()
Gets the ID of the guild this config entry is attached to.- Returns:
- the guild ID
-
getDisplayName
String getDisplayName()
Gets the display name of this entry.- Returns:
- the name
-
getKey
String getKey()
Gets the unique key of this entry.- Returns:
- the key
-
isReadOnly
boolean isReadOnly()
Tells whether this entry is read-only. If this method returns true, any call tosetValue(Object)
will result in a Mono emittingReadOnlyConfigEntryException
.- Returns:
- true if read-only
-
getValue
reactor.core.publisher.Mono<T> getValue()
Gets the current value of this entry.- Returns:
- the value
-
setValue
reactor.core.publisher.Mono<Void> setValue(@Nullable T newValue)
Sets a new value for this entry. The value is first validated using the validator held by this entry. If validation is successful, the value is set and the returned Mono completes. If the validation fails, the value is not set, andValidationException
is emitted instead.- Parameters:
newValue
- the new value for this entry, may be null- Returns:
- a Mono completing when value is validated and set, or
ValidationException
if validation fails
-
accept
<R> reactor.core.publisher.Mono<R> accept(ConfigEntryVisitor<R> visitor)
Accepts a visitor to visit the concrete type of this config entry.- Type Parameters:
R
- the return value type of the visitor- Parameters:
visitor
- the visitor to accept- Returns:
- a Mono emitting the result of the visit
-
-