From 420990940c88d63eafab69d4f144410c5a97363f Mon Sep 17 00:00:00 2001 From: KSGRelewise <119578211+KSGRelewise@users.noreply.github.com> Date: Thu, 8 Aug 2024 13:39:29 +0200 Subject: [PATCH 1/2] Updated name resolver to succeed for any level of nested types. --- Generator/JavaTypeResolver.cs | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/Generator/JavaTypeResolver.cs b/Generator/JavaTypeResolver.cs index 455f8cba..63fbc3f3 100644 --- a/Generator/JavaTypeResolver.cs +++ b/Generator/JavaTypeResolver.cs @@ -1,9 +1,6 @@ -using System; -using System.Linq; +using Generator.Extensions; using System.Reflection; -using System.Reflection.Metadata; -using Generator.Extensions; -using Relewise.Client.DataTypes.Search.Facets.Result; +using System.Text.RegularExpressions; namespace Generator; @@ -59,12 +56,17 @@ private string GetOrAddTypeDefinition(Type type) private static string GetTypeName(Type type) { - if (type.IsNested) + var name = type.Name; + + Type? typeToPrependToName = type.DeclaringType; + while (typeToPrependToName is not null) { - return type.DeclaringType!.Name + type.Name.Replace("`1", "").Replace("`2", ""); + name = typeToPrependToName.Name + name; + + typeToPrependToName = typeToPrependToName.DeclaringType; } - return type.Name.Replace("`1", "").Replace("`2", ""); + return Regex.Replace(name, @"`\d+", ""); } private string AddCollectionTypeDefinition(Type type) From 2de309560ae5b2a48ff1e09cf46de603a0564aaf Mon Sep 17 00:00:00 2001 From: KSGRelewise <119578211+KSGRelewise@users.noreply.github.com> Date: Thu, 8 Aug 2024 13:45:50 +0200 Subject: [PATCH 2/2] Regenerated types. --- .../client/model/PredictionRulePromotion.java | 10 +++++----- ...n.java => PredictionRulePromotionPosition.java} | 2 +- .../client/model/PredictionRuleSuppression.java | 10 +++++----- ...=> PredictionRuleSuppressionConditionKind.java} | 2 +- ...oductCategoryInterestTriggerResultCategory.java | 14 +++++++------- ...estTriggerResultCategoryProductAndVariant.java} | 12 ++++++------ 6 files changed, 25 insertions(+), 25 deletions(-) rename src/src/main/java/com/relewise/client/model/{PromotionPosition.java => PredictionRulePromotionPosition.java} (94%) rename src/src/main/java/com/relewise/client/model/{SuppressionConditionKind.java => PredictionRuleSuppressionConditionKind.java} (93%) rename src/src/main/java/com/relewise/client/model/{CategoryProductAndVariant.java => ProductCategoryInterestTriggerResultCategoryProductAndVariant.java} (66%) diff --git a/src/src/main/java/com/relewise/client/model/PredictionRulePromotion.java b/src/src/main/java/com/relewise/client/model/PredictionRulePromotion.java index 0bc98769..22a43631 100644 --- a/src/src/main/java/com/relewise/client/model/PredictionRulePromotion.java +++ b/src/src/main/java/com/relewise/client/model/PredictionRulePromotion.java @@ -22,13 +22,13 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class PredictionRulePromotion { - public PromotionPosition to; + public PredictionRulePromotionPosition to; public String[] values; - public static PredictionRulePromotion create(PromotionPosition toPosition, String... values) + public static PredictionRulePromotion create(PredictionRulePromotionPosition toPosition, String... values) { return new PredictionRulePromotion(toPosition, values); } - public PredictionRulePromotion(PromotionPosition toPosition, String... values) + public PredictionRulePromotion(PredictionRulePromotionPosition toPosition, String... values) { this.to = toPosition; this.values = values; @@ -36,7 +36,7 @@ public PredictionRulePromotion(PromotionPosition toPosition, String... values) public PredictionRulePromotion() { } - public PromotionPosition getTo() + public PredictionRulePromotionPosition getTo() { return this.to; } @@ -44,7 +44,7 @@ public String[] getValues() { return this.values; } - public PredictionRulePromotion setTo(PromotionPosition to) + public PredictionRulePromotion setTo(PredictionRulePromotionPosition to) { this.to = to;; return this; diff --git a/src/src/main/java/com/relewise/client/model/PromotionPosition.java b/src/src/main/java/com/relewise/client/model/PredictionRulePromotionPosition.java similarity index 94% rename from src/src/main/java/com/relewise/client/model/PromotionPosition.java rename to src/src/main/java/com/relewise/client/model/PredictionRulePromotionPosition.java index 1afbe8db..ef4a546d 100644 --- a/src/src/main/java/com/relewise/client/model/PromotionPosition.java +++ b/src/src/main/java/com/relewise/client/model/PredictionRulePromotionPosition.java @@ -19,7 +19,7 @@ import java.util.Set; import java.util.HashSet; -public enum PromotionPosition +public enum PredictionRulePromotionPosition { Top { public String toString() { diff --git a/src/src/main/java/com/relewise/client/model/PredictionRuleSuppression.java b/src/src/main/java/com/relewise/client/model/PredictionRuleSuppression.java index 11603f87..3e9f4268 100644 --- a/src/src/main/java/com/relewise/client/model/PredictionRuleSuppression.java +++ b/src/src/main/java/com/relewise/client/model/PredictionRuleSuppression.java @@ -22,13 +22,13 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class PredictionRuleSuppression { - public SuppressionConditionKind condition; + public PredictionRuleSuppressionConditionKind condition; public String[] values; - public static PredictionRuleSuppression create(SuppressionConditionKind condition, String... values) + public static PredictionRuleSuppression create(PredictionRuleSuppressionConditionKind condition, String... values) { return new PredictionRuleSuppression(condition, values); } - public PredictionRuleSuppression(SuppressionConditionKind condition, String... values) + public PredictionRuleSuppression(PredictionRuleSuppressionConditionKind condition, String... values) { this.condition = condition; this.values = values; @@ -36,7 +36,7 @@ public PredictionRuleSuppression(SuppressionConditionKind condition, String... v public PredictionRuleSuppression() { } - public SuppressionConditionKind getCondition() + public PredictionRuleSuppressionConditionKind getCondition() { return this.condition; } @@ -44,7 +44,7 @@ public String[] getValues() { return this.values; } - public PredictionRuleSuppression setCondition(SuppressionConditionKind condition) + public PredictionRuleSuppression setCondition(PredictionRuleSuppressionConditionKind condition) { this.condition = condition;; return this; diff --git a/src/src/main/java/com/relewise/client/model/SuppressionConditionKind.java b/src/src/main/java/com/relewise/client/model/PredictionRuleSuppressionConditionKind.java similarity index 93% rename from src/src/main/java/com/relewise/client/model/SuppressionConditionKind.java rename to src/src/main/java/com/relewise/client/model/PredictionRuleSuppressionConditionKind.java index 291e7f72..24df740f 100644 --- a/src/src/main/java/com/relewise/client/model/SuppressionConditionKind.java +++ b/src/src/main/java/com/relewise/client/model/PredictionRuleSuppressionConditionKind.java @@ -19,7 +19,7 @@ import java.util.Set; import java.util.HashSet; -public enum SuppressionConditionKind +public enum PredictionRuleSuppressionConditionKind { Contains { public String toString() { diff --git a/src/src/main/java/com/relewise/client/model/ProductCategoryInterestTriggerResultCategory.java b/src/src/main/java/com/relewise/client/model/ProductCategoryInterestTriggerResultCategory.java index 52401af1..1658bb3d 100644 --- a/src/src/main/java/com/relewise/client/model/ProductCategoryInterestTriggerResultCategory.java +++ b/src/src/main/java/com/relewise/client/model/ProductCategoryInterestTriggerResultCategory.java @@ -24,7 +24,7 @@ public class ProductCategoryInterestTriggerResultCategory { public String[] lastPath; public Integer views; - public CategoryProductAndVariant[] viewedProducts; + public ProductCategoryInterestTriggerResultCategoryProductAndVariant[] viewedProducts; public static ProductCategoryInterestTriggerResultCategory create() { return new ProductCategoryInterestTriggerResultCategory(); @@ -40,7 +40,7 @@ public Integer getViews() { return this.views; } - public CategoryProductAndVariant[] getViewedProducts() + public ProductCategoryInterestTriggerResultCategoryProductAndVariant[] getViewedProducts() { return this.viewedProducts; } @@ -68,22 +68,22 @@ public ProductCategoryInterestTriggerResultCategory setViews(Integer views) this.views = views;; return this; } - public ProductCategoryInterestTriggerResultCategory setViewedProducts(CategoryProductAndVariant... viewedProducts) + public ProductCategoryInterestTriggerResultCategory setViewedProducts(ProductCategoryInterestTriggerResultCategoryProductAndVariant... viewedProducts) { this.viewedProducts = viewedProducts;; return this; } - public ProductCategoryInterestTriggerResultCategory addToViewedProducts(CategoryProductAndVariant viewedProduct) + public ProductCategoryInterestTriggerResultCategory addToViewedProducts(ProductCategoryInterestTriggerResultCategoryProductAndVariant viewedProduct) { if (this.viewedProducts == null) { - this.viewedProducts = new CategoryProductAndVariant[] { viewedProduct }; + this.viewedProducts = new ProductCategoryInterestTriggerResultCategoryProductAndVariant[] { viewedProduct }; } else { - ArrayList existingList = new ArrayList<>(Arrays.asList(this.viewedProducts)); + ArrayList existingList = new ArrayList<>(Arrays.asList(this.viewedProducts)); existingList.add(viewedProduct); - this.viewedProducts = existingList.toArray(new CategoryProductAndVariant[0]); + this.viewedProducts = existingList.toArray(new ProductCategoryInterestTriggerResultCategoryProductAndVariant[0]); } return this; } diff --git a/src/src/main/java/com/relewise/client/model/CategoryProductAndVariant.java b/src/src/main/java/com/relewise/client/model/ProductCategoryInterestTriggerResultCategoryProductAndVariant.java similarity index 66% rename from src/src/main/java/com/relewise/client/model/CategoryProductAndVariant.java rename to src/src/main/java/com/relewise/client/model/ProductCategoryInterestTriggerResultCategoryProductAndVariant.java index 9368a2b5..39e534e5 100644 --- a/src/src/main/java/com/relewise/client/model/CategoryProductAndVariant.java +++ b/src/src/main/java/com/relewise/client/model/ProductCategoryInterestTriggerResultCategoryProductAndVariant.java @@ -20,15 +20,15 @@ import java.util.HashSet; @JsonIgnoreProperties(ignoreUnknown = true) -public class CategoryProductAndVariant +public class ProductCategoryInterestTriggerResultCategoryProductAndVariant { public ProductResultDetails product; public VariantResultDetails variant; - public static CategoryProductAndVariant create() + public static ProductCategoryInterestTriggerResultCategoryProductAndVariant create() { - return new CategoryProductAndVariant(); + return new ProductCategoryInterestTriggerResultCategoryProductAndVariant(); } - public CategoryProductAndVariant() + public ProductCategoryInterestTriggerResultCategoryProductAndVariant() { } public ProductResultDetails getProduct() @@ -39,12 +39,12 @@ public VariantResultDetails getVariant() { return this.variant; } - public CategoryProductAndVariant setProduct(ProductResultDetails product) + public ProductCategoryInterestTriggerResultCategoryProductAndVariant setProduct(ProductResultDetails product) { this.product = product;; return this; } - public CategoryProductAndVariant setVariant(VariantResultDetails variant) + public ProductCategoryInterestTriggerResultCategoryProductAndVariant setVariant(VariantResultDetails variant) { this.variant = variant;; return this;