org.apache.geode.pdx

## Interface PdxSerializable

-     public interface PdxSerializable

  When a domain class implements PdxSerializable it marks itself as a PDX. The implementation of `toData` provides the serialization code and `fromData` provides the deserialization code. These methods also define each field name and field type of the PDX. Domain classes should serialize and deserialize all its member fields in the same order in toData and fromData method. Also fromData and toData must read and write the same fields each time they are called. A domain class that implements this interface must also have a public zero-arg constructor which is used during deserialization.

  Simple example:

       public class User implements PdxSerializable {
         private String name;
         private int userId;

         public User() {}

         public void toData(PdxWriter out) {
           out.writeString("name", this.name);
           out.writeInt("userId", this.userId);
         }

         public void fromData(PdxReader in) {
           this.name = in.readString("name");
           this.userId = in.readInt("userId");
         }
       }

  Since:
    GemFire 6.6

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `fromData(PdxReader reader)` Deserializes the PDX fields using the given reader.
    `void` | `toData(PdxWriter writer)` Serializes the PDX fields using the given writer.

- - ### Method Detail

    - #### toData

          void toData(PdxWriter writer)

      Serializes the PDX fields using the given writer.
      Parameters:
        `writer` - the `PdxWriter` to use to write the PDX fields.

    - #### fromData

          void fromData(PdxReader reader)

      Deserializes the PDX fields using the given reader.
      Parameters:
        `reader` - the `PdxReader` to use to read the PDX fields.