As a follow-up to #1001, it would be nice to simplify Matcher implementations. For example IdMatcher could be reduced to just
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
|
* <li>Implement {@link Object#toString()}</li> |
|
* <li>Implement {@link Object#equals(Object)} and {@link Object#hashCode()}</li> |
|
* <li>Define a {@code serialVersionUID} field to ensure consistent serialization</li> |
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.
As a follow-up to #1001, it would be nice to simplify
Matcherimplementations. For exampleIdMatchercould be reduced to justThis would replace the advice in
credentials-plugin/src/main/java/com/cloudbees/plugins/credentials/CredentialsMatcher.java
Lines 32 to 34 in 36c1cee
It is important to retain binary compatibility for the constructors, since many plugins appear to instantiate at least
IdCredentialsdirectly rather than going throughCredentialsMatchers.withId.