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