src/main/java/com/googlecode/objectify/impl/Keys.java
@SuppressWarnings("unchecked")
	public <T> Key<T> anythingToKey(final Object keyOrEntity) {

		if (keyOrEntity instanceof Key<?>)
			return (Key<T>)keyOrEntity;
		else if (keyOrEntity instanceof com.google.cloud.datastore.Key)
			return Key.create((com.google.cloud.datastore.Key)keyOrEntity);
		else if (keyOrEntity instanceof Ref)
			return ((Ref<T>)keyOrEntity).key();
		else if (keyOrEntity instanceof FullEntity<?>)
			return Key.create(getKey((FullEntity<?>)keyOrEntity));
		else
			return keyOf((T)keyOrEntity);
	}
@SuppressWarnings("unchecked")
	public <T> Key<T> anythingToKey(final Object keyOrEntity) {

		if (keyOrEntity instanceof Key<?>)
			return (Key<T>)keyOrEntity;
		else if (keyOrEntity instanceof com.google.cloud.datastore.Key)
			return Key.create((com.google.cloud.datastore.Key)keyOrEntity);
		else if (keyOrEntity instanceof Ref)
			return ((Ref<T>)keyOrEntity).key();
		else if (keyOrEntity instanceof FullEntity<?>)
			return Key.create(getKey((FullEntity<?>)keyOrEntity));
		else
			return keyOf((T)keyOrEntity);
	}
<p>Gets the Key<T> 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