001/*
002 *  Copyright 2019 Anyware Services
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 *      http://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 */
016package org.ametys.odf.ose.db.parameter;
017
018/**
019 * Object to represent a query parameter to add : value and type.
020 */
021public class ValuedQueryParameter implements QueryParameter
022{
023    private String _name;
024    private Object _value;
025    private int _type;
026    
027    /**
028     * Constructor.
029     * @param name The name of the parameter
030     * @param value The value of the parameter, can be null for nullable columns
031     * @param type The type of the parameter
032     */
033    public ValuedQueryParameter(String name, Object value, int type)
034    {
035        this._name = name;
036        this._value = value;
037        this._type = type;
038    }
039
040    @Override
041    public String getName()
042    {
043        return _name;
044    }
045    
046    @Override
047    public String getParameter()
048    {
049        return ":" + _name;
050    }
051    
052    /**
053     * Get the value.
054     * @return the value
055     */
056    public Object getValue()
057    {
058        return _value;
059    }
060    
061    /**
062     * Get the type.
063     * @return the type
064     */
065    public int getType()
066    {
067        return _type;
068    }
069}