This item can be opened (or viewed) by creating an {@link Intent#ACTION_VIEW} intent
* with this URL as the {@link Intent#setData(Uri)} uri.
*
* @see Intent Structure
*/
@Nullable
public String getUrl() {
return mUrl;
}
/** Builder for {@link Thing}. */
public static final class Builder extends BuilderImpl See {@link androidx.appsearch.annotation.Document.Score} for more information on
* score.
*/
@NonNull
@SuppressWarnings("unchecked")
public T setDocumentScore(int documentScore) {
mDocumentScore = documentScore;
return (T) this;
}
/**
* Sets the creation timestamp for the current AppSearch entity, in milliseconds using the
* {@link System#currentTimeMillis()} time base.
*
* This timestamp refers to the creation time of the AppSearch entity, not when the
* document is written into AppSearch.
*
* If not set, then the current timestamp will be used.
*
* See {@link androidx.appsearch.annotation.Document.CreationTimestampMillis} for more
* information on creation timestamp.
*/
@NonNull
@SuppressWarnings("unchecked")
public T setCreationTimestampMillis(long creationTimestampMillis) {
mCreationTimestampMillis = creationTimestampMillis;
return (T) this;
}
/**
* Sets the time-to-live (TTL) for the current AppSearch document as a duration in
* milliseconds.
*
* The document will be automatically deleted when the TTL expires.
*
* If not set, then the document will never expire.
*
* See {@link androidx.appsearch.annotation.Document.TtlMillis} for more information on
* TTL.
*/
@NonNull
@SuppressWarnings("unchecked")
public T setDocumentTtlMillis(long documentTtlMillis) {
mDocumentTtlMillis = documentTtlMillis;
return (T) this;
}
/** Sets the name of the item. */
@NonNull
public T setName(@Nullable String name) {
mName = name;
return (T) this;
}
/** Adds an alias for the item. */
@NonNull
public T addAlternateName(@NonNull String alternateName) {
Preconditions.checkNotNull(alternateName);
mAlternateNames.add(alternateName);
return (T) this;
}
/** Clears the aliases, if any, for the item. */
@NonNull
public T clearAlternateNames() {
mAlternateNames.clear();
return (T) this;
}
/** Sets the description for the item. */
@NonNull
public T setDescription(@Nullable String description) {
mDescription = description;
return (T) this;
}
/** Sets the URL for an image of the item. */
@NonNull
public T setImage(@Nullable String image) {
mImage = image;
return (T) this;
}
/**
* Sets the deeplink URL of the item.
*
* If this item can be displayed by any system UI surface, or can be read by another
* Android package, through one of the
* {@link androidx.appsearch.app.SetSchemaRequest.Builder} methods, this {@code url}
* should act as a deeplink into the activity that can open it. Callers should be able to
* construct an {@link Intent#ACTION_VIEW} intent with the {@code url} as the
* {@link Intent#setData(Uri)} to view the item inside your application.
*
* See Allowing Other Apps to Start Your
* Activity for more details on how to make activities in your app open for use by other
* apps by defining intent filters.
*/
@NonNull
public T setUrl(@Nullable String url) {
mUrl = url;
return (T) this;
}
/** Builds a {@link Thing} object. */
@NonNull
public Thing build() {
return new Thing(mNamespace, mId, mDocumentScore, mCreationTimestampMillis,
mDocumentTtlMillis, mName, mAlternateNames, mDescription, mImage, mUrl);
}
}
}