Clover icon

sunshower-base

  1. Project Clover database Fri Apr 6 2018 03:41:27 UTC
  2. Package io.sunshower.persistence.core

File AbstractEntity.java

 

Coverage histogram

../../../../img/srcFileCovDistChart7.png
25% of files have more coverage

Code metrics

6
10
4
1
32
24
7
0.7
2.5
4
1.75

Classes

Class Line # Actions
AbstractEntity 7 10 7
0.770%
 

Contributing tests

This file is covered by 3 tests. .

Source view

1    package io.sunshower.persistence.core;
2   
3    import java.io.Serializable;
4    import javax.persistence.*;
5   
6    @MappedSuperclass
 
7    public abstract class AbstractEntity<T extends Serializable> implements Persistable<T> {
8   
 
9  5 toggle protected AbstractEntity(T id) {
10  5 setId(id);
11  5 setDefaults();
12    }
13   
 
14  5 toggle protected void setDefaults() {}
15   
16    public abstract T getId();
17   
18    public abstract void setId(T id);
19   
 
20  0 toggle public int hashCode() {
21  0 return getId().hashCode();
22    }
23   
 
24  3 toggle public boolean equals(Object o) {
25  1 if (o == this) return true;
26  2 if (o == null) return false;
27  2 if (o.getClass().isAssignableFrom(getClass())) {
28  2 return ((Persistable) o).getId().equals(getId());
29    }
30  0 return false;
31    }
32    }