Skip to content

Commit

Permalink
More compact index accessors
Browse files Browse the repository at this point in the history
  • Loading branch information
mdesalvo committed Nov 24, 2023
1 parent 7b4f5b3 commit 21a2bb4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 16 deletions.
10 changes: 2 additions & 8 deletions RDFSharp/Model/RDFGraph.cs
Original file line number Diff line number Diff line change
Expand Up @@ -507,14 +507,8 @@ public RDFGraph SelectTriplesByLiteral(RDFLiteral objectLiteral)
/// (null values are threated as * selectors. Ensure to keep object and literal mutually exclusive!)
/// </summary>
public RDFGraph this[RDFResource subj, RDFResource pred, RDFResource obj, RDFLiteral lit]
{
get
{
if (obj != null && lit != null)
throw new RDFModelException("Cannot access a graph when both object and literals are given: they have to be mutually exclusive!");
return new RDFGraph(RDFModelUtilities.SelectTriples(this, subj, pred, obj, lit));
}
}
=> (obj != null && lit != null) ? throw new RDFModelException("Cannot access a graph when both object and literals are given: they must be mutually exclusive!")
: new RDFGraph(RDFModelUtilities.SelectTriples(this, subj, pred, obj, lit));
#endregion

#region Set
Expand Down
10 changes: 2 additions & 8 deletions RDFSharp/Store/Engines/RDFMemoryStore.cs
Original file line number Diff line number Diff line change
Expand Up @@ -603,14 +603,8 @@ public override bool ContainsQuadruple(RDFQuadruple quadruple)
/// (null values are threated as * selectors. Ensure to keep object and literal mutually exclusive!)
/// </summary>
public RDFMemoryStore this[RDFContext ctx, RDFResource subj, RDFResource pred, RDFResource obj, RDFLiteral lit]
{
get
{
if (obj != null && lit != null)
throw new RDFStoreException("Cannot access a store when both object and literals are given: they have to be mutually exclusive!");
return new RDFMemoryStore(RDFStoreUtilities.SelectQuadruples(this, ctx, subj, pred, obj, lit));
}
}
=> (obj != null && lit != null) ? throw new RDFStoreException("Cannot access a memory store when both object and literals are given: they must be mutually exclusive!")
: SelectQuadruples(ctx, subj, pred, obj, lit);

/// <summary>
/// Gets a store containing quadruples satisfying the given pattern
Expand Down

0 comments on commit 21a2bb4

Please sign in to comment.