Skip to content

Commit fbc5766

Browse files
committed
Document the types in QueryExpression hierarchy
1 parent d62327f commit fbc5766

30 files changed

+340
-26
lines changed

src/JsonApiDotNetCore/Queries/Expressions/AnyExpression.cs

+13-1
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,24 @@
66
namespace JsonApiDotNetCore.Queries.Expressions;
77

88
/// <summary>
9-
/// Represents the "any" filter function, resulting from text such as: any(name,'Jack','Joe')
9+
/// This expression allows to test if an attribute value equals any of the specified constants. It represents the "any" filter function, resulting from
10+
/// text such as:
11+
/// <c>
12+
/// any(owner.name,'Jack','Joe','John')
13+
/// </c>
14+
/// .
1015
/// </summary>
1116
[PublicAPI]
1217
public class AnyExpression : FilterExpression
1318
{
19+
/// <summary>
20+
/// The attribute whose value to compare. Chain format: an optional list of to-one relationships, followed by an attribute.
21+
/// </summary>
1422
public ResourceFieldChainExpression TargetAttribute { get; }
23+
24+
/// <summary>
25+
/// One or more constants to compare the attribute's value against.
26+
/// </summary>
1527
public IImmutableSet<LiteralConstantExpression> Constants { get; }
1628

1729
public AnyExpression(ResourceFieldChainExpression targetAttribute, IImmutableSet<LiteralConstantExpression> constants)

src/JsonApiDotNetCore/Queries/Expressions/ComparisonExpression.cs

+26-1
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,38 @@
44
namespace JsonApiDotNetCore.Queries.Expressions;
55

66
/// <summary>
7-
/// Represents a comparison filter function, resulting from text such as: equals(name,'Joe')
7+
/// This expression allows to compare two operands using a comparison operator. It represents comparison filter functions, resulting from text such as:
8+
/// <c>
9+
/// equals(name,'Joe')
10+
/// </c>
11+
/// ,
12+
/// <c>
13+
/// equals(owner,null)
14+
/// </c>
15+
/// , or:
16+
/// <c>
17+
/// greaterOrEqual(count(upVotes),count(downVotes),'1')
18+
/// </c>
19+
/// .
820
/// </summary>
921
[PublicAPI]
1022
public class ComparisonExpression : FilterExpression
1123
{
24+
/// <summary>
25+
/// The operator used to compare <see cref="Left" /> and <see cref="Right" />.
26+
/// </summary>
1227
public ComparisonOperator Operator { get; }
28+
29+
/// <summary>
30+
/// The left-hand operand, which can be a function or a field chain. Chain format: an optional list of to-one relationships, followed by an attribute.
31+
/// When comparing equality with null, the chain may also end in a to-one relationship.
32+
/// </summary>
1333
public QueryExpression Left { get; }
34+
35+
/// <summary>
36+
/// The right-hand operand, which can be a function, a field chain, a constant, or null (if the type of <see cref="Left" /> is nullable). Chain format:
37+
/// an optional list of to-one relationships, followed by an attribute.
38+
/// </summary>
1439
public QueryExpression Right { get; }
1540

1641
public ComparisonExpression(ComparisonOperator @operator, QueryExpression left, QueryExpression right)

src/JsonApiDotNetCore/Queries/Expressions/CountExpression.cs

+12-1
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,24 @@
44
namespace JsonApiDotNetCore.Queries.Expressions;
55

66
/// <summary>
7-
/// Represents the "count" function, resulting from text such as: count(articles)
7+
/// This expression allows to determine the number of related resources in a to-many relationship. It represents the "count" function, resulting from
8+
/// text such as:
9+
/// <c>
10+
/// count(articles)
11+
/// </c>
12+
/// .
813
/// </summary>
914
[PublicAPI]
1015
public class CountExpression : FunctionExpression
1116
{
17+
/// <summary>
18+
/// The to-many relationship to count related resources for. Chain format: an optional list of to-one relationships, followed by a to-many relationship.
19+
/// </summary>
1220
public ResourceFieldChainExpression TargetCollection { get; }
1321

22+
/// <summary>
23+
/// The CLR type this function returns, which is always <see cref="int" />.
24+
/// </summary>
1425
public override Type ReturnType { get; } = typeof(int);
1526

1627
public CountExpression(ResourceFieldChainExpression targetCollection)

src/JsonApiDotNetCore/Queries/Expressions/FilterExpression.cs

+3
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@ namespace JsonApiDotNetCore.Queries.Expressions;
55
/// </summary>
66
public abstract class FilterExpression : FunctionExpression
77
{
8+
/// <summary>
9+
/// The CLR type this function returns, which is always <see cref="bool" />.
10+
/// </summary>
811
public override Type ReturnType { get; } = typeof(bool);
912
}

src/JsonApiDotNetCore/Queries/Expressions/FunctionExpression.cs

+3
Original file line numberDiff line numberDiff line change
@@ -5,5 +5,8 @@ namespace JsonApiDotNetCore.Queries.Expressions;
55
/// </summary>
66
public abstract class FunctionExpression : QueryExpression
77
{
8+
/// <summary>
9+
/// The CLR type this function returns.
10+
/// </summary>
811
public abstract Type ReturnType { get; }
912
}

src/JsonApiDotNetCore/Queries/Expressions/HasExpression.cs

+18-1
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,29 @@
55
namespace JsonApiDotNetCore.Queries.Expressions;
66

77
/// <summary>
8-
/// Represents the "has" filter function, resulting from text such as: has(articles) or has(articles,equals(isHidden,'false'))
8+
/// This expression allows to test if a to-many relationship has related resources, optionally with a condition. It represents the "has" filter function,
9+
/// resulting from text such as:
10+
/// <c>
11+
/// has(articles)
12+
/// </c>
13+
/// , or:
14+
/// <c>
15+
/// has(articles,equals(isHidden,'false'))
16+
/// </c>
17+
/// .
918
/// </summary>
1019
[PublicAPI]
1120
public class HasExpression : FilterExpression
1221
{
22+
/// <summary>
23+
/// The to-many relationship to determine related resources for. Chain format: an optional list of to-one relationships, followed by a to-many
24+
/// relationship.
25+
/// </summary>
1326
public ResourceFieldChainExpression TargetCollection { get; }
27+
28+
/// <summary>
29+
/// An optional filter that is applied on the related resources. Any related resources that do not match the filter are ignored.
30+
/// </summary>
1431
public FilterExpression? Filter { get; }
1532

1633
public HasExpression(ResourceFieldChainExpression targetCollection, FilterExpression? filter)

src/JsonApiDotNetCore/Queries/Expressions/IdentifierExpression.cs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
namespace JsonApiDotNetCore.Queries.Expressions;
22

33
/// <summary>
4-
/// Represents the base type for an identifier, such as a field/relationship name, a constant between quotes or <c>null</c>.
4+
/// Represents the base type for an identifier, such as a JSON:API attribute/relationship name, a constant value between quotes, or <c>null</c>.
55
/// </summary>
66
public abstract class IdentifierExpression : QueryExpression
77
{

src/JsonApiDotNetCore/Queries/Expressions/IncludeElementExpression.cs

+12-1
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,23 @@
66
namespace JsonApiDotNetCore.Queries.Expressions;
77

88
/// <summary>
9-
/// Represents an element in <see cref="IncludeExpression" />.
9+
/// Represents an element in an <see cref="IncludeExpression" /> tree, resulting from text such as:
10+
/// <c>
11+
/// articles.revisions
12+
/// </c>
13+
/// .
1014
/// </summary>
1115
[PublicAPI]
1216
public class IncludeElementExpression : QueryExpression
1317
{
18+
/// <summary>
19+
/// The JSON:API relationship to include.
20+
/// </summary>
1421
public RelationshipAttribute Relationship { get; }
22+
23+
/// <summary>
24+
/// The direct children of this subtree. Can be empty.
25+
/// </summary>
1526
public IImmutableSet<IncludeElementExpression> Children { get; }
1627

1728
public IncludeElementExpression(RelationshipAttribute relationship)

src/JsonApiDotNetCore/Queries/Expressions/IncludeExpression.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,11 @@
44
namespace JsonApiDotNetCore.Queries.Expressions;
55

66
/// <summary>
7-
/// Represents an inclusion tree, resulting from text such as: owner,articles.revisions
7+
/// Represents an inclusion tree, resulting from text such as:
8+
/// <c>
9+
/// owner,articles.revisions
10+
/// </c>
11+
/// .
812
/// </summary>
913
[PublicAPI]
1014
public class IncludeExpression : QueryExpression
@@ -13,6 +17,9 @@ public class IncludeExpression : QueryExpression
1317

1418
public static readonly IncludeExpression Empty = new();
1519

20+
/// <summary>
21+
/// The direct children of this tree. Use <see cref="Empty" /> if there are no children.
22+
/// </summary>
1623
public IImmutableSet<IncludeElementExpression> Elements { get; }
1724

1825
public IncludeExpression(IImmutableSet<IncludeElementExpression> elements)

src/JsonApiDotNetCore/Queries/Expressions/IsTypeExpression.cs

+24-1
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,37 @@
66
namespace JsonApiDotNetCore.Queries.Expressions;
77

88
/// <summary>
9-
/// Represents the "isType" filter function, resulting from text such as: isType(,men), isType(creator,men) or
9+
/// This expression allows to test if a resource in an inheritance hierarchy can be upcast to a derived type, optionally with a condition where the
10+
/// derived type is accessible. It represents the "isType" filter function, resulting from text such as:
11+
/// <c>
12+
/// isType(,men)
13+
/// </c>
14+
/// ,
15+
/// <c>
16+
/// isType(creator,men)
17+
/// </c>
18+
/// , or:
19+
/// <c>
1020
/// isType(creator,men,equals(hasBeard,'true'))
21+
/// </c>
22+
/// .
1123
/// </summary>
1224
[PublicAPI]
1325
public class IsTypeExpression : FilterExpression
1426
{
27+
/// <summary>
28+
/// An optional to-one relationship to start from. Chain format: one or more to-one relationships.
29+
/// </summary>
1530
public ResourceFieldChainExpression? TargetToOneRelationship { get; }
31+
32+
/// <summary>
33+
/// The derived resource type to upcast to.
34+
/// </summary>
1635
public ResourceType DerivedType { get; }
36+
37+
/// <summary>
38+
/// An optional filter that the derived resource must match.
39+
/// </summary>
1740
public FilterExpression? Child { get; }
1841

1942
public IsTypeExpression(ResourceFieldChainExpression? targetToOneRelationship, ResourceType derivedType, FilterExpression? child)

src/JsonApiDotNetCore/Queries/Expressions/LiteralConstantExpression.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,17 @@
44
namespace JsonApiDotNetCore.Queries.Expressions;
55

66
/// <summary>
7-
/// Represents a non-null constant value, resulting from text such as: equals(firstName,'Jack')
7+
/// Represents a non-null constant value, resulting from text such as: <c>'Jack'</c>, <c>'123'</c>, or: <c>'true'</c>.
88
/// </summary>
99
[PublicAPI]
1010
public class LiteralConstantExpression : IdentifierExpression
1111
{
1212
// Only used to show the original input in errors and diagnostics. Not part of the semantic expression value.
1313
private readonly string _stringValue;
1414

15+
/// <summary>
16+
/// The constant value. Call <see cref="object.GetType()" /> to determine the .NET runtime type.
17+
/// </summary>
1518
public object TypedValue { get; }
1619

1720
public LiteralConstantExpression(object typedValue)

src/JsonApiDotNetCore/Queries/Expressions/LogicalExpression.cs

+17-1
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,28 @@
66
namespace JsonApiDotNetCore.Queries.Expressions;
77

88
/// <summary>
9-
/// Represents a logical filter function, resulting from text such as: and(equals(title,'Work'),has(articles))
9+
/// This expression allows to test whether one or all of its boolean operands are true. It represents the logical AND/OR filter functions, resulting from
10+
/// text such as:
11+
/// <c>
12+
/// and(equals(title,'Work'),has(articles))
13+
/// </c>
14+
/// , or:
15+
/// <c>
16+
/// or(equals(title,'Work'),has(articles))
17+
/// </c>
18+
/// .
1019
/// </summary>
1120
[PublicAPI]
1221
public class LogicalExpression : FilterExpression
1322
{
23+
/// <summary>
24+
/// The operator used to compare <see cref="Terms" />.
25+
/// </summary>
1426
public LogicalOperator Operator { get; }
27+
28+
/// <summary>
29+
/// The list of one or more boolean operands.
30+
/// </summary>
1531
public IImmutableList<FilterExpression> Terms { get; }
1632

1733
public LogicalExpression(LogicalOperator @operator, params FilterExpression[] terms)

src/JsonApiDotNetCore/Queries/Expressions/MatchTextExpression.cs

+25-1
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,37 @@
55
namespace JsonApiDotNetCore.Queries.Expressions;
66

77
/// <summary>
8-
/// Represents a text-matching filter function, resulting from text such as: startsWith(name,'A')
8+
/// This expression allows partial matching on the value of a JSON:API attribute. It represents text-matching filter functions, resulting from text such
9+
/// as:
10+
/// <c>
11+
/// startsWith(name,'The')
12+
/// </c>
13+
/// ,
14+
/// <c>
15+
/// endsWith(name,'end.')
16+
/// </c>
17+
/// , or:
18+
/// <c>
19+
/// contains(name,'middle')
20+
/// </c>
21+
/// .
922
/// </summary>
1023
[PublicAPI]
1124
public class MatchTextExpression : FilterExpression
1225
{
26+
/// <summary>
27+
/// The attribute whose value to match. Chain format: an optional list of to-one relationships, followed by an attribute.
28+
/// </summary>
1329
public ResourceFieldChainExpression TargetAttribute { get; }
30+
31+
/// <summary>
32+
/// The text to match the attribute's value against.
33+
/// </summary>
1434
public LiteralConstantExpression TextValue { get; }
35+
36+
/// <summary>
37+
/// The kind of matching to perform.
38+
/// </summary>
1539
public TextMatchKind MatchKind { get; }
1640

1741
public MatchTextExpression(ResourceFieldChainExpression targetAttribute, LiteralConstantExpression textValue, TextMatchKind matchKind)

src/JsonApiDotNetCore/Queries/Expressions/NotExpression.cs

+8-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,18 @@
44
namespace JsonApiDotNetCore.Queries.Expressions;
55

66
/// <summary>
7-
/// Represents the "not" filter function, resulting from text such as: not(equals(title,'Work'))
7+
/// This expression allows to test for the logical negation of its operand. It represents the "not" filter function, resulting from text such as:
8+
/// <c>
9+
/// not(equals(title,'Work'))
10+
/// </c>
11+
/// .
812
/// </summary>
913
[PublicAPI]
1014
public class NotExpression : FilterExpression
1115
{
16+
/// <summary>
17+
/// The filter whose value to negate.
18+
/// </summary>
1219
public FilterExpression Child { get; }
1320

1421
public NotExpression(FilterExpression child)

src/JsonApiDotNetCore/Queries/Expressions/NullConstantExpression.cs

+4-1
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@
44
namespace JsonApiDotNetCore.Queries.Expressions;
55

66
/// <summary>
7-
/// Represents the constant <c>null</c>, resulting from text such as: equals(lastName,null)
7+
/// Represents the constant <c>null</c>, resulting from the text: <c>null</c>.
88
/// </summary>
99
[PublicAPI]
1010
public class NullConstantExpression : IdentifierExpression
1111
{
12+
/// <summary>
13+
/// Provides access to the singleton instance.
14+
/// </summary>
1215
public static readonly NullConstantExpression Instance = new();
1316

1417
private NullConstantExpression()

src/JsonApiDotNetCore/Queries/Expressions/PaginationElementQueryStringValueExpression.cs

+16-1
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,28 @@
33
namespace JsonApiDotNetCore.Queries.Expressions;
44

55
/// <summary>
6-
/// Represents an element in <see cref="PaginationQueryStringValueExpression" />.
6+
/// Represents an element in <see cref="PaginationQueryStringValueExpression" />, resulting from text such as: <c>1</c>, or:
7+
/// <c>
8+
/// articles:2
9+
/// </c>
10+
/// .
711
/// </summary>
812
[PublicAPI]
913
public class PaginationElementQueryStringValueExpression : QueryExpression
1014
{
15+
/// <summary>
16+
/// The relationship this pagination applies to. Chain format: zero or more relationships, followed by a to-many relationship.
17+
/// </summary>
1118
public ResourceFieldChainExpression? Scope { get; }
19+
20+
/// <summary>
21+
/// The numeric pagination value.
22+
/// </summary>
1223
public int Value { get; }
24+
25+
/// <summary>
26+
/// The zero-based position in the text of the query string parameter value.
27+
/// </summary>
1328
public int Position { get; }
1429

1530
public PaginationElementQueryStringValueExpression(ResourceFieldChainExpression? scope, int value, int position)

0 commit comments

Comments
 (0)