001package ca.uhn.fhir.context; 002 003import java.util.ArrayList; 004import java.util.Collections; 005import java.util.List; 006import java.util.StringTokenizer; 007 008import ca.uhn.fhir.rest.method.RestSearchParameterTypeEnum; 009 010/* 011 * #%L 012 * HAPI FHIR - Core Library 013 * %% 014 * Copyright (C) 2014 - 2016 University Health Network 015 * %% 016 * Licensed under the Apache License, Version 2.0 (the "License"); 017 * you may not use this file except in compliance with the License. 018 * You may obtain a copy of the License at 019 * 020 * http://www.apache.org/licenses/LICENSE-2.0 021 * 022 * Unless required by applicable law or agreed to in writing, software 023 * distributed under the License is distributed on an "AS IS" BASIS, 024 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 025 * See the License for the specific language governing permissions and 026 * limitations under the License. 027 * #L% 028 */ 029 030public class RuntimeSearchParam { 031 032 private String myDescription; 033 private String myName; 034 private RestSearchParameterTypeEnum myParamType; 035 private String myPath; 036 private List<RuntimeSearchParam> myCompositeOf; 037 038 public RuntimeSearchParam(String theName, String theDescription, String thePath, RestSearchParameterTypeEnum theParamType) { 039 this(theName, theDescription, thePath, theParamType, null); 040 } 041 042 public RuntimeSearchParam(String theName, String theDescription, String thePath, RestSearchParameterTypeEnum theParamType, List<RuntimeSearchParam> theCompositeOf) { 043 super(); 044 myName = theName; 045 myDescription = theDescription; 046 myPath = thePath; 047 myParamType = theParamType; 048 myCompositeOf = theCompositeOf; 049 } 050 051 public List<RuntimeSearchParam> getCompositeOf() { 052 return myCompositeOf; 053 } 054 055 public String getDescription() { 056 return myDescription; 057 } 058 059 public String getName() { 060 return myName; 061 } 062 063 public RestSearchParameterTypeEnum getParamType() { 064 return myParamType; 065 } 066 067 public String getPath() { 068 return myPath; 069 } 070 071 public List<String> getPathsSplit() { 072 String path = getPath(); 073 if (path.indexOf('|')==-1) { 074 return Collections.singletonList(path); 075 } 076 077 List<String> retVal = new ArrayList<String>(); 078 StringTokenizer tok = new StringTokenizer(path, "|"); 079 while (tok.hasMoreElements()) { 080 String nextPath = tok.nextToken().trim(); 081 retVal.add(nextPath.trim()); 082 } 083 return retVal; 084 } 085 086}