All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.azure.cosmos.implementation.JavaStreamUtils Maven / Gradle / Ivy

Go to download

This Package contains Microsoft Azure Cosmos SDK (with Reactive Extension Reactor support) for Azure Cosmos DB SQL API

There is a newer version: 4.60.0
Show newest version
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.

package com.azure.cosmos.implementation;

import java.util.Arrays;
import java.util.Collection;
import java.util.stream.Collectors;

public class JavaStreamUtils {

    private static  String safeToString(T t) {
        return t != null ? t.toString() : "null";
    }

    public static  String info(Collection collection) {
        return collection == null ? "null collection" :
                   "collection size: " + collection.size();
    }

    public static  String info(T[] collection) {
        return collection == null ? "null collection" :
                   "collection size: " + collection.length;
    }


    public static  String toString(Collection collection, String delimiter) {
        return collection == null ? "null collection" :
                   collection.isEmpty() ? "empty collection" :
                       collection.stream()
                           .map(t -> safeToString(t))
                           .collect(Collectors.joining(delimiter));
    }

    public static  String toString(T[] array, String delimiter) {
        return array == null ? "null array" :
                   toString(Arrays.asList(array), delimiter);
    }

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy