001/* 002 * Copyright 2026 Revetware LLC. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package com.revetsec.scim; 018 019import com.google.errorprone.annotations.CheckReturnValue; 020import org.jspecify.annotations.NonNull; 021import javax.annotation.concurrent.Immutable; 022import static java.util.Objects.requireNonNull; 023 024/** A complete filter evaluation, or a fixed rejection without a partial verdict. 025 * @since 1.0.0 026 */ 027@Immutable 028public sealed interface ScimFilterEvaluationResult permits ScimFilterEvaluationResult.Succeeded, 029 ScimFilterEvaluationResult.Rejected { 030 /** A verdict after every filter clause was checked and evaluated. 031 * @since 1.0.0 032 */ 033 @Immutable 034 final class Succeeded implements ScimFilterEvaluationResult { 035 private final boolean matched; 036 Succeeded(boolean matched) { this.matched = matched; } 037 /** Returns whether the complete filter matched the resource. 038 * @return the complete verdict 039 * @since 1.0.0 040 */ 041 @CheckReturnValue public @NonNull Boolean isMatched() { return matched; } 042 /** Returns a fixed redacted description. 043 * @return the description 044 * @since 1.0.0 045 */ 046 @Override public @NonNull String toString() { return "ScimFilterEvaluationResult.Succeeded{<redacted>}"; } 047 } 048 /** A fixed rejection; no partial verdict or application failure is exposed. 049 * @since 1.0.0 050 */ 051 @Immutable 052 final class Rejected implements ScimFilterEvaluationResult { 053 private final @NonNull ScimError error; 054 Rejected(@NonNull ScimError error) { this.error = requireNonNull(error); } 055 /** Returns the fixed rejection. 056 * @return the error 057 * @since 1.0.0 058 */ 059 @CheckReturnValue public @NonNull ScimError getError() { return error; } 060 /** Returns a fixed redacted description. 061 * @return the description 062 * @since 1.0.0 063 */ 064 @Override public @NonNull String toString() { return "ScimFilterEvaluationResult.Rejected{<redacted>}"; } 065 } 066}