Remove API/SPI grouping into different files
This commit is contained in:
parent
9f3a3520af
commit
e2640fc192
|
@ -11,13 +11,11 @@ import java.io.IOException;
|
|||
import java.io.Writer;
|
||||
import java.util.Map;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Predicate;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import org.hibernate.orm.properties.processor.AsciiDocWriter;
|
||||
import org.hibernate.orm.properties.processor.ConfigPropertyHolder;
|
||||
import org.hibernate.orm.properties.processor.ConfigurationProperty;
|
||||
import org.hibernate.orm.properties.processor.HibernateOrmConfiguration;
|
||||
|
||||
import org.gradle.api.DefaultTask;
|
||||
import org.gradle.api.Project;
|
||||
|
@ -28,11 +26,6 @@ import org.gradle.api.tasks.TaskAction;
|
|||
*/
|
||||
public class ConfigPropertyWriterTask extends DefaultTask {
|
||||
|
||||
private static final Predicate<Map.Entry<String, ConfigurationProperty>> API_FILTER = entry -> HibernateOrmConfiguration.Type.API.equals(
|
||||
entry.getValue().type() );
|
||||
private static final Predicate<Map.Entry<String, ConfigurationProperty>> SPI_FILTER = entry -> HibernateOrmConfiguration.Type.SPI.equals(
|
||||
entry.getValue().type() );
|
||||
|
||||
private final Project project;
|
||||
private final ConfigPropertyHolder properties;
|
||||
private final String fileName = "configs";
|
||||
|
@ -46,22 +39,10 @@ public class ConfigPropertyWriterTask extends DefaultTask {
|
|||
@TaskAction
|
||||
public void writeProperties() {
|
||||
if ( properties.hasProperties() ) {
|
||||
if ( properties.hasProperties( API_FILTER ) ) {
|
||||
writeProperties(
|
||||
fileName + ".asciidoc",
|
||||
new AsciiDocWriter(
|
||||
API_FILTER
|
||||
)
|
||||
);
|
||||
}
|
||||
if ( properties.hasProperties( SPI_FILTER ) ) {
|
||||
writeProperties(
|
||||
fileName + "-spi.asciidoc",
|
||||
new AsciiDocWriter(
|
||||
SPI_FILTER
|
||||
)
|
||||
);
|
||||
}
|
||||
writeProperties(
|
||||
fileName + ".asciidoc",
|
||||
new AsciiDocWriter()
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -15,21 +15,13 @@ import java.util.Map;
|
|||
import java.util.TreeMap;
|
||||
import java.util.TreeSet;
|
||||
import java.util.function.BiConsumer;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
public class AsciiDocWriter implements BiConsumer<Map<String, ConfigurationProperty>, Writer> {
|
||||
|
||||
private final Predicate<Map.Entry<String, ConfigurationProperty>> filter;
|
||||
|
||||
public AsciiDocWriter(Predicate<Map.Entry<String, ConfigurationProperty>> filter) {
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void accept(Map<String, ConfigurationProperty> propertyMap, Writer writer) {
|
||||
Map<String, Collection<ConfigurationProperty>> groups = propertyMap.entrySet().stream()
|
||||
.filter( filter )
|
||||
.map( Map.Entry::getValue )
|
||||
.collect(
|
||||
Collectors.groupingBy(
|
||||
|
|
Loading…
Reference in New Issue