001/* 002 * Copyright 2002-2018 the original author or authors. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * https://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016 017package org.springframework.jdbc.core.namedparam; 018 019import org.springframework.lang.Nullable; 020 021/** 022 * A simple empty implementation of the {@link SqlParameterSource} interface. 023 * 024 * @author Juergen Hoeller 025 * @since 3.2.2 026 */ 027public class EmptySqlParameterSource implements SqlParameterSource { 028 029 /** 030 * A shared instance of {@link EmptySqlParameterSource}. 031 */ 032 public static final EmptySqlParameterSource INSTANCE = new EmptySqlParameterSource(); 033 034 035 @Override 036 public boolean hasValue(String paramName) { 037 return false; 038 } 039 040 @Override 041 @Nullable 042 public Object getValue(String paramName) throws IllegalArgumentException { 043 throw new IllegalArgumentException("This SqlParameterSource is empty"); 044 } 045 046 @Override 047 public int getSqlType(String paramName) { 048 return TYPE_UNKNOWN; 049 } 050 051 @Override 052 @Nullable 053 public String getTypeName(String paramName) { 054 return null; 055 } 056 057 @Override 058 @Nullable 059 public String[] getParameterNames() { 060 return null; 061 } 062 063}