001/*- 002 * #%L 003 * Smile CDR - CDR 004 * %% 005 * Copyright (C) 2016 - 2024 Smile CDR, Inc. 006 * %% 007 * All rights reserved. 008 * #L% 009 */ 010package ca.cdr.api.fhirgw.model; 011 012import ca.cdr.api.fhirgw.json.GatewayTargetJson; 013import ca.cdr.api.fhirgw.svc.IFhirEndpointGatewayTarget; 014import jakarta.annotation.Nonnull; 015import org.apache.commons.lang3.Validate; 016 017import java.util.HashMap; 018import java.util.Map; 019 020public class TargetMap { 021 022 private final HashMap<String, GatewayTargetJson> myDefinitions; 023 private final HashMap<String, IFhirEndpointGatewayTarget> myTargets; 024 025 public TargetMap( 026 Map<String, GatewayTargetJson> theDefinitions, Map<String, IFhirEndpointGatewayTarget> theTargets) { 027 myDefinitions = new HashMap<>(theDefinitions); 028 myTargets = new HashMap<>(theTargets); 029 } 030 031 @Nonnull 032 public GatewayTargetJson getDefinition(String theTargetId) { 033 GatewayTargetJson retVal = myDefinitions.get(theTargetId); 034 Validate.notNull(retVal, "No target with ID: %s - Have IDs: %s", theTargetId, myDefinitions.keySet()); 035 return retVal; 036 } 037 038 @Nonnull 039 public IFhirEndpointGatewayTarget getTarget(String theTargetId) { 040 IFhirEndpointGatewayTarget retVal = myTargets.get(theTargetId); 041 Validate.notNull(retVal, "No target with ID: %s - Have IDs: %s", theTargetId, myDefinitions.keySet()); 042 return retVal; 043 } 044}