Key(String projectId, String namespace, ImmutableList<PathElement> path) { super(projectId, namespace, path); Preconditions.checkArgument(getNameOrId() != null); }
@Test public void testNameOrId() throws Exception { Key.Builder builder = Key.newBuilder("d", "k", "n"); Key key = builder.build(); assertEquals("n", key.getNameOrId()); key = builder.setId(1).build(); assertEquals(Long.valueOf(1), key.getNameOrId()); }
return result; else if (this.raw.getNameOrId() == null && other.raw.getNameOrId() == null) { return compareToWithIdentityHash(this.raw, other.raw);
@Override public Object nameOrId() { return key.getNameOrId(); }
Key(String projectId, String namespace, ImmutableList<PathElement> path) { super(projectId, namespace, path); Preconditions.checkArgument(getNameOrId() != null); }
/** * Unamrshals the identifier. * * @throws Throwable * propagated */ private void unmarshalIdentifier() throws Throwable { IdentifierMetadata identifierMetadata = entityMetadata.getIdentifierMetadata(); Object id = ((Key) nativeEntity.getKey()).getNameOrId(); // If the ID is not a simple type... IdClassMetadata idClassMetadata = identifierMetadata.getIdClassMetadata(); if (idClassMetadata != null) { Object wrappedId = idClassMetadata.getConstructor().invoke(id); id = wrappedId; } // Now set the ID (either simple or complex) on the Entity MethodHandle writeMethod = identifierMetadata.getWriteMethod(); writeMethod.invoke(entity, id); }