cn.dreampie.common.entity
类 Entity<M extends Entity>

java.lang.Object
  继承者 cn.dreampie.common.entity.Entity<M>

public abstract class Entity<M extends Entity>
extends Object

Created by ice on 14-12-31.


构造方法摘要
Entity()
           
 
方法摘要
 boolean checkMethod()
          check method for to json
 M clearAttrs()
          Remove all attrs of this entity.
 M clearModifyAttrs()
           
<T> T
get(String attr)
          Get attr of any sql type
<T> T
get(String attr, Class<T> clazz)
          Parse attr to any type
<T> T
get(String attr, Class<T> clazz, Object defaultValue)
          Get attr for clazz.
<T> T
get(String attr, Object defaultValue)
          Get attr of any sql type.
 String[] getAttrNames()
          Return attr name of this record.
 Map<String,Object> getAttrs()
          Return attribute Map.
 Object[] getAttrValues()
          Return attr values of this record.
abstract  Class getColumnType(String attr)
          获取改数据库列对应的java类型
 String[] getModifyAttrNames()
          Return attribute name of this entity.
 Map<String,Object> getModifyAttrs()
          获取更新的属性列表
 Object[] getModifyAttrValues()
          Return attribute values of this entity.
abstract  boolean hasColumn(String attr)
          判断数据库是否拥有该列
 M init(String attr, Object value)
          初始化属性 不会添加到modify
 M initAttrs(M entity)
           
 M initAttrs(Map<String,Object> attrs)
           
 M keep(String... attrs)
          Keep attrs of this entity and remove other attrs.
 M keep(String attr)
          Keep attr of this entity and remove other attrs.
 M put(String attr, Object value)
          Put key value pair to the entity when the key is not attribute of the entity.
 M putAttrs(M entity)
          Set attrs value with entity.
 M putAttrs(Map<String,Object> attrs)
           
 M remove(String... attrs)
          Remove attrs of this entity.
 M remove(String attr)
          Remove attribute of this entity.
 M removeNull()
          Remove attrs if it is null.
 M reSetAttrs(Map<String,Object> attrs)
           
 M reSetModifyAttrs(Map<String,Object> modifyAttrs)
           
 M set(String attr, Object value)
          Set attribute to entity.
 M setAttrs(M entity)
          Set attributes with other entity.
 M setAttrs(Map<String,Object> attrs)
          Set attributes with Map.
 String toJson()
          Return json string of this record.
 String toString()
           
 
从类 java.lang.Object 继承的方法
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

构造方法详细信息

Entity

public Entity()
方法详细信息

getAttrs

public Map<String,Object> getAttrs()
Return attribute Map. Danger! The update method will ignore the attribute if you change it directly. You must use set method to change attribute that update method can handle it.


setAttrs

public M setAttrs(M entity)
Set attributes with other entity.

参数:
entity - the Model
返回:
this Model

setAttrs

public M setAttrs(Map<String,Object> attrs)
Set attributes with Map.

参数:
attrs - attributes of this entity
返回:
this Model

getModifyAttrs

public Map<String,Object> getModifyAttrs()
获取更新的属性列表

返回:
Map

checkMethod

public boolean checkMethod()
check method for to json

返回:
boolean

hasColumn

public abstract boolean hasColumn(String attr)
判断数据库是否拥有该列

参数:
attr - 属性名
返回:
boolean

getColumnType

public abstract Class getColumnType(String attr)
获取改数据库列对应的java类型

参数:
attr - 属性名
返回:
class

set

public M set(String attr,
             Object value)
Set attribute to entity.

参数:
attr - the attribute name of the entity
value - the value of the attribute
返回:
this entity
抛出:
EntityException - if the attribute is not exists of the entity

init

public M init(String attr,
              Object value)
初始化属性 不会添加到modify

参数:
attr -
value -
返回:

initAttrs

public M initAttrs(Map<String,Object> attrs)

initAttrs

public M initAttrs(M entity)

put

public M put(String attr,
             Object value)
Put key value pair to the entity when the key is not attribute of the entity.

参数:
attr - 属性名称
value - 属性值
返回:
当前entity对象

putAttrs

public M putAttrs(Map<String,Object> attrs)

putAttrs

public M putAttrs(M entity)
Set attrs value with entity.

参数:
entity - the entity

get

public <T> T get(String attr)
Get attr of any sql type


get

public <T> T get(String attr,
                 Class<T> clazz)
Parse attr to any type


get

public <T> T get(String attr,
                 Object defaultValue)
Get attr of any sql type. Returns defaultValue if null.


get

public <T> T get(String attr,
                 Class<T> clazz,
                 Object defaultValue)
Get attr for clazz. Returns defaultValue if null.


remove

public M remove(String attr)
Remove attribute of this entity.

参数:
attr - the attr name of the entity

remove

public M remove(String... attrs)
Remove attrs of this entity.

参数:
attrs - the attr name of the entity

removeNull

public M removeNull()
Remove attrs if it is null.


keep

public M keep(String... attrs)
Keep attrs of this entity and remove other attrs.

参数:
attrs - the attr name of the entity

keep

public M keep(String attr)
Keep attr of this entity and remove other attrs.

参数:
attr - the attr name of the entity

clearAttrs

public M clearAttrs()
Remove all attrs of this entity.


clearModifyAttrs

public M clearModifyAttrs()

reSetAttrs

public M reSetAttrs(Map<String,Object> attrs)

reSetModifyAttrs

public M reSetModifyAttrs(Map<String,Object> modifyAttrs)

getAttrNames

public String[] getAttrNames()
Return attr name of this record.


getAttrValues

public Object[] getAttrValues()
Return attr values of this record.


getModifyAttrNames

public String[] getModifyAttrNames()
Return attribute name of this entity.


getModifyAttrValues

public Object[] getModifyAttrValues()
Return attribute values of this entity.


toString

public String toString()
覆盖:
Object 中的 toString

toJson

public String toJson()
Return json string of this record.



Copyright © 2015. All rights reserved.