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 [CriteriaQuery.java]

nameclass, %method, %block, %line, %
CriteriaQuery.java100% (1/1)43%  (3/7)26%  (19/74)33%  (8/24)

COVERAGE BREAKDOWN BY CLASS AND METHOD

nameclass, %method, %block, %line, %
     
class CriteriaQuery100% (1/1)43%  (3/7)26%  (19/74)33%  (8/24)
CriteriaQuery (): void 0%   (0/1)0%   (0/3)0%   (0/2)
addCriteria (Criteria): CriteriaQuery 0%   (0/1)0%   (0/17)0%   (0/5)
fromQuery (CriteriaQuery): Query 0%   (0/1)0%   (0/6)0%   (0/1)
fromQuery (CriteriaQuery, CriteriaQuery): CriteriaQuery 0%   (0/1)0%   (0/24)0%   (0/7)
CriteriaQuery (Criteria, Pageable): void 100% (1/1)69%  (11/16)83%  (5/6)
CriteriaQuery (Criteria): void 100% (1/1)100% (5/5)100% (2/2)
getCriteria (): Criteria 100% (1/1)100% (3/3)100% (1/1)

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 
18 
19import org.springframework.data.domain.Pageable;
20import org.springframework.util.Assert;
21 
22/**
23 *   CriteriaQuery
24 *
25 * @author Rizwan Idrees
26 * @author Mohsin Husen
27 */
28public class CriteriaQuery extends AbstractQuery implements Query {
29 
30    private Criteria criteria;
31    private CriteriaQuery() {
32    }
33 
34    public CriteriaQuery(Criteria criteria) {
35        this(criteria, null);
36    }
37 
38    public CriteriaQuery(Criteria criteria, Pageable pageable) {
39        this.criteria = criteria;
40        this.pageable = pageable;
41        if (pageable != null) {
42            this.addSort(pageable.getSort());
43        }
44    }
45 
46    public static final Query fromQuery(CriteriaQuery source) {
47        return fromQuery(source, new CriteriaQuery());
48    }
49 
50    public static <T extends CriteriaQuery> T fromQuery(CriteriaQuery source, T destination) {
51        if (source == null || destination == null) {
52            return null;
53        }
54 
55        if (source.getCriteria() != null) {
56            destination.addCriteria(source.getCriteria());
57        }
58 
59        if (source.getSort() != null) {
60            destination.addSort(source.getSort());
61        }
62 
63        return destination;
64    }
65 
66    @SuppressWarnings("unchecked")
67    public final <T extends CriteriaQuery> T addCriteria(Criteria criteria) {
68        Assert.notNull(criteria, "Cannot add null criteria.");
69        if (this.criteria == null) {
70            this.criteria = criteria;
71        } else {
72            this.criteria.and(criteria);
73        }
74        return (T) this;
75    }
76 
77    public Criteria getCriteria() {
78        return this.criteria;
79    }
80 
81}

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