code: public static ServiceInstance toServiceInstance(
              ModelServiceInstance modelInstance) {
          if (modelInstance==null) throw new NullPointerException();
          Map<String, String> meta = new HashMap<>();
          if (modelInstance.getMetadata() != null) {
              for (Entry<String, String> en : modelInstance.getMetadata()
                      .entrySet()) {
                  meta.put(en.getKey(), en.getValue());
              }
          }
          return new ServiceInstance(modelInstance.getServiceName(),
                  modelInstance.getUri(),
                  modelInstance.isMonitorEnabled(), modelInstance.getStatus(),
                  modelInstance.getAddress(),meta, modelInstance.getPort(), modelInstance.getTls_port(), modelInstance.getProtocol());
      }
docs: Convert a ModelServiceInstance to a ServiceInstance object.
  
  It will do the deep clone for the metadata.
  
  @param modelInstance
  the ModelServiceInstance object.
  @return the ServiceInstance Object.