code: VirtualMachineLease cloneLease(VirtualMachineLease lease, final String hostname, long now) {
          final List<VirtualMachineLease.Range> ports = new LinkedList<>();
          final List<VirtualMachineLease.Range> ranges = lease.portRanges();
          if (ranges != null && !ranges.isEmpty()) {
              for (VirtualMachineLease.Range r : ranges)
                  ports.add(new VirtualMachineLease.Range(r.getBeg(), r.getEnd()));
          }
          final double cpus = lease.cpuCores();
          final double memory = lease.memoryMB();
          final double network = lease.networkMbps();
          final double disk = lease.diskMB();
          final Map<String, Protos.Attribute> attributes = new HashMap<>(lease.getAttributeMap());
          final Map<String, Double> scalarValues = new HashMap<>(lease.getScalarValues());
          return new VirtualMachineLease() {
              @Override
              public String getId() {
                  return hostname;
              }
  
              @Override
              public long getOfferedTime() {
                  return now;
              }
  
              @Override
              public String hostname() {
                  return hostname;
              }
  
              @Override
              public String getVMID() {
                  return hostname;
              }
  
              @Override
              public double cpuCores() {
                  return cpus;
              }
  
              @Override
              public double memoryMB() {
                  return memory;
              }
  
              @Override
              public double networkMbps() {
                  return network;
              }
  
              @Override
              public double diskMB() {
                  return disk;
              }
  
              @Override
              public List<Range> portRanges() {
                  return ports;
              }
  
              @Override
              public Protos.Offer getOffer() {
                  return null;
              }
  
              @Override
              public Map<String, Protos.Attribute> getAttributeMap() {
                  return attributes;
              }
  
              @Override
              public Double getScalarValue(String name) {
                  return scalarValues.get(name);
              }
  
              @Override
              public Map<String, Double> getScalarValues() {
                  return scalarValues;
              }
          };
      }
  
  }
docs: /* package