package codeu.chat.common;

import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.util.Collection;

import codeu.chat.util.Serializer;
import codeu.chat.util.Serializers;
import codeu.chat.util.Time;
import codeu.chat.util.Uuid;

public final class Interests {

  public static final Serializer<Interests> SERIALIZER = new Serializer<Interests>() {

    @Override
    public void write(OutputStream out, Interests value) throws IOException {

      Serializers.collection(new Serializer(Interests)).write(out, value.interests);
      Time.SERIALIZER.write(out, value.lastStatusUpdate);
      Time.SERIALIZER.write(out, value.creation);

    }

    @Override
    public Interests read(InputStream in) throws IOException {

      return new Interests(
          Serializers.collection(new Serializer(Interests)).read(in),
          Serializers.STRING.read(in),
          Time.SERIALIZER.read(in)
      );

    }
  };

  public final Collection<Interests> interests;
  public final Time lastStatusUpdate;
  public final Time creation;

  public Interests(Collection<Interests> interests, Time lastStatusUpdate, Time creation) {

    this.interests = interests;
    this.lastStatusUpdate = lastStatusUpdate;
    this.creation = creation;

  }
}
Add Interests.java