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

de.akquinet.jbosscc.guttenbase.hints.impl.HighPriorityTableOrderHint Maven / Gradle / Ivy

The newest version!
package de.akquinet.jbosscc.guttenbase.hints.impl;

import de.akquinet.jbosscc.guttenbase.mapping.TableOrderComparatorFactory;

import java.util.List;
import java.util.Locale;
import java.util.stream.Collectors;

/**
 * Order by natural order of table names with some high priority exceptions ranked first
 *
 * 

* © 2012-2034 akquinet tech@spree *

* * @author M. Dahm */ public class HighPriorityTableOrderHint extends DefaultTableOrderHint { private final List _tableNames; public HighPriorityTableOrderHint(final List tableNames) { assert tableNames != null : "assert tableNames != null"; _tableNames = tableNames.stream().map(s -> s.toLowerCase(Locale.ROOT)).collect(Collectors.toList()); } @Override public TableOrderComparatorFactory getValue() { return () -> (t1, t2) -> { if (_tableNames.contains(t1.getTableName().toLowerCase(Locale.ROOT))) { return -1; } else if (_tableNames.contains(t2.getTableName().toLowerCase(Locale.ROOT))) { return 1; } else { return t1.compareTo(t2); } }; } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy