Package org.pgpainless.util.selection.userid

# Class SelectUserId

java.lang.Object
org.pgpainless.util.selection.userid.SelectUserId

public abstract class SelectUserId extends Object
Filter for selecting user-ids from keys and from lists.

## Constructor Summary

Constructors
Constructor
Description
`SelectUserId()`

## Method Summary

Modifier and Type
Method
Description
`protected abstract boolean`
`accept(String userId)`
Return true, if the given user-id is accepted by this particular filter, false otherwise.
`static SelectUserId`
`and(SelectUserId... filters)`
Filter that filters for user-ids which pass all the given
`static SelectUserId`
`byEmail(CharSequence email)`
Filter that selects user-ids by the given
`static SelectUserId`
`containsEmailAddress(CharSequence email)`
Filter that filters for user-ids which contain the given
`static SelectUserId`
`containsSubstring(CharSequence query)`
Filter that filters for user-ids which contain the given
`static SelectUserId`
`exactMatch(CharSequence query)`
Filter that filters for user-ids which match the given
`String`
`firstMatch(List<String> userIds)`
Return the first valid, acceptable user-id from the list of user-ids.
`String`
`firstMatch(org.bouncycastle.openpgp.PGPKeyRing keyRing)`
Return the first valid, acceptable user-id from the given public or secret key ring.
`static SelectUserId`
`not(SelectUserId filter)`
Filter that inverts the result of the given
`static SelectUserId`
`or(SelectUserId... filters)`
Filter that filters for user-ids which pass at least one of the given
`List<String>`
`selectUserIds(List<String> userIds)`
Select all acceptable (see `accept(String)`) from the given list of user-ids.
`List<String>`
`selectUserIds(org.bouncycastle.openpgp.PGPKeyRing keyRing)`
Select all currently valid user-ids of the given key ring.
`static SelectUserId`
`startsWith(CharSequence substring)`
Filter that filters for user-ids which start with the given
`static SelectUserId`
`validUserId(org.bouncycastle.openpgp.PGPKeyRing keyRing)`
Filter that filters for valid user-ids on the given

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

## Constructor Details

### SelectUserId

public SelectUserId()

## Method Details

### accept

protected abstract boolean accept(String userId)
Return true, if the given user-id is accepted by this particular filter, false otherwise.

Parameters:
  `userId` - user-id
Returns:
  acceptance of the filter

### selectUserIds

@Nonnull public List<String> selectUserIds(@Nonnull org.bouncycastle.openpgp.PGPKeyRing keyRing)
Select all currently valid user-ids of the given key ring.

Parameters:
  `keyRing` - public or secret key ring
Returns:
  valid user-ids

### selectUserIds

@Nonnull public List<String> selectUserIds(@Nonnull List<String> userIds)
Select all acceptable (see `accept(String)`) from the given list of user-ids.

Parameters:
  `userIds` - list of user-ids
Returns:
  sub-list of acceptable user-ids

### firstMatch

@Nullable public String firstMatch(org.bouncycastle.openpgp.PGPKeyRing keyRing)
Return the first valid, acceptable user-id from the given public or secret key ring.

Parameters:
  `keyRing` - public or secret key ring
Returns:
  first matching valid user-id or null

### firstMatch

@Nullable public String firstMatch(@Nonnull List<String> userIds)
Return the first valid, acceptable user-id from the list of user-ids.

Parameters:
  `userIds` - list of user-ids
Returns:
  first matching valid user-id or null

### containsSubstring

public static SelectUserId containsSubstring(@Nonnull CharSequence query)
Filter that filters for user-ids which contain the given

    query

as a substring.

Parameters:
  `query` - query
Returns:
  filter

### exactMatch

public static SelectUserId exactMatch(@Nonnull CharSequence query)
Filter that filters for user-ids which match the given

    query

exactly.

Parameters:
  `query` - query
Returns:
  filter

### startsWith

public static SelectUserId startsWith(@Nonnull CharSequence substring)
Filter that filters for user-ids which start with the given

    substring

.

Parameters:
  `substring` - substring
Returns:
  filter

### containsEmailAddress

public static SelectUserId containsEmailAddress(@Nonnull CharSequence email)
Filter that filters for user-ids which contain the given

    email

address. Note: This only accepts user-ids which properly have the email address surrounded by angle brackets. The argument

    email

can both be a plain email address (

    "foo@bar.baz"

), or surrounded by angle brackets (`<pre>"<foo@bar.baz>"</pre>`), the result of the filter will be the same.

Parameters:
  `email` - email address
Returns:
  filter

### validUserId

public static SelectUserId validUserId(org.bouncycastle.openpgp.PGPKeyRing keyRing)
Filter that filters for valid user-ids on the given

    keyRing

only.

Parameters:
  `keyRing` - public / secret keys
Returns:
  filter

### and

public static SelectUserId and(SelectUserId... filters)
Filter that filters for user-ids which pass all the given

    filters

.

Parameters:
  `filters` - filters
Returns:
  filter

### or

public static SelectUserId or(SelectUserId... filters)
Filter that filters for user-ids which pass at least one of the given

    filters

.

Parameters:
  `filters` - filters
Returns:
  filter

### not

public static SelectUserId not(SelectUserId filter)
Filter that inverts the result of the given

    filter

.

Parameters:
  `filter` - filter
Returns:
  inverting filter

### byEmail

public static SelectUserId byEmail(CharSequence email)
Filter that selects user-ids by the given

    email

address. It returns user-ids which either contain the given

    email

address as angle-bracketed string, or which equal the given

    email

string exactly.

Parameters:
  `email` - email
Returns:
  filter