com.googlecode.objectify.Key.getRaw()方法的使用及代码示例

x33g5p2x  于2022-01-23 转载在 其他  
字(6.4k)|赞(0)|评价(0)|浏览(108)

本文整理了Java中com.googlecode.objectify.Key.getRaw()方法的一些代码示例,展示了Key.getRaw()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Key.getRaw()方法的具体详情如下:
包路径:com.googlecode.objectify.Key
类名称:Key
方法名:getRaw

Key.getRaw介绍

暂无

代码示例

代码示例来源:origin: objectify/objectify

/**
 * Easy null-safe conversion of the typed key.
 */
public static com.google.cloud.datastore.Key key(final Key<?> typed) {
  if (typed == null)
    return null;
  else
    return typed.getRaw();
}

代码示例来源:origin: objectify/objectify

/** Null-safe extraction of the raw key */
public static com.google.cloud.datastore.Key raw(final Key<?> key) {
  return key == null ? null : key.getRaw();
}

代码示例来源:origin: objectify/objectify

@Override
  protected Value<com.google.cloud.datastore.Key> toDatastore(final Key<?> value) {
    return KeyValue.of(value.getRaw());
  }
}

代码示例来源:origin: objectify/objectify

/**
   * Callback that we found a Ref in the object graph. Subclasses of this context may want to do something
   * special with this.
   */
  public Key saveRef(final Ref<?> value, final LoadConditions loadConditions) {
    return value.key().getRaw();
  }
}

代码示例来源:origin: objectify/objectify

@Override
public Result<Void> keys(final Iterable<? extends Key<?>> keys) {
  final List<com.google.cloud.datastore.Key> rawKeys = new ArrayList<>();
  for (final Key<?> key: keys)
    rawKeys.add(key.getRaw());
  return ofy.createWriteEngine().delete(rawKeys);
}

代码示例来源:origin: objectify/objectify

/**
 * <p>Gets the raw datstore Key given an object that might be a Key, Key<T>, or entity.</p>
 *
 * @param keyOrEntity must be a Key, Key<T>, or registered entity.
 * @throws NullPointerException if keyOrEntity is null
 * @throws IllegalArgumentException if keyOrEntity is not a Key, Key<T>, or registered entity
 */
public com.google.cloud.datastore.Key anythingToRawKey(final Object keyOrEntity) {
  if (keyOrEntity instanceof com.google.cloud.datastore.Key)
    return (com.google.cloud.datastore.Key)keyOrEntity;
  else if (keyOrEntity instanceof Key<?>)
    return ((Key<?>)keyOrEntity).getRaw();
  else if (keyOrEntity instanceof Ref)
    return ((Ref<?>)keyOrEntity).key().getRaw();
  else if (keyOrEntity instanceof FullEntity<?>)
    return getKey((FullEntity<?>)keyOrEntity);
  else
    return rawKeyOf(keyOrEntity);
}

代码示例来源:origin: objectify/objectify

/**
 * Preallocate a contiguous range of unique ids within the namespace of the
 * specified entity class and the parent key.  These ids can be used in concert with the normal
 * automatic allocation of ids when put()ing entities with null Long id fields.
 *
 * @param parentKeyOrEntity must be a legitimate parent for the class type.  It need not
 * point to an existent entity, but it must be the correct type for clazz.
 * @param clazz must be a registered entity class with a Long or long id field, and
 * a parent key of the correct type.
 * @param num must be >= 1 and <= 1 billion
 */
public <T> KeyRange<T> allocateIds(final Object parentKeyOrEntity, final Class<T> clazz, final int num) {
  final Key<?> parent = keys().anythingToKey(parentKeyOrEntity);
  final String kind = Key.getKind(clazz);
  final IncompleteKey incompleteKey = com.google.cloud.datastore.Key.newBuilder(parent.getRaw(), kind).build();
  return allocate(incompleteKey, num);
}

代码示例来源:origin: objectify/objectify

final int result = this.getRaw().getKind().compareTo(other.getRaw().getKind());
if (result != 0) {
  return result;

代码示例来源:origin: com.googlecode.cedar-common/objectify

@Override
public Object forDatastore(Object value, ConverterSaveContext ctx)
{
  if (value instanceof Key<?>)
    return ((Key<?>)value).getRaw();
  else
    return null;
}

代码示例来源:origin: com.googlecode.cedar-common/objectify

/**
 * Easy null-safe conversion of the typed key.
 */
public static com.google.appengine.api.datastore.Key raw(Key<?> typed)
{
  if (typed == null)
    return null;
  else
    return typed.getRaw();
}

代码示例来源:origin: objectify/objectify

log.trace("Adding to round (session miss): {}", key);
this.pending.add(key.getRaw());

代码示例来源:origin: com.googlecode.cedar-common/objectify

/** @return the raw key even if the field is an Key */
private com.google.appengine.api.datastore.Key getRawKey(Field keyField, Object obj) throws IllegalAccessException
{
  Object key = keyField.get(obj);
  if (key == null)
    return null;
  else if (key instanceof com.google.appengine.api.datastore.Key)
    return (com.google.appengine.api.datastore.Key)key;
  else
    return ((Key<?>)key).getRaw();
}

代码示例来源:origin: nmorel/gwt-jackson

@Override
  public void serialize( Key value, JsonGenerator jgen, SerializerProvider provider ) throws IOException {
    jgen.writeStartObject();
    jgen.writeObjectField( KeyConstant.RAW, value.getRaw() );
    jgen.writeEndObject();
  }
}

代码示例来源:origin: instacount/appengine-counter

/**
 * Assembles the Key for this entity. If an Entity has a Parent Key, that key will be included in the returned Key
 * heirarchy.
 */
public com.google.appengine.api.datastore.Key getKey()
{
  return this.getTypedKey().getRaw();
}

代码示例来源:origin: instacount/appengine-counter

/**
 * Assembles the Key for this entity. If an Entity has a Parent Key, that key will be included in the returned Key
 * heirarchy.
 */
public com.google.appengine.api.datastore.Key getKey()
{
  return this.getTypedKey().getRaw();
}

代码示例来源:origin: instacount/appengine-counter

/**
 * Assembles the Key for this entity. If an Entity has a Parent Key, that key will be included in the returned Key
 * heirarchy.
 */
public com.google.appengine.api.datastore.Key getKey()
{
  return this.getTypedKey().getRaw();
}

代码示例来源:origin: com.googlecode.cedar-common/objectify

/**
 * <p>Converts a Key<?> into a web-safe string suitable for http parameters
 * in URLs.  Note that you can convert back and forth with the {@code keyToString()}
 * and {@code stringToKey()} methods.</p>
 * 
 * <p>The String is actually generated by using the KeyFactory {@code keyToString()}
 * method on a raw version of the datastore key.  You can, if you wanted, use
 * these web safe strings interchangeably.</p>
 * 
 * @param key is any Objectify key
 * @return a simple String which does not need urlencoding
 */
public String keyToString(Key<?> key)
{
  return KeyFactory.keyToString(key.getRaw());
}

代码示例来源:origin: bedatadriven/activityinfo

public static Key columnKey(ResourceId formId, String columnId) {
  Key formKey = FormEntity.key(formId).getRaw();
  return KeyFactory.createKey(formKey, COLUMN_KIND, columnId);
}

代码示例来源:origin: bedatadriven/activityinfo

public static com.google.appengine.api.datastore.Key key(Key<FormEntity> formKey, String fieldId, int blockIndex) {
  com.google.appengine.api.datastore.Key fieldKey = KeyFactory.createKey(formKey.getRaw(),"FormField", fieldId);
  return KeyFactory.createKey(fieldKey, "Block", blockIndex);
}

代码示例来源:origin: nmorel/gwt-jackson

@Override
  protected void doSerialize( JsonWriter writer, Key<T> key, JsonSerializationContext ctx, JsonSerializerParameters params ) {
    writer.beginObject();
    writer.name( KeyConstant.RAW );
    RawKeyJsonSerializer.getInstance().serialize( writer, key.getRaw(), ctx, params );
    writer.endObject();
  }
}

相关文章