View Javadoc
1   /*
2    * Licensed to the Apache Software Foundation (ASF) under one
3    * or more contributor license agreements.  See the NOTICE file
4    * distributed with this work for additional information
5    * regarding copyright ownership.  The ASF licenses this file
6    * to you under the Apache License, Version 2.0 (the
7    * "License"); you may not use this file except in compliance
8    * with the License.  You may obtain a copy of the License at
9    *
10   *   http://www.apache.org/licenses/LICENSE-2.0
11   *
12   * Unless required by applicable law or agreed to in writing,
13   * software distributed under the License is distributed on an
14   * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
15   * KIND, either express or implied.  See the License for the
16   * specific language governing permissions and limitations
17   * under the License.
18   */
19  package org.apache.maven.index;
20  
21  import java.util.ArrayList;
22  import java.util.Collection;
23  import java.util.Collections;
24  import java.util.List;
25  
26  public class Field {
27      public static final String NOT_PRESENT = "N/P";
28  
29      private final Field parent;
30  
31      private final String namespace;
32  
33      private final String fieldName;
34  
35      private final String description;
36  
37      private final List<IndexerField> indexerFields;
38  
39      public Field(final Field parent, final String namespace, final String name, final String description) {
40          this.parent = parent;
41  
42          this.namespace = namespace;
43  
44          this.fieldName = name;
45  
46          this.description = description;
47  
48          this.indexerFields = new ArrayList<>();
49      }
50  
51      public Field getParent() {
52          return parent;
53      }
54  
55      public String getNamespace() {
56          return namespace;
57      }
58  
59      public String getFieldName() {
60          return fieldName;
61      }
62  
63      public String getDescription() {
64          return description;
65      }
66  
67      public Collection<IndexerField> getIndexerFields() {
68          return Collections.unmodifiableList(indexerFields);
69      }
70  
71      public boolean addIndexerField(IndexerField field) {
72          return indexerFields.add(field);
73      }
74  
75      public boolean removeIndexerField(IndexerField field) {
76          return indexerFields.remove(field);
77      }
78  
79      public String getFQN() {
80          return getNamespace() + getFieldName();
81      }
82  
83      public String toString() {
84          return getFQN() + " (with " + getIndexerFields().size() + " registered index fields)";
85      }
86  }