summaryrefslogtreecommitdiff
path: root/src/main/java/com/android/vts/entity/RoleEntity.java
blob: d001cfadf1fc169f5bed53fba9448e9966f2f6ca (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
package com.android.vts.entity;

import static com.googlecode.objectify.ObjectifyService.ofy;

import com.googlecode.objectify.Key;
import com.googlecode.objectify.annotation.Cache;
import com.googlecode.objectify.annotation.Entity;
import com.googlecode.objectify.annotation.Id;
import com.googlecode.objectify.annotation.Index;
import com.googlecode.objectify.annotation.Load;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import lombok.Data;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;


@Cache
@Entity
@EqualsAndHashCode(of = "role")
@NoArgsConstructor
public class RoleEntity implements Serializable {

  private static final long serialVersionUID = 1L;

  @Id
  private String role;

  /** When this record was created or updated */
  @Getter
  Date updated;

  /** Construction function for UserEntity Class */
  public RoleEntity(String roleName) {
    this.role = roleName;
  }

  /** Get role by email */
  public static RoleEntity getRole(String role) {
    return ofy().load()
        .type(RoleEntity.class)
        .id(role)
        .now();
  }

  /** Saving function for the instance of this class */
  public void save() {
    this.updated = new Date();
    ofy().save().entity(this).now();
  }
}