@Test public void mustMatchSomethingTest() { StarPathElement star = new StarRegexPathElement( "tuna-*-*"); Assert.assertNull( star.match( "tuna--", null ) ); Assert.assertNull( star.match( "tuna-bob-", null ) ); Assert.assertNull( star.match( "tuna--bob", null ) ); StarPathElement multiMetacharStarpathelement = new StarRegexPathElement( "rating-$-*-*"); Assert.assertNull( multiMetacharStarpathelement.match( "rating-capGrp1-capGrp2", null ) ); Assert.assertNull( multiMetacharStarpathelement.match( "rating-$capGrp1-capGrp2", null ) ); Assert.assertNotNull(multiMetacharStarpathelement.match( "rating-$-capGrp1-capGrp2",null) ); }
@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();  }