001/* 002 * (C) Copyright 2014 Nuxeo SA (http://nuxeo.com/) and others. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 * 016 * Contributors: 017 * Benoit Delbosc 018 */ 019package org.nuxeo.ecm.platform.query.core; 020 021import org.nuxeo.ecm.platform.query.api.Bucket; 022 023/** 024 * Immutable Bucket for terms. 025 * 026 * @since 6.0 027 */ 028public final class BucketTerm implements Bucket { 029 030 private final String key; 031 032 private final long docCount; 033 034 public BucketTerm(String key, long docCount) { 035 if (key == null) { 036 throw new IllegalArgumentException("key is null"); 037 }; 038 this.key = key; 039 this.docCount = docCount; 040 } 041 042 @Override 043 public String getKey() { 044 return key; 045 } 046 047 @Override 048 public long getDocCount() { 049 return docCount; 050 } 051 052 @Override 053 public String toString() { 054 return String.format("BucketTerm(%s, %d)", key, docCount); 055 } 056 057}