This is an automated email from the ASF dual-hosted git repository.
exceptionfactory pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/nifi-api.git
The following commit(s) were added to refs/heads/main by this push:
new d3c0121 NIFI-15574 Added the Javadoc snippet tag for the code
examples in Javadocs (#65)
d3c0121 is described below
commit d3c0121de87c459407f7f6af5421ae3a49755aa9
Author: dan-s1 <[email protected]>
AuthorDate: Sat Feb 28 15:13:12 2026 -0500
NIFI-15574 Added the Javadoc snippet tag for the code examples in Javadocs
(#65)
Signed-off-by: David Handermann <[email protected]>
---
.../nifi/components/ConfigurableComponent.java | 4 ++--
.../apache/nifi/components/PropertyDescriptor.java | 12 +++++++---
.../apache/nifi/controller/ControllerService.java | 19 ++++++++-------
.../nifi/migration/PropertyConfiguration.java | 18 +++++++-------
.../nifi/migration/RelationshipConfiguration.java | 14 +++++------
.../org/apache/nifi/processor/ProcessSession.java | 28 +++++++++++-----------
.../java/org/apache/nifi/time/DurationFormat.java | 14 +++++------
7 files changed, 58 insertions(+), 51 deletions(-)
diff --git
a/src/main/java/org/apache/nifi/components/ConfigurableComponent.java
b/src/main/java/org/apache/nifi/components/ConfigurableComponent.java
index 2c47dab..4ab462c 100644
--- a/src/main/java/org/apache/nifi/components/ConfigurableComponent.java
+++ b/src/main/java/org/apache/nifi/components/ConfigurableComponent.java
@@ -63,7 +63,7 @@ public interface ConfigurableComponent {
* onPropertyModified method. This can be done as follows:
* </p>
*
- * <pre>{@code
+ * {@snippet :
* private volatile boolean configurationRestored = false;
*
* @OnConfigurationRestored
@@ -76,7 +76,7 @@ public interface ConfigurableComponent {
* return;
* }
* }
- * }</pre>
+ * }
*
* @param descriptor the descriptor for the property being modified
* @param oldValue the value that was previously set. Will be
<code>null</code> if no value
diff --git a/src/main/java/org/apache/nifi/components/PropertyDescriptor.java
b/src/main/java/org/apache/nifi/components/PropertyDescriptor.java
index 5e959d2..3e316d6 100644
--- a/src/main/java/org/apache/nifi/components/PropertyDescriptor.java
+++ b/src/main/java/org/apache/nifi/components/PropertyDescriptor.java
@@ -561,9 +561,15 @@ public final class PropertyDescriptor implements
Comparable<PropertyDescriptor>
* Any property descriptor that identifies an external resource will
be automatically validated against the following rules:
* <ul>
* <li>If the ResourceCardinality is SINGLE, the given property
value must be a file, a directory, or a URL that uses a protocol of
http/https/file.</li>
- * <li>The given resourceTypes dictate which types of input are
allowed. For example, if
<code>identifiesExternalResource(ResourceCardinality.SINGLE,
ResourceType.FILE)</code>
- * is used, the input must be a regular file. If
<code>identifiesExternalResource(ResourceCardinality.SINGLE, ResourceType.FILE,
ResourceType.DIRECTORY)</code> is used, then the input
- * must be exactly one file OR directory.
+ * <li>The given resourceTypes dictate which types of input are
allowed. For example, if
+ * {@snippet :
+ * identifiesExternalResource(ResourceCardinality.SINGLE,
ResourceType.FILE)
+ * }
+ * is used, the input must be a regular file. If
+ * {@snippet :
+ * identifiesExternalResource(ResourceCardinality.SINGLE,
ResourceType.FILE, ResourceType.DIRECTORY)
+ * }
+ * is used, then the input must be exactly one file OR directory.
* </li>
* <li>If the ResourceCardinality is MULTIPLE, the given property
value may consist of one or more resources, each separated by a comma and
optional white space.</li>
* </ul>
diff --git a/src/main/java/org/apache/nifi/controller/ControllerService.java
b/src/main/java/org/apache/nifi/controller/ControllerService.java
index e8f9850..c8acebe 100644
--- a/src/main/java/org/apache/nifi/controller/ControllerService.java
+++ b/src/main/java/org/apache/nifi/controller/ControllerService.java
@@ -70,21 +70,22 @@ import org.apache.nifi.reporting.ReportingTask;
* <p>
* For example:
* </p>
- * <pre><code>
+ * {@snippet :
* public static final PropertyDescriptor MY_PROPERTY = new
PropertyDescriptor.Builder()
* .name("My Property")
* .description("Example Property")
* .identifiesControllerService( MyControllerServiceInterface.class )
* .build();
*
- * ...
+ * // Other code
+ *
* public void onTrigger(ProcessContext context, ProcessSessionFactory
sessionFactory) throws ProcessException {
* // Obtain the user-selected controller service
* final MyControllerServiceInterface service =
context.getProperty(MY_PROPERTY).asControllerService(
MyControllerServiceInterface.class );
- * ...
- * }
*
- * </code></pre>
+ * // Other code
+ * }
+ * }
* <li>A Controller Service can be obtained via a
* {@link ControllerServiceLookup}. This lookup may be obtained, for example,
* from the {@link ProcessContext} that is provided to a {@link Processor}'s
@@ -94,11 +95,11 @@ import org.apache.nifi.reporting.ReportingTask;
* For example:
* </p>
*
- * <pre><code>
+ * {@snippet :
* public void onTrigger(ProcessContext context, ProcessSessionFactory
sessionFactory) throws ProcessException {
* final MyControllerServiceInterface service =
(MyControllerServiceInterface)
context.getControllerServiceLookup().getControllerService("service_identifier");
* }
- * </code></pre>
+ * }
* </li>
* </ul>
*
@@ -139,14 +140,14 @@ import org.apache.nifi.reporting.ReportingTask;
*
* <p>
* Typically, this is done by creating a NAR structure as follows:
- * <pre>
+ * {@snippet lang="text" :
* + my-services-api-nar
* +--- service-X-implementation-nar
* +--- service-Y-implementation-nar
* +--- service-Z-implementation-nar
* +--- processor-A-nar
* +--- processor-B-nar
- * </pre>
+ * }
*
* <p>
* In this case, the {@code MyControllerServiceInterface} interface, and any
diff --git a/src/main/java/org/apache/nifi/migration/PropertyConfiguration.java
b/src/main/java/org/apache/nifi/migration/PropertyConfiguration.java
index e6e2cc9..92bf371 100644
--- a/src/main/java/org/apache/nifi/migration/PropertyConfiguration.java
+++ b/src/main/java/org/apache/nifi/migration/PropertyConfiguration.java
@@ -50,9 +50,9 @@ public interface PropertyConfiguration {
* <p>
* An idiom to determine if the property was explicitly set to
<code>null</code> is as follows:
* </p>
- * <pre><code>
- * final boolean setToNull = configuration.hasProperty("MyProperty")
&& !configuration.isPropertySet("MyProperty");
- * </code></pre>
+ * {@snippet :
+ * final boolean setToNull = configuration.hasProperty("MyProperty") &&
!configuration.isPropertySet("MyProperty");
+ * }
*
* @param propertyName the name of the property
* @return <code>true</code> if the property name is known to this
configuration, <code>false</code> otherwise.
@@ -69,9 +69,9 @@ public interface PropertyConfiguration {
* <p>
* An idiom to determine if the property was explicitly set to
<code>null</code> is as follows:
* </p>
- * <pre><code>
- * final boolean setToNull = configuration.hasProperty(MY_PROPERTY)
&& !configuration.isSet(MY_PROPERTY);
- * </code></pre>
+ * {@snippet :
+ * final boolean setToNull = configuration.hasProperty(MY_PROPERTY) &&
!configuration.isSet(MY_PROPERTY);
+ * }
*
* @param descriptor the property descriptor that identifies the property
* @return <code>true</code> if the property name is known to this
configuration, <code>false</code> otherwise.
@@ -176,10 +176,10 @@ public interface PropertyConfiguration {
* use this method as such:
* </p>
*
- * <pre><code>
+ * {@snippet :
* // Create a new Controller Service of type
org.apache.nifi.services.authentication.UsernamePassword whose Username and
Password
* // properties match those currently configured for this Processor.
- * final Map<String, String> serviceProperties =
Map.of("Username", propertyConfiguration.getRawPropertyValue("Username"),
+ * final Map<String, String> serviceProperties = Map.of("Username",
propertyConfiguration.getRawPropertyValue("Username"),
* "Password",
propertyConfiguration.getRawPropertyValue("Password"));
* final String serviceId =
propertyConfiguration.createControllerService("org.apache.nifi.services.authentication.UsernamePassword",
serviceProperties);
*
@@ -189,7 +189,7 @@ public interface PropertyConfiguration {
* // Remove the Username and Password properties from this Processor,
since we are now going to use then Authentication Service.
* propertyConfiguration.removeProperty("Username");
* propertyConfiguration.removeProperty("Password");
- * </code></pre>
+ * }
*
* <p>
* Note the use of {@link #getRawPropertyValue(String)} here instead of
{@link #getPropertyValue(String)}. Because we want to set
diff --git
a/src/main/java/org/apache/nifi/migration/RelationshipConfiguration.java
b/src/main/java/org/apache/nifi/migration/RelationshipConfiguration.java
index e43aa64..da5ab2c 100644
--- a/src/main/java/org/apache/nifi/migration/RelationshipConfiguration.java
+++ b/src/main/java/org/apache/nifi/migration/RelationshipConfiguration.java
@@ -58,9 +58,9 @@ public interface RelationshipConfiguration {
* It is possible to split an existing relationship into the same
relationship and additional relationships. For example, it is
* valid to call this method as:
* </p>
- * <pre><code>
- * relationshipConfiguration.splitRelationship("A", "A", "B", "C");
- * </code></pre>
+ * {@snippet :
+ * relationshipConfiguration.splitRelationship("A", "A", "B", "C");
+ * }
*
* <p>
* In order to split the "A" relationship into three relationships: "A",
"B", and "C". However, upon restart, NiFi will have already split the "A"
@@ -69,11 +69,11 @@ public interface RelationshipConfiguration {
* exist first:
* </p>
*
- * <pre><code>
- * if (!relationshipConfiguration.hasRelationship("B")) {
- * relationshipConfiguration.splitRelationship("A", "A", "B", "C");
+ * {@snippet :
+ * if (!relationshipConfiguration.hasRelationship("B")) {
+ * relationshipConfiguration.splitRelationship("A", "A", "B", "C");
+ * }
* }
- * </code></pre>
*
* <p>
* This ensures that we do not attempt to split relationship "A" if it has
already been done.
diff --git a/src/main/java/org/apache/nifi/processor/ProcessSession.java
b/src/main/java/org/apache/nifi/processor/ProcessSession.java
index 7028962..2f4b630 100644
--- a/src/main/java/org/apache/nifi/processor/ProcessSession.java
+++ b/src/main/java/org/apache/nifi/processor/ProcessSession.java
@@ -105,24 +105,24 @@ public interface ProcessSession {
* and implementing that action in the provided callback.
* <p>
* As a result, the following very common idiom:
- * <pre><code>
- * getDataFromSource();
- * session.commit();
- * acknowledgeReceiptOfData();
- * </code></pre>
+ * {@snippet :
+ * getDataFromSource();
+ * session.commit();
+ * acknowledgeReceiptOfData();
+ * }
* Cannot be simply changed to:
- * <pre><code>
- * getDataFromSource();
- * session.commitAsync();
- * acknowledgeReceiptOfData();
- * </code></pre>
+ * {@snippet :
+ * getDataFromSource();
+ * session.commitAsync();
+ * acknowledgeReceiptOfData();
+ * }
* Doing so could result in acknowledging receipt of data from the source
system before data has been committed to the repositories.
* If NiFi were to then be restarted, there is potential for data loss.
* Rather, the following idiom should take its place to ensure that there
is no data loss:
- * <pre><code>
- * getDataFromSource();
- * session.commitAsync( () -> acknowledgeReceiptOfData() );
- * </code></pre>
+ * {@snippet :
+ * getDataFromSource();
+ * session.commitAsync( () -> acknowledgeReceiptOfData() );
+ * }
* <p>
* If the session cannot be committed, an error will be logged and the
session will be rolled back instead.
*
diff --git a/src/main/java/org/apache/nifi/time/DurationFormat.java
b/src/main/java/org/apache/nifi/time/DurationFormat.java
index 5c7cb33..0527cc4 100644
--- a/src/main/java/org/apache/nifi/time/DurationFormat.java
+++ b/src/main/java/org/apache/nifi/time/DurationFormat.java
@@ -72,13 +72,13 @@ public class DurationFormat {
* This method handles decimal values over {@code 1 ns}, but {@code < 1
ns} will return {@code 0} in any other unit.
* <p>
* Examples:
- * <p>
- * "10 seconds", {@code TimeUnit.MILLISECONDS} -> 10_000.0
- * "0.010 s", {@code TimeUnit.MILLISECONDS} -> 10.0
- * "0.010 s", {@code TimeUnit.SECONDS} -> 0.010
- * "0.010 ns", {@code TimeUnit.NANOSECONDS} -> 1
- * "0.010 ns", {@code TimeUnit.MICROSECONDS} -> 0
- *
+ * {@snippet lang="text" :
+ * "10 seconds", {@code TimeUnit.MILLISECONDS} -> 10_000.0
+ * "0.010 s", {@code TimeUnit.MILLISECONDS} -> 10.0
+ * "0.010 s", {@code TimeUnit.SECONDS} -> 0.010
+ * "0.010 ns", {@code TimeUnit.NANOSECONDS} -> 1
+ * "0.010 ns", {@code TimeUnit.MICROSECONDS} -> 0
+ * }
* @param value the {@code String} input
* @param desiredUnit the desired output {@link TimeUnit}
* @return the parsed and converted amount (without a unit)