All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.day.cq.search.facets.extractors.FacetImpl Maven / Gradle / Ivy

There is a newer version: 6.5.21
Show newest version
/*
 * Copyright 1997-2008 Day Management AG
 * Barfuesserplatz 6, 4001 Basel, Switzerland
 * All Rights Reserved.
 *
 * This software is the confidential and proprietary information of
 * Day Management AG, ("Confidential Information"). You shall not
 * disclose such Confidential Information and shall use it only in
 * accordance with the terms of the license agreement you entered into
 * with Day.
 */
package com.day.cq.search.facets.extractors;

import java.util.ArrayList;
import java.util.Collection;
import java.util.List;

import com.day.cq.search.facets.Bucket;
import com.day.cq.search.facets.Facet;
import com.day.cq.search.facets.FacetExtractor;

/**
 * FacetImpl is a simple implementation of the {@link Facet}
 * interface, which basically holds a collection of {@link Bucket Buckets}.
 * 
 * 

* Note that this class resides in a public package (OSGi) for easy reuse of * custom {@link FacetExtractor FacetExtractors}. * * @since 5.2 */ public class FacetImpl implements Facet { private List buckets = new ArrayList(); /** * Creates a facet without any buckets. Use {@link #addBucket(Bucket)} to * add buckets one by one. */ public FacetImpl() { } /** * Creates a facet with a given list of buckets. */ public FacetImpl(Collection buckets) { this.buckets.addAll(buckets); } /** * Adds a bucket to the list of buckets that will be returned in * {@link #getBuckets()}. */ public void addBucket(Bucket bucket) { this.buckets.add(bucket); } // -------------------------------------------------------< Facet interface > public List getBuckets() { return buckets; } public boolean getContainsHit() { for (Bucket bucket : getBuckets()) { if (bucket.getCount() > 0) { return true; } } return false; } }





© 2015 - 2024 Weber Informatics LLC | Privacy Policy