本文整理了Java中com.googlecode.objectify.Key.getParent()
方法的一些代码示例,展示了Key.getParent()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Key.getParent()
方法的具体详情如下:
包路径:com.googlecode.objectify.Key
类名称:Key
方法名:getParent
暂无
代码示例来源:origin: objectify/objectify
/**
* Gets the root of a parent graph of keys. If a Key has no parent, it is the root.
*
* @return the topmost parent key, or this object itself if it is the root.
* Note that the root key could potentially have any type.
*/
@SuppressWarnings("unchecked")
public <V> Key<V> getRoot() {
if (this.getParent() == null)
return (Key<V>)this;
else
return this.getParent().getRoot();
}
代码示例来源:origin: objectify/objectify
/**
* Gets the result, possibly from the session, putting it in the session if necessary.
* Also will recursively prepare the session with @Load parents as appropriate.
* @throws NullPointerException if key is null
*/
public <T> Result<T> load(final Key<T> key) {
if (key == null)
throw new NullPointerException("You tried to load a null key!");
final Result<T> result = round.get(key);
// If we are running a transaction, enlist the result so that it gets processed on commit even
// if the client never materializes the result.
if (ofy.getTransaction() != null)
((PrivateAsyncTransaction)ofy.getTransaction()).enlist(result);
// Now check to see if we need to recurse and add our parent(s) to the round
if (key.getParent() != null) {
final KeyMetadata<?> meta = ofy.factory().keys().getMetadata(key);
// Is it really possible for this to be null?
if (meta != null) {
if (meta.shouldLoadParent(loadArrangement)) {
load(key.getParent());
}
}
}
return result;
}
代码示例来源:origin: com.googlecode.cedar-common/objectify
/**
* Gets the root of a parent graph of keys. If a Key has no parent, it is the root.
*
* @return the topmost parent key, or this object itself if it is the root.
* Note that the root key could potentially have any type.
*/
@SuppressWarnings("unchecked")
public <V> Key<V> getRoot()
{
if (this.getParent() == null)
return (Key<V>)this;
else
return this.getParent().getRoot();
}
代码示例来源:origin: com.googlecode.cedar-common/objectify
@Override
public <V> Set<Key<V>> fetchParentKeys()
{
Set<Key<V>> parentKeys = new LinkedHashSet<Key<V>>();
for (Key<T> key: this.fetchKeys())
{
if (key.getParent() == null)
throw new IllegalStateException("Tried to fetch parent from a key that has no parent: " + key);
parentKeys.add(key.<V>getParent());
}
return parentKeys;
}
代码示例来源:origin: instacount/appengine-counter
@Test
public void getterTest() throws Exception
{
final Key<CounterData> counterDataKey = CounterData.key(TEST_COUNTER1);
final Key<CounterShardData> counterShardDataKey = CounterShardData.key(counterDataKey, 0);
final UUID uuid = UUID.randomUUID();
final CounterShardOperationData counterShardOperationData = new CounterShardOperationData(counterShardDataKey,
uuid, CounterOperationType.INCREMENT, 1L);
assertThat(counterShardOperationData.getMutationAmount(), is(1L));
assertThat(counterShardOperationData.getCounterShardDataKey(), is(counterShardDataKey));
assertThat(counterShardOperationData.getId(), is(uuid.toString()));
assertThat(
counterShardOperationData.getCreationDateTime().isBefore(DateTime.now(DateTimeZone.UTC).plusSeconds(10)),
is(true));
// TypedKey
assertThat(counterShardOperationData.getTypedKey().getName(), is(uuid.toString()));
assertThat(counterShardOperationData.getTypedKey().getParent().getName(), is(counterShardDataKey.getName()));
// RawKey
assertThat(counterShardOperationData.getKey().getName(), is(uuid.toString()));
}
内容来源于网络,如有侵权,请联系作者删除!