| 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 | /// This class provides static methods to create different types of | |
| 21 | /// [ObjectResolver]. | |
| 22 | /// | |
| 23 | /// @author Joseph Verron | |
| 24 | /// @since 1.6.7 | |
| 25 | public class Resolvers { | |
| 26 | ||
| 27 | private Resolvers() { | |
| 28 | throw new OfficeStamperException("Resolvers cannot be instantiated"); | |
| 29 | } | |
| 30 | ||
| 31 | /// Returns an instance of [ObjectResolver] that can act as a fallback | |
| 32 | /// resolver. | |
| 33 | /// | |
| 34 | /// Will call the [Object#toString()] method on every type of objects. | |
| 35 | /// | |
| 36 | /// @param linebreakPlaceholder The placeholder to use for linebreaks. | |
| 37 | /// | |
| 38 | /// @return An instance of [ObjectResolver] | |
| 39 | public static ObjectResolver fallback(String linebreakPlaceholder) { | |
| 40 |
1
1. fallback : replaced return value with null for pro/verron/officestamper/preset/Resolvers::fallback → KILLED |
return new ToStringResolver(linebreakPlaceholder); |
| 41 | } | |
| 42 | ||
| 43 | /// Returns an instance of [ObjectResolver] that replaces `null` values with | |
| 44 | /// an empty string. | |
| 45 | /// | |
| 46 | /// @return An instance of [ObjectResolver] | |
| 47 | public static ObjectResolver nullToEmpty() { | |
| 48 |
1
1. nullToEmpty : replaced return value with null for pro/verron/officestamper/preset/Resolvers::nullToEmpty → KILLED |
return nullToDefault(""); |
| 49 | } | |
| 50 | ||
| 51 | /// Returns an instance of [ObjectResolver] that resolves `null` values by | |
| 52 | /// creating a run with a default text value. | |
| 53 | /// | |
| 54 | /// @param value The default value for null objects. | |
| 55 | /// | |
| 56 | /// @return An instance of [ObjectResolver] | |
| 57 | public static ObjectResolver nullToDefault(String value) { | |
| 58 |
1
1. nullToDefault : replaced return value with null for pro/verron/officestamper/preset/Resolvers::nullToDefault → KILLED |
return new Null2DefaultResolver(value); |
| 59 | } | |
| 60 | ||
| 61 | /// Returns an instance of [ObjectResolver] that resolves `null` values by | |
| 62 | /// not replacing their expression. | |
| 63 | /// | |
| 64 | /// @return An instance of [ObjectResolver] | |
| 65 | public static ObjectResolver nullToPlaceholder() { | |
| 66 |
1
1. nullToPlaceholder : replaced return value with null for pro/verron/officestamper/preset/Resolvers::nullToPlaceholder → KILLED |
return nullToPlaceholder("${%s}"); |
| 67 | } | |
| 68 | ||
| 69 | /// Returns an instance of [ObjectResolver] that resolves `null` values by | |
| 70 | /// not replacing their expression. | |
| 71 | /// | |
| 72 | /// @param placeholderTemplate The placeholder to use for null objects. | |
| 73 | /// | |
| 74 | /// @return An instance of [ObjectResolver] | |
| 75 | public static ObjectResolver nullToPlaceholder(String placeholderTemplate) { | |
| 76 |
1
1. nullToPlaceholder : replaced return value with null for pro/verron/officestamper/preset/Resolvers::nullToPlaceholder → KILLED |
return new Null2PlaceholderResolver(placeholderTemplate); |
| 77 | } | |
| 78 | ||
| 79 | /// Returns an instance of [ObjectResolver] that resolves [LocalDateTime] | |
| 80 | /// values to a formatted string using the | |
| 81 | /// [DateTimeFormatter#ISO_LOCAL_DATE_TIME] pattern. | |
| 82 | /// | |
| 83 | /// @return An instance of [ObjectResolver] | |
| 84 | public static ObjectResolver isoDateTime() { | |
| 85 |
1
1. isoDateTime : replaced return value with null for pro/verron/officestamper/preset/Resolvers::isoDateTime → KILLED |
return new LocalDateTimeResolver(); |
| 86 | } | |
| 87 | ||
| 88 | /// Returns an instance of [ObjectResolver] that resolves [LocalTime] values | |
| 89 | /// to a formatted string using the [DateTimeFormatter#ISO_LOCAL_TIME] | |
| 90 | /// pattern. | |
| 91 | /// | |
| 92 | /// @return An instance of [ObjectResolver] | |
| 93 | public static ObjectResolver isoTime() { | |
| 94 |
1
1. isoTime : replaced return value with null for pro/verron/officestamper/preset/Resolvers::isoTime → KILLED |
return new LocalTimeResolver(); |
| 95 | } | |
| 96 | ||
| 97 | /// Returns an instance of [ObjectResolver] that resolves [LocalDate] values | |
| 98 | /// to a formatted string using the [DateTimeFormatter#ISO_LOCAL_DATE] | |
| 99 | /// pattern. | |
| 100 | /// | |
| 101 | /// @return An instance of [ObjectResolver] | |
| 102 | public static ObjectResolver isoDate() { | |
| 103 |
1
1. isoDate : replaced return value with null for pro/verron/officestamper/preset/Resolvers::isoDate → KILLED |
return new LocalDateResolver(); |
| 104 | } | |
| 105 | ||
| 106 | /// Returns an instance of [ObjectResolver] that resolves [LocalTime] values | |
| 107 | /// to a formatted string using the given [DateTimeFormatter] pattern. | |
| 108 | /// | |
| 109 | /// @param formatter the [DateTimeFormatter] pattern to use | |
| 110 | /// | |
| 111 | /// @return An instance of [ObjectResolver] | |
| 112 | public static ObjectResolver isoTime(DateTimeFormatter formatter) { | |
| 113 |
1
1. isoTime : replaced return value with null for pro/verron/officestamper/preset/Resolvers::isoTime → KILLED |
return new LocalTimeResolver(formatter); |
| 114 | } | |
| 115 | ||
| 116 | /// Returns an instance of [ObjectResolver] that resolves [LocalDate] values | |
| 117 | /// to a formatted string using the given [DateTimeFormatter] pattern. | |
| 118 | /// | |
| 119 | /// @param formatter the [DateTimeFormatter] pattern to use | |
| 120 | /// | |
| 121 | /// @return An instance of [ObjectResolver] | |
| 122 | public static ObjectResolver isoDate(DateTimeFormatter formatter) { | |
| 123 |
1
1. isoDate : replaced return value with null for pro/verron/officestamper/preset/Resolvers::isoDate → KILLED |
return new LocalDateResolver(formatter); |
| 124 | } | |
| 125 | ||
| 126 | /// Returns an instance of [ObjectResolver] that resolves [LocalDateTime] | |
| 127 | /// values to a formatted string using the given [DateTimeFormatter] | |
| 128 | /// pattern. | |
| 129 | /// | |
| 130 | /// @param formatter the [DateTimeFormatter] pattern to use | |
| 131 | /// | |
| 132 | /// @return An instance of [ObjectResolver] | |
| 133 | public static ObjectResolver isoDateTime(DateTimeFormatter formatter) { | |
| 134 |
1
1. isoDateTime : replaced return value with null for pro/verron/officestamper/preset/Resolvers::isoDateTime → KILLED |
return new LocalDateTimeResolver(formatter); |
| 135 | } | |
| 136 | ||
| 137 | /// Returns an instance of [ObjectResolver] that resolves [Date] values to a | |
| 138 | /// formatted string using the "dd.MM.yyyy" pattern. | |
| 139 | /// | |
| 140 | /// @return An instance of [ObjectResolver] | |
| 141 | public static ObjectResolver legacyDate() { | |
| 142 |
1
1. legacyDate : replaced return value with null for pro/verron/officestamper/preset/Resolvers::legacyDate → KILLED |
return new DateResolver(); |
| 143 | } | |
| 144 | ||
| 145 | /// Returns an instance of [ObjectResolver] that resolves [Date] values to a | |
| 146 | /// formatted string using the given [DateTimeFormatter] pattern. | |
| 147 | /// | |
| 148 | /// @param formatter the [DateTimeFormatter] pattern to use | |
| 149 | /// | |
| 150 | /// @return An instance of [ObjectResolver] | |
| 151 | public static ObjectResolver legacyDate(DateTimeFormatter formatter) { | |
| 152 |
1
1. legacyDate : replaced return value with null for pro/verron/officestamper/preset/Resolvers::legacyDate → KILLED |
return new DateResolver(formatter); |
| 153 | } | |
| 154 | ||
| 155 | /// Returns an instance of [ObjectResolver] that resolves [Image] to an | |
| 156 | /// actual image in the resulting .docx document. The image will be put | |
| 157 | /// as an inline into the surrounding paragraph of text. | |
| 158 | /// | |
| 159 | /// @param deduplicate whether to deduplicate identical images in the | |
| 160 | /// document | |
| 161 | /// | |
| 162 | /// @return An instance of [ObjectResolver] | |
| 163 | public static ObjectResolver image(boolean deduplicate) { | |
| 164 |
1
1. image : replaced return value with null for pro/verron/officestamper/preset/Resolvers::image → KILLED |
return new ImageResolver(deduplicate); |
| 165 | } | |
| 166 | } | |
Mutations | ||
| 40 |
1.1 |
|
| 48 |
1.1 |
|
| 58 |
1.1 |
|
| 66 |
1.1 |
|
| 76 |
1.1 |
|
| 85 |
1.1 |
|
| 94 |
1.1 |
|
| 103 |
1.1 |
|
| 113 |
1.1 |
|
| 123 |
1.1 |
|
| 134 |
1.1 |
|
| 142 |
1.1 |
|
| 152 |
1.1 |
|
| 164 |
1.1 |