Extracted generator of ranges into GenerateRanges class.
This commit is contained in:
@@ -14,20 +14,13 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
|
||||
package jet.runtime;
|
||||
|
||||
import jet.*;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* @author alex.tkachman
|
||||
*/
|
||||
/* This file is generated by org.jetbrains.jet.generators.GenerateRanges. DO NOT EDIT! */
|
||||
public class Ranges {
|
||||
private Ranges() {
|
||||
}
|
||||
|
||||
public static ByteRange rangeTo(byte from, byte to) {
|
||||
if (from > to) {
|
||||
return ByteRange.EMPTY;
|
||||
@@ -349,49 +342,5 @@ public class Ranges {
|
||||
}
|
||||
}
|
||||
|
||||
public static void main(String[] args) {
|
||||
List<String> strings = Arrays.asList("byte", "short", "int", "long", "float", "double", "char");
|
||||
for (String t1 : strings) {
|
||||
for (String t2 : strings) {
|
||||
String resType;
|
||||
if (t1.equals("double") || t2.equals("double")) {
|
||||
resType = "DoubleRange";
|
||||
}
|
||||
else if (t1.equals("float") || t2.equals("float")) {
|
||||
resType = "FloatRange";
|
||||
}
|
||||
else if (t1.equals("long") || t2.equals("long")) {
|
||||
resType = "LongRange";
|
||||
}
|
||||
else if (t1.equals("int") || t2.equals("int")) {
|
||||
resType = "IntRange";
|
||||
}
|
||||
else if (t1.equals("short") || t2.equals("short")) {
|
||||
resType = "ShortRange";
|
||||
}
|
||||
else if (t1.equals("char") || t2.equals("char")) {
|
||||
resType = "CharRange";
|
||||
}
|
||||
else {
|
||||
resType = "ByteRange";
|
||||
}
|
||||
|
||||
if (resType.equals("FloatRange") || resType.equals("DoubleRange")) {
|
||||
System.out.println("\npublic static " + resType + " rangeTo(" + t1 + " from, " + t2 + " to) {\n" +
|
||||
" return new " + resType + "(from, to - from);\n" +
|
||||
"}");
|
||||
}
|
||||
else {
|
||||
System.out.println("\npublic static " + resType + " rangeTo(" + t1 + " from, " + t2 + " to) {" +
|
||||
"\n if (from > to) {\n" +
|
||||
" return " + resType + ".EMPTY;\n" +
|
||||
" }\n" +
|
||||
" else {\n" +
|
||||
" return new " + resType + "(from, to - from + 1);\n" +
|
||||
" }\n" +
|
||||
"}");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
private Ranges() {}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user