SOLR-2027: FacetField.getValues() now returns empty list instead of null

git-svn-id: https://svn.apache.org/repos/asf/lucene/dev/trunk@1144561 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Christopher John Male 2011-07-09 00:49:49 +00:00
parent 1ae1d6b4fa
commit 038a555aef
3 changed files with 39 additions and 2 deletions

View File

@ -256,7 +256,10 @@ Other Changes
* LUCENE-2883: FunctionQuery, DocValues (and its impls), ValueSource (and its * LUCENE-2883: FunctionQuery, DocValues (and its impls), ValueSource (and its
impls) and BoostedQuery have been consolidated into the queries module. They impls) and BoostedQuery have been consolidated into the queries module. They
can now be found at o.a.l.queries.function. can now be found at o.a.l.queries.function.
* SOLR-2027: FacetField.getValues() now returns an empty list if there are no
values, instead of null (Chris Male)
Documentation Documentation
---------------------- ----------------------

View File

@ -19,6 +19,7 @@ package org.apache.solr.client.solrj.response;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
@ -145,7 +146,7 @@ import org.apache.solr.client.solrj.util.ClientUtils;
} }
public List<Count> getValues() { public List<Count> getValues() {
return _values; return _values == null ? Collections.<Count>emptyList() : _values;
} }
public int getValueCount() public int getValueCount()

View File

@ -0,0 +1,33 @@
package org.apache.solr.client.solrj.response;
/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You 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.
*/
import org.apache.lucene.util.LuceneTestCase;
public class FacetFieldTest extends LuceneTestCase {
public void testGetValues() {
FacetField facetField = new FacetField("field");
assertNotNull(facetField.getValues());
assertEquals(0, facetField.getValues().size());
facetField.add("value", 1);
assertEquals(1, facetField.getValues().size());
}
}