1 | package pro.verron.officestamper.preset; | |
2 | ||
3 | import pro.verron.officestamper.api.ObjectResolver; | |
4 | import pro.verron.officestamper.api.OfficeStamperException; | |
5 | import pro.verron.officestamper.preset.resolvers.date.DateResolver; | |
6 | import pro.verron.officestamper.preset.resolvers.image.ImageResolver; | |
7 | import pro.verron.officestamper.preset.resolvers.localdate.LocalDateResolver; | |
8 | import pro.verron.officestamper.preset.resolvers.localdatetime.LocalDateTimeResolver; | |
9 | import pro.verron.officestamper.preset.resolvers.localtime.LocalTimeResolver; | |
10 | import pro.verron.officestamper.preset.resolvers.nulls.Null2DefaultResolver; | |
11 | import pro.verron.officestamper.preset.resolvers.nulls.Null2PlaceholderResolver; | |
12 | import pro.verron.officestamper.preset.resolvers.objects.ToStringResolver; | |
13 | ||
14 | import java.time.LocalDate; | |
15 | import java.time.LocalDateTime; | |
16 | import java.time.LocalTime; | |
17 | import java.time.format.DateTimeFormatter; | |
18 | import java.util.Date; | |
19 | ||
20 | /** | |
21 | * This class provides static methods to create different types of | |
22 | * {@link ObjectResolver}. | |
23 | * | |
24 | * @author Joseph Verron | |
25 | * @version ${version} | |
26 | * @since 1.6.7 | |
27 | */ | |
28 | public class Resolvers { | |
29 | ||
30 | private Resolvers() { | |
31 | throw new OfficeStamperException("Resolvers cannot be instantiated"); | |
32 | } | |
33 | ||
34 | /** | |
35 | * Returns an instance of {@link ObjectResolver} that can act as a fallback | |
36 | * resolver. Will call the {@link Object#toString()} method on every type | |
37 | * of objects. | |
38 | * | |
39 | * @return An instance of {@link ObjectResolver} | |
40 | */ | |
41 | public static ObjectResolver fallback() { | |
42 |
1
1. fallback : replaced return value with null for pro/verron/officestamper/preset/Resolvers::fallback → KILLED |
return new ToStringResolver(); |
43 | } | |
44 | ||
45 | /** | |
46 | * Returns an instance of {@link ObjectResolver} that replaces null values with an empty string. | |
47 | * | |
48 | * @return An instance of {@link ObjectResolver} | |
49 | */ | |
50 | public static ObjectResolver nullToEmpty() { | |
51 |
1
1. nullToEmpty : replaced return value with null for pro/verron/officestamper/preset/Resolvers::nullToEmpty → KILLED |
return nullToDefault(""); |
52 | } | |
53 | ||
54 | /** | |
55 | * Returns an instance of {@link ObjectResolver} that resolves null objects | |
56 | * by creating a run with a default text value. | |
57 | * | |
58 | * @param value The default value for null objects. | |
59 | * | |
60 | * @return An instance of {@link ObjectResolver} | |
61 | */ | |
62 | public static ObjectResolver nullToDefault(String value) { | |
63 |
1
1. nullToDefault : replaced return value with null for pro/verron/officestamper/preset/Resolvers::nullToDefault → KILLED |
return new Null2DefaultResolver(value); |
64 | } | |
65 | ||
66 | /** | |
67 | * Returns an instance of {@link ObjectResolver} that resolves null objects | |
68 | * by not replacing their expression. | |
69 | * | |
70 | * @return An instance of {@link ObjectResolver} | |
71 | */ | |
72 | public static ObjectResolver nullToPlaceholder() { | |
73 |
1
1. nullToPlaceholder : replaced return value with null for pro/verron/officestamper/preset/Resolvers::nullToPlaceholder → SURVIVED |
return new Null2PlaceholderResolver(); |
74 | } | |
75 | ||
76 | /** | |
77 | * Returns an instance of {@link ObjectResolver} that resolves | |
78 | * {@link LocalDateTime} values to a formatted string using the | |
79 | * {@link DateTimeFormatter#ISO_LOCAL_DATE_TIME} pattern. | |
80 | * | |
81 | * @return An instance of {@link ObjectResolver} | |
82 | */ | |
83 | public static ObjectResolver isoDateTime() { | |
84 |
1
1. isoDateTime : replaced return value with null for pro/verron/officestamper/preset/Resolvers::isoDateTime → KILLED |
return new LocalDateTimeResolver(); |
85 | } | |
86 | ||
87 | /** | |
88 | * Returns an instance of {@link ObjectResolver} that resolves | |
89 | * {@link LocalTime} values to a formatted string using the | |
90 | * {@link DateTimeFormatter#ISO_LOCAL_TIME} pattern. | |
91 | * | |
92 | * @return An instance of {@link ObjectResolver} | |
93 | */ | |
94 | public static ObjectResolver isoTime() { | |
95 |
1
1. isoTime : replaced return value with null for pro/verron/officestamper/preset/Resolvers::isoTime → KILLED |
return new LocalTimeResolver(); |
96 | } | |
97 | ||
98 | /** | |
99 | * Returns an instance of {@link ObjectResolver} that resolves | |
100 | * {@link LocalDate} values to a formatted string using the | |
101 | * {@link DateTimeFormatter#ISO_LOCAL_DATE} pattern. | |
102 | * | |
103 | * @return An instance of {@link ObjectResolver} | |
104 | */ | |
105 | public static ObjectResolver isoDate() { | |
106 |
1
1. isoDate : replaced return value with null for pro/verron/officestamper/preset/Resolvers::isoDate → KILLED |
return new LocalDateResolver(); |
107 | } | |
108 | ||
109 | /** | |
110 | * Returns an instance of {@link ObjectResolver} that resolves | |
111 | * {@link LocalTime} values to a formatted string using the given | |
112 | * {@link DateTimeFormatter} pattern. | |
113 | * | |
114 | * @param formatter the {@link DateTimeFormatter} pattern to use | |
115 | * | |
116 | * @return An instance of {@link ObjectResolver} | |
117 | */ | |
118 | public static ObjectResolver isoTime(DateTimeFormatter formatter) { | |
119 |
1
1. isoTime : replaced return value with null for pro/verron/officestamper/preset/Resolvers::isoTime → NO_COVERAGE |
return new LocalTimeResolver(formatter); |
120 | } | |
121 | ||
122 | /** | |
123 | * Returns an instance of {@link ObjectResolver} that resolves | |
124 | * {@link LocalDate} values to a formatted string using the given | |
125 | * {@link DateTimeFormatter} pattern. | |
126 | * | |
127 | * @param formatter the {@link DateTimeFormatter} pattern to use | |
128 | * | |
129 | * @return An instance of {@link ObjectResolver} | |
130 | */ | |
131 | public static ObjectResolver isoDate(DateTimeFormatter formatter) { | |
132 |
1
1. isoDate : replaced return value with null for pro/verron/officestamper/preset/Resolvers::isoDate → NO_COVERAGE |
return new LocalDateResolver(formatter); |
133 | } | |
134 | ||
135 | /** | |
136 | * Returns an instance of {@link ObjectResolver} that resolves | |
137 | * {@link LocalDateTime} values to a formatted string using the given | |
138 | * {@link DateTimeFormatter} pattern. | |
139 | * | |
140 | * @param formatter the {@link DateTimeFormatter} pattern to use | |
141 | * | |
142 | * @return An instance of {@link ObjectResolver} | |
143 | */ | |
144 | public static ObjectResolver isoDateTime(DateTimeFormatter formatter) { | |
145 |
1
1. isoDateTime : replaced return value with null for pro/verron/officestamper/preset/Resolvers::isoDateTime → NO_COVERAGE |
return new LocalDateTimeResolver(formatter); |
146 | } | |
147 | ||
148 | /** | |
149 | * Returns an instance of {@link ObjectResolver} that resolves | |
150 | * {@link Date} values to a formatted string using the | |
151 | * "dd.MM.yyyy" pattern. | |
152 | * | |
153 | * @return An instance of {@link ObjectResolver} | |
154 | */ | |
155 | public static ObjectResolver legacyDate() { | |
156 |
1
1. legacyDate : replaced return value with null for pro/verron/officestamper/preset/Resolvers::legacyDate → KILLED |
return new DateResolver(); |
157 | } | |
158 | ||
159 | /** | |
160 | * Returns an instance of {@link ObjectResolver} that resolves | |
161 | * {@link Date} values to a formatted string using the given | |
162 | * {@link DateTimeFormatter} pattern. | |
163 | * | |
164 | * @param formatter the {@link DateTimeFormatter} pattern to use | |
165 | * | |
166 | * @return An instance of {@link ObjectResolver} | |
167 | */ | |
168 | public static ObjectResolver legacyDate(DateTimeFormatter formatter) { | |
169 |
1
1. legacyDate : replaced return value with null for pro/verron/officestamper/preset/Resolvers::legacyDate → NO_COVERAGE |
return new DateResolver(formatter); |
170 | } | |
171 | ||
172 | /** | |
173 | * Returns an instance of {@link ObjectResolver} that resolves | |
174 | * {@link Image} to an actual image in the resulting .docx document. | |
175 | * The image will be put as an inline into the surrounding paragraph of text. | |
176 | * | |
177 | * @return An instance of {@link ObjectResolver} | |
178 | */ | |
179 | public static ObjectResolver image() { | |
180 |
1
1. image : replaced return value with null for pro/verron/officestamper/preset/Resolvers::image → KILLED |
return new ImageResolver(); |
181 | } | |
182 | ||
183 | ||
184 | } | |
Mutations | ||
42 |
1.1 |
|
51 |
1.1 |
|
63 |
1.1 |
|
73 |
1.1 |
|
84 |
1.1 |
|
95 |
1.1 |
|
106 |
1.1 |
|
119 |
1.1 |
|
132 |
1.1 |
|
145 |
1.1 |
|
156 |
1.1 |
|
169 |
1.1 |
|
180 |
1.1 |