1 /*
2 * Copyright 2011 Werner Guttmann
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except
5 * in compliance with the License. You may obtain a copy of the License at
6 *
7 * http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software distributed under the License
10 * is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express
11 * or implied. See the License for the specific language governing permissions and limitations under
12 * the License.
13 *
14 */
15 package org.exolab.castor.builder.info.nature;
16
17 import org.castor.core.nature.BaseNature;
18 import org.exolab.castor.builder.info.FieldInfo;
19
20 /**
21 * A SOLRJ specific view of a {@link FieldInfo}. Implementation based on property access on
22 * {@link FieldInfo}.
23 *
24 * @author Werner Guttmann
25 * @since 1.3.3
26 */
27 public final class SolrjFieldInfoNature extends BaseNature {
28
29 /**
30 * Constant for the property name for the of the solrj field name.
31 */
32 private static final String FIELD_NAME = "name";
33
34 /**
35 * Indicates whether the solrj annotation indicates an Id field.
36 */
37 private static final String ID_DEFINITION = "idDefinition";
38
39 /**
40 * Constructor taking a {@link FieldInfo}.
41 *
42 * @param fieldInfo in focus.
43 */
44 public SolrjFieldInfoNature(final FieldInfo fieldInfo) {
45 super(fieldInfo);
46 }
47
48 /**
49 * Returns the fully qualified class name of the nature.
50 *
51 * @return the nature id.
52 * @see org.exolab.castor.builder.info.nature.Nature#getId()
53 */
54 public String getId() {
55 return getClass().getName();
56 }
57
58 /**
59 * Retrieves the solrj field name.
60 *
61 * @return name of field.
62 */
63 public String getFieldName() {
64 return (String) this.getProperty(FIELD_NAME);
65 }
66
67 /**
68 * Sets the solrj field name.
69 *
70 * @param fieldName name of the field.
71 */
72 public void setFieldName(final String fieldName) {
73 this.setProperty(FIELD_NAME, fieldName);
74 }
75
76 /**
77 * Returns true if the solrj annotation is of type @Id.
78 *
79 * @return true if the solrj annotation is of type @Id.
80 */
81 public boolean isIdDefinition() {
82 return getBooleanPropertyDefaultFalse(ID_DEFINITION);
83 }
84
85 /**
86 * Sets whether or not the annotated solrj field is of type @Id.
87 *
88 * @param elementDef The flag indicating whether or not the annotated solrj field is of type @Id.
89 */
90 public void setIdDefinition(final boolean idDefinition) {
91 this.setProperty(ID_DEFINITION, Boolean.valueOf(idDefinition));
92 }
93
94 }