<commit_before>package org.axonframework.eventsourcing.eventstore;

import org.axonframework.serialization.RevisionResolver;
import org.axonframework.serialization.SerializedType;

import java.util.Optional;

import static org.axonframework.common.ObjectUtils.getOrDefault;

/**
 * A simple {@link org.axonframework.serialization.RevisionResolver} based implementation of
 * SnapshotJury. Decides whether to use a snapshot based on the current aggregate revision and the current snapshot
 * revision. It simply does an 'equals' match and does not consider the order of revisions.
 *
 * @author <NAME>
 * @since 3.3
 */
public class RevisionBasedSnapshotJury implements SnapshotJury {

    private final RevisionResolver resolver;

    /**
     * Initializes a RevisionBasedSnapshotJury with given {@code resolver}.
     *
     * @param resolver Resolver of type {@link org.axonframework.serialization.RevisionResolver } to resolve the
     *                 revision of aggregate corresponding to the snapshot
     */
    public RevisionBasedSnapshotJury(RevisionResolver resolver) {
        this.resolver = resolver;
    }

    @Override
    public boolean decide(DomainEventData<?> snapshot) {
        final SerializedType payloadType = snapshot.getPayload().getType();
        final Optional<String> payloadRevision = Optional.ofNullable(payloadType.getRevision());
        final Optional<String> aggregateRevision;
        try {
            aggregateRevision = Optional.ofNullable(resolver.revisionOf(Class.forName(payloadType.getName())));<commit_msg>remove unused import<commit_after>package org.axonframework.eventsourcing.eventstore;

import org.axonframework.serialization.RevisionResolver;
import org.axonframework.serialization.SerializedType;

import java.util.Optional;

/**
 * A simple {@link org.axonframework.serialization.RevisionResolver} based implementation of
 * SnapshotJury. Decides whether to use a snapshot based on the current aggregate revision and the current snapshot
 * revision. It simply does an 'equals' match and does not consider the order of revisions.
 *
 * @author <NAME>
 * @since 3.3
 */
public class RevisionBasedSnapshotJury implements SnapshotJury {

    private final RevisionResolver resolver;

    /**
     * Initializes a RevisionBasedSnapshotJury with given {@code resolver}.
     *
     * @param resolver Resolver of type {@link org.axonframework.serialization.RevisionResolver } to resolve the
     *                 revision of aggregate corresponding to the snapshot
     */
    public RevisionBasedSnapshotJury(RevisionResolver resolver) {
        this.resolver = resolver;
    }

    @Override
    public boolean decide(DomainEventData<?> snapshot) {
        final SerializedType payloadType = snapshot.getPayload().getType();
        final Optional<String> payloadRevision = Optional.ofNullable(payloadType.getRevision());
        final Optional<String> aggregateRevision;
        try {
            aggregateRevision = Optional.ofNullable(resolver.revisionOf(Class.forName(payloadType.getName())));
{'fraction_non_alphanumeric': 0.07828365542089748, 'fraction_numerical': 0.0013101867016049786, 'mean_word_length': 4.064676616915423, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1923786', 'n_tokens_mistral': 780, 'n_tokens_neox': 746, 'n_words': 220}