@Override
  public boolean toData(Object o, DataOutput out) throws IOException {
    if (o instanceof Company) {
      Company company = (Company) o;
      out.writeUTF(company.getName());

      // Let's assume that Address is java.io.Serializable
      Address address = company.getAddress();
      writeObject(address, out);
      return true;

    } else {
      return false;
    }
  }
May be invoked reflectively if instances of Company are distributed to other VMs.
geode-junit/src/main/java/com/examples/ds/CompanySerializer.java