本文整理汇总了Java中com.fasterxml.jackson.annotation.ObjectIdGenerator.IdKey类的典型用法代码示例。如果您正苦于以下问题:Java IdKey类的具体用法?Java IdKey怎么用?Java IdKey使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
IdKey类属于com.fasterxml.jackson.annotation.ObjectIdGenerator包,在下文中一共展示了IdKey类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: findObjectId
import com.fasterxml.jackson.annotation.ObjectIdGenerator.IdKey; //导入依赖的package包/类
public ReadableObjectId findObjectId(Object paramObject, ObjectIdGenerator<?> paramObjectIdGenerator)
{
ObjectIdGenerator.IdKey localIdKey = paramObjectIdGenerator.key(paramObject);
if (this._objectIds == null)
{
this._objectIds = new LinkedHashMap();
}
else
{
ReadableObjectId localReadableObjectId1 = (ReadableObjectId)this._objectIds.get(localIdKey);
if (localReadableObjectId1 != null)
return localReadableObjectId1;
}
ReadableObjectId localReadableObjectId2 = new ReadableObjectId(paramObject);
this._objectIds.put(localIdKey, localReadableObjectId2);
return localReadableObjectId2;
}
示例2: resolveId
import com.fasterxml.jackson.annotation.ObjectIdGenerator.IdKey; //导入依赖的package包/类
/**
*
*/
@Override
public E resolveId(IdKey idKey) {
try {
if (idKey.key instanceof Integer) {
final Integer id = (Integer) idKey.key;
// we only "load" the entity to follow a lazy approach, i.e.
// requests to the database will only be queried if any properties
// of the entity will (later) be accessed (which may already
// the case when jackson is doing some magic)
return service.loadById(id);
} else {
throw new Exception("ID is not of type Integer.");
}
} catch (Exception e) {
LOG.error("Could not resolve object by ID: " + e.getMessage());
return null;
}
}
示例3: bindItem
import com.fasterxml.jackson.annotation.ObjectIdGenerator.IdKey; //导入依赖的package包/类
@Override
public void bindItem(IdKey id, Object ob)
{
if (_items == null) {
_items = new HashMap<ObjectIdGenerator.IdKey,Object>();
} else if (_items.containsKey(id)) {
throw new IllegalStateException("Already had POJO for id (" + id.key.getClass().getName() + ") [" + id
+ "]");
}
_items.put(id, ob);
}
示例4: bindItem
import com.fasterxml.jackson.annotation.ObjectIdGenerator.IdKey; //导入依赖的package包/类
@Override
public void bindItem(IdKey id, Object ob)
{
if (_items == null) {
_items = new HashMap<IdKey,Object>();
} else if (_items.containsKey(id)) {
throw new IllegalStateException("Already had POJO for id (" + id.key.getClass().getName() + ") [" + id
+ "]");
}
_items.put(id, ob);
}
示例5: addObjectId
import com.fasterxml.jackson.annotation.ObjectIdGenerator.IdKey; //导入依赖的package包/类
/**
* <p>addObjectId</p>
*
* @param id a {@link com.fasterxml.jackson.annotation.ObjectIdGenerator.IdKey} object.
* @param instance a {@link Object} object.
*/
@Override
public void addObjectId(IdKey id, Object instance) {
if (null == idToObject) {
idToObject = new HashMap<IdKey, Object>();
}
idToObject.put(id, instance);
}
示例6: getObjectWithId
import com.fasterxml.jackson.annotation.ObjectIdGenerator.IdKey; //导入依赖的package包/类
/**
* <p>getObjectWithId</p>
*
* @param id a {@link com.fasterxml.jackson.annotation.ObjectIdGenerator.IdKey} object.
* @return a {@link Object} object.
*/
@Override
public Object getObjectWithId(IdKey id) {
if (null != idToObject) {
return idToObject.get(id);
}
return null;
}
示例7: getItemMap
import com.fasterxml.jackson.annotation.ObjectIdGenerator.IdKey; //导入依赖的package包/类
public Map<IdKey, Object> getItemMap() {
if(_items == null) {
return Collections.emptyMap();
} else {
return _items;
}
}
示例8: registerTokens
import com.fasterxml.jackson.annotation.ObjectIdGenerator.IdKey; //导入依赖的package包/类
public static void registerTokens(ObjectMapper mapper, List<String> tokens) {
TokenList list = new TokenList();
list.setTokens(tokens);
TokensIdGenerator generator = MapperFactory.getTokenIdGenerator(mapper);
TokensIdResolver resolver = MapperFactory.getTokenIdResolver(mapper);
Integer keyAsId = generator.generateId(list);
IdKey id = generator.key(keyAsId);
resolver.bindItem(id, list);
}
示例9: addObjectId
import com.fasterxml.jackson.annotation.ObjectIdGenerator.IdKey; //导入依赖的package包/类
/**
* <p>addObjectId</p>
*
* @param id a {@link com.fasterxml.jackson.annotation.ObjectIdGenerator.IdKey} object.
* @param instance a {@link java.lang.Object} object.
*/
public void addObjectId( IdKey id, Object instance ) {
if ( null == idToObject ) {
idToObject = new HashMap<IdKey, Object>();
}
idToObject.put( id, instance );
}
示例10: resolveId
import com.fasterxml.jackson.annotation.ObjectIdGenerator.IdKey; //导入依赖的package包/类
@Override
public Object resolveId(IdKey id) {
return ImmutableByid.builder()
.id(id.key.toString())
.build();
}
示例11: resolveId
import com.fasterxml.jackson.annotation.ObjectIdGenerator.IdKey; //导入依赖的package包/类
@Override
public Object resolveId(IdKey id) {
return (_items == null) ? null : _items.get(id);
}
示例12: newIdKey
import com.fasterxml.jackson.annotation.ObjectIdGenerator.IdKey; //导入依赖的package包/类
/**
* {@inheritDoc}
*/
@Override
public IdKey newIdKey(Object id) {
return new IdKey(type, scope, id);
}
示例13: isRegistered
import com.fasterxml.jackson.annotation.ObjectIdGenerator.IdKey; //导入依赖的package包/类
public boolean isRegistered(IdKey id) {
return getItemMap().containsKey(id);
}
示例14: getItems
import com.fasterxml.jackson.annotation.ObjectIdGenerator.IdKey; //导入依赖的package包/类
public Set<Entry<IdKey, Object>> getItems() {
return getItemMap().entrySet();
}
示例15: key
import com.fasterxml.jackson.annotation.ObjectIdGenerator.IdKey; //导入依赖的package包/类
public ObjectIdGenerator.IdKey key(Object paramObject)
{
return new ObjectIdGenerator.IdKey(getClass(), this._scope, paramObject);
}