001package org.hl7.fhir.r4.model; 002 003/*- 004 * #%L 005 * org.hl7.fhir.r4 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 java.util.Map; 024 025import org.hl7.fhir.r4.utils.FHIRPathEngine; 026 027/** 028 * This class is the base class for Profile classes - whether generated or manual 029 * 030 * @author Grahame Grieve 031 * 032 */ 033public class ProfilingWrapper { 034 035 // some discriminators require on features of external resources 036 // to do slice matching. This provides external services to match 037 public interface IResourceResolver { 038 Resource resolve(Base context, Base resource, Base reference); 039 } 040 041 // context 042 private Base context; // bundle, if one is present and related; sole use is to pass to IResourceResolver.resolve as context 043 private Base resource; // resource that contains the wrapped object 044 protected Base wrapped; // the actual wrapped object 045 046 // FHIRPath engine 047 private Map<String, ExpressionNode> cache; 048 private FHIRPathEngine engine; 049 050 public ProfilingWrapper(Base context, Base resource, Base wrapped) { 051 super(); 052 this.context = context; 053 this.resource = resource; 054 this.wrapped = wrapped; 055 } 056 057 public ProfilingWrapper(Base context, Base resource) { 058 super(); 059 this.context = context; 060 this.resource = resource; 061 this.wrapped = resource; 062 } 063 064 /** 065 * This is a convenient called for 066 * @param object 067 * @return 068 */ 069 private ProfilingWrapper wrap(Base object) { 070 ProfilingWrapper res = new ProfilingWrapper(context, resource, object); 071 res.cache = cache; 072 res.engine = engine; 073 return res; 074 } 075 076 077}