1
0
Fork 0
mirror of https://github.com/pgpainless/pgpainless.git synced 2024-11-26 22:32:07 +01:00

Document KeyRingSelectionStrategy

This commit is contained in:
Paul Schaub 2022-04-04 12:32:37 +02:00
parent bfbe03f9e0
commit 7ca9934cbe
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311

View file

@ -8,11 +8,41 @@ import java.util.Set;
import org.pgpainless.util.MultiMap; import org.pgpainless.util.MultiMap;
/**
*
* @param <R> Type of {@link org.bouncycastle.openpgp.PGPKeyRing} ({@link org.bouncycastle.openpgp.PGPSecretKeyRing}
* or {@link org.bouncycastle.openpgp.PGPPublicKeyRing}).
* @param <C> Type of key ring collection (e.g. {@link org.bouncycastle.openpgp.PGPSecretKeyRingCollection}
* or {@link org.bouncycastle.openpgp.PGPPublicKeyRingCollection}).
* @param <O> Type of key identifier
*/
public interface KeyRingSelectionStrategy<R, C, O> { public interface KeyRingSelectionStrategy<R, C, O> {
/**
* Return true, if the filter accepts the given <pre>keyRing</pre> based on the given <pre>identifier</pre>.
*
* @param identifier identifier
* @param keyRing key ring
* @return acceptance
*/
boolean accept(O identifier, R keyRing); boolean accept(O identifier, R keyRing);
/**
* Iterate of the given <pre>keyRingCollection</pre> and return a {@link Set} of all acceptable
* keyRings in the collection, based on the given <pre>identifier</pre>.
*
* @param identifier identifier
* @param keyRingCollection collection
* @return set of acceptable key rings
*/
Set<R> selectKeyRingsFromCollection(O identifier, C keyRingCollection); Set<R> selectKeyRingsFromCollection(O identifier, C keyRingCollection);
/**
* Iterate over all keyRings in the given {@link MultiMap} of keyRingCollections and return a new {@link MultiMap}
* which for every identifier (key of the map) contains all acceptable keyRings based on that identifier.
*
* @param keyRingCollections MultiMap of identifiers and keyRingCollections.
* @return MultiMap of identifiers and acceptable keyRings.
*/
MultiMap<O, R> selectKeyRingsFromCollections(MultiMap<O, C> keyRingCollections); MultiMap<O, R> selectKeyRingsFromCollections(MultiMap<O, C> keyRingCollections);
} }