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

io.github.nichetoolkit.mybatis.MybatisMapper Maven / Gradle / Ivy

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

import io.github.nichetoolkit.rest.reflect.RestGenericTypes;

import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

/**
 * MybatisMapper
 * 

The mybatis mapper interface.

* @param {@link java.lang.Object}

The parameter can be of any type.

* @author Cyan ([email protected]) * @since Jdk1.8 */ public interface MybatisMapper { /** * mapperType *

The mapper type method.

* @return {@link java.lang.Class}

The mapper type return object is Class type.

* @see java.lang.Class * @see java.lang.SuppressWarnings */ @SuppressWarnings(value = "unchecked") default Class mapperType() { return (Class) Instance.mapperType(getClass()); } /** * table *

The table method.

* @return {@link io.github.nichetoolkit.mybatis.MybatisTable}

The table return object is MybatisTable type.

* @see io.github.nichetoolkit.mybatis.MybatisTable */ default MybatisTable table() { return MybatisFactory.createTable(mapperType(), null, null, null); } /** * Instance *

The instance class.

* @author Cyan ([email protected]) * @since Jdk1.8 */ class Instance { /** * MAPPER_TYPES * {@link java.util.Map}

The MAPPER_TYPES field.

* @see java.util.Map */ private static Map, Class> MAPPER_TYPES; /** * mapperType *

The mapper type method.

* @param clazz {@link java.lang.Class}

The clazz parameter is Class type.

* @return {@link java.lang.Class}

The mapper type return object is Class type.

* @see java.lang.Class */ private static Class mapperType(Class clazz) { if (MAPPER_TYPES == null) { MAPPER_TYPES = new ConcurrentHashMap<>(); } if (!MAPPER_TYPES.containsKey(clazz)) { MAPPER_TYPES.put(clazz, RestGenericTypes.resolveClass(RestGenericTypes.resolveType( MybatisMapper.class.getTypeParameters()[0], clazz, MybatisMapper.class))); } return MAPPER_TYPES.get(clazz); } } }




© 2015 - 2024 Weber Informatics LLC | Privacy Policy