NodeResources { @Override public String toString() { StringBuffer sb = new StringBuffer("[vcpu: "); appendDouble(sb, vcpu); sb.append(", memory: "); appendDouble(sb, memoryGb); sb.append(" Gb, disk "); appendDouble(sb, diskGb); sb.append(" Gb"); if (bandwidthGbps > 0) { sb.append(", bandwidth: "); appendDouble(sb, bandwidthGbps); sb.append(" Gbps"); } if ( !diskSpeed.isDefault()) { sb.append(", disk speed: ").append(diskSpeed); } if ( !storageType.isDefault()) { sb.append(", storage type: ").append(storageType); } sb.append(']'); return sb.toString(); } NodeResources(double vcpu, double memoryGb, double diskGb, double bandwidthGbps);  NodeResources(double vcpu, double memoryGb, double diskGb, double bandwidthGbps, DiskSpeed diskSpeed);  NodeResources(double vcpu, double memoryGb, double diskGb, double bandwidthGbps, DiskSpeed diskSpeed, StorageType storageType); double vcpu(); double memoryGb(); double diskGb(); double bandwidthGbps(); DiskSpeed diskSpeed(); StorageType storageType(); double cost(); NodeResources withVcpu(double vcpu); NodeResources withMemoryGb(double memoryGb); NodeResources withDiskGb(double diskGb); NodeResources withBandwidthGbps(double bandwidthGbps); NodeResources with(DiskSpeed diskSpeed); NodeResources with(StorageType storageType); NodeResources justNumbers(); NodeResources justNonNumbers(); NodeResources subtract(NodeResources other); NodeResources add(NodeResources other); @Override boolean equals(Object o); @Override int hashCode(); @Override String toString(); boolean satisfies(NodeResources other); boolean compatibleWith(NodeResources other); static NodeResources unspecified(); boolean isUnspecified(); Optional<NodeResources> asOptional(); static NodeResources fromLegacyName(String name);  }
@Test public void testToString() { assertEquals("[vcpu: 1.0, memory: 10.0 Gb, disk 100.0 Gb]", new NodeResources(1., 10., 100., 0).toString()); assertEquals("[vcpu: 0.3, memory: 3.3 Gb, disk 33.3 Gb, bandwidth: 0.3 Gbps]", new NodeResources(1/3., 10/3., 100/3., 0.3).toString()); assertEquals("[vcpu: 0.7, memory: 9.0 Gb, disk 66.7 Gb, bandwidth: 0.7 Gbps]", new NodeResources(2/3., 8.97, 200/3., 0.67).toString()); }