GRAILS-1019: Allowing expressions to be used with the 'disabled' attribute for g...
[grails.git] / src / persistence / org / codehaus / groovy / grails / orm / hibernate / GrailsHibernateDomainClassProperty.java
blob558344591439242911dc061d2514a553067791b5
1 /* Copyright 2004-2005 the original author or authors.
3 * Licensed under the Apache License, Version 2.0 (the "License");
4 * you may not use this file except in compliance with the License.
5 * You may obtain a copy of the License at
7 * http://www.apache.org/licenses/LICENSE-2.0
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
15 package org.codehaus.groovy.grails.orm.hibernate;
17 import org.codehaus.groovy.grails.commons.GrailsClassUtils;
18 import org.codehaus.groovy.grails.commons.GrailsDomainClass;
19 import org.codehaus.groovy.grails.commons.GrailsDomainClassProperty;
21 /**
22 * An implementation of the GrailsDomainClassProperty interface that allows Classes mapped in
23 * Hibernate to integrate with Grails' validation, dynamic methods etc. seamlessly
25 * @author Graeme Rocher
26 * @since 0.1
28 * Created - 18-Feb-2006
30 public class GrailsHibernateDomainClassProperty implements GrailsDomainClassProperty {
31 private GrailsHibernateDomainClass domainClass;
33 private String name;
34 private String naturalName;
35 private Class type;
36 private boolean identity;
37 private boolean oneToOne;
38 private boolean manyToOne;
39 private boolean association;
40 private boolean oneToMany;
41 private boolean manyToMany;
42 private boolean bidirectional;
43 private boolean optional;
44 private Class relatedClassType;
45 private GrailsDomainClass referencedDomainClass;
46 private GrailsDomainClassProperty otherSide;
47 private boolean owingSide;
48 private String columnName;
51 public GrailsHibernateDomainClassProperty(GrailsHibernateDomainClass domainClass, String propertyName) {
52 this.domainClass = domainClass;
53 this.name = propertyName;
54 this.naturalName = GrailsClassUtils.getNaturalName(propertyName);
57 public String getName() {
58 return this.name;
61 public Class getType() {
62 return this.type;
65 public void setType(Class type) {
66 this.type = type;
69 public String getTypePropertyName() {
70 return GrailsClassUtils.getPropertyNameRepresentation(this.type);
73 public GrailsDomainClass getDomainClass() {
74 return this.domainClass;
77 public boolean isPersistent() {
78 return true;
81 public String getNaturalName() {
82 return this.naturalName;
85 public void setReferencedDomainClass(GrailsDomainClass referencedGrailsDomainClass) {
86 this.referencedDomainClass = referencedGrailsDomainClass;
89 public void setOtherSide(GrailsDomainClassProperty referencedProperty) {
90 this.otherSide = referencedProperty;
93 public GrailsDomainClassProperty getOtherSide() {
94 return this.otherSide;
97 public Class getReferencedPropertyType() {
98 return this.relatedClassType;
101 public boolean isIdentity() {
102 return identity;
105 public void setIdentity(boolean identity) {
106 this.identity = identity;
109 public boolean isOptional() {
110 return optional;
113 public void setOptional(boolean optional) {
114 this.optional = optional;
117 public boolean isOneToOne() {
118 return oneToOne;
121 public void setOneToOne(boolean oneToOne) {
122 this.oneToOne = oneToOne;
125 public boolean isManyToOne() {
126 return manyToOne;
129 public void setManyToOne(boolean manyToOne) {
130 this.manyToOne = manyToOne;
133 public boolean isAssociation() {
134 return association;
137 public boolean isEnum() {
138 return GrailsClassUtils.isJdk5Enum(getType());
141 public void setAssociation(boolean association) {
142 this.association = association;
145 public boolean isOneToMany() {
146 return oneToMany;
149 public void setOneToMany(boolean oneToMany) {
150 this.oneToMany = oneToMany;
153 public boolean isManyToMany() {
154 return manyToMany;
157 public void setManyToMany(boolean manyToMany) {
158 this.manyToMany = manyToMany;
161 public boolean isBidirectional() {
162 return bidirectional;
165 public String getFieldName() {
166 throw new UnsupportedOperationException("Method 'getFieldName' is not supported by implementation");
169 public void setBidirectional(boolean bidirectional) {
170 this.bidirectional = bidirectional;
173 public GrailsDomainClass getReferencedDomainClass() {
174 return this.referencedDomainClass;
178 public void setRelatedClassType(Class relatedType) {
179 this.relatedClassType = relatedType;
182 public boolean isInherited() {
183 throw new UnsupportedOperationException("Method 'isInherited' is not supported by implementation");
186 public int getFetchMode() {
187 throw new UnsupportedOperationException("Method 'getFetchMode' is not supported by implementation");
190 public boolean isOwningSide() {
191 return this.owingSide;
194 public boolean isCircular() {
195 throw new UnsupportedOperationException("Method 'isCircular' is not supported by implementation");
198 public String getReferencedPropertyName() {
199 throw new UnsupportedOperationException("Method 'getReferencedPropertyName' is not supported by implementation");
202 public boolean isEmbedded() {
203 return false;
206 public GrailsDomainClass getComponent() {
207 throw new UnsupportedOperationException("Method 'getComponent' is not supported by implementation");
210 public void setOwningSide(boolean b) {
211 this.owingSide = b;
214 public void setColumnName(String columnName) {
215 this.columnName = columnName;
218 public String getColumnName() {
219 return columnName;