@Test public void testInit() { { TypeDef t = defineType("DECIMAL(19,4)"); Assert.assertEquals(19, t.getDefaultPrecision()); Assert.assertEquals(4, t.getDefaultScale()); Assert.assertEquals("DECIMAL(19,4)", t.buildString(30, 2)); Assert.assertEquals("DECIMAL", t.getName()); Assert.assertEquals(t.getId(), t.getId().toUpperCase(Locale.ROOT)); } { TypeDef t = defineType("DECIMAL($p,$s)"); Assert.assertEquals(-1, t.getDefaultPrecision()); Assert.assertEquals(-1, t.getDefaultScale()); Assert.assertEquals("DECIMAL(19,4)", t.buildString(19, 4)); Assert.assertEquals("DECIMAL", t.getName()); Assert.assertEquals(t.getId(), t.getId().toUpperCase(Locale.ROOT)); } }
void init() { id = id.toUpperCase(Locale.ROOT); Matcher m = P.matcher(expression); if (m.matches()) { name = m.group(1).toUpperCase(Locale.ROOT); Integer p = m.group(2) != null ? Ints.tryParse(m.group(2)) : null; Integer s = m.group(3) != null ? Ints.tryParse(m.group(3)) : null; defaultPrecision = p != null ? p : -1; defaultScale = s != null ? s : -1; } }
TypeDef { void init() { id = id.toUpperCase(Locale.ROOT); Matcher m = P.matcher(expression); if (m.matches()) { name = m.group(1).toUpperCase(Locale.ROOT); Integer p = m.group(2) != null ? Ints.tryParse(m.group(2)) : null; Integer s = m.group(3) != null ? Ints.tryParse(m.group(3)) : null; defaultPrecision = p != null ? p : -1; defaultScale = s != null ? s : -1; } } }
TypeDef { void init() { id = id.toUpperCase(Locale.ROOT); Matcher m = P.matcher(expression); if (m.matches()) { name = m.group(1).toUpperCase(Locale.ROOT); Integer p = m.group(2) != null ? Ints.tryParse(m.group(2)) : null; Integer s = m.group(3) != null ? Ints.tryParse(m.group(3)) : null; defaultPrecision = p != null ? p : -1; defaultScale = s != null ? s : -1; } } TypeDef(); }
TypeDef { void init() { id = id.toUpperCase(Locale.ROOT); Matcher m = P.matcher(expression); if (m.matches()) { name = m.group(1).toUpperCase(Locale.ROOT); Integer p = m.group(2) != null ? Ints.tryParse(m.group(2)) : null; Integer s = m.group(3) != null ? Ints.tryParse(m.group(3)) : null; defaultPrecision = p != null ? p : -1; defaultScale = s != null ? s : -1; } } TypeDef(); String getId(); String getExpression(); int getMaxPrecision(); String getName(); int getDefaultPrecision(); int getDefaultScale(); String buildString(int p, int s); static TypeDef fromString(String kylinTypeName); }
TypeDef { void init() { id = id.toUpperCase(Locale.ROOT); Matcher m = P.matcher(expression); if (m.matches()) { name = m.group(1).toUpperCase(Locale.ROOT); Integer p = m.group(2) != null ? Ints.tryParse(m.group(2)) : null; Integer s = m.group(3) != null ? Ints.tryParse(m.group(3)) : null; defaultPrecision = p != null ? p : -1; defaultScale = s != null ? s : -1; } } TypeDef(); String getId(); String getExpression(); int getMaxPrecision(); String getName(); int getDefaultPrecision(); int getDefaultScale(); String buildString(int p, int s); static TypeDef fromString(String kylinTypeName);  }