Skip to content

Switch CredentialsMatcher implementations to be records #1002

@jglick

Description

@jglick

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions