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); }
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); }