001/*
002 * Licensed to the Apache Software Foundation (ASF) under one or more
003 * contributor license agreements.  See the NOTICE file distributed with
004 * this work for additional information regarding copyright ownership.
005 * The ASF licenses this file to You under the Apache License, Version 2.0
006 * (the "License"); you may not use this file except in compliance with
007 * the License.  You may obtain a copy of the License at
008 *
009 *      http://www.apache.org/licenses/LICENSE-2.0
010 *
011 * Unless required by applicable law or agreed to in writing, software
012 * distributed under the License is distributed on an "AS IS" BASIS,
013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
014 * See the License for the specific language governing permissions and
015 * limitations under the License.
016 */
017package org.apache.juneau.rest.server.mcp;
018
019import static org.apache.juneau.commons.utils.Shorts.*;
020
021/**
022 * A single revision-neutral change event published through {@link McpSubscriptions} and fanned out by an
023 * {@link McpSubscriptionBroker} to every matching {@link McpSubscription}.
024 *
025 * <p>
026 * Immutable value carrier. {@link #resourceUri()} is only ever non-{@code null} when {@link #kind()} is
027 * {@link McpChangeKind#RESOURCE_UPDATED}; this is a documented contract of the four {@link McpSubscriptions}
028 * publish methods, not an invariant enforced by this constructor.
029 *
030 * @param kind The change kind. Never {@code null}.
031 * @param resourceUri The affected resource URI, or {@code null} for a list-changed kind.
032 */
033public record McpChangeEvent(McpChangeKind kind, String resourceUri) {
034
035   /**
036    * Canonical constructor.
037    *
038    * @throws IllegalArgumentException If {@code kind} is {@code null}.
039    */
040   public McpChangeEvent {
041      if (kind == null)
042         throw iaex("kind must not be null");
043   }
044}