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.bean.jsonpatch; 018 019import java.util.*; 020 021/** 022 * Represents a JSON Patch document per 023 * <a href="https://datatracker.ietf.org/doc/html/rfc6902">RFC 6902</a>. 024 * 025 * <p> 026 * A JSON Patch document is a JSON array of operation objects; this type therefore extends 027 * {@link LinkedList} of {@link JsonPatchOperation}. Mirrors the top-level-array pattern used by 028 * {@code JsonSchemaArray} - no {@code @Json(wrapperAttr=...)} wrapping. 029 * 030 * @serial exclude 031 */ 032public class JsonPatch extends LinkedList<JsonPatchOperation> { 033 034 private static final long serialVersionUID = 1L; 035 036 /** 037 * Default constructor. 038 */ 039 public JsonPatch() {} 040 041 /** 042 * Constructor with predefined operations to add to this patch. 043 * 044 * @param value The operations in this patch. 045 */ 046 public JsonPatch(JsonPatchOperation...value) { 047 append(value); 048 } 049 050 /** 051 * Convenience method for appending one or more {@link JsonPatchOperation} objects to this patch. 052 * 053 * @param value The operations to append. 054 * @return This object. 055 */ 056 public JsonPatch append(JsonPatchOperation...value) { 057 Collections.addAll(this, value); 058 return this; 059 } 060}