001package org.hl7.fhir.r5.utils; 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 023import org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDefinitionComponent; 024import org.hl7.fhir.r5.model.ImplementationGuide.ImplementationGuideDefinitionParameterComponent; 025 026public class IGHelper { 027 028 029 public static final String EXT_SPREADSHEET = ToolingExtensions.EXT_IGP_SPREADSHEET; 030 public static final String EXT_MAPPING_CSV = ToolingExtensions.EXT_IGP_MAPPING_CSV; 031 public static final String EXT_BUNDLE = ToolingExtensions.EXT_IGP_BUNDLE; 032 public static final String EXT_RESOURCE_INFO = ToolingExtensions.EXT_IGP_RESOURCE_INFO; 033 public static final String EXT_PRIVATE_BASE = ToolingExtensions.EXT_PRIVATE_BASE; 034 035 public static String readStringParameter(ImplementationGuideDefinitionComponent ig, String name) { 036 for (ImplementationGuideDefinitionParameterComponent p : ig.getParameter()) { 037 if (name == p.getCode()) { 038 return p.getValue(); 039 } 040 } 041 return null; 042 } 043 044 public static boolean getBooleanParameter(ImplementationGuideDefinitionComponent ig, String name, boolean defaultValue) { 045 String v = readStringParameter(ig, name); 046 return v == null ? false : Boolean.parseBoolean(v); 047 } 048 049 public static void setParameter(ImplementationGuideDefinitionComponent ig, String name, String value) { 050 for (ImplementationGuideDefinitionParameterComponent p : ig.getParameter()) { 051 if (name == p.getCode()) { 052 p.setValue(value); 053 return; 054 } 055 } 056 ImplementationGuideDefinitionParameterComponent p = ig.addParameter(); 057 p.setCode(name); 058 p.setValue(value); 059 } 060 061 public static void addParameter(ImplementationGuideDefinitionComponent ig, String name, String value) { 062 ImplementationGuideDefinitionParameterComponent p = ig.addParameter(); 063 p.setCode(name); 064 p.setValue(value); 065 } 066 067 public static void setParameter(ImplementationGuideDefinitionComponent ig, String name, boolean value) { 068 setParameter(ig, name, Boolean.toString(value)); 069 } 070 071}