Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagejava
titleDelete Results
package org.apache.kafka.server.authorizer;

import java.util.Collections;
import java.util.SetCollection;
import org.apache.kafka.common.acl.AclBinding;
import org.apache.kafka.common.errors.ApiException;

public class AclDeleteResult {
    private final ApiException exception;
    private final Set<DeleteResult>Collection<DeletionResult> deleteResultsdeletionResults;

    public AclDeleteResult(ApiException exception) {
        this(Collections.emptySet(), exception);
    }

    public AclDeleteResult(Set<DeleteResult>Collection<DeletionResult> deleteResults) {
        this(deleteResults, null);
    }

    private AclDeleteResult(Set<DeleteResult>Collection<DeletionResult> deleteResults, ApiException exception) {
        this.deleteResultsdeletionResults = deleteResults;
        this.exception = exception;
    }

    /**
     * Returns any exception while attempting to match ACL filter to delete ACLs.
     */
    public ApiException exception() {
        return exception;
    }

    /**
     * Returns delete result for each matching ACL binding.
     */
    public Set<DeleteResult>Collection<DeletionResult> deleteResultsdeletionResults() {
        return deleteResultsdeletionResults;
    }


    /**
     * Delete result for each ACL binding that matched a delete filter.
     */
    public static class DeleteResultDeletionResult {
        private final AclBinding aclBinding;
        private final ApiException exception;

        public DeleteResultDeletionResult(AclBinding aclBinding) {
            this(aclBinding, null);
        }

        public DeleteResultDeletionResult(AclBinding aclBinding, ApiException exception) {
            this.aclBinding = aclBinding;
            this.exception = exception;
        }

        /**
         * Returns ACL binding that matched the delete filter. {@link #deleted()} indicates if
         * the binding was deleted.
         */
        public AclBinding aclBinding() {
            return aclBinding;
        }

        /**
         * Returns exception that resulted in failure to delete ACL binding.
         */
        public ApiException exception() {
            return exception;
        }

        /**
         * Returns true if ACL binding was deleted, false otherwise.
         */
        public boolean deleted() {
            return exception == null;
        }
    }
}

...