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 PATCH outcome with fixed rejection diagnostics and no partial success.
025 * @since 1.0.0
026 */
027@Immutable
028public sealed interface ScimPatchApplicationResult permits ScimPatchApplicationResult.Succeeded, ScimPatchApplicationResult.Rejected {
029    /** The complete accepted payload.
030     * @since 1.0.0 */
031    @Immutable final class Succeeded implements ScimPatchApplicationResult {
032        private final @NonNull ScimPatchResult patchResult;
033        Succeeded(@NonNull ScimPatchResult value) { patchResult=requireNonNull(value); }
034        /** Returns the complete accepted payload.
035         * @return the payload
036     * @since 1.0.0 */
037        @CheckReturnValue public @NonNull ScimPatchResult getPatchResult() { return patchResult; }
038        /** Returns a fixed redacted description.
039         * @return the description
040     * @since 1.0.0 */
041        @Override public @NonNull String toString() { return "ScimPatchApplicationResult.Succeeded{<redacted>}"; }
042    }
043    /** A fixed rejection with no partial payload.
044     * @since 1.0.0 */
045    @Immutable final class Rejected implements ScimPatchApplicationResult {
046        private final @NonNull ScimError error;
047        Rejected(@NonNull ScimError value) { error=requireNonNull(value); }
048        /** Returns the fixed rejection.
049         * @return the error
050     * @since 1.0.0 */
051        @CheckReturnValue public @NonNull ScimError getError() { return error; }
052        /** Returns a fixed redacted description.
053         * @return the description
054     * @since 1.0.0 */
055        @Override public @NonNull String toString() { return "ScimPatchApplicationResult.Rejected{<redacted>}"; }
056    }
057}