Conversation
…ename under to startWith
…uilder, given same precedence, option added after overrides previous
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #809 +/- ##
============================================
- Coverage 65.71% 65.67% -0.05%
- Complexity 3289 3337 +48
============================================
Files 350 356 +6
Lines 13731 13911 +180
Branches 1488 1510 +22
============================================
+ Hits 9024 9136 +112
- Misses 3863 3921 +58
- Partials 844 854 +10 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
common/src/main/java/com/linecorp/centraldogma/common/PathPattern.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternBuilder.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternOptions.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternOption.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternOption.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternOption.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternOptions.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternBuilder.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternBuilder.java
Outdated
Show resolved
Hide resolved
…ernOptions.java Co-authored-by: Ikhun Um <ih.pert@gmail.com>
…ernOption.java Co-authored-by: Ikhun Um <ih.pert@gmail.com>
… logic from PathPatternOption to PathPatternBuilder
As a result of moving the pattern build order logic from |
ikhoon
left a comment
There was a problem hiding this comment.
Overall looks good. Left minor comments.
common/src/main/java/com/linecorp/centraldogma/common/PathPattern.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternBuilder.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternBuilder.java
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternBuilder.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternBuilder.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternOption.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternOptions.java
Outdated
Show resolved
Hide resolved
common/src/test/java/com/linecorp/centraldogma/common/PathPatternBuilderTest.java
Outdated
Show resolved
Hide resolved
common/src/test/java/com/linecorp/centraldogma/common/PathPatternBuilderTest.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternOptions.java
Outdated
Show resolved
Hide resolved
…ern.java Co-authored-by: Ikhun Um <ih.pert@gmail.com>
…ernBuilderTest.java Co-authored-by: Ikhun Um <ih.pert@gmail.com>
…ernBuilderTest.java Co-authored-by: Ikhun Um <ih.pert@gmail.com>
…ernBuilder.java Co-authored-by: Ikhun Um <ih.pert@gmail.com>
common/src/main/java/com/linecorp/centraldogma/common/PathPattern.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternBuilder.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternBuilder.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternOptions.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternOptions.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternOptions.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternOptions.java
Outdated
Show resolved
Hide resolved
…ern.java Co-authored-by: Ikhun Um <ih.pert@gmail.com>
…ernOptions.java Co-authored-by: Ikhun Um <ih.pert@gmail.com>
…ernOptions.java Co-authored-by: Ikhun Um <ih.pert@gmail.com>
…ernOptions.java Co-authored-by: Ikhun Um <ih.pert@gmail.com>
…ernBuilder.java Co-authored-by: Ikhun Um <ih.pert@gmail.com>
…ernOptions.java Co-authored-by: Ikhun Um <ih.pert@gmail.com>
common/src/main/java/com/linecorp/centraldogma/common/PathPattern.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternBuilder.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternBuilder.java
Outdated
Show resolved
Hide resolved
common/src/main/java/com/linecorp/centraldogma/common/PathPatternOptions.java
Outdated
Show resolved
Hide resolved
…tions: endsWith, startsWith, contains and hasExtension
common/src/main/java/com/linecorp/centraldogma/common/PathPattern.java
Outdated
Show resolved
Hide resolved
| if (pathPatterns.length == 1) { | ||
| return pathPatterns[0]; | ||
| } | ||
| return new DefaultPathPattern(ImmutableList.copyOf(pathPatterns)); |
There was a problem hiding this comment.
| return new DefaultPathPattern(ImmutableList.copyOf(pathPatterns)); | |
| return new DefaultPathPattern(ImmutableSet.copyOf(pathPatterns)); |
There was a problem hiding this comment.
Previously, a new constructor for DefaultPathPattern(List<PathPattern> verifiedPatterns) was introduced that would skip the validatePathPattern step.
I changed the argument type from List<PathPattern> -> varargs PathPattern... in commit 0d85d78.
| @Nullable | ||
| private PathPatternOption startPattern; | ||
| private final List<PathPatternOption> innerPatterns = new ArrayList<>(); | ||
| @Nullable | ||
| private PathPatternOption endPattern; |
There was a problem hiding this comment.
Can't we just use PathPattern here?
| /** | ||
| * A {@link PathPatternBuilder} option. | ||
| */ | ||
| final class PathPatternOption { |
There was a problem hiding this comment.
I'm not sure if this class is needed at all. Why do we need to create a PathPattern lazily? Can't we just create it as early as possible?
There was a problem hiding this comment.
I have merged PathPatternOptions and PathPatternOption with PathPatternBuilder
…ern.java Co-authored-by: Trustin Lee <t@motd.kr>
892ecf3 to
49b5d3f
Compare
| assertThat(PathPattern.builder() | ||
| .contains("/foo") | ||
| .contains("/bar") | ||
| .build() | ||
| .patternString()).isEqualTo("/**/foo/**/bar/**"); | ||
| assertThat(PathPattern.builder() | ||
| .startsWith("/foo/bar") | ||
| .startsWith("/override") | ||
| .hasExtension("json") | ||
| .build() | ||
| .patternString()).isEqualTo("/override/**/*.json"); |
There was a problem hiding this comment.
I think this can be quite confusing to users. Should we always override, even for contains()?
There was a problem hiding this comment.
Hi @trustin ,
Your point about differing behavior for contains(combining allowed) vs other options (combining not allowed , will override) being confusing is valid.
I also understand @ikhoon point's that, when considered in isolation, contains can be combined (ref #809 (comment) ).
Personally, I am on the fence, with no strong opinion.
Perhaps @minwoox , and @jrhee17 could share their opinion :)
Motivation:
Addresses #659.
PathPattern#ofacceptingPathPattern... pathPatternsPathPatternBuilderto provide a way to combination many patterns into one.The following initial options have been added:
Modifications:
PathPatternOption,PathPathOptions-> define and manage the options available.PathPatternBuilder-> responsible for composing one pathPattern from the added options.endsWithorextension; currently, option added after will override previousResult: