io.github.nichetoolkit.mybatis.defaults.DefaultTableFactoryChain Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of mybatis-toolkit-context Show documentation
Show all versions of mybatis-toolkit-context Show documentation
Mybatis toolkit context project for Spring Boot
The newest version!
package io.github.nichetoolkit.mybatis.defaults;
import io.github.nichetoolkit.mybatis.MybatisTable;
import io.github.nichetoolkit.mybatis.MybatisTableFactory;
import org.springframework.lang.NonNull;
import org.springframework.lang.Nullable;
import java.util.List;
/**
* DefaultTableFactoryChain
* The default table factory chain class.
* @author Cyan ([email protected])
* @see io.github.nichetoolkit.mybatis.MybatisTableFactory.Chain
* @since Jdk1.8
*/
public class DefaultTableFactoryChain implements MybatisTableFactory.Chain {
/**
* factories
* {@link java.util.List} The factories
field.
* @see java.util.List
*/
private final List factories;
/**
* next
* {@link io.github.nichetoolkit.mybatis.defaults.DefaultTableFactoryChain} The next
field.
*/
private final DefaultTableFactoryChain next;
/**
* index
* The index
field.
*/
private final int index;
/**
* DefaultTableFactoryChain
* Instantiates a new default table factory chain.
* @param factories {@link java.util.List} The factories parameter is List
type.
* @see java.util.List
*/
public DefaultTableFactoryChain(List factories) {
this(factories, 0);
}
/**
* DefaultTableFactoryChain
* Instantiates a new default table factory chain.
* @param factories {@link java.util.List} The factories parameter is List
type.
* @param index int The index parameter is int
type.
* @see java.util.List
*/
private DefaultTableFactoryChain(List factories, int index) {
this.factories = factories;
this.index = index;
if (this.index < this.factories.size()) {
this.next = new DefaultTableFactoryChain(factories, this.index + 1);
} else {
this.next = null;
}
}
@Override
public MybatisTable createTable(@NonNull Class> entityType, @Nullable Class> identityType, @Nullable Class> linkageType, @Nullable Class> alertnessType) {
if (index < factories.size()) {
MybatisTableFactory mybatisTableFactory = factories.get(index);
if (mybatisTableFactory.supports(entityType)) {
return mybatisTableFactory.createTable(entityType, identityType, linkageType, alertnessType, next);
}
}
return null;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy