[Add] Framework-API 为 BotCode 添加 'hasProperty(String)' 方法以用于检查某参数是否存在;

[Add] BotCode 添加 'hasProperty(String)' 方法以用于检查某参数是否存在;
[Change] AbstractBotCode 添加新方法的实现;
This commit is contained in:
LamGC 2020-11-26 23:41:40 +08:00
parent c7d0ccb3ef
commit 62a46d9348
Signed by: LamGC
GPG Key ID: 6C5AE2A913941E1D
2 changed files with 12 additions and 0 deletions

View File

@ -133,4 +133,8 @@ public abstract class AbstractBotCode implements BotCode {
return Collections.unmodifiableSet(functionProperties.keySet());
}
@Override
public boolean hasProperty(String key) {
return functionProperties.containsKey(Objects.requireNonNull(key));
}
}

View File

@ -68,4 +68,12 @@ public interface BotCode extends Message {
*/
Set<String> getPropertiesKeys();
/**
* 检查指定参数是否存在.
* @param key 待检查的参数名.
* @return 如果存在, 返回 {@code true}.
* @throws NullPointerException key {@code null} 时抛出.
*/
boolean hasProperty(String key);
}