Skip to content

Commit 9d25329

Browse files
committed
removed over cautious null checks from other query descriptors similar to #262, passing null is not an error
1 parent abd85d3 commit 9d25329

9 files changed

+53
-78
lines changed

Diff for: src/Nest/DSL/Query/ConstantScoreQueryDescriptor.cs

-1
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public ConstantScoreQueryDescriptor<T> Filter(Func<FilterDescriptor<T>, BaseFilt
5656

5757
public ConstantScoreQueryDescriptor<T> Boost(double boost)
5858
{
59-
boost.ThrowIfNull("boostFactor");
6059
this._Boost = boost;
6160
return this;
6261
}

Diff for: src/Nest/DSL/Query/CustomBoostFactorQueryDescriptor.cs

-1
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,6 @@ public CustomBoostFactorQueryDescriptor<T> Query(Func<QueryDescriptor<T>, BaseQu
3636

3737
public CustomBoostFactorQueryDescriptor<T> BoostFactor(double boostFactor)
3838
{
39-
boostFactor.ThrowIfNull("boostFactor");
4039
this._BoostFactor = boostFactor;
4140
return this;
4241
}

Diff for: src/Nest/DSL/Query/CustomFiltersScoreDescriptor.cs

-3
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@ public CustomFiltersScoreDescriptor<T> Query(Func<QueryDescriptor<T>, BaseQuery>
5252

5353
public CustomFiltersScoreDescriptor<T> ScoreMode(ScoreMode scoreMode)
5454
{
55-
scoreMode.ThrowIfNull("scoreMode");
5655
this._ScoreMode = scoreMode;
5756
return this;
5857
}
@@ -82,14 +81,12 @@ public CustomFiltersScoreDescriptor<T> Params(Func<FluentDictionary<string, obje
8281

8382
public CustomFiltersScoreDescriptor<T> Language(string language)
8483
{
85-
language.ThrowIfNull("language");
8684
this._Lang = language;
8785
return this;
8886
}
8987

9088
public CustomFiltersScoreDescriptor<T> MaxBoost(string maxBoost)
9189
{
92-
maxBoost.ThrowIfNull("maxBoost");
9390
this._MaxBoost = maxBoost;
9491
return this;
9592
}

Diff for: src/Nest/DSL/Query/CustomScoreQueryDescriptor.cs

+53-54
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,66 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Text;
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Text;
55
using Newtonsoft.Json;
66
using Newtonsoft.Json.Converters;
77

8-
namespace Nest
9-
{
10-
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
11-
public class CustomScoreQueryDescriptor<T> : IQuery where T : class
8+
namespace Nest
9+
{
10+
[JsonObject(MemberSerialization = MemberSerialization.OptIn)]
11+
public class CustomScoreQueryDescriptor<T> : IQuery where T : class
1212
{
1313
[JsonProperty(PropertyName = "lang")]
14-
internal string _Lang { get; set; }
15-
16-
[JsonProperty(PropertyName = "script")]
17-
internal string _Script { get; set; }
18-
14+
internal string _Lang { get; set; }
15+
16+
[JsonProperty(PropertyName = "script")]
17+
internal string _Script { get; set; }
18+
1919
[JsonProperty(PropertyName = "params")]
2020
[JsonConverter(typeof(DictionaryKeysAreNotPropertyNamesJsonConverter))]
21-
internal Dictionary<string, object> _Params { get; set; }
22-
23-
[JsonProperty(PropertyName = "query")]
24-
internal BaseQuery _Query { get; set; }
25-
26-
internal bool IsConditionless
27-
{
28-
get
29-
{
30-
return this._Query == null || this._Query.IsConditionless;
31-
}
21+
internal Dictionary<string, object> _Params { get; set; }
22+
23+
[JsonProperty(PropertyName = "query")]
24+
internal BaseQuery _Query { get; set; }
25+
26+
internal bool IsConditionless
27+
{
28+
get
29+
{
30+
return this._Query == null || this._Query.IsConditionless;
31+
}
3232
}
3333

3434
public CustomScoreQueryDescriptor<T> Lang(string lang)
3535
{
3636
this._Lang = lang;
3737
return this;
38-
}
39-
40-
public CustomScoreQueryDescriptor<T> Query(Func<QueryDescriptor<T>, BaseQuery> querySelector)
41-
{
42-
querySelector.ThrowIfNull("querySelector");
43-
var query = new QueryDescriptor<T>();
44-
var q = querySelector(query);
45-
46-
this._Query = q;
47-
return this;
48-
}
49-
/// <summary>
50-
/// Scripts are cached for faster execution. If the script has parameters that it needs to take into account, it is preferable to use the same script, and provide parameters to it:
51-
/// </summary>
52-
/// <param name="script"></param>
53-
/// <returns></returns>
54-
public CustomScoreQueryDescriptor<T> Script(string script)
55-
{
56-
script.ThrowIfNull("script");
57-
this._Script = script;
58-
return this;
59-
}
60-
public CustomScoreQueryDescriptor<T> Params(Func<FluentDictionary<string, object>, FluentDictionary<string, object>> paramDictionary)
61-
{
62-
paramDictionary.ThrowIfNull("paramDictionary");
63-
this._Params = paramDictionary(new FluentDictionary<string, object>());
64-
return this;
65-
}
66-
}
67-
}
38+
}
39+
40+
public CustomScoreQueryDescriptor<T> Query(Func<QueryDescriptor<T>, BaseQuery> querySelector)
41+
{
42+
querySelector.ThrowIfNull("querySelector");
43+
var query = new QueryDescriptor<T>();
44+
var q = querySelector(query);
45+
46+
this._Query = q;
47+
return this;
48+
}
49+
/// <summary>
50+
/// Scripts are cached for faster execution. If the script has parameters that it needs to take into account, it is preferable to use the same script, and provide parameters to it:
51+
/// </summary>
52+
/// <param name="script"></param>
53+
/// <returns></returns>
54+
public CustomScoreQueryDescriptor<T> Script(string script)
55+
{
56+
this._Script = script;
57+
return this;
58+
}
59+
public CustomScoreQueryDescriptor<T> Params(Func<FluentDictionary<string, object>, FluentDictionary<string, object>> paramDictionary)
60+
{
61+
paramDictionary.ThrowIfNull("paramDictionary");
62+
this._Params = paramDictionary(new FluentDictionary<string, object>());
63+
return this;
64+
}
65+
}
66+
}

Diff for: src/Nest/DSL/Query/DismaxQueryDescriptor.cs

-2
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,11 @@ public DismaxQueryDescriptor<T> Queries(params Func<QueryDescriptor<T>, BaseQuer
4545

4646
public DismaxQueryDescriptor<T> Boost(double boost)
4747
{
48-
boost.ThrowIfNull("boost");
4948
this._Boost = boost;
5049
return this;
5150
}
5251
public DismaxQueryDescriptor<T> TieBreaker(double tieBreaker)
5352
{
54-
tieBreaker.ThrowIfNull("tieBreaker");
5553
this._TieBreaker = tieBreaker;
5654
return this;
5755
}

Diff for: src/Nest/DSL/Query/FilterScoreDescriptor.cs

-2
Original file line numberDiff line numberDiff line change
@@ -20,15 +20,13 @@ public class FilterScoreDescriptor<T> : IQuery where T : class
2020

2121
public FilterScoreDescriptor<T> Boost(float boost)
2222
{
23-
boost.ThrowIfNull("boost");
2423
this._Boost = boost;
2524

2625
return this;
2726
}
2827

2928
public FilterScoreDescriptor<T> Script(string script)
3029
{
31-
script.ThrowIfNull("script");
3230
this._Script = script;
3331

3432
return this;

Diff for: src/Nest/DSL/Query/MatchQueryDescriptor.cs

-1
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ public MatchQueryDescriptor<T> Rewrite(RewriteMultiTerm rewrite)
9797

9898
public MatchQueryDescriptor<T> Boost(double boost)
9999
{
100-
boost.ThrowIfNull("boost");
101100
this._Boost = boost;
102101
return this;
103102
}

Diff for: src/Nest/DSL/Query/MultiMatchQueryDescriptor.cs

-8
Original file line numberDiff line numberDiff line change
@@ -85,51 +85,43 @@ public MultiMatchQueryDescriptor<T> QueryString(string queryString)
8585
}
8686
public MultiMatchQueryDescriptor<T> Analyzer(string analyzer)
8787
{
88-
analyzer.ThrowIfNullOrEmpty("analyzer");
8988
this._Analyzer = analyzer;
9089
return this;
9190
}
9291
public MultiMatchQueryDescriptor<T> Fuzziness(double fuzziness)
9392
{
94-
fuzziness.ThrowIfNull("fuzziness");
9593
this._Fuzziness = fuzziness;
9694
return this;
9795
}
9896
public MultiMatchQueryDescriptor<T> CutoffFrequency(double cutoffFrequency)
9997
{
100-
cutoffFrequency.ThrowIfNull("cutoffFrequency");
10198
this._CutoffFrequency = cutoffFrequency;
10299
return this;
103100
}
104101

105102
public MultiMatchQueryDescriptor<T> Rewrite(RewriteMultiTerm rewrite)
106103
{
107-
rewrite.ThrowIfNull("rewrite");
108104
this._Rewrite = rewrite;
109105
return this;
110106
}
111107

112108
public MultiMatchQueryDescriptor<T> Boost(double boost)
113109
{
114-
boost.ThrowIfNull("boost");
115110
this._Boost = boost;
116111
return this;
117112
}
118113
public MultiMatchQueryDescriptor<T> PrefixLength(int prefixLength)
119114
{
120-
prefixLength.ThrowIfNull("prefixLength");
121115
this._PrefixLength = prefixLength;
122116
return this;
123117
}
124118
public MultiMatchQueryDescriptor<T> MaxExpansions(int maxExpansions)
125119
{
126-
maxExpansions.ThrowIfNull("maxExpansions");
127120
this._MaxExpansions = maxExpansions;
128121
return this;
129122
}
130123
public MultiMatchQueryDescriptor<T> Slop(int slop)
131124
{
132-
slop.ThrowIfNull("slop");
133125
this._Slop = slop;
134126
return this;
135127
}

Diff for: src/Nest/DSL/Query/TextQueryDescriptor.cs

-6
Original file line numberDiff line numberDiff line change
@@ -68,37 +68,31 @@ public TextQueryDescriptor<T> QueryString(string queryString)
6868
}
6969
public TextQueryDescriptor<T> Analyzer(string analyzer)
7070
{
71-
analyzer.ThrowIfNullOrEmpty("analyzer");
7271
this._Analyzer = analyzer;
7372
return this;
7473
}
7574
public TextQueryDescriptor<T> Fuzziness(double fuzziness)
7675
{
77-
fuzziness.ThrowIfNull("fuzziness");
7876
this._Fuzziness = fuzziness;
7977
return this;
8078
}
8179
public TextQueryDescriptor<T> Boost(double boost)
8280
{
83-
boost.ThrowIfNull("boost");
8481
this._Boost = boost;
8582
return this;
8683
}
8784
public TextQueryDescriptor<T> PrefixLength(int prefixLength)
8885
{
89-
prefixLength.ThrowIfNull("prefixLength");
9086
this._PrefixLength = prefixLength;
9187
return this;
9288
}
9389
public TextQueryDescriptor<T> MaxExpansions(int maxExpansions)
9490
{
95-
maxExpansions.ThrowIfNull("maxExpansions");
9691
this._MaxExpansions = maxExpansions;
9792
return this;
9893
}
9994
public TextQueryDescriptor<T> Slop(int slop)
10095
{
101-
slop.ThrowIfNull("slop");
10296
this._Slop = slop;
10397
return this;
10498
}

0 commit comments

Comments
 (0)