
com.ktanx.common.model.Model Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of ktanx-common Show documentation
Show all versions of ktanx-common Show documentation
Ktanx is a java development kit.
The newest version!
package com.ktanx.common.model;
import com.ktanx.common.exception.KtanxException;
import com.ktanx.common.utils.ClassUtils;
import java.util.LinkedHashMap;
import java.util.Map;
public class Model extends Pageable {
private static final long serialVersionUID = 3793689719542455985L;
/**
* 关键字
*/
private String keywords;
/**
* 排序名称
*/
private String sortName;
/**
* 排序方式
*/
private String sortOrder;
/**
* 数据map
*/
private Map extensionProperties;
public Model() {
extensionProperties = new LinkedHashMap();
}
/**
* 放入数据
*
* @param name the name
* @param value the value
*/
public void addExtensionProperty(String name, Object value) {
extensionProperties.put(name, value);
}
/**
* 放入数据
*
* @param propertyMap the map
*/
public void addExtensionProperties(Map propertyMap) {
if (propertyMap == null) {
return;
}
extensionProperties.putAll(propertyMap);
}
public void removeExtensionProperty(String name) {
this.extensionProperties.remove(name);
}
/**
* 获取数据
*
* @param key
* @return
*/
public Object getExtensionProperty(String key) {
return this.getExtensionProperty(key, Object.class);
}
/**
* 获取数据
*
* @param the type parameter
* @param name the name
* @param elementType the element type
* @return t t
*/
@SuppressWarnings("unchecked")
public T getExtensionProperty(String name, Class elementType) {
if (this.extensionProperties == null) {
return null;
}
Object obj = this.extensionProperties.get(name);
if (obj == null) {
return null;
}
if (!elementType.isAssignableFrom(obj.getClass())) {
throw new KtanxException(
"类型不匹配。expected:" + elementType.getName() + ",actual:" + obj.getClass());
}
return (T) obj;
}
public Map getExtensionProperties() {
return extensionProperties;
}
/**
* 获取数据
*
* @param key
* @return
*/
public Object get(String key) {
return this.getExtensionProperty(key);
}
/**
* 获取指定属性值
*
* @param fieldName
* @return
*/
public Object getFieldValue(String fieldName) {
return ClassUtils.getFieldValue(this.getClass(), this, fieldName);
}
/**
* 关键字 简化前端参数
*
* @param keywords
*/
public void setK(String keywords) {
this.keywords = keywords;
}
public String getKeywords() {
return keywords;
}
public void setKeywords(String keywords) {
this.keywords = keywords;
}
public String getSortName() {
return sortName;
}
public void setSortName(String sortName) {
this.sortName = sortName;
}
public String getSortOrder() {
return sortOrder;
}
public void setSortOrder(String sortOrder) {
this.sortOrder = sortOrder;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy