|
| 1 | +package org.jruby; |
| 2 | + |
| 3 | +/** |
| 4 | + * Removed from JRuby Core as of 10.0; but deprecated and unused for a long time. |
| 5 | + * <p/> |
| 6 | + * Added back to jruby-rack 1.2.x to allow JRuby 10 support without an API changed, but |
| 7 | + * will be removed in jruby-rack 1.3.0 |
| 8 | + * <p/> |
| 9 | + * @link https://github.com/jruby/jruby/blob/jruby-9.3/core/src/main/java/org/jruby/CompatVersion.java |
| 10 | + * @deprecated since JRuby 9.2 with no replacement; for removal with jruby-rack 1.3.0 |
| 11 | + */ |
| 12 | +@Deprecated |
| 13 | +public enum CompatVersion { |
| 14 | + |
| 15 | + @Deprecated RUBY1_8, |
| 16 | + @Deprecated RUBY1_9, |
| 17 | + @Deprecated RUBY2_0, |
| 18 | + @Deprecated RUBY2_1, |
| 19 | + @Deprecated BOTH; |
| 20 | + |
| 21 | + @Deprecated |
| 22 | + public boolean is1_9() { |
| 23 | + return this == RUBY1_9 || this == RUBY2_0 || this == RUBY2_1; |
| 24 | + } |
| 25 | + |
| 26 | + @Deprecated |
| 27 | + public boolean is2_0() { |
| 28 | + return this == RUBY2_0 || this == RUBY2_1; |
| 29 | + } |
| 30 | + |
| 31 | + @Deprecated |
| 32 | + public static CompatVersion getVersionFromString(String compatString) { |
| 33 | + if (compatString.equalsIgnoreCase("RUBY1_8")) { |
| 34 | + return CompatVersion.RUBY1_8; |
| 35 | + } else if (compatString.equalsIgnoreCase("1.8")) { |
| 36 | + return CompatVersion.RUBY1_8; |
| 37 | + } else if (compatString.equalsIgnoreCase("RUBY1_9")) { |
| 38 | + return CompatVersion.RUBY1_9; |
| 39 | + } else if (compatString.equalsIgnoreCase("1.9")) { |
| 40 | + return CompatVersion.RUBY1_9; |
| 41 | + } else if (compatString.equalsIgnoreCase("RUBY2_0")) { |
| 42 | + return CompatVersion.RUBY2_0; |
| 43 | + } else if (compatString.equalsIgnoreCase("2.0")) { |
| 44 | + return CompatVersion.RUBY2_0; |
| 45 | + } else if (compatString.equalsIgnoreCase("RUBY2_1")) { |
| 46 | + return CompatVersion.RUBY2_1; |
| 47 | + } else if (compatString.equalsIgnoreCase("2.1")) { |
| 48 | + return CompatVersion.RUBY2_1; |
| 49 | + } else { |
| 50 | + return null; |
| 51 | + } |
| 52 | + } |
| 53 | + |
| 54 | + @Deprecated |
| 55 | + public static boolean shouldBindMethod(CompatVersion runtimeVersion, CompatVersion methodVersion) { |
| 56 | + if (runtimeVersion == RUBY1_8) return methodVersion == RUBY1_8 || methodVersion == BOTH; |
| 57 | + if (runtimeVersion == RUBY1_9) return methodVersion == RUBY1_9 || methodVersion == BOTH; |
| 58 | + if (runtimeVersion == RUBY2_0) return methodVersion == RUBY1_9 || methodVersion == RUBY2_0 || methodVersion == BOTH; |
| 59 | + if (runtimeVersion == RUBY2_1) return methodVersion == RUBY1_9 || methodVersion == RUBY2_0 || methodVersion == RUBY2_1 || methodVersion == BOTH; |
| 60 | + return false; |
| 61 | + } |
| 62 | +} |
0 commit comments