mirror of
https://github.com/google/nomulus.git
synced 2025-06-27 14:54:51 +02:00
Make EppInput.getSingleExtension() return Optional, not @Nullable
This makes it harder to use it incorrectly by accident. ------------- Created by MOE: https://github.com/google/moe MOE_MIGRATED_REVID=181795813
This commit is contained in:
parent
fbdb148540
commit
315e6d57bf
21 changed files with 290 additions and 239 deletions
|
@ -151,15 +151,15 @@ public class EppInput extends ImmutableObject {
|
|||
}
|
||||
|
||||
/** Get the extension based on type, or null. If there are multiple, it chooses the first. */
|
||||
@Nullable
|
||||
public <E extends CommandExtension> E getSingleExtension(Class<E> clazz) {
|
||||
return getCommandWrapper()
|
||||
.getExtensions()
|
||||
.stream()
|
||||
.filter(clazz::isInstance)
|
||||
.map(clazz::cast)
|
||||
.findFirst()
|
||||
.orElse(null);
|
||||
public <E extends CommandExtension> Optional<E> getSingleExtension(Class<E> clazz) {
|
||||
return Optional.ofNullable(
|
||||
getCommandWrapper()
|
||||
.getExtensions()
|
||||
.stream()
|
||||
.filter(clazz::isInstance)
|
||||
.map(clazz::cast)
|
||||
.findFirst()
|
||||
.orElse(null));
|
||||
}
|
||||
|
||||
/** A tag that goes inside of an EPP {@literal <command>}. */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue