@Test( dataProvider = "getStarPatternTests") public void starPatternTest( String testName, String spec, String dataKey, String expected1, String expected2 ) { StarPathElement star = new StarRegexPathElement( spec ); MatchedElement lpe = star.match( dataKey, null ); Assert.assertEquals( 3, lpe.getSubKeyCount() ); Assert.assertEquals( dataKey, lpe.getSubKeyRef( 0 ) ); Assert.assertEquals( expected1, lpe.getSubKeyRef( 1 ) ); Assert.assertEquals( expected2, lpe.getSubKeyRef( 2 ) ); }
@Override public MatchedElement match( String dataKey, WalkedPath walkedPath ) { Matcher matcher = pattern.matcher( dataKey ); if ( ! matcher.find() ) { return null; } int groupCount = matcher.groupCount(); List<String> subKeys = new ArrayList<>(groupCount); for ( int index = 1; index <= groupCount; index++) { subKeys.add( matcher.group( index ) ); } return new MatchedElement(dataKey, subKeys); }
StarRegexPathElement extends BasePathElement implements StarPathElement { @Override public MatchedElement match( String dataKey, WalkedPath walkedPath ) { Matcher matcher = pattern.matcher( dataKey ); if ( ! matcher.find() ) { return null; } int groupCount = matcher.groupCount(); List<String> subKeys = new ArrayList<>(groupCount); for ( int index = 1; index <= groupCount; index++) { subKeys.add( matcher.group( index ) ); } return new MatchedElement(dataKey, subKeys); } }
StarRegexPathElement extends BasePathElement implements StarPathElement { @Override public MatchedElement match( String dataKey, WalkedPath walkedPath ) { Matcher matcher = pattern.matcher( dataKey ); if ( ! matcher.find() ) { return null; } int groupCount = matcher.groupCount(); List<String> subKeys = new ArrayList<>(groupCount); for ( int index = 1; index <= groupCount; index++) { subKeys.add( matcher.group( index ) ); } return new MatchedElement(dataKey, subKeys); } StarRegexPathElement( String key ); }
StarRegexPathElement extends BasePathElement implements StarPathElement { @Override public MatchedElement match( String dataKey, WalkedPath walkedPath ) { Matcher matcher = pattern.matcher( dataKey ); if ( ! matcher.find() ) { return null; } int groupCount = matcher.groupCount(); List<String> subKeys = new ArrayList<>(groupCount); for ( int index = 1; index <= groupCount; index++) { subKeys.add( matcher.group( index ) ); } return new MatchedElement(dataKey, subKeys); } StarRegexPathElement( String key ); @Override boolean stringMatch( String literal ); @Override MatchedElement match( String dataKey, WalkedPath walkedPath ); @Override String getCanonicalForm(); }
StarRegexPathElement extends BasePathElement implements StarPathElement { @Override public MatchedElement match( String dataKey, WalkedPath walkedPath ) { Matcher matcher = pattern.matcher( dataKey ); if ( ! matcher.find() ) { return null; } int groupCount = matcher.groupCount(); List<String> subKeys = new ArrayList<>(groupCount); for ( int index = 1; index <= groupCount; index++) { subKeys.add( matcher.group( index ) ); } return new MatchedElement(dataKey, subKeys); } StarRegexPathElement( String key ); @Override boolean stringMatch( String literal ); @Override MatchedElement match( String dataKey, WalkedPath walkedPath ); @Override String getCanonicalForm();  }