ScimSearchResult.java 3.0 KB
Newer Older
MaxKey单点登录官方's avatar
MaxKey单点登录官方 已提交
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
/*
 * Copyright [2020] [MaxKey of copyright http://www.maxkey.top]
 * 
 * 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.
 */
 

MaxKey单点登录官方's avatar
MaxKey单点登录官方 已提交
18 19 20 21 22 23 24 25 26 27 28 29
package org.maxkey.identity.scim.resources;

import java.util.ArrayList;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Set;

import com.fasterxml.jackson.annotation.JsonProperty;

public class ScimSearchResult <T>{

M
MaxKey 已提交
30 31 32 33 34 35 36 37
	public static class Constants{
		public static final String FILTER		=	"filter";
		public static final String SORTBY		=	"sortBy";
		public static final String COUNT		=	"count";
		public static final String STARTINDEX	=	"startIndex";
		
		
	}
MaxKey单点登录官方's avatar
MaxKey单点登录官方 已提交
38 39 40 41 42 43
    public static final String SCHEMA = "urn:ietf:params:scim:api:messages:2.0:ListResponse";
    public static final int MAX_RESULTS = 100;
    private long totalResults;
    private long itemsPerPage;
    private long startIndex;
    private Set<String> schemas = new HashSet<>(Collections.singletonList(SCHEMA));
M
MaxKey 已提交
44 45
    
    @JsonProperty("Resources")
MaxKey单点登录官方's avatar
MaxKey单点登录官方 已提交
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
    private List<T> resources = new ArrayList<>();

    /**
     * Default constructor for Jackson
     */
    ScimSearchResult() {
    }

    public ScimSearchResult(List<T> resources, long totalResults, long itemsPerPage, long startIndex) {
        this.resources = resources;
        this.totalResults = totalResults;
        this.itemsPerPage = itemsPerPage;
        this.startIndex = startIndex;
    }


    /**
M
MaxKey 已提交
63
     * gets a list of found {@link ScimUser}s or {@link ScimGroup}s
MaxKey单点登录官方's avatar
MaxKey单点登录官方 已提交
64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108
     *
     * @return a list of found resources
     */
    @JsonProperty("Resources")
    public List<T> getResources() {
        return resources;
    }

    /**
     * The total number of results returned by the list or query operation. This may not be equal to the number of
     * elements in the Resources attribute of the list response if pagination is requested.
     *
     * @return the total result
     */
    public long getTotalResults() {
        return totalResults;
    }

    /**
     * Gets the schemas of the search result
     *
     * @return the search result schemas
     */
    public Set<String> getSchemas() {
        return schemas;
    }

    /**
     * The number of Resources returned in a list response page.
     *
     * @return items per page
     */
    public long getItemsPerPage() {
        return itemsPerPage;
    }

    /**
     * The 1-based index of the first result in the current set of list results.
     *
     * @return the start index of the actual page
     */
    public long getStartIndex() {
        return startIndex;
    }
}