Skip to content

Commit

Permalink
Added nullability annotation on simple setter methods.
Browse files Browse the repository at this point in the history
  • Loading branch information
KSGRelewise committed Aug 13, 2024
1 parent 74cb4c9 commit 130b676
Show file tree
Hide file tree
Showing 300 changed files with 646 additions and 634 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public void Write(IndentedTextWriter writer, Type returnType, string returnTypeN
javaWriter.XmlDocumentation.GetSummary(returnType, propertyName),
deprecationComment
);
var parameterType = javaWriter.BetterTypedParameterTypeName(propertyType, new NullabilityInfoContext().Create(info));
var parameterType = javaWriter.BetterTypedParameterTypeName(info, new NullabilityInfoContext().Create(info));
if (!ownedProperties.Any(p => p.ToLower() == lowerCaseName.ToLower()))
{
writer.WriteLine("@Override");
Expand Down
12 changes: 12 additions & 0 deletions Generator/JavaWriter.cs
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,18 @@ parameterType.GenericTypeArguments is [var elementType]
: TypeName(parameterType);
}

public string BetterTypedParameterTypeName(PropertyInfo property, NullabilityInfo nullabilityInfo)
{
Type parameterType = property.PropertyType;

return parameterType.IsGenericType && parameterType.GetGenericTypeDefinition() == typeof(List<>) &&
parameterType.GenericTypeArguments is [var elementType]
? TypeName(elementType) + "..."
: parameterType.IsArray
? TypeName(parameterType.GetElementType()!) + "..."
: TypeName(property);
}

public string ValueSetter(Type toType, string toName, Type fromType, string fromName) => (toType, fromType) switch
{
{ fromType: { IsArray: true }, toType: { IsGenericType: true } generic } when generic.GetGenericTypeDefinition() == typeof(List<>) => $"{toName} = new ArrayList<>(Arrays.asList({fromName}));",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public AbandonedContentSearch setHits(Integer hits)
return this;
}
@Override
public AbandonedContentSearch setLanguage(Language language)
public AbandonedContentSearch setLanguage(@Nullable Language language)
{
this.language = language;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public AbandonedProductCategorySearch setHits(Integer hits)
return this;
}
@Override
public AbandonedProductCategorySearch setLanguage(Language language)
public AbandonedProductCategorySearch setLanguage(@Nullable Language language)
{
this.language = language;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ public AbandonedProductSearch setHits(Integer hits)
return this;
}
@Override
public AbandonedProductSearch setLanguage(Language language)
public AbandonedProductSearch setLanguage(@Nullable Language language)
{
this.language = language;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ public AbandonedSearch setHits(Integer hits)
this.hits = hits;
return this;
}
public AbandonedSearch setLanguage(Language language)
public AbandonedSearch setLanguage(@Nullable Language language)
{
this.language = language;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ public AbandonedSearchTriggerConfiguration addToSearchTypesInPrioritizedOrder(Se
}
return this;
}
public AbandonedSearchTriggerConfiguration setSearchTermCondition(SearchTermCondition searchTermCondition)
public AbandonedSearchTriggerConfiguration setSearchTermCondition(@Nullable SearchTermCondition searchTermCondition)
{
this.searchTermCondition = searchTermCondition;
return this;
Expand Down
4 changes: 2 additions & 2 deletions src/src/main/java/com/relewise/client/model/Advertiser.java
Original file line number Diff line number Diff line change
Expand Up @@ -66,13 +66,13 @@ public Advertiser setName(String name)
return this;
}
/** Defines what kind of promotions an advertiser is allowed to create, and constraints to what may be promoted. Constraints could as an example be all products belonging to the brand(s) this Advertiser is associated with. If <code>null</code> or empty, an advertiser will not be allowed to make any promotions anywhere, only useful for Advertisers in draft. */
public Advertiser setAllowedPromotions(PromotionSpecificationCollection allowedPromotions)
public Advertiser setAllowedPromotions(@Nullable PromotionSpecificationCollection allowedPromotions)
{
this.allowedPromotions = allowedPromotions;
return this;
}
/** Defines locations/placements/variations where this advertiser is allowed to make promotions at. If <code>null</code> or empty, an advertiser will not be allowed to make any promotions anywhere, only useful for Advertisers in draft. */
public Advertiser setAllowedLocations(PromotionLocationCollection allowedLocations)
public Advertiser setAllowedLocations(@Nullable PromotionLocationCollection allowedLocations)
{
this.allowedLocations = allowedLocations;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,12 +47,12 @@ public Integer getTake()
{
return this.take;
}
public AdvertiserEntityStateAdvertiserMetadataValuesAdvertisersRequestSortByAdvertisersRequestEntityFiltersEntitiesRequest setFilters(AdvertisersRequestEntityFilters filters)
public AdvertiserEntityStateAdvertiserMetadataValuesAdvertisersRequestSortByAdvertisersRequestEntityFiltersEntitiesRequest setFilters(@Nullable AdvertisersRequestEntityFilters filters)
{
this.filters = filters;
return this;
}
public AdvertiserEntityStateAdvertiserMetadataValuesAdvertisersRequestSortByAdvertisersRequestEntityFiltersEntitiesRequest setSorting(AdvertisersRequestSortBySorting sorting)
public AdvertiserEntityStateAdvertiserMetadataValuesAdvertisersRequestSortByAdvertisersRequestEntityFiltersEntitiesRequest setSorting(@Nullable AdvertisersRequestSortBySorting sorting)
{
this.sorting = sorting;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ public abstract class AdvertiserEntityStateAdvertiserMetadataValuesRetailMediaEn
{
return this.states;
}
public AdvertiserEntityStateAdvertiserMetadataValuesRetailMediaEntityEntityFilters setTerm(String term)
public AdvertiserEntityStateAdvertiserMetadataValuesRetailMediaEntityEntityFilters setTerm(@Nullable String term)
{
this.term = term;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public AdvertiserMetadataValues setInactivated(@Nullable OffsetDateTime inactiva
this.inactivated = inactivated;
return this;
}
public AdvertiserMetadataValues setInactivatedBy(String inactivatedBy)
public AdvertiserMetadataValues setInactivatedBy(@Nullable String inactivatedBy)
{
this.inactivatedBy = inactivatedBy;
return this;
Expand All @@ -78,7 +78,7 @@ public AdvertiserMetadataValues setActivated(@Nullable OffsetDateTime activated)
this.activated = activated;
return this;
}
public AdvertiserMetadataValues setActivatedBy(String activatedBy)
public AdvertiserMetadataValues setActivatedBy(@Nullable String activatedBy)
{
this.activatedBy = activatedBy;
return this;
Expand All @@ -88,7 +88,7 @@ public AdvertiserMetadataValues setArchived(@Nullable OffsetDateTime archived)
this.archived = archived;
return this;
}
public AdvertiserMetadataValues setArchivedBy(String archivedBy)
public AdvertiserMetadataValues setArchivedBy(@Nullable String archivedBy)
{
this.archivedBy = archivedBy;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,13 +41,13 @@ public AdvertisersRequest()
{
}
@Override
public AdvertisersRequest setFilters(AdvertisersRequestEntityFilters filters)
public AdvertisersRequest setFilters(@Nullable AdvertisersRequestEntityFilters filters)
{
this.filters = filters;
return this;
}
@Override
public AdvertisersRequest setSorting(AdvertisersRequestSortBySorting sorting)
public AdvertisersRequest setSorting(@Nullable AdvertisersRequestSortBySorting sorting)
{
this.sorting = sorting;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public AdvertisersRequestEntityFilters addToIds(UUID id)
return this;
}
@Override
public AdvertisersRequestEntityFilters setTerm(String term)
public AdvertisersRequestEntityFilters setTerm(@Nullable String term)
{
this.term = term;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ public abstract class AnalyzerRequest extends LicensedRequest
{
return this.currency;
}
public AnalyzerRequest setLanguage(Language language)
public AnalyzerRequest setLanguage(@Nullable Language language)
{
this.language = language;
return this;
}
public AnalyzerRequest setCurrency(Currency currency)
public AnalyzerRequest setCurrency(@Nullable Currency currency)
{
this.currency = currency;
return this;
Expand Down
2 changes: 1 addition & 1 deletion src/src/main/java/com/relewise/client/model/AndFilter.java
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public AndFilter setNegated(Boolean negated)
return this;
}
@Override
public AndFilter setSettings(FilterSettings settings)
public AndFilter setSettings(@Nullable FilterSettings settings)
{
this.settings = settings;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public AssortmentFacet setField(FacetingField field)
return this;
}
@Override
public AssortmentFacet setSettings(FacetSettings settings)
public AssortmentFacet setSettings(@Nullable FacetSettings settings)
{
this.settings = settings;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public BooleanContentDataValueFacet setField(FacetingField field)
return this;
}
@Override
public BooleanContentDataValueFacet setSettings(FacetSettings settings)
public BooleanContentDataValueFacet setSettings(@Nullable FacetSettings settings)
{
this.settings = settings;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public BooleanDataObjectValueFacet setField(FacetingField field)
return this;
}
@Override
public BooleanDataObjectValueFacet setSettings(FacetSettings settings)
public BooleanDataObjectValueFacet setSettings(@Nullable FacetSettings settings)
{
this.settings = settings;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ public BooleanDataValueFacet setField(FacetingField field)
return this;
}
@Override
public BooleanDataValueFacet setSettings(FacetSettings settings)
public BooleanDataValueFacet setSettings(@Nullable FacetSettings settings)
{
this.settings = settings;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ public BooleanProductCategoryDataValueFacet setField(FacetingField field)
return this;
}
@Override
public BooleanProductCategoryDataValueFacet setSettings(FacetSettings settings)
public BooleanProductCategoryDataValueFacet setSettings(@Nullable FacetSettings settings)
{
this.settings = settings;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ public BooleanProductDataValueFacet setField(FacetingField field)
return this;
}
@Override
public BooleanProductDataValueFacet setSettings(FacetSettings settings)
public BooleanProductDataValueFacet setSettings(@Nullable FacetSettings settings)
{
this.settings = settings;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ public BooleanValueFacet setField(FacetingField field)
return this;
}
@Override
public BooleanValueFacet setSettings(FacetSettings settings)
public BooleanValueFacet setSettings(@Nullable FacetSettings settings)
{
this.settings = settings;
return this;
Expand Down
4 changes: 2 additions & 2 deletions src/src/main/java/com/relewise/client/model/Brand.java
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public Brand setId(String id)
this.id = id;
return this;
}
public Brand setDisplayName(String displayName)
public Brand setDisplayName(@Nullable String displayName)
{
this.displayName = displayName;
return this;
Expand Down Expand Up @@ -84,7 +84,7 @@ public Brand addToData(String key, DataValue value)
this.data.put(key, value);
return this;
}
public Brand setData(HashMap<String, DataValue> data)
public Brand setData(@Nullable HashMap<String, DataValue> data)
{
this.data = data;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public BrandAdministrativeAction setFilters(FilterCollection filters)
this.filters = filters;
return this;
}
public BrandAdministrativeAction setLanguage(Language language)
public BrandAdministrativeAction setLanguage(@Nullable Language language)
{
this.language = language;
return this;
Expand All @@ -75,7 +75,7 @@ public BrandAdministrativeAction setKind(BrandAdministrativeActionUpdateKind kin
this.kind = kind;
return this;
}
public BrandAdministrativeAction setCurrency(Currency currency)
public BrandAdministrativeAction setCurrency(@Nullable Currency currency)
{
this.currency = currency;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public BrandAssortmentFilter setNegated(Boolean negated)
return this;
}
@Override
public BrandAssortmentFilter setSettings(FilterSettings settings)
public BrandAssortmentFilter setSettings(@Nullable FilterSettings settings)
{
this.settings = settings;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -107,19 +107,19 @@ public BrandDataFilter setMustMatchAllConditions(Boolean mustMatchAllConditions)
return this;
}
@Override
public BrandDataFilter setConditions(ValueConditionCollection conditions)
public BrandDataFilter setConditions(@Nullable ValueConditionCollection conditions)
{
this.conditions = conditions;
return this;
}
@Override
public BrandDataFilter setLanguage(Language language)
public BrandDataFilter setLanguage(@Nullable Language language)
{
this.language = language;
return this;
}
@Override
public BrandDataFilter setCurrency(Currency currency)
public BrandDataFilter setCurrency(@Nullable Currency currency)
{
this.currency = currency;
return this;
Expand Down Expand Up @@ -151,7 +151,7 @@ public BrandDataFilter setNegated(Boolean negated)
return this;
}
@Override
public BrandDataFilter setSettings(FilterSettings settings)
public BrandDataFilter setSettings(@Nullable FilterSettings settings)
{
this.settings = settings;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ public BrandDataHasKeyFilter setNegated(Boolean negated)
return this;
}
@Override
public BrandDataHasKeyFilter setSettings(FilterSettings settings)
public BrandDataHasKeyFilter setSettings(@Nullable FilterSettings settings)
{
this.settings = settings;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public BrandDisabledFilter setNegated(Boolean negated)
return this;
}
@Override
public BrandDisabledFilter setSettings(FilterSettings settings)
public BrandDisabledFilter setSettings(@Nullable FilterSettings settings)
{
this.settings = settings;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public BrandFacet setField(FacetingField field)
return this;
}
@Override
public BrandFacet setSettings(FacetSettings settings)
public BrandFacet setSettings(@Nullable FacetSettings settings)
{
this.settings = settings;
return this;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ public BrandIdFilter setNegated(Boolean negated)
return this;
}
@Override
public BrandIdFilter setSettings(FilterSettings settings)
public BrandIdFilter setSettings(@Nullable FilterSettings settings)
{
this.settings = settings;
return this;
Expand Down
4 changes: 2 additions & 2 deletions src/src/main/java/com/relewise/client/model/BrandQuery.java
Original file line number Diff line number Diff line change
Expand Up @@ -89,12 +89,12 @@ public BrandQuery setNumberOfResults(Integer numberOfResults)
this.numberOfResults = numberOfResults;
return this;
}
public BrandQuery setLanguage(Language language)
public BrandQuery setLanguage(@Nullable Language language)
{
this.language = language;
return this;
}
public BrandQuery setCurrency(Currency currency)
public BrandQuery setCurrency(@Nullable Currency currency)
{
this.currency = currency;
return this;
Expand Down
Loading

0 comments on commit 130b676

Please sign in to comment.