jenkinsci / jenkinsci/credentials-plugin
Switch `CredentialsMatcher` implementations to be `record`s
- 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
Assessment
This issue has not been assessed yet.