001
014
015 package com.liferay.portal.kernel.search.facet;
016
017 import com.liferay.portal.kernel.search.BooleanClause;
018 import com.liferay.portal.kernel.search.SearchContext;
019 import com.liferay.portal.kernel.search.facet.collector.FacetCollector;
020 import com.liferay.portal.kernel.search.facet.config.FacetConfiguration;
021 import com.liferay.portal.kernel.search.facet.util.BaseFacetValueValidator;
022 import com.liferay.portal.kernel.search.facet.util.FacetValueValidator;
023
024
027 public abstract class BaseFacet implements Facet {
028
029 public BaseFacet(SearchContext searchContext) {
030 _searchContext = searchContext;
031 }
032
033 @Override
034 public BooleanClause getFacetClause() {
035 return doGetFacetClause();
036 }
037
038 @Override
039 public FacetCollector getFacetCollector() {
040 return _facetCollector;
041 }
042
043 @Override
044 public FacetConfiguration getFacetConfiguration() {
045 return _facetConfiguration;
046 }
047
048 @Override
049 public FacetValueValidator getFacetValueValidator() {
050 if (_facetValueValidator == null) {
051 _facetValueValidator = new BaseFacetValueValidator();
052 }
053
054 return _facetValueValidator;
055 }
056
057 @Override
058 public String getFieldName() {
059 return _facetConfiguration.getFieldName();
060 }
061
062 @Override
063 public SearchContext getSearchContext() {
064 return _searchContext;
065 }
066
067 @Override
068 public boolean isStatic() {
069 return _facetConfiguration.isStatic();
070 }
071
072 @Override
073 public void setFacetCollector(FacetCollector facetCollector) {
074 _facetCollector = facetCollector;
075 }
076
077 @Override
078 public void setFacetConfiguration(FacetConfiguration facetConfiguration) {
079 _facetConfiguration = facetConfiguration;
080 }
081
082 @Override
083 public void setFacetValueValidator(
084 FacetValueValidator facetValueValidator) {
085
086 _facetValueValidator = facetValueValidator;
087 }
088
089 @Override
090 public void setFieldName(String fieldName) {
091 _facetConfiguration.setFieldName(fieldName);
092 }
093
094 @Override
095 public void setStatic(boolean isStatic) {
096 _facetConfiguration.setStatic(isStatic);
097 }
098
099 protected abstract BooleanClause doGetFacetClause();
100
101 private FacetCollector _facetCollector;
102 private FacetConfiguration _facetConfiguration = new FacetConfiguration();
103 private FacetValueValidator _facetValueValidator;
104 private SearchContext _searchContext;
105
106 }