Search in sources :

Example 1 with QueryParamsDataMap

use of com.linkedin.restli.internal.common.QueryParamsDataMap in project rest.li by linkedin.

the class ComplexResourceKey method buildFromDataMap.

/**
 * Build complex key instance from an untyped datamap representing a complex key as
 * defined in {@link QueryParamsDataMap}
 *
 * @param keyDataMap untyped DataMap - all primitive values are represented as strings.
 * @param complexKeyType type of {@link ComplexResourceKey}
 * @return {@link ComplexResourceKey} initialized with id and param values specified in
 *         the input DataMap
 */
public static ComplexResourceKey<RecordTemplate, RecordTemplate> buildFromDataMap(DataMap keyDataMap, ComplexKeySpec<?, ?> complexKeyType) {
    // Copy in case the original is immutable
    keyDataMap = new DataMap(keyDataMap);
    // Separate key from its parameters (those are under "params" key in the total map)
    DataMap paramsDataMap = (DataMap) keyDataMap.remove(COMPLEX_KEY_PARAMS);
    if (paramsDataMap == null) {
        paramsDataMap = new DataMap();
    }
    RecordTemplate key = validateDataMap(keyDataMap, complexKeyType.getKeyType());
    RecordTemplate params = validateDataMap(paramsDataMap, complexKeyType.getParamsType());
    return new ComplexResourceKey<>(key, params);
}
Also used : RecordTemplate(com.linkedin.data.template.RecordTemplate) DataMap(com.linkedin.data.DataMap) QueryParamsDataMap(com.linkedin.restli.internal.common.QueryParamsDataMap)

Aggregations

DataMap (com.linkedin.data.DataMap)1 RecordTemplate (com.linkedin.data.template.RecordTemplate)1 QueryParamsDataMap (com.linkedin.restli.internal.common.QueryParamsDataMap)1