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

io.github.nichetoolkit.mybatis.defaults.DefaultColumnFactoryChain Maven / Gradle / Ivy

The newest version!
package io.github.nichetoolkit.mybatis.defaults;


import io.github.nichetoolkit.mybatis.MybatisColumn;
import io.github.nichetoolkit.mybatis.MybatisColumnFactory;
import io.github.nichetoolkit.mybatis.MybatisField;
import io.github.nichetoolkit.mybatis.MybatisTable;
import org.springframework.lang.NonNull;

import java.util.List;
import java.util.Optional;

/**
 * DefaultColumnFactoryChain
 * 

The default column factory chain class.

* @author Cyan ([email protected]) * @see io.github.nichetoolkit.mybatis.MybatisColumnFactory.Chain * @since Jdk1.8 */ public class DefaultColumnFactoryChain implements MybatisColumnFactory.Chain { /** * factories * {@link java.util.List}

The factories field.

* @see java.util.List */ private final List factories; /** * next * {@link io.github.nichetoolkit.mybatis.defaults.DefaultColumnFactoryChain}

The next field.

*/ private final DefaultColumnFactoryChain next; /** * index *

The index field.

*/ private final int index; /** * DefaultColumnFactoryChain *

Instantiates a new default column factory chain.

* @param factories {@link java.util.List}

The factories parameter is List type.

* @see java.util.List */ public DefaultColumnFactoryChain(List factories) { this(factories, 0); } /** * DefaultColumnFactoryChain *

Instantiates a new default column 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 DefaultColumnFactoryChain(List factories, int index) { this.factories = factories; this.index = index; if (this.index < this.factories.size()) { this.next = new DefaultColumnFactoryChain(factories, this.index + 1); } else { this.next = null; } } @Override public Optional> createColumn(@NonNull MybatisTable mybatisTable,@NonNull MybatisField mybatisField) { if (index < factories.size()) { MybatisColumnFactory mybatisColumnFactory = factories.get(index); if (mybatisColumnFactory.supports(mybatisTable,mybatisField)) { return mybatisColumnFactory.createColumn(mybatisTable, mybatisField, next); } } return Optional.empty(); } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy