
br.com.anteros.persistence.parameter.NamedParameter Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of Anteros-Persistence-Core Show documentation
Show all versions of Anteros-Persistence-Core Show documentation
Anteros Persistence Core for Java.
The newest version!
/*******************************************************************************
* Copyright 2012 Anteros Tecnologia
*
* 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
*
* http://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 br.com.anteros.persistence.parameter;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.Map;
import br.com.anteros.persistence.metadata.annotation.type.TemporalType;
import br.com.anteros.persistence.sql.binder.DateParameterBinding;
import br.com.anteros.persistence.sql.binder.DateTimeParameterBinding;
/**
*
* @author Edson Martins - Anteros
*
*/
public class NamedParameter {
protected String name;
protected Object value;
protected boolean key;
protected TemporalType temporalType;
public NamedParameter(String name) {
this.name = name;
this.key = false;
}
public NamedParameter(String name, Object value) {
this.name = name;
this.value = value;
this.key = false;
}
public NamedParameter(String name, Object value, TemporalType temporalType) {
this.name = name;
this.value = value;
this.key = false;
this.temporalType = temporalType;
}
public NamedParameter(String name, Object value, boolean key) {
this.name = name;
this.value = value;
this.key = key;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public Object getValue() {
if (temporalType != null && temporalType == TemporalType.DATE)
return new DateParameterBinding(value);
else if (temporalType != null && temporalType == TemporalType.DATE_TIME)
return new DateTimeParameterBinding(value);
else
return value;
}
public void setValue(Object value) {
this.value = value;
}
@Override
public String toString() {
return name + "=" + value;
}
public static NamedParameterList list() {
return new NamedParameterList();
}
public static String[] getAllNames(List parameters) {
List result = new ArrayList();
for (NamedParameter param : parameters) {
result.add(param.getName());
}
return result.toArray(new String[] {});
}
public static Object[] getAllValues(List parameters) {
List
© 2015 - 2025 Weber Informatics LLC | Privacy Policy