Clover icon

sunshower-core

  1. Project Clover database Fri Apr 6 2018 03:27:42 UTC
  2. Package io.sunshower.service.model

File BaseModelObject.java

 

Coverage histogram

../../../../img/srcFileCovDistChart9.png
10% of files have more coverage

Code metrics

6
11
8
1
65
51
11
1
1.38
8
1.38

Classes

Class Line # Actions
BaseModelObject 12 11 11
0.8888%
 

Contributing tests

This file is covered by 15 tests. .

Source view

1    package io.sunshower.service.model;
2   
3    import io.sunshower.model.core.auth.ProtectedDistributableEntity;
4    import java.util.Date;
5    import javax.persistence.*;
6    import javax.validation.constraints.NotNull;
7    import javax.validation.constraints.Size;
8   
9    /** Created by haswell on 5/16/17. */
10    @MappedSuperclass
11    @EntityListeners(UpdateListener.class)
 
12    public abstract class BaseModelObject extends ProtectedDistributableEntity implements Updatable {
13   
14    @Basic
15    @Column(name = "name", unique = true)
16    @Size(min = 3, max = 255)
17    private String name;
18   
19    @NotNull
20    @Temporal(TemporalType.TIMESTAMP)
21    private Date created;
22   
23    @NotNull
24    @Temporal(TemporalType.TIMESTAMP)
25    private Date modified;
26   
 
27  0 toggle public String getName() {
28  0 return name;
29    }
30   
 
31  10 toggle public void setName(String name) {
32  10 this.name = name;
33    }
34   
 
35  1 toggle public Date getCreated() {
36  1 return created;
37    }
38   
 
39  39 toggle public void setCreated(Date created) {
40  39 this.created = created;
41    }
42   
 
43  1 toggle public Date getModified() {
44  1 return modified;
45    }
46   
 
47  39 toggle public void setModified(Date modified) {
48  39 this.modified = modified;
49    }
50   
 
51  12 toggle @Override
52    public void setLastModified(Date date) {
53  12 this.modified = date == null ? new Date() : date;
54    }
55   
 
56  36 toggle @PrePersist
57    protected void setDefaults() {
58  36 if (created == null) {
59  26 created = new Date();
60    }
61  36 if (modified == null) {
62  26 modified = new Date();
63    }
64    }
65    }