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; 021 022import javax.annotation.concurrent.Immutable; 023import java.util.Objects; 024 025/** 026 * The outcome of parsing attribute-path syntax. Success does not establish a registered attribute or 027 * grant query permission. 028 * 029 * @since 1.0.0 030 */ 031@Immutable 032@CheckReturnValue 033public sealed interface ScimAttributePathParseResult permits ScimAttributePathParseResult.Succeeded, 034 ScimAttributePathParseResult.Rejected { 035 /** 036 * A syntactically valid, immutable attribute path. 037 * 038 * @since 1.0.0 039 */ 040 @Immutable 041 final class Succeeded implements ScimAttributePathParseResult { 042 private final @NonNull ScimAttributePath attributePath; 043 044 Succeeded(@NonNull ScimAttributePath attributePath) { 045 this.attributePath = Objects.requireNonNull(attributePath); 046 } 047 048 /** 049 * Returns the syntactically valid path. 050 * 051 * @return the path 052 * @since 1.0.0 053 */ 054 public @NonNull ScimAttributePath getAttributePath() { 055 return attributePath; 056 } 057 058 /** 059 * Returns a redacted description. 060 * 061 * @return a redacted description 062 * @since 1.0.0 063 */ 064 @Override public @NonNull String toString() { 065 return "ScimAttributePathParseResult.Succeeded{<redacted>}"; 066 } 067 } 068 069 /** 070 * A fixed rejection without retained input or an exception cause. 071 * 072 * @since 1.0.0 073 */ 074 @Immutable 075 final class Rejected implements ScimAttributePathParseResult { 076 private final @NonNull ScimError error; 077 078 Rejected(@NonNull ScimError error) { 079 this.error = Objects.requireNonNull(error); 080 } 081 082 /** 083 * Returns the fixed error and its optional expression offset. 084 * 085 * @return the error 086 * @since 1.0.0 087 */ 088 public @NonNull ScimError getError() { 089 return error; 090 } 091 092 /** 093 * Returns a redacted description. 094 * 095 * @return a redacted description 096 * @since 1.0.0 097 */ 098 @Override public @NonNull String toString() { 099 return "ScimAttributePathParseResult.Rejected{<redacted>}"; 100 } 101 } 102}