55 lines
2.0 KiB
Java
55 lines
2.0 KiB
Java
package love.distributedrebirth.no2all.nostr.model.tag;
|
|
|
|
import java.util.Optional;
|
|
|
|
import love.distributedrebirth.no2all.nostr.fire.NoStrFireStackFishWelder;
|
|
import love.distributedrebirth.no2all.nostr.fire.NoStrFireStackWelder;
|
|
import love.distributedrebirth.no2all.nostr.model.NoStrIdentityPublicKey;
|
|
import love.distributedrebirth.no2all.nostr.model.event.NoStrEventTagBase;
|
|
import love.distributedrebirth.no2all.nostr.nip.NoStrImplEventTag;
|
|
import love.distributedrebirth.no2all.nostr.nip.tag.NoStrImplTagP;
|
|
|
|
public final class NoStrTagP extends NoStrEventTagBase<NoStrImplTagP> {
|
|
|
|
public NoStrTagP(NoStrIdentityPublicKey publicKey, Optional<String> relayUrl, Optional<String> petName) {
|
|
super(NoStrImplEventTag.P);
|
|
setMetaArgumentStr(NoStrImplTagP.PUBLIC_KEY, publicKey.getHex());
|
|
setMetaArgumentOptStr(NoStrImplTagP.PET_NAME, petName);
|
|
}
|
|
|
|
public NoStrTagP(String[] args) {
|
|
super(NoStrImplEventTag.E, args);
|
|
}
|
|
|
|
public NoStrIdentityPublicKey getPublicKey() {
|
|
return NoStrIdentityPublicKey.ofHex(getMetaArgument(NoStrImplTagP.PUBLIC_KEY).get());
|
|
}
|
|
|
|
public Optional<String> getPetName() {
|
|
return getMetaArgument(NoStrImplTagP.PET_NAME);
|
|
}
|
|
|
|
public interface FishWelder extends NoStrFireStackFishWelder {
|
|
|
|
default NoStrFireStackWelder tagP(NoStrIdentityPublicKey publicKey, Optional<String> relayUrl, Optional<String> petName) {
|
|
return tag(new NoStrTagP(publicKey, relayUrl, petName));
|
|
}
|
|
|
|
default NoStrFireStackWelder tagP(NoStrIdentityPublicKey publicKey, String relayUrl, String petName) {
|
|
return tagP(publicKey, Optional.of(relayUrl), Optional.of(petName));
|
|
}
|
|
|
|
default NoStrFireStackWelder tagP(NoStrIdentityPublicKey publicKey) {
|
|
return tagP(publicKey, Optional.empty(), Optional.empty());
|
|
}
|
|
|
|
default NoStrFireStackWelder tagPRelayUrl(NoStrIdentityPublicKey publicKey, String relayUrl) {
|
|
return tagP(publicKey, Optional.of(relayUrl), Optional.empty());
|
|
}
|
|
|
|
default NoStrFireStackWelder tagPPetName(NoStrIdentityPublicKey publicKey, String petName) {
|
|
return tagP(publicKey, Optional.empty(), Optional.of(petName));
|
|
}
|
|
}
|
|
}
|