001package org.hl7.fhir.r5.openapi;
002
003/*-
004 * #%L
005 * org.hl7.fhir.r5
006 * %%
007 * Copyright (C) 2014 - 2019 Health Level 7
008 * %%
009 * Licensed under the Apache License, Version 2.0 (the "License");
010 * you may not use this file except in compliance with the License.
011 * You may obtain a copy of the License at
012 * 
013 *      http://www.apache.org/licenses/LICENSE-2.0
014 * 
015 * Unless required by applicable law or agreed to in writing, software
016 * distributed under the License is distributed on an "AS IS" BASIS,
017 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
018 * See the License for the specific language governing permissions and
019 * limitations under the License.
020 * #L%
021 */
022
023
024
025import org.hl7.fhir.utilities.Utilities;
026
027import com.google.gson.JsonObject;
028
029public class InfoWriter extends BaseWriter {
030
031
032  public InfoWriter(JsonObject object) {
033    super(object);
034  }
035
036  public InfoWriter title(String value) {
037    if (!Utilities.noString(value))
038      object.addProperty("title", value);
039    return this;            
040  }
041
042  public InfoWriter description(String value) {
043    if (!Utilities.noString(value))
044      object.addProperty("description", value);
045    return this;            
046  }
047  
048  public InfoWriter termsOfService(String value) {
049    if (!Utilities.noString(value))
050      object.addProperty("termsOfService", value);
051    return this;            
052  }
053
054  public InfoWriter version(String value) {
055    if (!Utilities.noString(value))
056      object.addProperty("version", value);
057    return this;            
058  }
059
060  public InfoWriter contact(String name, String email, String url) {
061    if (name != null && !object.has("contact")) {
062      JsonObject person = new JsonObject();
063      person.addProperty("name", name);
064      if (!Utilities.noString(email))
065        person.addProperty("email", email);
066      if (!Utilities.noString(url))
067        person.addProperty("url", url);
068      object.add("contact", person);
069    }
070    return this;            
071  }
072  
073  public InfoWriter license(String name, String url) {
074    JsonObject license = new JsonObject();
075    license.addProperty("name", name);
076    if (!Utilities.noString(url))
077      license.addProperty("url", url);
078    object.add("license", license);
079    return this;            
080  }
081  
082  
083}