Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/support multi nested types #6

Merged
merged 3 commits into from
Aug 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 10 additions & 8 deletions Generator/JavaTypeResolver.cs
Original file line number Diff line number Diff line change
@@ -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;

Expand Down Expand Up @@ -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)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,29 @@
@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;
}
public PredictionRulePromotion()
{
}
public PromotionPosition getTo()
public PredictionRulePromotionPosition getTo()
{
return this.to;
}
public String[] getValues()
{
return this.values;
}
public PredictionRulePromotion setTo(PromotionPosition to)
public PredictionRulePromotion setTo(PredictionRulePromotionPosition to)
{
this.to = to;;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.util.Set;
import java.util.HashSet;

public enum PromotionPosition
public enum PredictionRulePromotionPosition
{
Top {
public String toString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,29 +22,29 @@
@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;
}
public PredictionRuleSuppression()
{
}
public SuppressionConditionKind getCondition()
public PredictionRuleSuppressionConditionKind getCondition()
{
return this.condition;
}
public String[] getValues()
{
return this.values;
}
public PredictionRuleSuppression setCondition(SuppressionConditionKind condition)
public PredictionRuleSuppression setCondition(PredictionRuleSuppressionConditionKind condition)
{
this.condition = condition;;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
import java.util.Set;
import java.util.HashSet;

public enum SuppressionConditionKind
public enum PredictionRuleSuppressionConditionKind
{
Contains {
public String toString() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -40,7 +40,7 @@ public Integer getViews()
{
return this.views;
}
public CategoryProductAndVariant[] getViewedProducts()
public ProductCategoryInterestTriggerResultCategoryProductAndVariant[] getViewedProducts()
{
return this.viewedProducts;
}
Expand Down Expand Up @@ -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<CategoryProductAndVariant> existingList = new ArrayList<>(Arrays.asList(this.viewedProducts));
ArrayList<ProductCategoryInterestTriggerResultCategoryProductAndVariant> 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;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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;
Expand Down
Loading