All Downloads are FREE. Search and download functionalities are using the official Maven repository.

berlin.yuna.configmetadata.model.AutoConfigurationClass Maven / Gradle / Ivy

There is a newer version: 0.6.154
Show newest version
package berlin.yuna.configmetadata.model;

import berlin.yuna.configmetadata.logic.MetaDataGenerator;

import java.io.IOException;
import java.nio.file.Path;
import java.util.ArrayList;
import java.util.List;
import java.util.Objects;

import static java.util.Arrays.asList;

@SuppressWarnings({"UnusedReturnValue", "unused"})
public class AutoConfigurationClass extends MetaDataGenerator {

    private final List> autoConfigClasses = new ArrayList<>();

    public AutoConfigurationClass() {
    }

    public AutoConfigurationClass(final Class... autoConfigClasses) {
        this.autoConfigClasses.addAll(new ArrayList<>(asList(autoConfigClasses)));
    }

    public List> getAutoConfigClasses() {
        return autoConfigClasses;
    }

    public AutoConfigurationClass newAutoConfigClass(final Class... autoConfigClasses) {
        this.autoConfigClasses.addAll(new ArrayList<>(asList(autoConfigClasses)));
        return this;
    }

    public Path generate() throws IOException {
        final StringBuilder content = new StringBuilder();
        content.append("org.springframework.boot.autoconfigure.EnableAutoConfiguration=\\\n");

        for (Class clazz : getAutoConfigClasses()) {
            content.append(clazz.getTypeName()).append("\n");
        }
        return write(TYPE_AUTO_CONFIG, content.toString());
    }

    @Override
    public boolean equals(final Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
        final AutoConfigurationClass that = (AutoConfigurationClass) o;
        return Objects.equals(autoConfigClasses, that.autoConfigClasses);
    }

    @Override
    public int hashCode() {

        return Objects.hash(autoConfigClasses);
    }

    @Override
    public String toString() {
        return "AutoConfigurationClass{" +
                "autoConfigClasses=" + autoConfigClasses +
                '}';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy