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 ScimResponseResult 034 permits ScimResponseResult.Prepared, ScimResponseResult.Rejected { 035 /** Prepared outcome. 036 * @since 1.0.0 037 */ 038 @Immutable 039 final class Prepared implements ScimResponseResult { 040 private final @NonNull ScimResponse response; 041 042 Prepared(@NonNull ScimResponse value) { 043 response = requireNonNull(value); 044 } 045 046 /** Returns the outcome payload. 047 * @return payload 048 * @since 1.0.0 049 */ 050 @CheckReturnValue 051 public @NonNull ScimResponse getResponse() { 052 return response; 053 } 054 055 /** Returns a fixed diagnostic. 056 * @return redacted description 057 * @since 1.0.0 058 */ 059 @Override 060 public @NonNull String toString() { 061 return "ScimResponseResult.Prepared{<redacted>}"; 062 } 063 } 064 065 /** Rejected outcome. 066 * @since 1.0.0 067 */ 068 @Immutable 069 final class Rejected implements ScimResponseResult { 070 private final @NonNull ScimError error; 071 072 Rejected(@NonNull ScimError value) { 073 error = requireNonNull(value); 074 } 075 076 /** Returns the outcome payload. 077 * @return payload 078 * @since 1.0.0 079 */ 080 @CheckReturnValue 081 public @NonNull ScimError getError() { 082 return error; 083 } 084 085 /** Returns a fixed diagnostic. 086 * @return redacted description 087 * @since 1.0.0 088 */ 089 @Override 090 public @NonNull String toString() { 091 return "ScimResponseResult.Rejected{<redacted>}"; 092 } 093 } 094}