File tree Expand file tree Collapse file tree 8 files changed +58
-32
lines changed
main/java/pl/wavesoftware/utils/stringify/impl
test/java/pl/wavesoftware/utils/stringify Expand file tree Collapse file tree 8 files changed +58
-32
lines changed Original file line number Diff line number Diff line change 44
55 <groupId >pl.wavesoftware.utils</groupId >
66 <artifactId >stringify-object</artifactId >
7- <version >1.0.1 </version >
7+ <version >1.0.2 </version >
88 <packaging >jar</packaging >
99
1010 <name >Stringify Object for Java</name >
Original file line number Diff line number Diff line change 44 * @author <a href="mailto:krzysztof.suszynski@coi.gov.pl">Krzysztof Suszynski</a>
55 * @since 27.04.18
66 */
7- public interface InspectingField {
7+ interface InspectingField {
88 boolean shouldInspect ();
99 boolean showNull ();
1010}
Original file line number Diff line number Diff line change 22
33import lombok .RequiredArgsConstructor ;
44import pl .wavesoftware .utils .stringify .configuration .BeanFactory ;
5- import pl .wavesoftware .utils .stringify .configuration .DisplayNull ;
65import pl .wavesoftware .utils .stringify .configuration .InspectionPoint ;
76import pl .wavesoftware .utils .stringify .configuration .Mode ;
87
@@ -27,30 +26,4 @@ private InspectFieldPredicate createPredicate(BeanFactory beanFactory) {
2726 }
2827 }
2928
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- }
5629}
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 1111@ Data
1212@ EqualsAndHashCode (callSuper = true )
1313final class Earth extends Planet {
14+
15+ private static final long serialVersionUID = 20180430201544L ;
16+
1417 @ Inspect
1518 private Moon moon ;
1619 @ Inspect
Original file line number Diff line number Diff line change 1717@ ToString (exclude = "nullinside" )
1818@ EqualsAndHashCode (callSuper = true )
1919final class Moon extends Planet {
20+
21+ private static final long serialVersionUID = 20180430201602L ;
22+
2023 @ Inspect
2124 private Phase phase ;
2225 @ Inspect
Original file line number Diff line number Diff line change 1313 */
1414@ Setter
1515class Person {
16- private int id ;
16+ private volatile int id ;
1717 @ DisplayNull
18- private Person parent ;
18+ private transient Person parent ;
1919 private List <Person > childs ;
2020 private Account account ;
2121 @ Inspect (conditionally = IsInDevelopment .class )
Original file line number Diff line number Diff line change 55import pl .wavesoftware .utils .stringify .configuration .DoNotInspect ;
66import pl .wavesoftware .utils .stringify .configuration .Inspect ;
77
8+ import java .io .Serializable ;
9+
810/**
911 * @author <a href="krzysztof.suszynski@wavesoftware.pl">Krzysztof Suszyński</a>
1012 * @since 2018-04-18
1113 */
1214@ Data
13- abstract class Planet {
15+ abstract class Planet implements Serializable {
16+
17+ private static final long serialVersionUID = 20180430201529L ;
18+
1419 @ Inspect
1520 private String name ;
1621 @ Inspect
You can’t perform that action at this time.
0 commit comments