public Resource subtractAbsolute ( Resource other ) { double cpuDifference = this . getCpu ( ) - other . getCpu ( ) ; double extraCpu = Math . max ( 0 , cpuDifference ) ; ByteAmount ramDifference = this . getRam ( ) . minus ( other . getRam ( ) ) ; ByteAmount extraRam = ByteAmount . ZERO . max ( ramDifference ) ; ByteAmount diskDifference = this . getDisk ( ) . minus ( other . getDisk ( ) ) ; ByteAmount extraDisk = ByteAmount . ZERO . max ( diskDifference ) ; return new Resource ( extraCpu , extraRam , extraDisk ) ; }
Subtracts a given resource from the current resource . The results is never negative .