EMMA Coverage Report (generated Tue Mar 05 16:36:55 GMT 2013)
[all classes][org.springframework.data.elasticsearch.core.query]

COVERAGE SUMMARY FOR SOURCE FILE [AbstractQuery.java]

nameclass, %method, %block, %line, %
AbstractQuery.java100% (1/1)100% (12/12)93%  (81/87)96%  (25/26)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class AbstractQuery100% (1/1)100% (12/12)93%  (81/87)96%  (25/26)
addSort (Sort): Query 100% (1/1)68%  (13/19)83%  (5/6)
<static initializer> 100% (1/1)100% (7/7)100% (1/1)
AbstractQuery (): void 100% (1/1)100% (21/21)100% (5/5)
addFields (String []): void 100% (1/1)100% (5/5)100% (2/2)
addIndices (String []): void 100% (1/1)100% (5/5)100% (2/2)
addTypes (String []): void 100% (1/1)100% (5/5)100% (2/2)
getFields (): List 100% (1/1)100% (3/3)100% (1/1)
getIndices (): List 100% (1/1)100% (3/3)100% (1/1)
getPageable (): Pageable 100% (1/1)100% (3/3)100% (1/1)
getSort (): Sort 100% (1/1)100% (3/3)100% (1/1)
getTypes (): List 100% (1/1)100% (3/3)100% (1/1)
setPageable (Pageable): Query 100% (1/1)100% (10/10)100% (3/3)

1/*
2 * Copyright 2013 the original author or authors.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.springframework.data.elasticsearch.core.query;
17 
18import org.springframework.data.domain.PageRequest;
19import org.springframework.data.domain.Pageable;
20import org.springframework.data.domain.Sort;
21import org.springframework.util.Assert;
22 
23import java.util.ArrayList;
24import java.util.List;
25 
26import static org.apache.commons.collections.CollectionUtils.addAll;
27 
28/**
29 * AbstractQuery
30 *
31 * @author Rizwan Idrees
32 * @author Mohsin Husen
33 */
34abstract class AbstractQuery implements Query{
35 
36    private static final Pageable DEFAULT_PAGE = new PageRequest(0, DEFAULT_PAGE_SIZE);
37 
38    protected Pageable pageable = DEFAULT_PAGE;
39    protected Sort sort;
40    protected List<String> indices = new ArrayList<String>();
41    protected List<String> types = new ArrayList<String>();
42    protected List<String> fields = new ArrayList<String>();
43 
44    @Override
45    public Sort getSort() {
46        return this.sort;
47    }
48 
49    @Override
50    public Pageable getPageable() {
51        return this.pageable;
52    }
53 
54    @Override
55    public final <T extends Query> T setPageable(Pageable pageable) {
56        Assert.notNull(pageable);
57        this.pageable = pageable;
58        return (T) this.addSort(pageable.getSort());
59    }
60 
61    @Override
62    public void addFields(String...fields) {
63        addAll(this.fields, fields);
64    }
65 
66    @Override
67    public List<String> getFields() {
68        return fields;
69    }
70 
71    @Override
72    public List<String> getIndices() {
73        return indices;
74    }
75 
76    @Override
77    public void addIndices(String... indices) {
78        addAll(this.indices,indices);
79    }
80 
81    @Override
82    public void addTypes(String... types) {
83        addAll(this.types,types);
84    }
85 
86    @Override
87    public List<String> getTypes() {
88        return types;
89    }
90 
91    @SuppressWarnings("unchecked")
92    public final <T extends Query> T addSort(Sort sort) {
93        if (sort == null) {
94            return (T) this;
95        }
96 
97        if (this.sort == null) {
98            this.sort = sort;
99        } else {
100            this.sort = this.sort.and(sort);
101        }
102 
103        return (T) this;
104    }
105}

[all classes][org.springframework.data.elasticsearch.core.query]
EMMA 2.0.5312 (C) Vladimir Roubtsov