aboutsummaryrefslogtreecommitdiffstats
path: root/org.aspectj.matcher/src/main/java/org/aspectj/weaver/patterns/FormalBinding.java
blob: 37d674696c2a32feb13ec8f8e6b1ab2b6b324379 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
/* *******************************************************************
 * Copyright (c) 2002 Palo Alto Research Center, Incorporated (PARC).
 * All rights reserved.
 * This program and the accompanying materials are made available
 * under the terms of the Eclipse Public License v 2.0
 * which accompanies this distribution and is available at
 * https://www.eclipse.org/org/documents/epl-2.0/EPL-2.0.txt
 *
 * Contributors:
 *     PARC     initial implementation
 * ******************************************************************/

package org.aspectj.weaver.patterns;

import org.aspectj.weaver.IHasPosition;
import org.aspectj.weaver.UnresolvedType;

public class FormalBinding implements IHasPosition {
	private final UnresolvedType type;
	private final String name;
	private final int index;
	private final int start, end;

	public FormalBinding(UnresolvedType type, String name, int index, int start, int end) {
		this.type = type;
		this.name = name;
		this.index = index;
		this.start = start;
		this.end = end;
	}

	public FormalBinding(UnresolvedType type, int index) {
		this(type, "unknown", index, 0, 0);
	}

	public FormalBinding(UnresolvedType type, String name, int index) {
		this(type, name, index, 0, 0);
	}

	// ----

	public String toString() {
		return type.toString() + ":" + index;
	}

	public int getEnd() {
		return end;
	}

	public int getStart() {
		return start;
	}

	public int getIndex() {
		return index;
	}

	public String getName() {
		return name;
	}

	public UnresolvedType getType() {
		return type;
	}

	// ----

	public static final FormalBinding[] NONE = new FormalBinding[0];

	/**
	 * A marker class for bindings for which we want to ignore unbound issue and consider them as implicit binding - f.e. to handle
	 * JoinPoint in @AJ advices
	 *
	 * @author Alexandre Vasseur (alex AT gnilux DOT com)
	 */
	public static class ImplicitFormalBinding extends FormalBinding {
		public ImplicitFormalBinding(UnresolvedType type, String name, int index) {
			super(type, name, index);
		}
	}

}