/** * Determines which all matchers are affected by this property change * * @param name modified property name */ private void checkAggregates(String name) { for (Matcher m : matcherState.matched) { if (!matcherState.affectedMatchers.contains(m) && m.aggregatesProperty(name)) { matcherState.affectedMatchers.add(m); } } }
private MatcherState getMatcherState(String name, NodeState after) { List<Matcher> matched = Lists.newArrayList(); List<Matcher> inherited = Lists.newArrayList(); for (Matcher m : Iterables.concat(matcherState.inherited, currentMatchers)) { Matcher result = m.match(name, after); if (result.getStatus() == Matcher.Status.MATCH_FOUND){ matched.add(result); } if (result.getStatus() != Matcher.Status.FAIL){ inherited.addAll(result.nextSet()); } } if (!matched.isEmpty() || !inherited.isEmpty()) { return new MatcherState(matched, inherited); } return MatcherState.NONE; }
public Collection<Matcher> nextSet() { checkArgument(status != Status.FAIL); if (status == Status.MATCH_FOUND){ Aggregate nextAgg = currentInclude.getAggregate(matchedNodeState); if (nextAgg != null){ int recursionLevel = aggregateStack.size() + 1; if (recursionLevel >= rootState.rootAggregate.reAggregationLimit){ return Collections.emptyList(); } List<Matcher> result = Lists.newArrayListWithCapacity(nextAgg.includes.size()); for (Include i : nextAgg.includes){ result.add(new Matcher(this, i, currentPath)); } return result; } return Collections.emptyList(); } return Collections.singleton(new Matcher(this, status, depth + 1, null, currentPath)); }
private void propertyUpdated(PropertyState before, PropertyState after) { PropertyUpdateCallback callback = context.getPropertyUpdateCallback(); //Avoid further work if no callback is present if (callback == null) { return; } String propertyName = before != null ? before.getName() : after.getName(); if (isIndexable()) { PropertyDefinition pd = indexingRule.getConfig(propertyName); if (pd != null) { callback.propertyUpdated(getPath(), propertyName, pd, before, after); } } for (Matcher m : matcherState.matched) { if (m.aggregatesProperty(propertyName)) { Aggregate.Include i = m.getCurrentInclude(); if (i instanceof Aggregate.PropertyInclude) { PropertyDefinition pd = ((Aggregate.PropertyInclude) i).getPropertyDefinition(); String propertyRelativePath = PathUtils.concat(m.getMatchedPath(), propertyName); callback.propertyUpdated(m.getRootPath(), propertyRelativePath, pd, before, after); } } } }
private void propertyUpdated(PropertyState before, PropertyState after) { PropertyUpdateCallback callback = context.getPropertyUpdateCallback(); //Avoid further work if no callback is present if (callback == null) { return; } String propertyName = before != null ? before.getName() : after.getName(); if (isIndexable()) { PropertyDefinition pd = indexingRule.getConfig(propertyName); if (pd != null) { callback.propertyUpdated(getPath(), propertyName, pd, before, after); } } for (Matcher m : matcherState.matched) { if (m.aggregatesProperty(propertyName)) { Aggregate.Include i = m.getCurrentInclude(); if (i instanceof Aggregate.PropertyInclude) { PropertyDefinition pd = ((Aggregate.PropertyInclude) i).getPropertyDefinition(); String propertyRelativePath = PathUtils.concat(m.getMatchedPath(), propertyName); callback.propertyUpdated(m.getRootPath(), propertyRelativePath, pd, before, after); } } } }
private void propertyUpdated(PropertyState before, PropertyState after) { PropertyUpdateCallback callback = context.getPropertyUpdateCallback(); //Avoid further work if no callback is present if (callback == null) { return; } String propertyName = before != null ? before.getName() : after.getName(); if (isIndexable()) { PropertyDefinition pd = indexingRule.getConfig(propertyName); if (pd != null) { callback.propertyUpdated(getPath(), propertyName, pd, before, after); } } for (Aggregate.Matcher m : matcherState.matched) { if (m.aggregatesProperty(propertyName)) { Aggregate.Include i = m.getCurrentInclude(); if (i instanceof Aggregate.PropertyInclude) { PropertyDefinition pd = ((Aggregate.PropertyInclude) i).getPropertyDefinition(); String propertyRelativePath = PathUtils.concat(m.getMatchedPath(), propertyName); callback.propertyUpdated(m.getRootPath(), propertyRelativePath, pd, before, after); } } } }
private static void matchChildren(List<Matcher> matchers, ResultCollector collector, Iterable<? extends ChildNodeEntry> children) { for (ChildNodeEntry cne : children) { List<Matcher> nextSet = newArrayListWithCapacity(matchers.size()); for (Matcher m : matchers) { Matcher result = m.match(cne.getName(), cne.getNodeState()); if (result.getStatus() == Matcher.Status.MATCH_FOUND){ result.collectResults(collector); } if (result.getStatus() != Matcher.Status.FAIL){ nextSet.addAll(result.nextSet()); } } if (!nextSet.isEmpty()) { collectAggregates(cne.getNodeState(), nextSet, collector); } } }
private MatcherState getMatcherState(String name, NodeState after) { List<Aggregate.Matcher> matched = Lists.newArrayList(); List<Aggregate.Matcher> inherited = Lists.newArrayList(); for (Aggregate.Matcher m : Iterables.concat(matcherState.inherited, currentMatchers)) { Aggregate.Matcher result = m.match(name, after); if (result.getStatus() == Aggregate.Matcher.Status.MATCH_FOUND){ matched.add(result); } if (result.getStatus() != Aggregate.Matcher.Status.FAIL){ inherited.addAll(result.nextSet()); } } if (!matched.isEmpty() || !inherited.isEmpty()) { return new MatcherState(matched, inherited); } return MatcherState.NONE; }
private MatcherState getMatcherState(String name, NodeState after) { List<Matcher> matched = Lists.newArrayList(); List<Matcher> inherited = Lists.newArrayList(); for (Matcher m : Iterables.concat(matcherState.inherited, currentMatchers)) { Matcher result = m.match(name, after); if (result.getStatus() == Matcher.Status.MATCH_FOUND){ matched.add(result); } if (result.getStatus() != Matcher.Status.FAIL){ inherited.addAll(result.nextSet()); } } if (!matched.isEmpty() || !inherited.isEmpty()) { return new MatcherState(matched, inherited); } return MatcherState.NONE; }
/** * Determines which all matchers are affected by this property change * * @param name modified property name */ private void checkAggregates(String name) { for (Matcher m : matcherState.matched) { if (!matcherState.affectedMatchers.contains(m) && m.aggregatesProperty(name)) { matcherState.affectedMatchers.add(m); } } }
public Matcher match(String name, NodeState nodeState) { boolean result = currentInclude.match(name, nodeState, depth); if (result){ if (hasMore()){ return new Matcher(this, Status.CONTINUE, depth, nodeState, path(name)); } else { return new Matcher(this, Status.MATCH_FOUND, depth, nodeState, path(name)); } } else { return new Matcher(this, Status.FAIL, depth); } }
public List<Matcher> createMatchers(AggregateRoot root){ List<Matcher> matchers = newArrayListWithCapacity(includes.size()); for (Include include : includes) { matchers.add(new Matcher(this, include, root)); } return matchers; }
private void checkAggregates(String name) { for (Aggregate.Matcher m : matcherState.matched) { if (!matcherState.affectedMatchers.contains(m) && m.aggregatesProperty(name)) { matcherState.affectedMatchers.add(m); } } }
private List<Matcher> createMatchers() { List<Matcher> matchers = newArrayListWithCapacity(includes.size()); for (Include include : includes) { matchers.add(new Matcher(this, include)); } return matchers; }