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.openapi3;
018
019import org.apache.juneau.commons.utils.*;
020
021/**
022 * Copy utilities for the OpenAPI 3.0 bean module.
023 *
024 * <p>
025 * Extends {@link CopyUtils} so that a single static-import-on-demand of this class
026 * (<c>import static org.apache.juneau.bean.openapi3.OpenApiCopyUtils.*;</c>) brings in both the inherited
027 * collection/map/array <c>copyOf(...)</c> overloads <b>and</b> the OpenAPI bean <c>copyOf(&lt;BeanType&gt;)</c>
028 * overloads declared here, resolved via ordinary Java overload resolution.
029 *
030 * <h5 class='section'>See Also:</h5><ul>
031 *    <li class='jc'>{@link CopyUtils}
032 * </ul>
033 */
034public class OpenApiCopyUtils extends CopyUtils {
035
036   /** Constructor. */
037   protected OpenApiCopyUtils() {}
038
039   /**
040    * Null-safe copy: returns a deep copy of the specified value, or <jk>null</jk> if the value is <jk>null</jk>.
041    *
042    * @param value The value to copy.  Can be <jk>null</jk> (returns <jk>null</jk>).
043    * @return A copy of the value, or <jk>null</jk> if the value was <jk>null</jk>.
044    */
045   public static Components copyOf(Components value) {
046      return value == null ? null : value.copy();
047   }
048
049   /**
050    * Null-safe copy: returns a deep copy of the specified value, or <jk>null</jk> if the value is <jk>null</jk>.
051    *
052    * @param value The value to copy.  Can be <jk>null</jk> (returns <jk>null</jk>).
053    * @return A copy of the value, or <jk>null</jk> if the value was <jk>null</jk>.
054    */
055   public static Contact copyOf(Contact value) {
056      return value == null ? null : value.copy();
057   }
058
059   /**
060    * Null-safe copy: returns a deep copy of the specified value, or <jk>null</jk> if the value is <jk>null</jk>.
061    *
062    * @param value The value to copy.  Can be <jk>null</jk> (returns <jk>null</jk>).
063    * @return A copy of the value, or <jk>null</jk> if the value was <jk>null</jk>.
064    */
065   public static Discriminator copyOf(Discriminator value) {
066      return value == null ? null : value.copy();
067   }
068
069   /**
070    * Null-safe copy: returns a deep copy of the specified value, or <jk>null</jk> if the value is <jk>null</jk>.
071    *
072    * @param value The value to copy.  Can be <jk>null</jk> (returns <jk>null</jk>).
073    * @return A copy of the value, or <jk>null</jk> if the value was <jk>null</jk>.
074    */
075   public static ExternalDocumentation copyOf(ExternalDocumentation value) {
076      return value == null ? null : value.copy();
077   }
078
079   /**
080    * Null-safe copy: returns a deep copy of the specified value, or <jk>null</jk> if the value is <jk>null</jk>.
081    *
082    * @param value The value to copy.  Can be <jk>null</jk> (returns <jk>null</jk>).
083    * @return A copy of the value, or <jk>null</jk> if the value was <jk>null</jk>.
084    */
085   public static Info copyOf(Info value) {
086      return value == null ? null : value.copy();
087   }
088
089   /**
090    * Null-safe copy: returns a deep copy of the specified value, or <jk>null</jk> if the value is <jk>null</jk>.
091    *
092    * @param value The value to copy.  Can be <jk>null</jk> (returns <jk>null</jk>).
093    * @return A copy of the value, or <jk>null</jk> if the value was <jk>null</jk>.
094    */
095   public static Items copyOf(Items value) {
096      return value == null ? null : value.copy();
097   }
098
099   /**
100    * Null-safe copy: returns a deep copy of the specified value, or <jk>null</jk> if the value is <jk>null</jk>.
101    *
102    * @param value The value to copy.  Can be <jk>null</jk> (returns <jk>null</jk>).
103    * @return A copy of the value, or <jk>null</jk> if the value was <jk>null</jk>.
104    */
105   public static License copyOf(License value) {
106      return value == null ? null : value.copy();
107   }
108
109   /**
110    * Null-safe copy: returns a deep copy of the specified value, or <jk>null</jk> if the value is <jk>null</jk>.
111    *
112    * @param value The value to copy.  Can be <jk>null</jk> (returns <jk>null</jk>).
113    * @return A copy of the value, or <jk>null</jk> if the value was <jk>null</jk>.
114    */
115   public static OAuthFlow copyOf(OAuthFlow value) {
116      return value == null ? null : value.copy();
117   }
118
119   /**
120    * Null-safe copy: returns a deep copy of the specified value, or <jk>null</jk> if the value is <jk>null</jk>.
121    *
122    * @param value The value to copy.  Can be <jk>null</jk> (returns <jk>null</jk>).
123    * @return A copy of the value, or <jk>null</jk> if the value was <jk>null</jk>.
124    */
125   public static Operation copyOf(Operation value) {
126      return value == null ? null : value.copy();
127   }
128
129   /**
130    * Null-safe copy: returns a deep copy of the specified value, or <jk>null</jk> if the value is <jk>null</jk>.
131    *
132    * @param value The value to copy.  Can be <jk>null</jk> (returns <jk>null</jk>).
133    * @return A copy of the value, or <jk>null</jk> if the value was <jk>null</jk>.
134    */
135   public static RequestBodyInfo copyOf(RequestBodyInfo value) {
136      return value == null ? null : value.copy();
137   }
138
139   /**
140    * Null-safe copy: returns a deep copy of the specified value, or <jk>null</jk> if the value is <jk>null</jk>.
141    *
142    * @param value The value to copy.  Can be <jk>null</jk> (returns <jk>null</jk>).
143    * @return A copy of the value, or <jk>null</jk> if the value was <jk>null</jk>.
144    */
145   public static SchemaInfo copyOf(SchemaInfo value) {
146      return value == null ? null : value.copy();
147   }
148
149   /**
150    * Null-safe copy: returns a deep copy of the specified value, or <jk>null</jk> if the value is <jk>null</jk>.
151    *
152    * @param value The value to copy.  Can be <jk>null</jk> (returns <jk>null</jk>).
153    * @return A copy of the value, or <jk>null</jk> if the value was <jk>null</jk>.
154    */
155   public static Server copyOf(Server value) {
156      return value == null ? null : value.copy();
157   }
158
159   /**
160    * Null-safe copy: returns a deep copy of the specified value, or <jk>null</jk> if the value is <jk>null</jk>.
161    *
162    * @param value The value to copy.  Can be <jk>null</jk> (returns <jk>null</jk>).
163    * @return A copy of the value, or <jk>null</jk> if the value was <jk>null</jk>.
164    */
165   public static Xml copyOf(Xml value) {
166      return value == null ? null : value.copy();
167   }
168}