001package ca.uhn.fhir.context; 002 003/* 004 * #%L 005 * HAPI FHIR - Core Library 006 * %% 007 * Copyright (C) 2014 - 2017 University Health Network 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.lang.reflect.Field; 024 025import org.hl7.fhir.instance.model.api.IBase; 026 027import ca.uhn.fhir.model.api.annotation.Child; 028import ca.uhn.fhir.model.api.annotation.Description; 029 030public class RuntimeChildPrimitiveDatatypeDefinition extends BaseRuntimeChildDatatypeDefinition { 031// private static final org.slf4j.Logger ourLog = org.slf4j.LoggerFactory.getLogger(RuntimeChildPrimitiveDatatypeDefinition.class); 032// private IMutator myReferenceMutator; 033 034 public RuntimeChildPrimitiveDatatypeDefinition(Field theField, String theElementName, Description theDescriptionAnnotation, Child theChildAnnotation, Class<? extends IBase> theDatatype) { 035 super(theField, theElementName, theChildAnnotation, theDescriptionAnnotation, theDatatype); 036 } 037 038// @Override 039// void sealAndInitialize(FhirContext theContext, Map<Class<? extends IBase>, BaseRuntimeElementDefinition<?>> theClassToElementDefinitions) { 040// super.sealAndInitialize(theContext, theClassToElementDefinitions); 041// 042// if (theContext.getVersion().getVersion().equals(FhirVersionEnum.DSTU2_HL7ORG)) { 043// if (IReference.class.isAssignableFrom(getDatatype())) { 044// String fieldName = getField().getName() + "Target"; 045// try { 046// Field targetField = getField().getDeclaringClass().getField(fieldName); 047// if (List.class.isAssignableFrom(targetField.getType())) { 048// myReferenceMutator = new FieldListMutator(); 049// } else if (IBaseResource.class.isAssignableFrom(targetField.getType())) { 050// myReferenceMutator = new FieldPlainMutator(); 051// } 052// } catch (Exception e) { 053// ourLog.debug("Unable to find target field named {}", fieldName); 054// } 055// } 056// } else { 057// if (BaseResourceReferenceDt.class.isAssignableFrom(getDatatype())) { 058// myReferenceMutator = new IMutator() { 059// @Override 060// public void addValue(Object theTarget, IBase theValue) { 061// BaseResourceReferenceDt dt = (BaseResourceReferenceDt)theTarget; 062// dt.setResource((IBaseResource) theValue); 063// }}; 064// } 065// } 066// 067// } 068// 069// public IMutator getReferenceMutator() { 070// return myReferenceMutator; 071// } 072 073 074}