title: Android Architecture Components: Using Enums
body: <p>Is it possible to use an Enum type as an embedded field in an Entity class with the new Android Architecture Components and Room Persistence Library?</p>
  
  <p>My Entity (with embedded Enum):</p>
  
  <pre><code>@Entity(tableName = "tasks")
  public class Task extends SyncEntity {
  
      @PrimaryKey(autoGenerate = true)
      String taskId;
  
      String title;
  
      /** Status of the given task.
       * Enumerated Values: 0 (Active), 1 (Inactive), 2 (Completed)
       */
      @Embedded
      Status status;
  
      @TypeConverters(DateConverter.class)
      Date startDate;
  
      @TypeConverters(StatusConverter.class)
      public enum Status {
          ACTIVE(0),
          INACTIVE(1),
          COMPLETED(2);
  
          private int code;
  
          Status(int code) {
              this.code = code;
          }
  
          public int getCode() {
              return code;
          }
      }
  }
  </code></pre>
  
  <p>My TypeConverter:</p>
  
  <pre><code>public class StatusConverter {
  
      @TypeConverter
      public static Task.Status toStatus(int status) {
          if (status == ACTIVE.getCode()) {
              return ACTIVE;
          } else if (status == INACTIVE.getCode()) {
              return INACTIVE;
          } else if (status == COMPLETED.getCode()) {
              return COMPLETED;
          } else {
              throw new IllegalArgumentException("Could not recognize status");
          }
      }
  
      @TypeConverter
      public static Integer toInteger(Task.Status status) {
          return status.getCode();
      }
  }
  </code></pre>
  
  <p>When I compile this I get an error saying <code>Error:(52, 12) error: Entities and Pojos must have a usable public constructor. You can have an empty constructor or a constructor whose parameters match the fields (by name and type).</code></p>
  
  <p><strong>Update 1</strong>
  My SyncEntity class:</p>
  
  <pre><code>/**
   * Base class for all Room entities that are synchronized.
   */
  @Entity
  public class SyncEntity {
  
      @ColumnInfo(name = "created_at")
      Long createdAt;
  
      @ColumnInfo(name = "updated_at")
      Long updatedAt;
  }
  </code></pre>