All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.javaclub.cdl.client.matrix.rule.SuffixParse Maven / Gradle / Ivy

There is a newer version: 2.3.9
Show newest version
package com.github.javaclub.cdl.client.matrix.rule;

public class SuffixParse {
	public static String getTableSuffix(int tableNum, int indexBits) {
		if (indexBits == 1) {
			return String.valueOf(tableNum);
		} else if (indexBits == 2) {
			if (tableNum < 10) {
				return "0" + tableNum;
			} else {
				return String.valueOf(tableNum);
			}
		} else if (indexBits == 3) {
			if (tableNum < 10) {
				return "00" + tableNum;
			} else if (tableNum > 10 && tableNum < 100) {
				return "0" + tableNum;
			} else {
				return String.valueOf(tableNum);
			}
		} else if (indexBits == 4) {
			if (tableNum < 10) {
				return "000" + tableNum;
			} else if (tableNum > 10 && tableNum < 100) {
				return "00" + tableNum;
			} else if (tableNum > 100 && tableNum < 1000) {
				return "0" + tableNum;
			} else {
				return String.valueOf(tableNum);
			}
		}
		throw new RuntimeException("too many sharding table");
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy