/*
* Copyright (C) 2017 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.android.example.github.api;
import com.google.gson.annotations.SerializedName;
import com.android.example.github.vo.Repo;
import android.support.annotation.NonNull;
import java.util.ArrayList;
import java.util.List;
/**
* POJO to hold repo search responses. This is different from the Entity in the database because
* we are keeping a search result in 1 row and denormalizing list of results into a single column.
*/
public class RepoSearchResponse {
@SerializedName("total_count")
private int total;
@SerializedName("items")
private List<Repo> items;
private Integer nextPage;
public int getTotal() {
return total;
}
public void setTotal(int total) {
this.total = total;
}
public List<Repo> getItems() {
return items;
}
public void setItems(List<Repo> items) {
this.items = items;
}
public void setNextPage(Integer nextPage) {
this.nextPage = nextPage;
}
public Integer getNextPage() {
return nextPage;
}
@NonNull
public List<Integer> getRepoIds() {
List<Integer> repoIds = new ArrayList<>();
for (Repo repo : items) {
repoIds.add(repo.id);
}
return repoIds;
}
}