1 package org.apache.lucene.facet.enhancements.association;
3 import org.apache.lucene.facet.index.attributes.CategoryAttribute;
4 import org.apache.lucene.facet.index.attributes.CategoryProperty;
7 * Licensed to the Apache Software Foundation (ASF) under one or more
8 * contributor license agreements. See the NOTICE file distributed with
9 * this work for additional information regarding copyright ownership.
10 * The ASF licenses this file to You under the Apache License, Version 2.0
11 * (the "License"); you may not use this file except in compliance with
12 * the License. You may obtain a copy of the License at
14 * http://www.apache.org/licenses/LICENSE-2.0
16 * Unless required by applicable law or agreed to in writing, software
17 * distributed under the License is distributed on an "AS IS" BASIS,
18 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
19 * See the License for the specific language governing permissions and
20 * limitations under the License.
24 * A {@link CategoryProperty} associating a single integer value to a
25 * {@link CategoryAttribute}. It should be used to describe the association
26 * between the category and the document.
28 * This class leave to extending classes the definition of
29 * {@link #merge(CategoryProperty)} policy for the integer associations.
31 * <B>Note:</B> The association value is added both to a special category list,
32 * and to the category tokens.
34 * @see AssociationEnhancement
35 * @lucene.experimental
37 public abstract class AssociationProperty implements CategoryProperty {
39 protected long association = Integer.MAX_VALUE + 1;
42 * Construct an {@link AssociationProperty}.
45 * The association value.
47 public AssociationProperty(int value) {
48 this.association = value;
52 * Returns the association value.
54 * @return The association value.
56 public int getAssociation() {
57 return (int) association;
61 * Returns whether this attribute has been set (not all categories have an
64 public boolean hasBeenSet() {
65 return this.association <= Integer.MAX_VALUE;
69 public String toString() {
70 return getClass().getSimpleName() + ": " + association;