-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into gen-sdk-updates
- Loading branch information
Showing
32 changed files
with
2,241 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -3,3 +3,4 @@ a8ec45c8ea4ba559247b654d01b0d35b21a68865 | |
430a1a0a5dd4efe78e21526c37bec9dbce036401 | ||
|
||
|
||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
version = 1 | ||
merge.show_missing_automerge_label_message = false |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
47 changes: 47 additions & 0 deletions
47
.../main/java/com/commercetools/api/client/ByProjectKeyProductProjectionsSearchGetMixin.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
package com.commercetools.api.client; | ||
|
||
import java.util.function.Function; | ||
|
||
import com.commercetools.api.search.products.FacetExpression; | ||
import com.commercetools.api.search.products.FilterExpression; | ||
import com.commercetools.api.search.products.ProductFacetExpressionBuilder; | ||
import com.commercetools.api.search.products.ProductFilterExpressionBuilder; | ||
|
||
public interface ByProjectKeyProductProjectionsSearchGetMixin { | ||
public <TValue> ByProjectKeyProductProjectionsSearchGet addFilter(final TValue filter); | ||
|
||
public <TValue> ByProjectKeyProductProjectionsSearchGet addFilterFacets(final TValue filterFacets); | ||
|
||
public <TValue> ByProjectKeyProductProjectionsSearchGet addFilterQuery(final TValue filterQuery); | ||
|
||
public <TValue> ByProjectKeyProductProjectionsSearchGet addFacet(final TValue facet); | ||
|
||
default ProductFilterExpressionBuilder filterDsl() { | ||
return new ProductFilterExpressionBuilder(); | ||
} | ||
|
||
default ProductFacetExpressionBuilder facetDsl() { | ||
return new ProductFacetExpressionBuilder(); | ||
} | ||
|
||
default ByProjectKeyProductProjectionsSearchGet filter( | ||
Function<ProductFilterExpressionBuilder, FilterExpression> fn) { | ||
return addFilter(fn.apply(filterDsl()).render()); | ||
} | ||
|
||
default ByProjectKeyProductProjectionsSearchGet filterFacets( | ||
Function<ProductFilterExpressionBuilder, FilterExpression> fn) { | ||
return addFilterFacets(fn.apply(filterDsl()).render()); | ||
} | ||
|
||
default ByProjectKeyProductProjectionsSearchGet filterQuery( | ||
Function<ProductFilterExpressionBuilder, FilterExpression> fn) { | ||
return addFilterQuery(fn.apply(filterDsl()).render()); | ||
} | ||
|
||
default ByProjectKeyProductProjectionsSearchGet facet( | ||
Function<ProductFacetExpressionBuilder, FacetExpression<?>> fn) { | ||
return addFacet(fn.apply(facetDsl()).render()); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
17 changes: 17 additions & 0 deletions
17
...ercetools-sdk-java-api/src/main/java/com/commercetools/api/models/SimpleIdentifiable.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
|
||
package com.commercetools.api.models; | ||
|
||
public class SimpleIdentifiable<T> implements Identifiable<T> { | ||
|
||
private final String id; | ||
|
||
public SimpleIdentifiable(String id) { | ||
this.id = id; | ||
} | ||
|
||
@Override | ||
public String getId() { | ||
return id; | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
71 changes: 71 additions & 0 deletions
71
...-api/src/main/java/com/commercetools/api/search/products/CategoryTermFacetExpression.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,71 @@ | ||
|
||
package com.commercetools.api.search.products; | ||
|
||
import java.util.ArrayList; | ||
import java.util.Collections; | ||
import java.util.List; | ||
import java.util.Optional; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.StreamSupport; | ||
|
||
import com.commercetools.api.models.Identifiable; | ||
import com.commercetools.api.models.category.Category; | ||
|
||
public class CategoryTermFacetExpression extends TermFacetExpression<String> { | ||
|
||
public CategoryTermFacetExpression(PathExpression expression) { | ||
super(expression, TermFormatter::format); | ||
} | ||
|
||
public CategoryTermFacetExpression(PathExpression expression, List<FilterExpression> term) { | ||
super(expression, term, TermFormatter::format); | ||
} | ||
|
||
public CategoryTermFacetExpression is(String value) { | ||
List<FilterExpression> terms = Optional.ofNullable(terms()).map(term -> { | ||
List<FilterExpression> expressions = new ArrayList<>(terms()); | ||
expressions.add(formatter().apply(value)); | ||
return expressions; | ||
}).orElse(Collections.singletonList(formatter().apply(value))); | ||
return new CategoryTermFacetExpression(expression(), terms); | ||
} | ||
|
||
public CategoryTermFacetExpression is(Identifiable<Category> value) { | ||
return is(value.getId()); | ||
} | ||
|
||
public CategoryTermFacetExpression subTree(String value) { | ||
List<FilterExpression> terms = Optional.ofNullable(terms()).map(term -> { | ||
List<FilterExpression> expressions = new ArrayList<>(terms()); | ||
expressions.add( | ||
ContainerExpression.of().parent(ConstantExpression.of("subTree")).inner(formatter().apply(value))); | ||
return expressions; | ||
}) | ||
.orElse(Collections.singletonList( | ||
ContainerExpression.of().parent(ConstantExpression.of("subTree")).inner(formatter().apply(value)))); | ||
return new CategoryTermFacetExpression(expression(), terms); | ||
} | ||
|
||
public CategoryTermFacetExpression subTree(Identifiable<Category> value) { | ||
return subTree(value.getId()); | ||
} | ||
|
||
public CategoryTermFacetExpression isIn(Iterable<String> values) { | ||
List<FilterExpression> terms = Optional.ofNullable(terms()).map(term -> { | ||
List<FilterExpression> expressions = new ArrayList<>(terms()); | ||
values.forEach(v -> expressions.add(formatter().apply(v))); | ||
return expressions; | ||
}).orElse(StreamSupport.stream(values.spliterator(), false).map(formatter()).collect(Collectors.toList())); | ||
|
||
return new CategoryTermFacetExpression(expression(), terms); | ||
} | ||
|
||
public CategoryTermFacetExpression containsAny(Iterable<Identifiable<Category>> values) { | ||
return isIn( | ||
StreamSupport.stream(values.spliterator(), false).map(Identifiable::getId).collect(Collectors.toList())); | ||
} | ||
|
||
public static CategoryTermFacetExpression of(PathExpression expression) { | ||
return new CategoryTermFacetExpression(expression); | ||
} | ||
} |
68 changes: 68 additions & 0 deletions
68
...api/src/main/java/com/commercetools/api/search/products/CategoryTermFilterExpression.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
|
||
package com.commercetools.api.search.products; | ||
|
||
import java.util.*; | ||
import java.util.stream.Collectors; | ||
import java.util.stream.StreamSupport; | ||
|
||
import com.commercetools.api.models.Identifiable; | ||
import com.commercetools.api.models.category.Category; | ||
|
||
public class CategoryTermFilterExpression extends TermFilterExpression<String> { | ||
|
||
public CategoryTermFilterExpression(PathExpression expression) { | ||
super(expression, TermFormatter::format); | ||
} | ||
|
||
public CategoryTermFilterExpression(PathExpression expression, List<FilterExpression> term) { | ||
super(expression, term, TermFormatter::format); | ||
} | ||
|
||
public CategoryTermFilterExpression is(String value) { | ||
List<FilterExpression> terms = Optional.ofNullable(terms()).map(term -> { | ||
List<FilterExpression> expressions = new ArrayList<>(terms()); | ||
expressions.add(formatter().apply(value)); | ||
return expressions; | ||
}).orElse(Collections.singletonList(formatter().apply(value))); | ||
return new CategoryTermFilterExpression(expression(), terms); | ||
} | ||
|
||
public CategoryTermFilterExpression is(Identifiable<Category> value) { | ||
return is(value.getId()); | ||
} | ||
|
||
public CategoryTermFilterExpression subTree(String value) { | ||
List<FilterExpression> terms = Optional.ofNullable(terms()).map(term -> { | ||
List<FilterExpression> expressions = new ArrayList<>(terms()); | ||
expressions.add( | ||
ContainerExpression.of().parent(ConstantExpression.of("subTree")).inner(formatter().apply(value))); | ||
return expressions; | ||
}) | ||
.orElse(Collections.singletonList( | ||
ContainerExpression.of().parent(ConstantExpression.of("subTree")).inner(formatter().apply(value)))); | ||
return new CategoryTermFilterExpression(expression(), terms); | ||
} | ||
|
||
public CategoryTermFilterExpression subTree(Identifiable<Category> value) { | ||
return subTree(value.getId()); | ||
} | ||
|
||
public CategoryTermFilterExpression isIn(Iterable<String> values) { | ||
List<FilterExpression> terms = Optional.ofNullable(terms()).map(term -> { | ||
List<FilterExpression> expressions = new ArrayList<>(terms()); | ||
values.forEach(v -> expressions.add(formatter().apply(v))); | ||
return expressions; | ||
}).orElse(StreamSupport.stream(values.spliterator(), false).map(formatter()).collect(Collectors.toList())); | ||
|
||
return new CategoryTermFilterExpression(expression(), terms); | ||
} | ||
|
||
public CategoryTermFilterExpression containsAny(Iterable<Identifiable<Category>> values) { | ||
return isIn( | ||
StreamSupport.stream(values.spliterator(), false).map(Identifiable::getId).collect(Collectors.toList())); | ||
} | ||
|
||
public static CategoryTermFilterExpression of(PathExpression expression) { | ||
return new CategoryTermFilterExpression(expression); | ||
} | ||
} |
23 changes: 23 additions & 0 deletions
23
...-sdk-java-api/src/main/java/com/commercetools/api/search/products/ConstantExpression.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
|
||
package com.commercetools.api.search.products; | ||
|
||
public class ConstantExpression implements FilterExpression { | ||
private final String value; | ||
|
||
public ConstantExpression(String value) { | ||
this.value = value; | ||
} | ||
|
||
public String value() { | ||
return value; | ||
} | ||
|
||
@Override | ||
public String render() { | ||
return value; | ||
} | ||
|
||
public static ConstantExpression of(String value) { | ||
return new ConstantExpression(value); | ||
} | ||
} |
Oops, something went wrong.