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 static java.util.Objects.requireNonNull;
020
021import com.google.errorprone.annotations.CheckReturnValue;
022
023import org.jspecify.annotations.NonNull;
024
025import java.util.*;
026
027import javax.annotation.concurrent.Immutable;
028
029/** Closed SCIM operation outcome with redacted diagnostics.
030 * @since 1.0.0
031 */
032@Immutable
033public sealed interface ScimIfNoneMatchResult
034        permits ScimIfNoneMatchResult.Proceed,
035                ScimIfNoneMatchResult.NotModified,
036                ScimIfNoneMatchResult.Rejected {
037    /** Proceed outcome.
038     * @since 1.0.0
039     */
040    @Immutable
041    final class Proceed implements ScimIfNoneMatchResult {
042        static final @NonNull Proceed INSTANCE = new Proceed();
043
044        private Proceed() {}
045
046        /** Returns a fixed diagnostic.
047         * @return redacted description
048         * @since 1.0.0
049         */
050        @Override
051        public @NonNull String toString() {
052            return "ScimIfNoneMatchResult.Proceed{<redacted>}";
053        }
054    }
055
056    /** NotModified outcome.
057     * @since 1.0.0
058     */
059    @Immutable
060    final class NotModified implements ScimIfNoneMatchResult {
061        static final @NonNull NotModified INSTANCE = new NotModified();
062
063        private NotModified() {}
064
065        /** Returns a fixed diagnostic.
066         * @return redacted description
067         * @since 1.0.0
068         */
069        @Override
070        public @NonNull String toString() {
071            return "ScimIfNoneMatchResult.NotModified{<redacted>}";
072        }
073    }
074
075    /** Rejected outcome.
076     * @since 1.0.0
077     */
078    @Immutable
079    final class Rejected implements ScimIfNoneMatchResult {
080        private final @NonNull ScimError error;
081
082        Rejected(@NonNull ScimError value) {
083            error = requireNonNull(value);
084        }
085
086        /** Returns the outcome payload.
087         * @return payload
088         * @since 1.0.0
089         */
090        @CheckReturnValue
091        public @NonNull ScimError getError() {
092            return error;
093        }
094
095        /** Returns a fixed diagnostic.
096         * @return redacted description
097         * @since 1.0.0
098         */
099        @Override
100        public @NonNull String toString() {
101            return "ScimIfNoneMatchResult.Rejected{<redacted>}";
102        }
103    }
104}