spring EmptySqlParameterSource 源码

  • 2022-08-08
  • 浏览 (332)

spring EmptySqlParameterSource 代码

文件路径:/spring-jdbc/src/main/java/org/springframework/jdbc/core/namedparam/EmptySqlParameterSource.java

/*
 * Copyright 2002-2018 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      https://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.jdbc.core.namedparam;

import org.springframework.lang.Nullable;

/**
 * A simple empty implementation of the {@link SqlParameterSource} interface.
 *
 * @author Juergen Hoeller
 * @since 3.2.2
 */
public class EmptySqlParameterSource implements SqlParameterSource {

	/**
	 * A shared instance of {@link EmptySqlParameterSource}.
	 */
	public static final EmptySqlParameterSource INSTANCE = new EmptySqlParameterSource();


	@Override
	public boolean hasValue(String paramName) {
		return false;
	}

	@Override
	@Nullable
	public Object getValue(String paramName) throws IllegalArgumentException {
		throw new IllegalArgumentException("This SqlParameterSource is empty");
	}

	@Override
	public int getSqlType(String paramName) {
		return TYPE_UNKNOWN;
	}

	@Override
	@Nullable
	public String getTypeName(String paramName) {
		return null;
	}

	@Override
	@Nullable
	public String[] getParameterNames() {
		return null;
	}

}

相关信息

spring 源码目录

相关文章

spring AbstractSqlParameterSource 源码

spring BeanPropertySqlParameterSource 源码

spring MapSqlParameterSource 源码

spring NamedParameterJdbcDaoSupport 源码

spring NamedParameterJdbcOperations 源码

spring NamedParameterJdbcTemplate 源码

spring NamedParameterUtils 源码

spring ParsedSql 源码

spring SqlParameterSource 源码

spring SqlParameterSourceUtils 源码

0  赞