Skip to content

Package: GenVisibility

GenVisibility

nameinstructionbranchcomplexitylinemethod
GenVisibility(String, int, String)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 3
100%
M: 0 C: 1
100%
min(GenVisibility)
M: 38 C: 0
0%
M: 15 C: 0
0%
M: 10 C: 0
0%
M: 16 C: 0
0%
M: 1 C: 0
0%
static {...}
M: 0 C: 48
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
toString()
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%

Coverage

1: package de.fhdw.wtf.generator.java.generatorModel;
2:
3: /**
4: * An enum that contains all possible visibility modifiers that exist in Java.
5: */
6: public enum GenVisibility {
7:         /**
8:          * public means anyone can see it.
9:          */
10:         PUBLIC("public"),
11:         /**
12:          * protected means only the owner-class subclasses of that class and other classes in the same package can see it.
13:          */
14:         PROTECTED("protected"),
15:         /**
16:          * Per default the owner-class and other classes in the same package can see it.
17:          */
18:         DEFAULT(""),
19:         /**
20:          * private means it can only be seen by the owner-class.
21:          */
22:         PRIVATE("private");
23:         
24:         /**
25:          * String-representation of the instance of GenVisibility.
26:          */
27:         private final String t;
28:         
29:         /**
30:          * Instantiates a new GenVisibility.
31:          *
32:          * @param t
33:          * String-representation of the instance.
34:          */
35:         GenVisibility(final String t) {
36:                 this.t = t;
37:         }
38:         
39:         @Override
40:         public String toString() {
41:                 return this.t;
42:         }
43:         
44:         /**
45:          * selects the most restricting visibility from a collection of visibilities.
46:          *
47:          * @param visibilities
48:          * collection containing visibilities
49:          * @return the most restricting visibility
50:          */
51:         public GenVisibility min(final GenVisibility visibilities) {
52:                 boolean vis1Protected = false;
53:                 boolean vis1Default = false;
54:                 
55:•                switch (visibilities) {
56:                 case PUBLIC:
57:                         return this;
58:                 case PROTECTED:
59:                         vis1Protected = true;
60:                         break;
61:                 case PRIVATE:
62:                         return visibilities;
63:                 case DEFAULT:
64:                         vis1Default = true;
65:                         break;
66:                 default:
67:                         break;
68:                 }
69:                 
70:•                if (vis1Default) {
71:•                        if (this == GenVisibility.PRIVATE) {
72:                                 return this;
73:                         }
74:                 }
75:•                if (vis1Protected) {
76:•                        if (this == GenVisibility.DEFAULT || this == GenVisibility.PRIVATE) {
77:                                 return this;
78:                         }
79:                 }
80:                 return visibilities;
81:         }
82:         
83: }