summaryrefslogtreecommitdiff
path: root/src/main/java/com/android/vts/entity/RoleEntity.java
blob: 508a9cac047bc3d7933dca5bfd372c59db287877 (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
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 java.util.Date;
import lombok.EqualsAndHashCode;
import lombok.Getter;
import lombok.NoArgsConstructor;

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

    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 */
    @Override
    public Key<RoleEntity> save() {
        this.updated = new Date();
        return ofy().save().entity(this).now();
    }
}