Search in sources :

Example 1 with LogPagination

use of com.ibm.watson.developer_cloud.assistant.v1.model.LogPagination in project java-sdk by watson-developer-cloud.

the class LogPaginationTypeAdapter method read.

/*
   * (non-Javadoc)
   * @see com.google.gson.TypeAdapter#read(com.google.gson.stream.JsonReader)
   */
@Override
public LogPagination read(JsonReader reader) throws IOException {
    if (reader.peek() == JsonToken.NULL) {
        reader.nextNull();
        return null;
    }
    reader.beginObject();
    LogPagination pagination = new LogPagination();
    while (reader.hasNext()) {
        String name = reader.nextName();
        if (name.equals(NEXT_URL)) {
            String nextUrl = reader.nextString();
            HttpUrl url = HttpUrl.parse(DEFAULT_ENDPOINT + nextUrl);
            pagination.setCursor(url.queryParameter(CURSOR));
            pagination.setNextUrl(nextUrl);
        } else if (name.equals(MATCHED)) {
            pagination.setMatched(reader.nextLong());
        } else {
            reader.skipValue();
        }
    }
    reader.endObject();
    return pagination;
}
Also used : LogPagination(com.ibm.watson.developer_cloud.assistant.v1.model.LogPagination) HttpUrl(okhttp3.HttpUrl)

Example 2 with LogPagination

use of com.ibm.watson.developer_cloud.assistant.v1.model.LogPagination in project java-sdk by watson-developer-cloud.

the class LogPaginationTypeAdapter method read.

/*
   * (non-Javadoc)
   * @see com.google.gson.TypeAdapter#read(com.google.gson.stream.JsonReader)
   */
@Override
public LogPagination read(JsonReader reader) throws IOException {
    if (reader.peek() == JsonToken.NULL) {
        reader.nextNull();
        return null;
    }
    reader.beginObject();
    LogPagination pagination = new LogPagination();
    while (reader.hasNext()) {
        String name = reader.nextName();
        if (name.equals(NEXT_URL)) {
            String nextUrl = reader.nextString();
            HttpUrl url = HttpUrl.parse(DEFAULT_ENDPOINT + nextUrl);
            pagination.setCursor(url.queryParameter(CURSOR));
            pagination.setNextUrl(nextUrl);
        } else if (name.equals(MATCHED)) {
            pagination.setMatched(reader.nextLong());
        } else {
            reader.skipValue();
        }
    }
    reader.endObject();
    return pagination;
}
Also used : LogPagination(com.ibm.watson.developer_cloud.conversation.v1.model.LogPagination) HttpUrl(okhttp3.HttpUrl)

Aggregations

HttpUrl (okhttp3.HttpUrl)2 LogPagination (com.ibm.watson.developer_cloud.assistant.v1.model.LogPagination)1 LogPagination (com.ibm.watson.developer_cloud.conversation.v1.model.LogPagination)1