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

项目: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;
}
项目:joyplus-tv    文件:DefaultSerializerProvider.java   
@Override
public ObjectIdGenerator<?> objectIdGeneratorInstance(Annotated annotated,
        ObjectIdInfo objectIdInfo)
    throws JsonMappingException
{
    Class<?> implClass = objectIdInfo.getGeneratorType();
    HandlerInstantiator hi = _config.getHandlerInstantiator();
    ObjectIdGenerator<?> gen;

    if (hi != null) {
        gen =  hi.objectIdGeneratorInstance(_config, annotated, implClass);
    } else {
        gen = (ObjectIdGenerator<?>) ClassUtil.createInstance(implClass,
                _config.canOverrideAccessModifiers());
    }
    return gen.forScope(objectIdInfo.getScope());
}
项目:joyplus-tv    文件:PropertyBasedObjectIdGenerator.java   
/**
 * We must override this method, to prevent errors when scopes are the same,
 * but underlying class (on which to access property) is different.
 */
@Override
public boolean canUseFor(ObjectIdGenerator<?> gen) {
    if (gen.getClass() == getClass()) {
        PropertyBasedObjectIdGenerator other = (PropertyBasedObjectIdGenerator) gen;
        if (other.getScope() == _scope) {
            /* 26-Jul-2012, tatu: This is actually not enough, because the property
             *   accessor within BeanPropertyWriter won't work for other property fields
             *  (see [https://github.com/FasterXML/jackson-module-jaxb-annotations/issues/9]
             *  for details).
             *  So we need to verify that underlying property is actually the same.
             */
            return (other._property == _property);
        }
    }
    return false;
}
项目:joyplus-tv    文件:DefaultDeserializationContext.java   
@Override
public ObjectIdGenerator<?> objectIdGeneratorInstance(Annotated annotated,
        ObjectIdInfo objectIdInfo)
    throws JsonMappingException
{
    Class<?> implClass = objectIdInfo.getGeneratorType();
    HandlerInstantiator hi = _config.getHandlerInstantiator();
    ObjectIdGenerator<?> gen;

    if (hi != null) {
        gen = hi.objectIdGeneratorInstance(_config, annotated, implClass);
    } else {
        gen = (ObjectIdGenerator<?>) ClassUtil.createInstance(implClass,
                _config.canOverrideAccessModifiers());
    }
    return gen.forScope(objectIdInfo.getScope());
}
项目:xm-ms-entity    文件:XmEntityObjectIdResolver.java   
@Override
public Object resolveId(final ObjectIdGenerator.IdKey id) {
    Object entity = repository.findOne((Long) id.key);

    if (entity == null) {
        throw new BusinessException(ErrorConstants.ERR_NOTFOUND, "Can not resolve XmEntity by ID: " + id.key);
    }

    return entity;
}
项目:xm-ms-entity    文件:CalendarObjectIdResolver.java   
@Override
public Object resolveId(final ObjectIdGenerator.IdKey id) {
    Object entity = repository.findOne((Long) id.key);

    if (entity == null) {
        throw new BusinessException(ErrorConstants.ERR_NOTFOUND, "Can not resolve Calendar by ID: " + id.key);
    }

    return entity;
}
项目:gwt-jackson-apt    文件:DefaultJsonSerializationContext.java   
/**
 * Used by generated {@link AbstractBeanJsonSerializer}
 *
 * @param generator instance of generator to add
 */
@Override
@SuppressWarnings("UnusedDeclaration")
public void addGenerator(ObjectIdGenerator<?> generator) {
    if (null == generators) {
        generators = new ArrayList<ObjectIdGenerator<?>>();
    }
    generators.add(generator);
}
项目:gwt-jackson-apt    文件:DefaultJsonSerializationContext.java   
/**
 * Used by generated {@link AbstractBeanJsonSerializer}
 *
 * @param gen generator used to find equivalent generator
 * @param <T> a T object.
 * @return a {@link com.fasterxml.jackson.annotation.ObjectIdGenerator} object.
 */
@Override
@SuppressWarnings({"UnusedDeclaration", "unchecked"})
public <T> ObjectIdGenerator<T> findObjectIdGenerator(ObjectIdGenerator<T> gen) {
    if (null != generators) {
        for (ObjectIdGenerator<?> generator : generators) {
            if (generator.canUseFor(gen)) {
                return (ObjectIdGenerator<T>) generator;
            }
        }
    }
    return null;
}
项目:esBench    文件:WorkloadHandlerInstantiator.java   
@Override
public ObjectIdGenerator<?> objectIdGeneratorInstance(MapperConfig<?> config, Annotated annotated, Class<?> implClass) {
    if(annotated.getRawType().equals(TokenList.class)) {
        return tokenIdGenerator;
    } else {
        return null;
    }
}
项目:QuizUpWinner    文件:BeanSerializerFactory.java   
protected ObjectIdWriter constructObjectIdHandler(SerializerProvider paramSerializerProvider, BeanDescription paramBeanDescription, List<BeanPropertyWriter> paramList)
{
  ObjectIdInfo localObjectIdInfo = paramBeanDescription.getObjectIdInfo();
  if (localObjectIdInfo == null)
    return null;
  Class localClass = localObjectIdInfo.getGeneratorType();
  if (localClass == ObjectIdGenerators.PropertyGenerator.class)
  {
    String str = localObjectIdInfo.getPropertyName();
    int i = 0;
    int j = paramList.size();
    BeanPropertyWriter localBeanPropertyWriter;
    while (true)
    {
      if (i == j)
        throw new IllegalArgumentException("Invalid Object Id definition for " + paramBeanDescription.getBeanClass().getName() + ": can not find property with name '" + str + "'");
      localBeanPropertyWriter = (BeanPropertyWriter)paramList.get(i);
      if (str.equals(localBeanPropertyWriter.getName()))
      {
        if (i <= 0)
          break;
        paramList.remove(i);
        paramList.add(0, localBeanPropertyWriter);
        break;
      }
      i++;
    }
    return ObjectIdWriter.construct(localBeanPropertyWriter.getType(), null, new PropertyBasedObjectIdGenerator(localObjectIdInfo, localBeanPropertyWriter), localObjectIdInfo.getAlwaysAsId());
  }
  JavaType localJavaType1 = paramSerializerProvider.constructType(localClass);
  JavaType localJavaType2 = paramSerializerProvider.getTypeFactory().findTypeParameters(localJavaType1, ObjectIdGenerator.class)[0];
  ObjectIdGenerator localObjectIdGenerator = paramSerializerProvider.objectIdGeneratorInstance(paramBeanDescription.getClassInfo(), localObjectIdInfo);
  return ObjectIdWriter.construct(localJavaType2, localObjectIdInfo.getPropertyName(), localObjectIdGenerator, localObjectIdInfo.getAlwaysAsId());
}
项目:QuizUpWinner    文件:ObjectIdWriter.java   
protected ObjectIdWriter(JavaType paramJavaType, SerializedString paramSerializedString, ObjectIdGenerator<?> paramObjectIdGenerator, JsonSerializer<?> paramJsonSerializer, boolean paramBoolean)
{
  this.idType = paramJavaType;
  this.propertyName = paramSerializedString;
  this.generator = paramObjectIdGenerator;
  this.serializer = paramJsonSerializer;
  this.alwaysAsId = paramBoolean;
}
项目:QuizUpWinner    文件:PropertyBasedObjectIdGenerator.java   
public boolean canUseFor(ObjectIdGenerator<?> paramObjectIdGenerator)
{
  if (paramObjectIdGenerator.getClass() == getClass())
  {
    PropertyBasedObjectIdGenerator localPropertyBasedObjectIdGenerator = (PropertyBasedObjectIdGenerator)paramObjectIdGenerator;
    if (localPropertyBasedObjectIdGenerator.getScope() == this._scope)
      return localPropertyBasedObjectIdGenerator._property == this._property;
  }
  return false;
}
项目:QuizUpWinner    文件:ObjectIdInfo.java   
protected ObjectIdInfo(String paramString, Class<?> paramClass, Class<? extends ObjectIdGenerator<?>> paramClass1, boolean paramBoolean)
{
  this._propertyName = paramString;
  this._scope = paramClass;
  this._generator = paramClass1;
  this._alwaysAsId = paramBoolean;
}
项目:QuizUpWinner    文件:ObjectIdReader.java   
protected ObjectIdReader(JavaType paramJavaType, String paramString, ObjectIdGenerator<?> paramObjectIdGenerator, JsonDeserializer<?> paramJsonDeserializer, SettableBeanProperty paramSettableBeanProperty)
{
  this.idType = paramJavaType;
  this.propertyName = paramString;
  this.generator = paramObjectIdGenerator;
  this.deserializer = paramJsonDeserializer;
  this.idProperty = paramSettableBeanProperty;
}
项目:QuizUpWinner    文件:BeanDeserializerFactory.java   
protected void addObjectIdReader(DeserializationContext paramDeserializationContext, BeanDescription paramBeanDescription, BeanDeserializerBuilder paramBeanDeserializerBuilder)
{
  ObjectIdInfo localObjectIdInfo = paramBeanDescription.getObjectIdInfo();
  if (localObjectIdInfo == null)
    return;
  Class localClass = localObjectIdInfo.getGeneratorType();
  SettableBeanProperty localSettableBeanProperty1;
  JavaType localJavaType2;
  Object localObject;
  if (localClass == ObjectIdGenerators.PropertyGenerator.class)
  {
    String str = localObjectIdInfo.getPropertyName();
    SettableBeanProperty localSettableBeanProperty2 = paramBeanDeserializerBuilder.findProperty(str);
    localSettableBeanProperty1 = localSettableBeanProperty2;
    if (localSettableBeanProperty2 == null)
      throw new IllegalArgumentException("Invalid Object Id definition for " + paramBeanDescription.getBeanClass().getName() + ": can not find property with name '" + str + "'");
    localJavaType2 = localSettableBeanProperty1.getType();
    localObject = new PropertyBasedObjectIdGenerator(localObjectIdInfo.getScope());
  }
  else
  {
    JavaType localJavaType1 = paramDeserializationContext.constructType(localClass);
    localJavaType2 = paramDeserializationContext.getTypeFactory().findTypeParameters(localJavaType1, ObjectIdGenerator.class)[0];
    localSettableBeanProperty1 = null;
    localObject = paramDeserializationContext.objectIdGeneratorInstance(paramBeanDescription.getClassInfo(), localObjectIdInfo);
  }
  JsonDeserializer localJsonDeserializer = paramDeserializationContext.findRootValueDeserializer(localJavaType2);
  paramBeanDeserializerBuilder.setObjectIdReader(ObjectIdReader.construct(localJavaType2, localObjectIdInfo.getPropertyName(), (ObjectIdGenerator)localObject, localJsonDeserializer, localSettableBeanProperty1));
}
项目:gwt-jackson    文件:JsonSerializationContext.java   
/**
 * Used by generated {@link AbstractBeanJsonSerializer}
 *
 * @param generator instance of generator to add
 */
@SuppressWarnings( "UnusedDeclaration" )
public void addGenerator( ObjectIdGenerator<?> generator ) {
    if ( null == generators ) {
        generators = new ArrayList<ObjectIdGenerator<?>>();
    }
    generators.add( generator );
}
项目:gwt-jackson    文件:JsonSerializationContext.java   
/**
 * Used by generated {@link AbstractBeanJsonSerializer}
 *
 * @param gen generator used to find equivalent generator
 * @param <T> a T object.
 *
 * @return a {@link com.fasterxml.jackson.annotation.ObjectIdGenerator} object.
 */
@SuppressWarnings( {"UnusedDeclaration", "unchecked"} )
public <T> ObjectIdGenerator<T> findObjectIdGenerator( ObjectIdGenerator<T> gen ) {
    if ( null != generators ) {
        for ( ObjectIdGenerator<?> generator : generators ) {
            if ( generator.canUseFor( gen ) ) {
                return (ObjectIdGenerator<T>) generator;
            }
        }
    }
    return null;
}
项目:gwt-jackson    文件:BeanIdentityInfo.java   
BeanIdentityInfo( String propertyName, boolean alwaysAsId, Class<? extends ObjectIdGenerator<?>> generator, Class<?> scope ) {
    this.propertyName = propertyName;
    this.alwaysAsId = alwaysAsId;
    this.generator = generator;
    this.scope = scope;
    this.idABeanProperty = true;
    this.type = Optional.absent();
}
项目:gwt-jackson    文件:BeanIdentityInfo.java   
BeanIdentityInfo( String propertyName, boolean alwaysAsId, Class<? extends ObjectIdGenerator<?>> generator, Class<?> scope,
                  JType type ) {
    this.propertyName = propertyName;
    this.alwaysAsId = alwaysAsId;
    this.generator = generator;
    this.scope = scope;
    this.idABeanProperty = false;
    this.type = Optional.of( type );
}
项目:joyplus-tv    文件:ObjectIdWriter.java   
@SuppressWarnings("unchecked")
protected ObjectIdWriter(JavaType t, SerializedString propName,
        ObjectIdGenerator<?> gen, JsonSerializer<?> ser, boolean alwaysAsId)
{
    idType = t;
    propertyName = propName;
    generator = gen;
    serializer = (JsonSerializer<Object>) ser;
    this.alwaysAsId = alwaysAsId;
}
项目:joyplus-tv    文件:ObjectIdWriter.java   
/**
 * Factory method called by {@link com.fasterxml.jackson.databind.ser.std.BeanSerializerBase}
 * with the initial information based on standard settings for the type
 * for which serializer is being built.
 */
public static ObjectIdWriter construct(JavaType idType, String propName,
        ObjectIdGenerator<?> generator, boolean alwaysAsId)
{
    SerializedString serName = (propName == null) ? null : new SerializedString(propName);
    return new ObjectIdWriter(idType, serName, generator, null, alwaysAsId);
}
项目:joyplus-tv    文件:ObjectIdInfo.java   
protected ObjectIdInfo(String prop, Class<?> scope, Class<? extends ObjectIdGenerator<?>> gen,
        boolean alwaysAsId)
{
    _propertyName = prop;
    _scope = scope;
    _generator = gen;
    _alwaysAsId = alwaysAsId;
}
项目:joyplus-tv    文件:ObjectIdReader.java   
@SuppressWarnings("unchecked")
protected ObjectIdReader(JavaType t, String propName, ObjectIdGenerator<?> gen,
        JsonDeserializer<?> deser, SettableBeanProperty idProp)
{
    idType = t;
    propertyName = propName;
    generator = gen;
    deserializer = (JsonDeserializer<Object>) deser;
    idProperty = idProp;
}
项目:joyplus-tv    文件:ObjectIdReader.java   
/**
 * Factory method called by {@link com.fasterxml.jackson.databind.ser.std.BeanSerializerBase}
 * with the initial information based on standard settings for the type
 * for which serializer is being built.
 */
public static ObjectIdReader construct(JavaType idType, String propName,
        ObjectIdGenerator<?> generator, JsonDeserializer<?> deser,
        SettableBeanProperty idProp)
{
    return new ObjectIdReader(idType, propName, generator, deser, idProp);
}
项目:joyplus-tv    文件:BeanDeserializerFactory.java   
protected void addObjectIdReader(DeserializationContext ctxt,
        BeanDescription beanDesc, BeanDeserializerBuilder builder)
    throws JsonMappingException
{
    ObjectIdInfo objectIdInfo = beanDesc.getObjectIdInfo();
    if (objectIdInfo == null) {
        return;
    }
    Class<?> implClass = objectIdInfo.getGeneratorType();
    JavaType idType;
    SettableBeanProperty idProp;
    ObjectIdGenerator<?> gen;

    // Just one special case: Property-based generator is trickier
    if (implClass == ObjectIdGenerators.PropertyGenerator.class) { // most special one, needs extra work
        String propName = objectIdInfo.getPropertyName();
        idProp = builder.findProperty(propName);
        if (idProp == null) {
            throw new IllegalArgumentException("Invalid Object Id definition for "
                    +beanDesc.getBeanClass().getName()+": can not find property with name '"+propName+"'");
        }
        idType = idProp.getType();
        gen = new PropertyBasedObjectIdGenerator(objectIdInfo.getScope());
    } else {
        JavaType type = ctxt.constructType(implClass);
        idType = ctxt.getTypeFactory().findTypeParameters(type, ObjectIdGenerator.class)[0];
        idProp = null;
        gen = ctxt.objectIdGeneratorInstance(beanDesc.getClassInfo(), objectIdInfo);
    }
    // also: unlike with value deserializers, let's just resolve one we need here
    JsonDeserializer<?> deser = ctxt.findRootValueDeserializer(idType);
    builder.setObjectIdReader(ObjectIdReader.construct(idType,
            objectIdInfo.getPropertyName(), gen, deser, idProp));
}
项目:netto_rpc    文件:ArgsDeserializer.java   
@Override
public ReadableObjectId findObjectId(Object id, ObjectIdGenerator<?> generator, ObjectIdResolver resolver) {
    return this.context.findObjectId(id, generator, resolver);
}
项目:gwt-jackson-apt    文件:JsonSerializationContext.java   
@SuppressWarnings("UnusedDeclaration")
void addGenerator(ObjectIdGenerator<?> generator);
项目:gwt-jackson-apt    文件:JsonSerializationContext.java   
@SuppressWarnings({"UnusedDeclaration", "unchecked"})
<T> ObjectIdGenerator<T> findObjectIdGenerator(ObjectIdGenerator<T> gen);
项目:esBench    文件:TokensIdGenerator.java   
@Override
public ObjectIdGenerator<Integer> forScope(Class<?> scope) {
    return this;
}
项目:esBench    文件:TokensIdGenerator.java   
@Override
public ObjectIdGenerator<Integer> newForSerialization(Object context) {
    return this;
}
项目:esBench    文件:TokensIdGenerator.java   
@Override
public boolean canUseFor(ObjectIdGenerator<?> gen) {
    return (gen.getClass() == getClass()) && (gen.getScope() == _scope);
}
项目:requery    文件:EntityStoreResolver.java   
@Override
public void bindItem(ObjectIdGenerator.IdKey id, Object pojo) {
}
项目:requery    文件:EntityStoreResolver.java   
@Override
public Object resolveId(ObjectIdGenerator.IdKey id) {
    return store == null ? null : store.findByKey(id.scope, id.key);
}
项目:requery    文件:ResolverInstantiator.java   
@Override
public ObjectIdGenerator<?> objectIdGeneratorInstance(MapperConfig<?> config, Annotated annotated, Class<?> implClass) {
    return null;
}
项目:QuizUpWinner    文件:HandlerInstantiator.java   
public ObjectIdGenerator<?> objectIdGeneratorInstance(MapperConfig<?> paramMapperConfig, Annotated paramAnnotated, Class<?> paramClass)
{
  return null;
}
项目:QuizUpWinner    文件:DefaultSerializerProvider.java   
public WritableObjectId findObjectId(Object paramObject, ObjectIdGenerator<?> paramObjectIdGenerator)
{
  if (this._seenObjectIds == null)
  {
    this._seenObjectIds = new IdentityHashMap();
  }
  else
  {
    WritableObjectId localWritableObjectId1 = (WritableObjectId)this._seenObjectIds.get(paramObject);
    if (localWritableObjectId1 != null)
      return localWritableObjectId1;
  }
  Object localObject;
  if (this._objectIdGenerators == null)
  {
    this._objectIdGenerators = new ArrayList(8);
    localObject = null;
  }
  else
  {
    int i = 0;
    int j = this._objectIdGenerators.size();
    while (true)
    {
      localObject = null;
      if (i >= j)
        break;
      ObjectIdGenerator localObjectIdGenerator = (ObjectIdGenerator)this._objectIdGenerators.get(i);
      if (localObjectIdGenerator.canUseFor(paramObjectIdGenerator))
      {
        localObject = localObjectIdGenerator;
        break;
      }
      i++;
    }
  }
  if (localObject == null)
  {
    localObject = paramObjectIdGenerator.newForSerialization(this);
    this._objectIdGenerators.add(localObject);
  }
  WritableObjectId localWritableObjectId2 = new WritableObjectId((ObjectIdGenerator)localObject);
  this._seenObjectIds.put(paramObject, localWritableObjectId2);
  return localWritableObjectId2;
}
项目:QuizUpWinner    文件:WritableObjectId.java   
public WritableObjectId(ObjectIdGenerator<?> paramObjectIdGenerator)
{
  this.generator = paramObjectIdGenerator;
}
项目:QuizUpWinner    文件:PropertyBasedObjectIdGenerator.java   
public ObjectIdGenerator<Object> forScope(Class<?> paramClass)
{
  if (paramClass == this._scope)
    return this;
  return new PropertyBasedObjectIdGenerator(paramClass, this._property);
}
项目:QuizUpWinner    文件:PropertyBasedObjectIdGenerator.java   
public ObjectIdGenerator.IdKey key(Object paramObject)
{
  return new ObjectIdGenerator.IdKey(getClass(), this._scope, paramObject);
}
项目:QuizUpWinner    文件:PropertyBasedObjectIdGenerator.java   
public ObjectIdGenerator<Object> newForSerialization(Object paramObject)
{
  return this;
}