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

liquibase.configuration.ConfiguredValueModifierFactory Maven / Gradle / Ivy

There is a newer version: 4.30.0
Show newest version
package liquibase.configuration;

import liquibase.Scope;
import liquibase.SingletonObject;
import liquibase.servicelocator.ServiceLocator;

import java.util.*;

/**
 * Factory for working with {@link ConfiguredValueModifier}s.
 */
public class ConfiguredValueModifierFactory  implements SingletonObject {

    private final SortedSet allInstances;

    private ConfiguredValueModifierFactory() {
        this.allInstances = new TreeSet<>(Comparator.comparingInt(ConfiguredValueModifier::getOrder));

        ServiceLocator serviceLocator = Scope.getCurrentScope().getServiceLocator();
        this.allInstances.addAll(serviceLocator.findInstances(ConfiguredValueModifier.class));

    }

    public void register(ConfiguredValueModifier modifier) {
        allInstances.add(modifier);
    }

    public void unregister(ConfiguredValueModifier modifier) {
        allInstances.remove(modifier);
    }

    public void override(ConfiguredValue configuredValue) {
        for (ConfiguredValueModifier modifier: allInstances) {
            modifier.override(configuredValue);
        }
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy