Search in sources :

Example 1 with Event

use of org.flywaydb.core.api.callback.Event in project flyway by flyway.

the class ResourceNameParser method populatePrefixes.

private List<Pair<String, ResourceType>> populatePrefixes(Configuration configuration) {
    List<Pair<String, ResourceType>> prefixes = new ArrayList<>();
    prefixes.add(Pair.of(configuration.getSqlMigrationPrefix(), ResourceType.MIGRATION));
    prefixes.add(Pair.of(configuration.getRepeatableSqlMigrationPrefix(), ResourceType.REPEATABLE_MIGRATION));
    for (Event event : Event.values()) {
        prefixes.add(Pair.of(event.getId(), ResourceType.CALLBACK));
    }
    Comparator<Pair<String, ResourceType>> prefixComparator = (p1, p2) -> {
        // Sort most-hard-to-match first; that is, in descending order of prefix length
        return p2.getLeft().length() - p1.getLeft().length();
    };
    prefixes.sort(prefixComparator);
    return prefixes;
}
Also used : Configuration(org.flywaydb.core.api.configuration.Configuration) MigrationVersion(org.flywaydb.core.api.MigrationVersion) java.util(java.util) Event(org.flywaydb.core.api.callback.Event) Pair(org.flywaydb.core.internal.util.Pair) Event(org.flywaydb.core.api.callback.Event) Pair(org.flywaydb.core.internal.util.Pair)

Aggregations

java.util (java.util)1 MigrationVersion (org.flywaydb.core.api.MigrationVersion)1 Event (org.flywaydb.core.api.callback.Event)1 Configuration (org.flywaydb.core.api.configuration.Configuration)1 Pair (org.flywaydb.core.internal.util.Pair)1