View Javadoc

1   /*
2    * This file is a part of CAST project.
3    * (c) Copyright 2007, AGH University of Science & Technology
4    * https://caribou.iisg.agh.edu.pl/trac/cast
5    *
6    * Licensed under the Eclipse Public License, Version 1.0 (the "License").
7    * You may not use this file except in compliance with the License.
8    * You may obtain a copy of the License at
9    * http://www.eclipse.org/legal/epl-v10.html
10   */
11  /*
12   * File: LinkEntry.java
13   * Created: 2008-01-04
14   * Author: apohllo
15   * $Id: LinkEntry.java 2335 2009-01-13 16:40:16Z entrop $
16   */
17  
18  package pl.edu.agh.cast.model.mapper.internal;
19  
20  import java.lang.reflect.Method;
21  
22  import pl.edu.agh.cast.model.mapper.annotation.MapLink;
23  
24  /**
25   * The LinkEntry class is used to map methods to their annotations.
26   *
27   * @author AGH CAST Team
28   */
29  class LinkEntry {
30  
31  	private Method key;
32  
33  	private MapLink value;
34  
35  	/**
36  	 * The constructor.
37  	 *
38  	 * @param method
39  	 *            The method.
40  	 * @param annotation
41  	 *            The annotation which is bound to this method.
42  	 */
43  	public LinkEntry(Method method, MapLink annotation) {
44  		key = method;
45  		value = annotation;
46  	}
47  
48  	/**
49  	 * Method getter.
50  	 *
51  	 * @return The method.
52  	 */
53  	public Method getMethod() {
54  		return key;
55  	}
56  
57  	/**
58  	 * Annotation getter.
59  	 *
60  	 * @return The annotation.
61  	 */
62  	public MapLink getAnnotation() {
63  		return value;
64  	}
65  
66  	/**
67  	 * Annotation setter.
68  	 *
69  	 * @param newValue
70  	 *            New annotation.
71  	 * @return The old value of the annotation.
72  	 */
73  	public MapLink setValue(MapLink newValue) {
74  		MapLink oldValue = value;
75  		value = newValue;
76  		return oldValue;
77  	}
78  
79  	/**
80  	 * {@inheritDoc}
81  	 *
82  	 * @see java.lang.Object#toString()
83  	 */
84  	@Override
85  	public String toString() {
86  		return key + ":" + value; //$NON-NLS-1$
87  	}
88  }