Annotation Type IntentEntity
Marks one of your application's own nouns -- an order, a playlist, a saved
route -- as something the system can name, list, search and hand back to an
AppIntent.
@IntentEntity(value = "playlist", title = "Playlist")
public class Playlist {
@EntityId public String getId() { return id; }
@EntityTitle public String getName() { return name; }
@EntityQuery(EntityQuery.Kind.BY_ID)
public static Playlist byId(String id) { return Library.playlist(id); }
@EntityQuery(EntityQuery.Kind.SUGGESTED)
public static List<Playlist> recent() { return Library.recentPlaylists(); }
}
Your class stays your class. There is no interface to implement and no base class to extend, because a domain model outlives the framework it is used with; the build reads the annotated members and generates the adapter.
Why this is what makes intents feel intelligent
An entity-typed parameter is what lets the platform run its own picker
before your code is ever called. "Play a playlist" with nothing specified
makes the system ask "Which one?", fill the list from your SUGGESTED query,
and hand your handler the chosen object. A plain String parameter can never
do that -- it can only be typed or spoken verbatim.
A BY_ID query is mandatory. Entities cross the platform boundary as their
id and nothing else, so resolving that id back to an object is the one
operation the framework cannot do without.
-
Required Element Summary
Required Elements -
Optional Element Summary
Optional Elements
-
Element Details
-
value
String valueThe entity type id, matching[a-z][a-z0-9_]{2,63}. Required, and stable for the same reason an intent id is: indexed items persist it. -
title
-
indexed
boolean indexedTrue to make instances of this type eligible for device search throughcom.codename1.intents.Intents#index. Requires anEntityTitle, since an entry with nothing to display is not a search result.- Default:
false
-