org.apache.calcite.util.Util.enumVal()方法的使用及代码示例

x33g5p2x  于2022-02-01 转载在 其他  
字(6.6k)|赞(0)|评价(0)|浏览(109)

本文整理了Java中org.apache.calcite.util.Util.enumVal()方法的一些代码示例,展示了Util.enumVal()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Util.enumVal()方法的具体详情如下:
包路径:org.apache.calcite.util.Util
类名称:Util
方法名:enumVal

Util.enumVal介绍

[英]Returns the value of an enumeration with a particular name.

Similar to Enum#valueOf(Class,String), but returns null rather than throwing IllegalArgumentException.
[中]返回具有特定名称的枚举的值。
与Enum#valueOf(Class,String)类似,但返回null而不是抛出IllegalArgumentException。

代码示例

代码示例来源:origin: Qihoo360/Quicksql

public RelFieldCollation toFieldCollation(Map<String, Object> map) {
 final Integer field = (Integer) map.get("field");
 final RelFieldCollation.Direction direction =
   Util.enumVal(RelFieldCollation.Direction.class,
     (String) map.get("direction"));
 final RelFieldCollation.NullDirection nullDirection =
   Util.enumVal(RelFieldCollation.NullDirection.class,
     (String) map.get("nulls"));
 return new RelFieldCollation(field, direction, nullDirection);
}

代码示例来源:origin: org.apache.calcite/calcite-core

public RelFieldCollation toFieldCollation(Map<String, Object> map) {
 final Integer field = (Integer) map.get("field");
 final RelFieldCollation.Direction direction =
   Util.enumVal(RelFieldCollation.Direction.class,
     (String) map.get("direction"));
 final RelFieldCollation.NullDirection nullDirection =
   Util.enumVal(RelFieldCollation.NullDirection.class,
     (String) map.get("nulls"));
 return new RelFieldCollation(field, direction, nullDirection);
}

代码示例来源:origin: Qihoo360/Quicksql

public <E extends Enum<E>> E getEnum(String tag, Class<E> enumClass) {
 return Util.enumVal(enumClass,
   getString(tag).toUpperCase(Locale.ROOT));
}

代码示例来源:origin: org.apache.calcite/calcite-core

public <E extends Enum<E>> E getEnum(String tag, Class<E> enumClass) {
 return Util.enumVal(enumClass,
   getString(tag).toUpperCase(Locale.ROOT));
}

代码示例来源:origin: Qihoo360/Quicksql

: tableTypeName.toUpperCase(Locale.ROOT).replace(' ', '_');
final TableType tableType =
  Util.enumVal(TableType.OTHER, tableTypeName2);
if (tableType == TableType.OTHER  && tableTypeName2 != null) {
 System.out.println("Unknown table type: " + tableTypeName2);

代码示例来源:origin: org.apache.calcite/calcite-core

: tableTypeName.toUpperCase(Locale.ROOT).replace(' ', '_');
final TableType tableType =
  Util.enumVal(TableType.OTHER, tableTypeName2);
if (tableType == TableType.OTHER  && tableTypeName2 != null) {
 System.out.println("Unknown table type: " + tableTypeName2);

代码示例来源:origin: Qihoo360/Quicksql

public RelDataType toType(RelDataTypeFactory typeFactory, Object o) {
 if (o instanceof List) {
  @SuppressWarnings("unchecked")
  final List<Map<String, Object>> jsonList = (List<Map<String, Object>>) o;
  final RelDataTypeFactory.Builder builder = typeFactory.builder();
  for (Map<String, Object> jsonMap : jsonList) {
   builder.add((String) jsonMap.get("name"), toType(typeFactory, jsonMap));
  }
  return builder.build();
 } else {
  final Map<String, Object> map = (Map<String, Object>) o;
  final SqlTypeName sqlTypeName =
    Util.enumVal(SqlTypeName.class, (String) map.get("type"));
  final Integer precision = (Integer) map.get("precision");
  final Integer scale = (Integer) map.get("scale");
  final RelDataType type;
  if (precision == null) {
   type = typeFactory.createSqlType(sqlTypeName);
  } else if (scale == null) {
   type = typeFactory.createSqlType(sqlTypeName, precision);
  } else {
   type = typeFactory.createSqlType(sqlTypeName, precision, scale);
  }
  final boolean nullable = (Boolean) map.get("nullable");
  return typeFactory.createTypeWithNullability(type, nullable);
 }
}

代码示例来源:origin: org.apache.calcite/calcite-core

public RelDataType toType(RelDataTypeFactory typeFactory, Object o) {
 if (o instanceof List) {
  @SuppressWarnings("unchecked")
  final List<Map<String, Object>> jsonList = (List<Map<String, Object>>) o;
  final RelDataTypeFactory.Builder builder = typeFactory.builder();
  for (Map<String, Object> jsonMap : jsonList) {
   builder.add((String) jsonMap.get("name"), toType(typeFactory, jsonMap));
  }
  return builder.build();
 } else {
  final Map<String, Object> map = (Map<String, Object>) o;
  final SqlTypeName sqlTypeName =
    Util.enumVal(SqlTypeName.class, (String) map.get("type"));
  final Integer precision = (Integer) map.get("precision");
  final Integer scale = (Integer) map.get("scale");
  final RelDataType type;
  if (precision == null) {
   type = typeFactory.createSqlType(sqlTypeName);
  } else if (scale == null) {
   type = typeFactory.createSqlType(sqlTypeName, precision);
  } else {
   type = typeFactory.createSqlType(sqlTypeName, precision, scale);
  }
  final boolean nullable = (Boolean) map.get("nullable");
  return typeFactory.createTypeWithNullability(type, nullable);
 }
}

代码示例来源:origin: Qihoo360/Quicksql

final Object literal = map.get("literal");
final SqlTypeName sqlTypeName =
  Util.enumVal(SqlTypeName.class, (String) map.get("type"));
if (literal == null) {
 return rexBuilder.makeNullLiteral(

代码示例来源:origin: org.apache.calcite/calcite-core

final Object literal = map.get("literal");
final SqlTypeName sqlTypeName =
  Util.enumVal(SqlTypeName.class, (String) map.get("type"));
if (literal == null) {
 return rexBuilder.makeNullLiteral(

代码示例来源:origin: Qihoo360/Quicksql

/**
 * Tests the methods {@link Util#enumConstants(Class)} and
 * {@link Util#enumVal(Class, String)}.
 */
@Test public void testEnumConstants() {
 final Map<String, MemoryType> memoryTypeMap =
   Util.enumConstants(MemoryType.class);
 assertEquals(2, memoryTypeMap.size());
 assertEquals(MemoryType.HEAP, memoryTypeMap.get("HEAP"));
 assertEquals(MemoryType.NON_HEAP, memoryTypeMap.get("NON_HEAP"));
 try {
  memoryTypeMap.put("FOO", null);
  fail("expected exception");
 } catch (UnsupportedOperationException e) {
  // expected: map is immutable
 }
 assertEquals("HEAP", Util.enumVal(MemoryType.class, "HEAP").name());
 assertNull(Util.enumVal(MemoryType.class, "heap"));
 assertNull(Util.enumVal(MemoryType.class, "nonexistent"));
}

代码示例来源:origin: org.apache.calcite/calcite-core

/**
 * Tests the methods {@link Util#enumConstants(Class)} and
 * {@link Util#enumVal(Class, String)}.
 */
@Test public void testEnumConstants() {
 final Map<String, MemoryType> memoryTypeMap =
   Util.enumConstants(MemoryType.class);
 assertEquals(2, memoryTypeMap.size());
 assertEquals(MemoryType.HEAP, memoryTypeMap.get("HEAP"));
 assertEquals(MemoryType.NON_HEAP, memoryTypeMap.get("NON_HEAP"));
 try {
  memoryTypeMap.put("FOO", null);
  fail("expected exception");
 } catch (UnsupportedOperationException e) {
  // expected: map is immutable
 }
 assertEquals("HEAP", Util.enumVal(MemoryType.class, "HEAP").name());
 assertNull(Util.enumVal(MemoryType.class, "heap"));
 assertNull(Util.enumVal(MemoryType.class, "nonexistent"));
}

相关文章