You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

RuntimeVersion.java 1.4KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647
  1. /* *******************************************************************
  2. * Copyright (c) 2018 Contributors
  3. * All rights reserved.
  4. * This program and the accompanying materials are made available
  5. * under the terms of the Eclipse Public License v1.0
  6. * which accompanies this distribution and is available at
  7. * http://www.eclipse.org/legal/epl-v10.html
  8. * ******************************************************************/
  9. package org.aspectj.weaver;
  10. /**
  11. * Captures important runtime versions. Typically new versions are added here if something
  12. * changes in the runtime and the code generation may be able to do something different
  13. * (more optimal) for a later runtime.
  14. *
  15. * @author Andy Clement
  16. */
  17. public enum RuntimeVersion {
  18. V1_2("1.2"), V1_5("1.5"), V1_6_10("1.6.10"), V1_9("1.9");
  19. private String[] aliases = null;
  20. RuntimeVersion(String... aliases) {
  21. this.aliases = aliases;
  22. }
  23. public static RuntimeVersion getVersionFor(String version) {
  24. for (RuntimeVersion candidateVersion: values()) {
  25. if (candidateVersion.name().equals(version)) {
  26. return candidateVersion;
  27. }
  28. if (candidateVersion.aliases != null) {
  29. for (String alias: candidateVersion.aliases) {
  30. if (alias.equals(version)) {
  31. return candidateVersion;
  32. }
  33. }
  34. }
  35. }
  36. return null;
  37. }
  38. public boolean isThisVersionOrLater(RuntimeVersion version) {
  39. return this.compareTo(version) >= 0;
  40. }
  41. }