aboutsummaryrefslogtreecommitdiffstats
path: root/org.aspectj.matcher/src/main/java/org/aspectj/weaver/RuntimeVersion.java
blob: 0cf90a9a2777e87850d43f5a26463e3ce815aebc (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
/* *******************************************************************
 * Copyright (c) 2018 Contributors
 * All rights reserved.
 * This program and the accompanying materials are made available
 * under the terms of the Eclipse Public License v1.0
 * which accompanies this distribution and is available at
 * http://www.eclipse.org/legal/epl-v10.html
 * ******************************************************************/
package org.aspectj.weaver;

/**
 * Captures important runtime versions. Typically new versions are added here if something
 * changes in the runtime and the code generation may be able to do something different
 * (more optimal) for a later runtime.
 * 
 * @author Andy Clement
 */
public enum RuntimeVersion {
	
	V1_2("1.2"), V1_5("1.5"), V1_6_10("1.6.10"), V1_9("1.9");
	
	private String[] aliases = null;

	RuntimeVersion(String... aliases) {
		this.aliases = aliases;
	}
	
	public static RuntimeVersion getVersionFor(String version) {
		for (RuntimeVersion candidateVersion: values()) {
			if (candidateVersion.name().equals(version)) {
				return candidateVersion;
			}
			if (candidateVersion.aliases != null) {
				for (String alias: candidateVersion.aliases) {
					if (alias.equals(version)) {
						return candidateVersion;
					}
				}
			}
		}
		return null;
	}

	public boolean isThisVersionOrLater(RuntimeVersion version) {
		return this.compareTo(version) >= 0;
	}
}