001 /*
002 * Copyright 2004 Chris Nelson
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
007 * Unless required by applicable law or agreed to in writing,
008 * software distributed under the License is distributed on an "AS IS" BASIS,
009 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
010 * See the License for the specific language governing permissions and limitations under the License.
011 */
012 package org.tynamo.descriptor;
013
014 /**
015 * This class represents a to-one association and is created by HibernateDescriptorDecorator
016 *
017 * @author Chris Nelson
018 * @see HibernateDescriptorDecorator
019 */
020 public class ObjectReferenceDescriptor extends TynamoPropertyDescriptorImpl
021 {
022 private Class actualType;
023
024 public ObjectReferenceDescriptor(Class beanType, TynamoPropertyDescriptor descriptor,
025 Class actualType)
026 {
027 this(beanType, descriptor.getPropertyType(), actualType);
028 copyFrom(descriptor);
029 }
030
031 /**
032 * @param realDescriptor
033 */
034 public ObjectReferenceDescriptor(
035 Class beanType, Class declaredType, Class actualType)
036 {
037 super(beanType, declaredType);
038 this.actualType = actualType;
039 }
040
041 /* (non-Javadoc)
042 * @see org.tynamo.descriptor.PropertyDescriptor#getPropertyType()
043 */
044 public Class getPropertyType()
045 {
046 return actualType;
047 }
048
049 /* (non-Javadoc)
050 * @see org.tynamo.descriptor.PropertyDescriptor#isObjectReference()
051 */
052 public boolean isObjectReference()
053 {
054 return true;
055 }
056
057 public Object clone()
058 {
059 return new ObjectReferenceDescriptor(getBeanType(), this, getPropertyType());
060 }
061 }