class ResourceDimensions {

    public static ResourceDimension subtractPositive(ResourceDimension left, ResourceDimension right) {
        return ResourceDimension.newBuilder()
                .withCpus(Math.max(0, left.getCpu() - right.getCpu()))
                .withMemoryMB(Math.max(0, left.getMemoryMB() - right.getMemoryMB()))
                .withDiskMB(Math.max(0, left.getDiskMB() - right.getDiskMB()))
                .withNetworkMbs(Math.max(0, left.getNetworkMbs() - right.getNetworkMbs()))
                .withGpu(Math.max(0, left.getGpu() - right.getGpu()))
                .withOpportunisticCpus(Math.max(0, left.getOpportunisticCpu() - right.getOpportunisticCpu()))
                .build();
    }

}