Search in sources :

Example 41 with DataList

use of com.linkedin.data.DataList in project rest.li by linkedin.

the class BatchCollectionResponse method createCollectionFromDecoder.

private List<BatchFinderCriteriaResult<T>> createCollectionFromDecoder(BatchFinderCriteriaResultDecoder<T> decoder) {
    DataList elements = this.data().getDataList(CollectionResponse.ELEMENTS);
    List<BatchFinderCriteriaResult<T>> collection = elements.stream().map(obj -> decoder.makeValue((DataMap) obj)).collect(Collectors.toList());
    return collection;
}
Also used : RecordTemplate(com.linkedin.data.template.RecordTemplate) DataMap(com.linkedin.data.DataMap) Arrays(java.util.Arrays) List(java.util.List) RecordDataSchema(com.linkedin.data.schema.RecordDataSchema) DataList(com.linkedin.data.DataList) BatchFinderCriteriaResultDecoder(com.linkedin.restli.internal.common.BatchFinderCriteriaResultDecoder) ArrayDataSchema(com.linkedin.data.schema.ArrayDataSchema) Collectors(java.util.stream.Collectors) Name(com.linkedin.data.schema.Name) DataList(com.linkedin.data.DataList)

Example 42 with DataList

use of com.linkedin.data.DataList in project rest.li by linkedin.

the class BatchCreateIdEntityResponse method generateDataMap.

private static DataMap generateDataMap(List<? extends RecordTemplate> elements) {
    DataMap dataMap = new DataMap();
    DataList listElements = new DataList();
    for (RecordTemplate recordTemplate : elements) {
        CreateIdEntityStatus<?, ?> status = (CreateIdEntityStatus) recordTemplate;
        CheckedUtil.addWithoutChecking(listElements, status.data());
    }
    dataMap.put(CollectionResponse.ELEMENTS, listElements);
    return dataMap;
}
Also used : DataList(com.linkedin.data.DataList) RecordTemplate(com.linkedin.data.template.RecordTemplate) DataMap(com.linkedin.data.DataMap)

Example 43 with DataList

use of com.linkedin.data.DataList in project rest.li by linkedin.

the class BatchCreateIdEntityResponse method createCollectionFromDecoder.

private List<CreateIdEntityStatus<K, V>> createCollectionFromDecoder(CreateIdEntityStatusDecoder<K, V> decoder) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
    DataList elements = this.data().getDataList(CollectionResponse.ELEMENTS);
    List<CreateIdEntityStatus<K, V>> collection = new ArrayList<>(elements.size());
    for (Object obj : elements) {
        DataMap dataMap = (DataMap) obj;
        CreateIdEntityStatus<K, V> status = decodeValue(dataMap, decoder);
        collection.add(status);
    }
    return collection;
}
Also used : DataList(com.linkedin.data.DataList) ArrayList(java.util.ArrayList) DataMap(com.linkedin.data.DataMap)

Example 44 with DataList

use of com.linkedin.data.DataList in project rest.li by linkedin.

the class BatchCreateResponse method generateDataMap.

private static DataMap generateDataMap(List<? extends RecordTemplate> elements) {
    DataMap dataMap = new DataMap();
    DataList listElements = new DataList();
    for (RecordTemplate recordTemplate : elements) {
        listElements.add(recordTemplate.data());
    }
    dataMap.put(CollectionResponse.ELEMENTS, listElements);
    return dataMap;
}
Also used : DataList(com.linkedin.data.DataList) RecordTemplate(com.linkedin.data.template.RecordTemplate) DataMap(com.linkedin.data.DataMap)

Example 45 with DataList

use of com.linkedin.data.DataList in project rest.li by linkedin.

the class BatchCreateResponse method createCollectionFromDecoder.

private List<CreateStatus> createCollectionFromDecoder(CreateIdStatusDecoder<K> entityDecoder) throws NoSuchMethodException, InstantiationException, IllegalAccessException, InvocationTargetException {
    DataList elements = this.data().getDataList(CollectionResponse.ELEMENTS);
    List<CreateStatus> collection = new ArrayList<>(elements.size());
    for (Object obj : elements) {
        DataMap dataMap = (DataMap) obj;
        collection.add(decodeValue(dataMap, entityDecoder));
    }
    return collection;
}
Also used : DataList(com.linkedin.data.DataList) ArrayList(java.util.ArrayList) DataMap(com.linkedin.data.DataMap)

Aggregations

DataList (com.linkedin.data.DataList)202 DataMap (com.linkedin.data.DataMap)151 Test (org.testng.annotations.Test)109 ByteString (com.linkedin.data.ByteString)72 TestUtil.dataMapFromString (com.linkedin.data.TestUtil.dataMapFromString)34 TestUtil.dataSchemaFromString (com.linkedin.data.TestUtil.dataSchemaFromString)33 ArrayList (java.util.ArrayList)27 ArrayDataSchema (com.linkedin.data.schema.ArrayDataSchema)22 RecordDataSchema (com.linkedin.data.schema.RecordDataSchema)15 DataSchema (com.linkedin.data.schema.DataSchema)14 RecordTemplate (com.linkedin.data.template.RecordTemplate)14 HashMap (java.util.HashMap)13 MapDataSchema (com.linkedin.data.schema.MapDataSchema)12 TestUtil.asReadOnlyDataMap (com.linkedin.data.TestUtil.asReadOnlyDataMap)11 Map (java.util.Map)11 List (java.util.List)10 DataProvider (org.testng.annotations.DataProvider)10 DataComplex (com.linkedin.data.DataComplex)9 EnumDataSchema (com.linkedin.data.schema.EnumDataSchema)5 UnionDataSchema (com.linkedin.data.schema.UnionDataSchema)5