Skip to content

Package: UserObject

UserObject

nameinstructionbranchcomplexitylinemethod
UserObject(long, Type)
M: 0 C: 7
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
getId()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
init(long, Type)
M: 0 C: 15
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
isTheSameAs(Object)
M: 2 C: 16
89%
M: 1 C: 3
75%
M: 1 C: 2
67%
M: 1 C: 3
75%
M: 0 C: 1
100%

Coverage

1: package de.fhdw.wtf.persistence.meta;
2:
3: /**
4: * A class to represent an object to a user Type.
5: *
6: */
7: public class UserObject extends Object { // NOPMD: Object != java.lang.Object
8:
9:         /**
10:          * The identity of a user Object in the Database.
11:          */
12:         private final long id;
13:         
14:         /**
15:          * Constructor for a new User Object. It should only be called by the object facade or a junit test to guarantee
16:          * consisteny with the database.
17:          *
18:          * @param id
19:          * The Id of this object in the database.
20:          * @param instanceOf
21:          * The Type of this User Object. It must be a user type.
22:          * @return a UserTransaction when instance of is a transaction type UserObject otherwise.
23:          */
24:         public static UserObject init(final long id, final Type instanceOf) {
25:•                if (instanceOf.isTrans()) {
26:                         return new UserTransaction(id, instanceOf);
27:                 } else {
28:                         return new UserObject(id, instanceOf);
29:                 }
30:         }
31:         
32:         /**
33:          * Constructor for a new User Object. It should only be called by the object facade or a junit test to guarantee
34:          * consistency with the database.
35:          *
36:          * @param id
37:          * The Id of this object in the database.
38:          * @param instanceOf
39:          * The Type of this User Object. It must be a user type.
40:          */
41:         protected UserObject(final long id, final Type instanceOf) {
42:                 super(instanceOf);
43:                 this.id = id;
44:         }
45:         
46:         @Override
47:         public long getId() {
48:                 return this.id;
49:         }
50:         
51:         @Override
52:         public boolean isTheSameAs(final java.lang.Object other) {
53:•                if (!(other instanceof UserObject)) {
54:                         return false;
55:                 }
56:                 
57:                 final UserObject uo = (UserObject) other;
58:                 
59:•                return this.getId() == uo.getId();
60:         }
61:         
62: }