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 returnType;
010            private Class[] argumentTypes;
011    
012            public TynamoMethodDescriptorImpl(IMethodDescriptor methodDescriptor)
013            {
014                    super(methodDescriptor);
015            }
016    
017            public TynamoMethodDescriptorImpl(Class beanType, String name, Class returnType, Class[] argumentTypes)
018            {
019                    super(beanType);
020                    this.returnType = returnType;
021                    this.name = name;
022                    this.argumentTypes = argumentTypes;
023                    setNonVisual(true);
024            }
025    
026            /**
027             * (non-Javadoc)
028             *
029             * @see org.tynamo.descriptor.IMethodDescriptor#getArgumentTypes()
030             */
031    
032            public Class[] getArgumentTypes()
033            {
034                    return argumentTypes;
035            }
036    
037    
038            /**
039             * just for serialization pourposes
040             */
041            public void setArgumentTypes(Class[] argumentTypes)
042            {
043                    this.argumentTypes = argumentTypes;
044            }
045    
046    
047            /**
048             * (non-Javadoc)
049             *
050             * @see org.tynamo.descriptor.IMethodDescriptor#getName()
051             */
052            public String getName()
053            {
054                    return name;
055            }
056    
057    
058            /**
059             * just for serialization pourposes
060             */
061            public void setName(String name)
062            {
063                    this.name = name;
064            }
065    
066            public Class getReturnType()
067            {
068                    return returnType;
069            }
070    
071            /**
072             * just for serialization pourposes
073             */
074            public void setReturnType(Class returnType)
075            {
076                    this.returnType = returnType;
077            }
078    
079            public Method getMethod()
080            {
081                    try
082                    {
083                            return beanType.getMethod(name, argumentTypes);
084                    } catch (NoSuchMethodException e)
085                    {
086                            return null;
087                    }
088            }
089    
090            @Override
091            public Object clone()
092            {
093                    return new TynamoMethodDescriptorImpl(this);
094            }
095    }