Skip to content
Closed
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,12 @@
import java.util.Arrays;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.LinkedHashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.TreeSet;
import java.util.function.Function;
import javax.xml.stream.XMLOutputFactory;
import javax.xml.stream.XMLStreamException;
Expand Down Expand Up @@ -65,13 +67,11 @@
import org.apache.nifi.processor.Relationship;

/**
* XML-based implementation of DocumentationWriter
*
* XML-based implementation of DocumentationWriter.
* Please note that while this class lives within the nifi-api, it is provided primarily as a means for documentation components within
* the NiFi NAR Maven Plugin. Its home is the nifi-api, however, because the API is needed in order to extract the relevant information and
* the NAR Maven Plugin cannot have a direct dependency on nifi-api (doing so would cause a circular dependency). By having this homed within
* the nifi-api, the Maven plugin is able to discover the class dynamically and invoke the one or two methods necessary to create the documentation.
*
* This is a new capability in 1.9.0 in preparation for the Extension Registry and therefore, you should
* <b>NOTE WELL:</b> At this time, while this class is part of nifi-api, it is still evolving and may change in a non-backward-compatible manner or even be
* removed from one incremental release to the next. Use at your own risk!
Expand Down Expand Up @@ -108,12 +108,12 @@ protected void writeDeprecationNotice(final DeprecationNotice deprecationNotice)
return;
}

final Class[] classes = deprecationNotice.alternatives();
final Class<?>[] classes = deprecationNotice.alternatives();
final String[] classNames = deprecationNotice.classNames();

final Set<String> alternatives = new LinkedHashSet<>();
if (classes != null) {
for (final Class alternativeClass : classes) {
for (final Class<?> alternativeClass : classes) {
alternatives.add(alternativeClass.getName());
}
}
Expand Down Expand Up @@ -218,7 +218,16 @@ private void writeResourceDefinition(final ResourceDefinition resourceDefinition

writeStartElement("resourceDefinition");
writeTextElement("cardinality", resourceDefinition.getCardinality().name());
writeArray("resourceTypes", resourceDefinition.getResourceTypes(), this::writeResourceType);

final Set<ResourceType> resourceTypes = resourceDefinition.getResourceTypes();
if (resourceTypes == null) {
writeArray("resourceTypes", null, this::writeResourceType);
} else {
final Set<ResourceType> orderedResourceTypes = new TreeSet<>(Comparator.comparing(ResourceType::name));
orderedResourceTypes.addAll(resourceTypes);
writeArray("resourceTypes", orderedResourceTypes, this::writeResourceType);
}

writeEndElement();
}

Expand All @@ -242,15 +251,18 @@ private void writeDependencies(final PropertyDescriptor propertyDescriptor) thro

writeStartElement("dependencies");

for (final PropertyDependency dependency : dependencies) {
final Set<PropertyDependency> orderedDependencies = new TreeSet<>(Comparator.comparing(PropertyDependency::getPropertyName));
orderedDependencies.addAll(dependencies);
for (final PropertyDependency dependency : orderedDependencies) {
writeStartElement("dependency");
writeTextElement("propertyName", dependency.getPropertyName());
writeTextElement("propertyDisplayName", dependency.getPropertyDisplayName());

final Set<String> dependentValues = dependency.getDependentValues();
if (dependentValues != null) {
writeStartElement("dependentValues");
for (final String dependentValue : dependentValues) {
final Collection<String> orderedDependentValues = new TreeSet<>(dependentValues);
for (final String dependentValue : orderedDependentValues) {
writeTextElement("dependentValue", dependentValue);
}
writeEndElement();
Expand Down Expand Up @@ -355,12 +367,12 @@ protected void writeSeeAlso(final SeeAlso seeAlso) throws IOException {
return;
}

final Class[] classes = seeAlso.value();
final Class<?>[] classes = seeAlso.value();
final String[] classNames = seeAlso.classNames();

final Set<String> toSee = new LinkedHashSet<>();
if (classes != null) {
for (final Class classToSee : classes) {
for (final Class<?> classToSee : classes) {
toSee.add(classToSee.getName());
}
}
Expand Down Expand Up @@ -434,7 +446,9 @@ protected void writeRelationships(final Set<Relationship> relationships) throws
return;
}

writeArray("relationships", relationships, rel -> {
final Set<Relationship> ordered = new TreeSet<>(Comparator.comparing(Relationship::getName));
ordered.addAll(relationships);
writeArray("relationships", ordered, rel -> {
writeStartElement("relationship");

writeTextElement("name", rel.getName());
Expand Down
Loading
Loading