class ResourceDimensions {

    public static ResourceDimension add(ResourceDimension... parts) {
        if (isNullOrEmpty(parts)) {
            return ResourceDimension.empty();
        }
        double cpuSum = 0;
        long memorySum = 0;
        long diskSum = 0;
        long networkSum = 0;
        long gpuSum = 0;
        long opportunisticCpuSum = 0;
        for (ResourceDimension part : parts) {
            cpuSum += part.getCpu();
            memorySum += part.getMemoryMB();
            diskSum += part.getDiskMB();
            networkSum += part.getNetworkMbs();
            gpuSum += part.getGpu();
            opportunisticCpuSum += part.getOpportunisticCpu();
        }
        return ResourceDimension.newBuilder()
                .withCpus(cpuSum)
                .withMemoryMB(memorySum)
                .withDiskMB(diskSum)
                .withNetworkMbs(networkSum)
                .withGpu(gpuSum)
                .withOpportunisticCpus(opportunisticCpuSum)
                .build();
    }

}