
org.zodiac.ds.api.strategy.TableSwitchStrategyMatcher Maven / Gradle / Ivy
package org.zodiac.ds.api.strategy;
import java.lang.reflect.Method;
import java.util.Collections;
import java.util.Map;
import java.util.function.Supplier;
import org.zodiac.commons.proxy.MethodInterceptorContext;
/**
* You can use this to customize the table switching method.
*
*/
public interface TableSwitchStrategyMatcher {
/**
* Match the class and method, and return whether the data source switch is required.
*
* @param target The class
* @param method The method
* @return Whether you need to switch table.
*/
boolean match(Class target, Method method);
/**
* Get the table switching strategy.
*
* @param context The {@link MethodInterceptorContext}
* @return The {@link Strategy}
*/
Strategy getStrategy(MethodInterceptorContext context);
/**
* Table switching strategy.
*/
interface Strategy {
/**
* Get the Table mappings.
*
* @return Table mappings.
* @see org.zodiac.ds.api.switcher.TableSwitcher#getTable(String)
*/
Map getMapping();
static Strategy of(Map mapping) {
return () -> mapping;
}
static Strategy of(Supplier
© 2015 - 2025 Weber Informatics LLC | Privacy Policy