Clover icon

sunshower-sdk

  1. Project Clover database Sat May 12 2018 05:15:40 UTC
  2. Package io.sunshower.sdk.v1.model.core.element

File PersistentElement.java

 

Coverage histogram

../../../../../../../img/srcFileCovDistChart3.png
35% of files have more coverage

Code metrics

10
13
4
1
49
37
10
0.77
3.25
4
2.5

Classes

Class Line # Actions
PersistentElement 14 13 10
0.2222222222.2%
 

Contributing tests

This file is covered by 3 tests. .

Source view

1    package io.sunshower.sdk.v1.model.core.element;
2   
3    import javax.xml.bind.annotation.XmlTransient;
4    import java.io.Serializable;
5   
6    import io.sunshower.common.Identifier;
7    import io.sunshower.persist.Identifiers;
8    import io.sunshower.persist.Sequence;
9    import lombok.Getter;
10    import lombok.Setter;
11   
12    @Getter
13    @Setter
 
14    public abstract class PersistentElement<T extends Serializable, E extends PersistentElement<T, E>>
15    extends Element<E> {
16   
17    @XmlTransient public static final Sequence<Identifier> sequence = Identifiers.newSequence();
18   
 
19  7 toggle protected PersistentElement() {}
20   
 
21  2 toggle protected PersistentElement(Class<E> type, T id) {
22  2 setId(id);
23  2 if (type != null) {
24  2 this.type = type;
25    }
26    }
27   
28    public abstract T getId();
29   
30    public abstract void setId(T id);
31   
 
32  0 toggle @Override
33    public boolean equals(Object o) {
34  0 if (this == o) return true;
35  0 if (o == null || getClass() != o.getClass()) return false;
36   
37  0 PersistentElement<?, ?> element = (PersistentElement<?, ?>) o;
38  0 final Object thisId = getId();
39  0 final Object thatId = element.getId();
40   
41  0 return thisId != null ? thisId.equals(thatId) : thatId == null;
42    }
43   
 
44  0 toggle @Override
45    public int hashCode() {
46  0 final Object id = getId();
47  0 return id != null ? id.hashCode() : 0;
48    }
49    }