/** * Returns values stored in an element identified by its path. The list of values is of * type {@link Object}. * * @param theResource The resource instance to be accessed. Must not be null. * @param thePath The path for the element to be accessed. * @return A list of values of type {@link Object}. */ public List<Object> getValues(IBaseResource theResource, String thePath) { Class<Object> wantedClass = Object.class; return getValues(theResource, thePath, wantedClass); }
/** * Returns values stored in an element identified by its path. The list of values is of * type {@link Object}. * * @param theResource The resource instance to be accessed. Must not be null. * @param thePath The path for the element to be accessed. * @param theCreate When set to <code>true</code>, the terser will create a null-valued element where none exists. * @return A list of values of type {@link Object}. */ public List<Object> getValues(IBaseResource theResource, String thePath, boolean theCreate) { Class<Object> wantedClass = Object.class; return getValues(theResource, thePath, wantedClass, theCreate); }
private <T> List<T> getValues(BaseRuntimeElementCompositeDefinition<?> theCurrentDef, Object theCurrentObj, List<String> theSubList, Class<T> theWantedClass) { return getValues(theCurrentDef, theCurrentObj, theSubList, theWantedClass, false, false); }
/** * Returns values stored in an element identified by its path. The list of values is of * type {@link Object}. * * @param theResource The resource instance to be accessed. Must not be null. * @param thePath The path for the element to be accessed. * @param theCreate When set to <code>true</code>, the terser will create a null-valued element where none exists. * @param theAddExtension When set to <code>true</code>, the terser will add a null-valued extension where one or more such extensions already exist. * @return A list of values of type {@link Object}. */ public List<Object> getValues(IBaseResource theResource, String thePath, boolean theCreate, boolean theAddExtension) { Class<Object> wantedClass = Object.class; return getValues(theResource, thePath, wantedClass, theCreate, theAddExtension); }
public <T> T getSingleValueOrNull(IBase theTarget, String thePath, Class<T> theWantedType) { Validate.notNull(theTarget, "theTarget must not be null"); Validate.notBlank(thePath, "thePath must not be empty"); BaseRuntimeElementDefinition<?> def = myContext.getElementDefinition(theTarget.getClass()); if (!(def instanceof BaseRuntimeElementCompositeDefinition)) { throw new IllegalArgumentException("Target is not a composite type: " + theTarget.getClass().getName()); } BaseRuntimeElementCompositeDefinition<?> currentDef = (BaseRuntimeElementCompositeDefinition<?>) def; Object currentObj = theTarget; List<String> parts = parsePath(currentDef, thePath); List<T> retVal = getValues(currentDef, currentObj, parts, theWantedType); if (retVal.isEmpty()) { return null; } return retVal.get(0); }
/** * Returns values stored in an element identified by its path. The list of values is of * type <code>theWantedClass</code>. * * @param theResource The resource instance to be accessed. Must not be null. * @param thePath The path for the element to be accessed. * @param theWantedClass The desired class to be returned in a list. * @param <T> Type declared by <code>theWantedClass</code> * @return A list of values of type <code>theWantedClass</code>. */ public <T> List<T> getValues(IBaseResource theResource, String thePath, Class<T> theWantedClass) { RuntimeResourceDefinition def = myContext.getResourceDefinition(theResource); List<String> parts = parsePath(def, thePath); return getValues(def, theResource, parts, theWantedClass); }
/** * Returns values stored in an element identified by its path. The list of values is of * type <code>theWantedClass</code>. * * @param theResource The resource instance to be accessed. Must not be null. * @param thePath The path for the element to be accessed. * @param theWantedClass The desired class to be returned in a list. * @param theCreate When set to <code>true</code>, the terser will create a null-valued element where none exists. * @param <T> Type declared by <code>theWantedClass</code> * @return A list of values of type <code>theWantedClass</code>. */ public <T> List<T> getValues(IBaseResource theResource, String thePath, Class<T> theWantedClass, boolean theCreate) { RuntimeResourceDefinition def = myContext.getResourceDefinition(theResource); List<String> parts = parsePath(def, thePath); return getValues(def, theResource, parts, theWantedClass, theCreate, false); }
/** * Returns values stored in an element identified by its path. The list of values is of * type <code>theWantedClass</code>. * * @param theResource The resource instance to be accessed. Must not be null. * @param thePath The path for the element to be accessed. * @param theWantedClass The desired class to be returned in a list. * @param theCreate When set to <code>true</code>, the terser will create a null-valued element where none exists. * @param theAddExtension When set to <code>true</code>, the terser will add a null-valued extension where one or more such extensions already exist. * @param <T> Type declared by <code>theWantedClass</code> * @return A list of values of type <code>theWantedClass</code>. */ public <T> List<T> getValues(IBaseResource theResource, String thePath, Class<T> theWantedClass, boolean theCreate, boolean theAddExtension) { RuntimeResourceDefinition def = myContext.getResourceDefinition(theResource); List<String> parts = parsePath(def, thePath); return getValues(def, theResource, parts, theWantedClass, theCreate, theAddExtension); }
List<Object> parameters = t.getValues(theInput, "Parameters.parameter");
@Override protected List<Object> extractValues(String thePaths, IBaseResource theResource) { List<Object> values = new ArrayList<>(); String[] nextPathsSplit = SPLIT.split(thePaths); FhirTerser t = getContext().newTerser(); for (String nextPath : nextPathsSplit) { String nextPathTrimmed = nextPath.trim(); List<Object> allValues; try { allValues = t.getValues(theResource, nextPathTrimmed); } catch (Exception e) { String msg = getContext().getLocalizer().getMessage(BaseSearchParamExtractor.class, "failedToExtractPaths", nextPath, e.toString()); throw new InternalErrorException(msg, e); } for (Object next : allValues) { if (next instanceof IBaseExtension) { IBaseDatatype value = ((IBaseExtension) next).getValue(); if (value != null) { values.add(value); } } else { values.add(next); } } } return values; }
for (T nextElement : values) { BaseRuntimeElementCompositeDefinition<?> nextChildDef = (BaseRuntimeElementCompositeDefinition<?>) myContext.getElementDefinition((Class<? extends IBase>) nextElement.getClass()); List<T> foundValues = getValues(nextChildDef, nextElement, theSubList.subList(1, theSubList.size()), theWantedClass, theCreate, theAddExtension); retVal.addAll(foundValues); for (T nextElement : values) { BaseRuntimeElementCompositeDefinition<?> nextChildDef = (BaseRuntimeElementCompositeDefinition<?>) myContext.getElementDefinition((Class<? extends IBase>) nextElement.getClass()); List<T> foundValues = getValues(nextChildDef, nextElement, theSubList.subList(1, theSubList.size()), theWantedClass, theCreate, theAddExtension); retVal.addAll(foundValues); for (IBase nextElement : values) { BaseRuntimeElementCompositeDefinition<?> nextChildDef = (BaseRuntimeElementCompositeDefinition<?>) myContext.getElementDefinition(nextElement.getClass()); List<T> foundValues = getValues(nextChildDef, nextElement, theSubList.subList(1, theSubList.size()), theWantedClass, theCreate, theAddExtension); retVal.addAll(foundValues);
for (IBaseReference nextValue : getValues(theSource, nextPath, IBaseReference.class)) { IIdType nextTargetId = nextValue.getReferenceElement(); String nextRef = nextTargetId.toUnqualifiedVersionless().getValue();
/** * Returns values stored in an element identified by its path. The list of values is of * type {@link Object}. * * @param theResource The resource instance to be accessed. Must not be null. * @param thePath The path for the element to be accessed. * @return A list of values of type {@link Object}. */ public List<Object> getValues(IBaseResource theResource, String thePath) { Class<Object> wantedClass = Object.class; return getValues(theResource, thePath, wantedClass); }
/** * Returns values stored in an element identified by its path. The list of values is of * type {@link Object}. * * @param theResource The resource instance to be accessed. Must not be null. * @param thePath The path for the element to be accessed. * @param theCreate When set to <code>true</code>, the terser will create a null-valued element where none exists. * @return A list of values of type {@link Object}. */ public List<Object> getValues(IBaseResource theResource, String thePath, boolean theCreate) { Class<Object> wantedClass = Object.class; return getValues(theResource, thePath, wantedClass, theCreate); }
/** * Returns values stored in an element identified by its path. The list of values is of * type {@link Object}. * * @param theResource The resource instance to be accessed. Must not be null. * @param thePath The path for the element to be accessed. * @param theCreate When set to <code>true</code>, the terser will create a null-valued element where none exists. * @param theAddExtension When set to <code>true</code>, the terser will add a null-valued extension where one or more such extensions already exist. * @return A list of values of type {@link Object}. */ public List<Object> getValues(IBaseResource theResource, String thePath, boolean theCreate, boolean theAddExtension) { Class<Object> wantedClass = Object.class; return getValues(theResource, thePath, wantedClass, theCreate, theAddExtension); }
private <T> List<T> getValues(BaseRuntimeElementCompositeDefinition<?> theCurrentDef, Object theCurrentObj, List<String> theSubList, Class<T> theWantedClass) { return getValues(theCurrentDef, theCurrentObj, theSubList, theWantedClass, false, false); }
public <T> T getSingleValueOrNull(IBase theTarget, String thePath, Class<T> theWantedType) { Validate.notNull(theTarget, "theTarget must not be null"); Validate.notBlank(thePath, "thePath must not be empty"); BaseRuntimeElementDefinition<?> def = myContext.getElementDefinition(theTarget.getClass()); if (!(def instanceof BaseRuntimeElementCompositeDefinition)) { throw new IllegalArgumentException("Target is not a composite type: " + theTarget.getClass().getName()); } BaseRuntimeElementCompositeDefinition<?> currentDef = (BaseRuntimeElementCompositeDefinition<?>) def; Object currentObj = theTarget; List<String> parts = parsePath(currentDef, thePath); List<T> retVal = getValues(currentDef, currentObj, parts, theWantedType); if (retVal.isEmpty()) { return null; } return retVal.get(0); }
/** * Returns values stored in an element identified by its path. The list of values is of * type <code>theWantedClass</code>. * * @param theResource The resource instance to be accessed. Must not be null. * @param thePath The path for the element to be accessed. * @param theWantedClass The desired class to be returned in a list. * @param <T> Type declared by <code>theWantedClass</code> * @return A list of values of type <code>theWantedClass</code>. */ public <T> List<T> getValues(IBaseResource theResource, String thePath, Class<T> theWantedClass) { RuntimeResourceDefinition def = myContext.getResourceDefinition(theResource); List<String> parts = parsePath(def, thePath); return getValues(def, theResource, parts, theWantedClass); }
/** * Returns values stored in an element identified by its path. The list of values is of * type <code>theWantedClass</code>. * * @param theResource The resource instance to be accessed. Must not be null. * @param thePath The path for the element to be accessed. * @param theWantedClass The desired class to be returned in a list. * @param theCreate When set to <code>true</code>, the terser will create a null-valued element where none exists. * @param <T> Type declared by <code>theWantedClass</code> * @return A list of values of type <code>theWantedClass</code>. */ public <T> List<T> getValues(IBaseResource theResource, String thePath, Class<T> theWantedClass, boolean theCreate) { RuntimeResourceDefinition def = myContext.getResourceDefinition(theResource); List<String> parts = parsePath(def, thePath); return getValues(def, theResource, parts, theWantedClass, theCreate, false); }
/** * Returns values stored in an element identified by its path. The list of values is of * type <code>theWantedClass</code>. * * @param theResource The resource instance to be accessed. Must not be null. * @param thePath The path for the element to be accessed. * @param theWantedClass The desired class to be returned in a list. * @param theCreate When set to <code>true</code>, the terser will create a null-valued element where none exists. * @param theAddExtension When set to <code>true</code>, the terser will add a null-valued extension where one or more such extensions already exist. * @param <T> Type declared by <code>theWantedClass</code> * @return A list of values of type <code>theWantedClass</code>. */ public <T> List<T> getValues(IBaseResource theResource, String thePath, Class<T> theWantedClass, boolean theCreate, boolean theAddExtension) { RuntimeResourceDefinition def = myContext.getResourceDefinition(theResource); List<String> parts = parsePath(def, thePath); return getValues(def, theResource, parts, theWantedClass, theCreate, theAddExtension); }