当前位置: 首页>>代码示例>>Java>>正文


Java Matcher类代码示例

本文整理汇总了Java中org.terracotta.context.query.Matcher的典型用法代码示例。如果您正苦于以下问题:Java Matcher类的具体用法?Java Matcher怎么用?Java Matcher使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。


Matcher类属于org.terracotta.context.query包,在下文中一共展示了Matcher类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: findOperationStat

import org.terracotta.context.query.Matcher; //导入依赖的package包/类
public static OperationStatistic findOperationStat(Cache<?, ?> cache1, final String statName, final String tag) {
  Query q = queryBuilder()
      .descendants().filter(context(identifier(subclassOf(OperationStatistic.class)))).build();

  Set<TreeNode> operationStatisticNodes = q.execute(Collections.singleton(ContextManager.nodeFor(cache1)));
  Set<TreeNode> result = queryBuilder()
      .filter(
          context(attributes(Matchers.<Map<String, Object>>allOf(
              hasAttribute("name", statName), hasAttribute("tags", new Matcher<Set<String>>() {
                @Override
                protected boolean matchesSafely(Set<String> object) {
                  return object.contains(tag);
                }
              }))))).build().execute(operationStatisticNodes);

  if (result.size() != 1) {
    throw new RuntimeException("single stat not found; found " + result.size());
  }

  TreeNode node = result.iterator().next();
  return (OperationStatistic) node.getContext().attributes().get("this");
}
 
开发者ID:ehcache,项目名称:ehcache3-samples,代码行数:23,代码来源:Ehcache3Stats.java

示例2: findValueStat

import org.terracotta.context.query.Matcher; //导入依赖的package包/类
public static ValueStatistic findValueStat(Cache<?, ?> cache1, final String statName, final String tag) {
  Query q = queryBuilder().chain(self())
      .descendants().filter(context(identifier(subclassOf(ValueStatistic.class)))).build();

  Set<TreeNode> nodes = q.execute(Collections.singleton(ContextManager.nodeFor(cache1)));
  Set<TreeNode> result = queryBuilder()
      .filter(
          context(attributes(Matchers.<Map<String, Object>>allOf(
              hasAttribute("name", statName), hasAttribute("tags", new Matcher<Set<String>>() {
                @Override
                protected boolean matchesSafely(Set<String> object) {
                  return object.contains(tag);
                }
              }))))).build().execute(nodes);

  if (result.size() != 1) {
    throw new RuntimeException("single stat not found; found " + result.size());
  }

  TreeNode node = result.iterator().next();
  return (ValueStatistic) node.getContext().attributes().get("this");
}
 
开发者ID:ehcache,项目名称:ehcache3-samples,代码行数:23,代码来源:Ehcache3Stats.java

示例3: findOperationStat

import org.terracotta.context.query.Matcher; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static <S extends Enum<S>> OperationStatistic<S> findOperationStat(Object rootNode, final Class<S> statisticType, final String statName) {
  Query q = queryBuilder().descendants()
      .filter(context(identifier(subclassOf(OperationStatistic.class))))
      .filter(context(attributes(Matchers.allOf(
          hasAttribute("name", statName),
          hasAttribute("this", new Matcher<OperationStatistic>() {
            @Override
            protected boolean matchesSafely(OperationStatistic object) {
              return object.type().equals(statisticType);
            }
          })
      )))).build();


  Set<TreeNode> result = q.execute(Collections.singleton(ContextManager.nodeFor(rootNode)));

  if (result.size() != 1) {
    throw new RuntimeException("a single stat was expected; found " + result.size());
  }

  TreeNode node = result.iterator().next();
  return (OperationStatistic<S>) node.getContext().attributes().get("this");
}
 
开发者ID:Terracotta-OSS,项目名称:statistics,代码行数:25,代码来源:MappedOperationStatistic.java

示例4: findStat

import org.terracotta.context.query.Matcher; //导入依赖的package包/类
@SuppressWarnings("unchecked")
private static <T extends Enum<T>> OperationStatistic<T> findStat(Cache<?, ?> cache, final String statName, final String tag) {
  Query q = queryBuilder().chain(self())
      .descendants().filter(context(identifier(subclassOf(OperationStatistic.class)))).build();

  Set<TreeNode> operationStatisticNodes = q.execute(Collections.singleton(ContextManager.nodeFor(cache)));
  Set<TreeNode> result = queryBuilder()
      .filter(
          context(attributes(Matchers.<Map<String, Object>>allOf(
              hasAttribute("name", statName), hasAttribute("tags", new Matcher<Set<String>>() {
                @Override
                protected boolean matchesSafely(Set<String> object) {
                  return object.contains(tag);
                }
              }))))).build().execute(operationStatisticNodes);

  if (result.size() != 1) {
    throw new RuntimeException("query for unique stat '" + statName + "' with tag '" + tag + "' failed; found " + result.size() + " instance(s)");
  }

  TreeNode node = result.iterator().next();
  return (OperationStatistic<T>) node.getContext().attributes().get("this");
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:24,代码来源:StoreStatisticsTest.java

示例5: hasTags

import org.terracotta.context.query.Matcher; //导入依赖的package包/类
private Matcher<Map<String, Object>> hasTags(final Collection<String> tags) {
  return hasAttribute("tags", new Matcher<Collection<String>>() {
    @Override
    protected boolean matchesSafely(Collection<String> object) {
      return object.containsAll(tags);
    }
  });
}
 
开发者ID:Terracotta-OSS,项目名称:statistics,代码行数:9,代码来源:StatisticRegistry.java

示例6: hasTag

import org.terracotta.context.query.Matcher; //导入依赖的package包/类
static Matcher<Map<String, Object>> hasTag(final String tag) {
  return hasAttribute("tags", new Matcher<Set<String>>() {
    @Override
    protected boolean matchesSafely(Set<String> object) {
      return object.contains(tag);
    }
  });
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:9,代码来源:StatsUtils.java

示例7: hasProperty

import org.terracotta.context.query.Matcher; //导入依赖的package包/类
static Matcher<Map<String, Object>> hasProperty(final String key, final String value) {
  return hasAttribute("properties", new Matcher<Map<String, Object>>() {
    @Override
    protected boolean matchesSafely(Map<String, Object> properties) {
      Object val = properties.get(key);
      return val != null && value.equals(val);
    }
  });
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:10,代码来源:StatsUtils.java

示例8: testStatisticsAssociations

import org.terracotta.context.query.Matcher; //导入依赖的package包/类
@Test
public void testStatisticsAssociations() throws Exception {
  OffHeapDiskStore.Provider provider = new OffHeapDiskStore.Provider();

 ServiceLocator serviceLocator = dependencySet().with(mock(SerializationProvider.class))
   .with(new DefaultTimeSourceService(null)).with(mock(DiskResourceService.class)).build();
 provider.start(serviceLocator);

 OffHeapDiskStore<Long, String> store = provider.createStore(getStoreConfig(), mock(PersistableResourceService.PersistenceSpaceIdentifier.class));

 @SuppressWarnings("unchecked")
 Query storeQuery = queryBuilder()
   .children()
   .filter(context(attributes(Matchers.<Map<String, Object>>allOf(
     hasAttribute("tags", new Matcher<Set<String>>() {
       @Override
       protected boolean matchesSafely(Set<String> object) {
         return object.containsAll(singleton("Disk"));
       }
     })))))
   .build();

  Set<TreeNode> nodes = singleton(ContextManager.nodeFor(store));

  Set<TreeNode> storeResult = storeQuery.execute(nodes);
  assertThat(storeResult, not(empty()));

  provider.releaseStore(store);

  storeResult = storeQuery.execute(nodes);
  assertThat(storeResult, empty());
}
 
开发者ID:ehcache,项目名称:ehcache3,代码行数:33,代码来源:OffHeapDiskStoreProviderTest.java


注:本文中的org.terracotta.context.query.Matcher类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。