File tree Expand file tree Collapse file tree 1 file changed +21
-0
lines changed
src/main/java/cz/jiripinkas/jsitemapgenerator Expand file tree Collapse file tree 1 file changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -73,6 +73,23 @@ public I addPage(String name) {
73
73
return addPage (WebPage .of (name ));
74
74
}
75
75
76
+ /**
77
+ * Add single page to sitemap.
78
+ * @param supplier Supplier method which sneaks any checked exception
79
+ * https://www.baeldung.com/java-sneaky-throws
80
+ * Allows for calling method which performs some operation and then returns name of page.
81
+ * @return this
82
+ */
83
+ public I addPage (StringSupplierWithException <String > supplier ) {
84
+ try {
85
+ addPage (supplier .get ());
86
+ } catch (Exception e ) {
87
+ sneakyThrow (e );
88
+ }
89
+ return getThis ();
90
+ }
91
+
92
+
76
93
/**
77
94
* This method is called before adding a page to urls.
78
95
* It can be used to change webPage attributes
@@ -223,6 +240,10 @@ public interface GeneratorConsumerWithException<T> {
223
240
void accept (T t ) throws Exception ;
224
241
}
225
242
243
+ public interface StringSupplierWithException <String > {
244
+ String get () throws Exception ;
245
+ }
246
+
226
247
/**
227
248
* Sneak exception https://www.baeldung.com/java-sneaky-throws
228
249
* @param e Exception
You can’t perform that action at this time.
0 commit comments