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.swagger;
018
019import org.apache.juneau.commons.utils.*;
020
021/**
022 * Copy utilities for the Swagger 2.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.swagger.SwaggerCopyUtils.*;</c>) brings in both the inherited
027 * collection/map/array <c>copyOf(...)</c> overloads <b>and</b> the Swagger 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 SwaggerCopyUtils extends CopyUtils {
035
036   /** Constructor. */
037   protected SwaggerCopyUtils() {}
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 Contact copyOf(Contact 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 ExternalDocumentation copyOf(ExternalDocumentation 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 Info copyOf(Info 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 Items copyOf(Items 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 License copyOf(License 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 SchemaInfo copyOf(SchemaInfo 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 Xml copyOf(Xml value) {
106      return value == null ? null : value.copy();
107   }
108}