com.github.drinkjava2.jsqlbox.entitynet
Class EntityIdUtils

java.lang.Object
  extended by com.github.drinkjava2.jsqlbox.entitynet.EntityIdUtils

public abstract class EntityIdUtils
extends Object

 Entity Id Utils, an Entity ID can be:
 
 1. MAP (For compound id)
 2. Basic Java Objects (For single id)
 3. Instance of Entity Class, which implements ActiveRecordSupport interface or have @Entity annotation (for compound or single id)
 
 

Since:
1.0.0
Author:
Yong Zhu

Field Summary
static String COMPOUND_ID_SEPARATOR
          Used to combine compound key column values into a single String
 
Constructor Summary
EntityIdUtils()
           
 
Method Summary
static Object buildEntityIdFromEntity(Object entity, TableModel model)
           
static Object buildEntityIdFromMap(Map<String,Object> map, TableModel model)
           
static Object buildEntityIdFromOneRow(String[] titles, Object[] oneRow, TableModel model, String alias)
          Build entityId from titles, oneRow, model, alias
static Object buildEntityIdFromUnknow(Object entityId, TableModel model)
          Build Node id from unknown entityIdOrIdMap
static List<Object> getOnlyOneFieldFromIds(Iterable<?> ids, TableModel model, String entityFieldName)
          Get the real id list only for one java field, because Iterable ids may be compound id
static Object readFeidlValueFromEntityId(Object entityId, TableModel model, String entityFieldName)
          Read field value from entityId: 1) if entityId is map, get the value by use fieldName as key
2) if entityId is basic java Object, direct return it 3) if is Entity? read field value from it.
static
<T> T
setEntityIdValues(T bean, Object entityId, TableModel model)
          Put one id value into a entity bean, or put values according a map
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

COMPOUND_ID_SEPARATOR

public static final String COMPOUND_ID_SEPARATOR
Used to combine compound key column values into a single String

See Also:
Constant Field Values
Constructor Detail

EntityIdUtils

public EntityIdUtils()
Method Detail

buildEntityIdFromOneRow

public static Object buildEntityIdFromOneRow(String[] titles,
                                             Object[] oneRow,
                                             TableModel model,
                                             String alias)
Build entityId from titles, oneRow, model, alias


buildEntityIdFromEntity

public static Object buildEntityIdFromEntity(Object entity,
                                             TableModel model)

buildEntityIdFromMap

public static Object buildEntityIdFromMap(Map<String,Object> map,
                                          TableModel model)

buildEntityIdFromUnknow

public static Object buildEntityIdFromUnknow(Object entityId,
                                             TableModel model)
Build Node id from unknown entityIdOrIdMap


setEntityIdValues

public static <T> T setEntityIdValues(T bean,
                                      Object entityId,
                                      TableModel model)
Put one id value into a entity bean, or put values according a map


readFeidlValueFromEntityId

public static Object readFeidlValueFromEntityId(Object entityId,
                                                TableModel model,
                                                String entityFieldName)
Read field value from entityId: 1) if entityId is map, get the value by use fieldName as key
2) if entityId is basic java Object, direct return it 3) if is Entity? read field value from it.


getOnlyOneFieldFromIds

public static List<Object> getOnlyOneFieldFromIds(Iterable<?> ids,
                                                  TableModel model,
                                                  String entityFieldName)
Get the real id list only for one java field, because Iterable ids may be compound id



Copyright © 2018. All rights reserved.