001    package org.tynamo.descriptor;
002    
003    import java.lang.reflect.Method;
004    
005    public class TynamoMethodDescriptorImpl extends TynamoDescriptor implements IMethodDescriptor
006    {
007    
008            private String name;
009            private Class beanType;
010            private Class[] argumentTypes;
011    
012            /////////////////////////////////////////////////////////////////////////////////////////////////////////
013            // constructors
014            /////////////////////////////////////////////////////////////////////////////////////////////////////////
015            public TynamoMethodDescriptorImpl(IMethodDescriptor methodDescriptor)
016            {
017                    super(methodDescriptor);
018            }
019    
020            public TynamoMethodDescriptorImpl(Class beanType, String name, Class returnType, Class[] argumentTypes)
021            {
022                    super(returnType);
023                    this.beanType = beanType;
024                    this.name = name;
025                    this.argumentTypes = argumentTypes;
026                    setHidden(true);
027            }
028    
029            /////////////////////////////////////////////////////////////////////////////////////////////////////////
030            // bean setters/getters
031            /////////////////////////////////////////////////////////////////////////////////////////////////////////
032    
033            /**
034             * (non-Javadoc)
035             *
036             * @see org.tynamo.descriptor.IMethodDescriptor#getArgumentTypes()
037             */
038    
039            public Class[] getArgumentTypes()
040            {
041                    return argumentTypes;
042            }
043    
044    
045            /**
046             * just for serialization pourposes
047             */
048            public void setArgumentTypes(Class[] argumentTypes)
049            {
050                    this.argumentTypes = argumentTypes;
051            }
052    
053    
054            /**
055             * (non-Javadoc)
056             *
057             * @see org.tynamo.descriptor.IMethodDescriptor#getName()
058             */
059            public String getName()
060            {
061                    return name;
062            }
063    
064    
065            /**
066             * just for serialization pourposes
067             */
068            public void setName(String name)
069            {
070                    this.name = name;
071            }
072    
073            public Class getBeanType()
074            {
075                    return beanType;
076            }
077    
078            /**
079             * just for serialization pourposes
080             */
081            public void setBeanType(Class beanType)
082            {
083                    this.beanType = beanType;
084            }
085    
086            public Method getMethod()
087            {
088                    try
089                    {
090                            return beanType.getMethod(name, argumentTypes);
091                    } catch (NoSuchMethodException e)
092                    {
093                            return null;
094                    }
095            }
096    
097            @Override
098            public Object clone()
099            {
100                    return new TynamoMethodDescriptorImpl(this);
101            }
102    }