File tree 7 files changed +57
-31
lines changed
main/java/pl/wavesoftware/utils/stringify/impl
test/java/pl/wavesoftware/utils/stringify
7 files changed +57
-31
lines changed Original file line number Diff line number Diff line change 4
4
* @author <a href="mailto:krzysztof.suszynski@coi.gov.pl">Krzysztof Suszynski</a>
5
5
* @since 27.04.18
6
6
*/
7
- public interface InspectingField {
7
+ interface InspectingField {
8
8
boolean shouldInspect ();
9
9
boolean showNull ();
10
10
}
Original file line number Diff line number Diff line change 2
2
3
3
import lombok .RequiredArgsConstructor ;
4
4
import pl .wavesoftware .utils .stringify .configuration .BeanFactory ;
5
- import pl .wavesoftware .utils .stringify .configuration .DisplayNull ;
6
5
import pl .wavesoftware .utils .stringify .configuration .InspectionPoint ;
7
6
import pl .wavesoftware .utils .stringify .configuration .Mode ;
8
7
@@ -27,30 +26,4 @@ private InspectFieldPredicate createPredicate(BeanFactory beanFactory) {
27
26
}
28
27
}
29
28
30
- @ RequiredArgsConstructor
31
- private class InspectingFieldImpl implements InspectingField {
32
- private final InspectionPoint inspectionPoint ;
33
- private final InspectFieldPredicate predicate ;
34
-
35
- @ Override
36
- public boolean shouldInspect () {
37
- return technically () && predicate .shouldInspect (inspectionPoint );
38
- }
39
-
40
- private boolean technically () {
41
- return !inspectionPoint .getField ().isEnumConstant ()
42
- && !inspectionPoint .getField ().isSynthetic ();
43
- }
44
-
45
- @ Override
46
- public boolean showNull () {
47
- DisplayNull displayNull = inspectionPoint .getField ()
48
- .getAnnotation (DisplayNull .class );
49
- if (displayNull != null ) {
50
- return displayNull .value ();
51
- } else {
52
- return DisplayNull .BY_DEFAULT ;
53
- }
54
- }
55
- }
56
29
}
Original file line number Diff line number Diff line change
1
+ package pl .wavesoftware .utils .stringify .impl ;
2
+
3
+ import lombok .RequiredArgsConstructor ;
4
+ import pl .wavesoftware .utils .stringify .configuration .DisplayNull ;
5
+ import pl .wavesoftware .utils .stringify .configuration .InspectionPoint ;
6
+
7
+ import java .lang .reflect .Field ;
8
+ import java .lang .reflect .Modifier ;
9
+
10
+ /**
11
+ * @author <a href="krzysztof.suszynski@wavesoftware.pl">Krzysztof Suszyński</a>
12
+ * @since 2018-04-30
13
+ */
14
+ @ RequiredArgsConstructor
15
+ final class InspectingFieldImpl implements InspectingField {
16
+ private final InspectionPoint inspectionPoint ;
17
+ private final InspectFieldPredicate predicate ;
18
+
19
+ @ Override
20
+ public boolean shouldInspect () {
21
+ return technically () && predicate .shouldInspect (inspectionPoint );
22
+ }
23
+
24
+ private boolean technically () {
25
+ Field field = inspectionPoint .getField ();
26
+ int mods = field .getModifiers ();
27
+ return !Modifier .isStatic (mods )
28
+ && !field .isEnumConstant ()
29
+ && !field .isSynthetic ();
30
+ }
31
+
32
+ @ Override
33
+ public boolean showNull () {
34
+ DisplayNull displayNull = inspectionPoint .getField ()
35
+ .getAnnotation (DisplayNull .class );
36
+ if (displayNull != null ) {
37
+ return displayNull .value ();
38
+ } else {
39
+ return DisplayNull .BY_DEFAULT ;
40
+ }
41
+ }
42
+ }
Original file line number Diff line number Diff line change 11
11
@ Data
12
12
@ EqualsAndHashCode (callSuper = true )
13
13
final class Earth extends Planet {
14
+
15
+ private static final long serialVersionUID = 20180430201544L ;
16
+
14
17
@ Inspect
15
18
private Moon moon ;
16
19
@ Inspect
Original file line number Diff line number Diff line change 17
17
@ ToString (exclude = "nullinside" )
18
18
@ EqualsAndHashCode (callSuper = true )
19
19
final class Moon extends Planet {
20
+
21
+ private static final long serialVersionUID = 20180430201602L ;
22
+
20
23
@ Inspect
21
24
private Phase phase ;
22
25
@ Inspect
Original file line number Diff line number Diff line change 13
13
*/
14
14
@ Setter
15
15
class Person {
16
- private int id ;
16
+ private volatile int id ;
17
17
@ DisplayNull
18
- private Person parent ;
18
+ private transient Person parent ;
19
19
private List <Person > childs ;
20
20
private Account account ;
21
21
@ Inspect (conditionally = IsInDevelopment .class )
Original file line number Diff line number Diff line change 5
5
import pl .wavesoftware .utils .stringify .configuration .DoNotInspect ;
6
6
import pl .wavesoftware .utils .stringify .configuration .Inspect ;
7
7
8
+ import java .io .Serializable ;
9
+
8
10
/**
9
11
* @author <a href="krzysztof.suszynski@wavesoftware.pl">Krzysztof Suszyński</a>
10
12
* @since 2018-04-18
11
13
*/
12
14
@ Data
13
- abstract class Planet {
15
+ abstract class Planet implements Serializable {
16
+
17
+ private static final long serialVersionUID = 20180430201529L ;
18
+
14
19
@ Inspect
15
20
private String name ;
16
21
@ Inspect
You can’t perform that action at this time.
0 commit comments