EMMA Coverage Report (generated Mon Jan 28 16:15:17 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 2012 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 
22public class CriteriaQuery extends AbstractQuery implements Query {
23 
24    private Criteria criteria;
25    private CriteriaQuery() {
26    }
27 
28    public CriteriaQuery(Criteria criteria) {
29        this(criteria, null);
30    }
31 
32    public CriteriaQuery(Criteria criteria, Pageable pageable) {
33        this.criteria = criteria;
34        this.pageable = pageable;
35        if (pageable != null) {
36            this.addSort(pageable.getSort());
37        }
38    }
39 
40    public static final Query fromQuery(CriteriaQuery source) {
41        return fromQuery(source, new CriteriaQuery());
42    }
43 
44    public static <T extends CriteriaQuery> T fromQuery(CriteriaQuery source, T destination) {
45        if (source == null || destination == null) {
46            return null;
47        }
48 
49        if (source.getCriteria() != null) {
50            destination.addCriteria(source.getCriteria());
51        }
52 
53        if (source.getSort() != null) {
54            destination.addSort(source.getSort());
55        }
56 
57        return destination;
58    }
59 
60    @SuppressWarnings("unchecked")
61    public final <T extends CriteriaQuery> T addCriteria(Criteria criteria) {
62        Assert.notNull(criteria, "Cannot add null criteria.");
63        if (this.criteria == null) {
64            this.criteria = criteria;
65        } else {
66            this.criteria.and(criteria);
67        }
68        return (T) this;
69    }
70 
71    public Criteria getCriteria() {
72        return this.criteria;
73    }
74 
75}

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