Java 类com.fasterxml.jackson.annotation.ObjectIdGenerator.IdKey 实例源码

项目:QuizUpWinner    文件:DefaultDeserializationContext.java   
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;
}
项目:shogun2    文件:PersistentObjectIdResolver.java   
/**
 *
 */
@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;
    }

}
项目:GitHub    文件:SimpleObjectIdResolver.java   
@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);
}
项目:gwt-jackson-apt    文件:SimpleObjectIdResolver.java   
@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);
}
项目:gwt-jackson-apt    文件:DefaultJsonDeserializationContext.java   
/**
 * <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);
}
项目:gwt-jackson-apt    文件:DefaultJsonDeserializationContext.java   
/**
 * <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;
}
项目:esBench    文件:TokensIdResolver.java   
public Map<IdKey, Object> getItemMap() {
    if(_items == null) {
        return Collections.emptyMap();
    } else {
        return _items;
    }
}
项目:esBench    文件:TokenListTestUtil.java   
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);
}
项目:esBench    文件:TokenListTestUtil.java   
public static void registerTokens(ObjectMapper mapper, Integer id, List<String> tokens) {
    TokenList list = new TokenList();
    list.setTokens(tokens);

    TokensIdGenerator generator = MapperFactory.getTokenIdGenerator(mapper);
    TokensIdResolver resolver = MapperFactory.getTokenIdResolver(mapper);

    if(!generator.isRegistered(id)) {
        generator.register(id, list);
    }
    IdKey idKey = generator.key(id);
    if(!resolver.isRegistered(idKey)) {
        resolver.bindItem(idKey, list);
    }
}
项目:gwt-jackson    文件:JsonDeserializationContext.java   
/**
 * <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 );
}
项目:GitHub    文件:ByIdProperty.java   
@Override
public Object resolveId(IdKey id) {
  return ImmutableByid.builder()
      .id(id.key.toString())
      .build();
}
项目:GitHub    文件:SimpleObjectIdResolver.java   
@Override
public Object resolveId(IdKey id) {
    return (_items == null) ? null : _items.get(id);
}
项目:gwt-jackson-apt    文件:SimpleObjectIdResolver.java   
@Override
public Object resolveId(IdKey id) {
    return (_items == null) ? null : _items.get(id);
}
项目:gwt-jackson-apt    文件:PropertyIdentityDeserializationInfo.java   
/**
 * {@inheritDoc}
 */
@Override
public IdKey newIdKey(Object id) {
    return new IdKey(type, scope, id);
}
项目:gwt-jackson-apt    文件:AbstractIdentityDeserializationInfo.java   
/**
 * {@inheritDoc}
 */
@Override
public IdKey newIdKey(Object id) {
    return new IdKey(type, scope, id);
}
项目:esBench    文件:TokensIdResolver.java   
public boolean isRegistered(IdKey id) {
    return getItemMap().containsKey(id);
}
项目:esBench    文件:TokensIdResolver.java   
public Set<Entry<IdKey, Object>> getItems() {
    return getItemMap().entrySet();
}
项目:QuizUpWinner    文件:PropertyBasedObjectIdGenerator.java   
public ObjectIdGenerator.IdKey key(Object paramObject)
{
  return new ObjectIdGenerator.IdKey(getClass(), this._scope, paramObject);
}
项目:QuizUpWinner    文件:PropertyBasedObjectIdGenerator.java   
public ObjectIdGenerator.IdKey key(Object paramObject)
{
  return new ObjectIdGenerator.IdKey(getClass(), this._scope, paramObject);
}
项目:shogun2    文件:PersistentObjectIdResolver.java   
/**
 *
 */
@Override
public void bindItem(IdKey id, Object ob) {
    super.bindItem(id, ob);
}
项目:gwt-jackson    文件:PropertyIdentityDeserializationInfo.java   
/** {@inheritDoc} */
@Override
public IdKey newIdKey( Object id ) {
    return new IdKey( type, scope, id );
}
项目:gwt-jackson    文件:AbstractIdentityDeserializationInfo.java   
/** {@inheritDoc} */
@Override
public IdKey newIdKey( Object id ) {
    return new IdKey( type, scope, id );
}
项目:immutables    文件:ByIdProperty.java   
@Override
public Object resolveId(IdKey id) {
  return ImmutableByid.builder()
      .id(id.key.toString())
      .build();
}
项目:gwt-jackson    文件:JsonDeserializationContext.java   
/**
 * <p>getObjectWithId</p>
 *
 * @param id a {@link com.fasterxml.jackson.annotation.ObjectIdGenerator.IdKey} object.
 *
 * @return a {@link java.lang.Object} object.
 */
public Object getObjectWithId( IdKey id ) {
    if ( null != idToObject ) {
        return idToObject.get( id );
    }
    return null;
}
项目:GitHub    文件:ObjectIdResolver.java   
/**
 * Method called when a POJO is deserialized and has an Object Identifier.
 * Method exists so that implementation can keep track of existing object in
 * JSON stream that could be useful for further resolution.
 * 
 * @param id The Object Identifer
 * @param pojo The POJO associated to that Identifier
 */
void bindItem(IdKey id, Object pojo);
项目:GitHub    文件:ObjectIdResolver.java   
/**
 * Method called when deserialization encounters the given Object Identifier
 * and requires the POJO associated with it.
 * 
 * @param id The Object Identifier
 * @return The POJO, or null if unable to resolve.
 */
Object resolveId(IdKey id);
项目:gwt-jackson-apt    文件:ObjectIdResolver.java   
/**
 * Method called when a POJO is deserialized and has an Object Identifier.
 * Method exists so that implementation can keep track of existing object in
 * JSON stream that could be useful for further resolution.
 * 
 * @param id The Object Identifer
 * @param pojo The POJO associated to that Identifier
 */
void bindItem(IdKey id, Object pojo);
项目:gwt-jackson-apt    文件:ObjectIdResolver.java   
/**
 * Method called when deserialization encounters the given Object Identifier
 * and requires the POJO associated with it.
 * 
 * @param id The Object Identifier
 * @return The POJO, or null if unable to resolve.
 */
Object resolveId(IdKey id);
项目:gwt-jackson-apt    文件:IdentityDeserializationInfo.java   
/**
 * <p>newIdKey</p>
 *
 * @param id Identifier
 * @return a new {@link IdKey}
 */
IdKey newIdKey(Object id);
项目:gwt-jackson    文件:IdentityDeserializationInfo.java   
/**
 * <p>newIdKey</p>
 *
 * @param id Identifier
 * @return a new {@link IdKey}
 */
IdKey newIdKey( Object id );