jenkinsci / jenkinsci/credentials-plugin

Switch `CredentialsMatcher` implementations to be `record`s

Open
#1,002 1 comment 0 reactions 0 assignees View on GitHub
Dominant language
Java
Stars
134
Forks
258
Avg merge
48m
Merged PRs (30d)
1

Description

As a follow-up to #1001, it would be nice to simplify `Matcher` implementations. For example `IdMatcher` could be reduced to just

```java
public record IdMatcher(@NonNull String id) implements CredentialsMatcher {
@Override
public boolean matches(@NonNull Credentials item) {
return item instanceof IdCredentials idc && id.equals(idc.getId());
}
}
```

This would replace the advice in https://github.com/jenkinsci/credentials-plugin/blob/36c1cee14873c854cb5b46030c0a35a5f68fe05f/src/main/java/com/cloudbees/plugins/credentials/CredentialsMatcher.java#L32-L34

It is important to retain binary compatibility for the constructors, since many plugins appear to instantiate at least `IdCredentials` directly rather than going through `CredentialsMatchers.withId`.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.