public static CacheScope create(String id) {
    Preconditions.checkArgument(id != null && id.length() > 0,
        "scope id can not be null or empty string");
    if (GLOBAL_ID.equals(id)) {
      return GLOBAL;
    } else if (Level.SCHEMA.matches(id)) {
      return new CacheScope(id, id.length(), Level.SCHEMA);
    } else if (Level.TABLE.matches(id)) {
      return new CacheScope(id, id.length(), Level.TABLE);
    } else if (Level.PARTITION.matches(id)) {
      return new CacheScope(id, id.length(), Level.PARTITION);
    }
    throw new IllegalArgumentException("Failed to parse cache scope: " + id);
  }
@Test
  public void scopeEquals() {
    assertEquals(CacheScope.GLOBAL, CacheScope.create("."));
    assertEquals(CacheScope.create("."), CacheScope.create("."));
    assertEquals(CacheScope.create("schema"), CacheScope.create("schema"));
    assertEquals(CacheScope.create("schema.table"), CacheScope.create("schema.table"));
    assertEquals(CacheScope.create("schema.table.partition"),
        CacheScope.create("schema.table.partition"));
    assertNotEquals(CacheScope.create("schema1"), CacheScope.create("schema2"));
    assertNotEquals(CacheScope.create("schema.table1"), CacheScope.create("schema.table2"));
    assertNotEquals(CacheScope.create("schema.Atable"), CacheScope.create("schema.Btable"));
    assertNotEquals(CacheScope.create("schema.table"), CacheScope.create("schema.table.partition"));
    assertNotEquals(CacheScope.create("schema.table.partition1"),
        CacheScope.create("schema.table.partition2"));
  }