1- using JetBrains . Annotations ;
21using JoinRpg . DataModel ;
32
43namespace JoinRpg . Domain ;
54
65public static class PlotExtensions
76{
8- public static IEnumerable < IWorldObject > GetTargets ( [ NotNull ] this PlotElement element )
7+ public static IEnumerable < IWorldObject > GetTargets ( this PlotElement element )
98 {
10- if ( element == null )
11- {
12- throw new ArgumentNullException ( nameof ( element ) ) ;
13- }
9+ ArgumentNullException . ThrowIfNull ( element ) ;
1410
1511 return element . TargetCharacters . Cast < IWorldObject > ( ) . Union ( element . TargetGroups ) ;
1612 }
1713
18- [ NotNull , ItemNotNull ]
19- public static PlotElement [ ] SelectPlots ( [ NotNull ] this Character character , [ NotNull ] IEnumerable < PlotElement > selectMany )
14+ public static PlotElement [ ] SelectPlots ( this Character character , IEnumerable < PlotElement > selectMany )
2015 {
21- if ( character == null )
22- {
23- throw new ArgumentNullException ( nameof ( character ) ) ;
24- }
16+ ArgumentNullException . ThrowIfNull ( character ) ;
2517
26- if ( selectMany == null )
27- {
28- throw new ArgumentNullException ( nameof ( selectMany ) ) ;
29- }
18+ ArgumentNullException . ThrowIfNull ( selectMany ) ;
3019
3120 var groups = character . GetParentGroupsToTop ( ) . Select ( g => g . CharacterGroupId ) ;
3221 return selectMany
@@ -35,18 +24,11 @@ public static PlotElement[] SelectPlots([NotNull] this Character character, [Not
3524 p . TargetGroups . Any ( g => groups . Contains ( g . CharacterGroupId ) ) ) . ToArray ( ) ;
3625 }
3726
38- public static int CountCharacters ( [ NotNull ] this PlotElement element ,
39- [ NotNull , ItemNotNull ] IReadOnlyCollection < Character > characters )
27+ public static int CountCharacters ( this PlotElement element , IReadOnlyCollection < Character > characters )
4028 {
41- if ( element == null )
42- {
43- throw new ArgumentNullException ( nameof ( element ) ) ;
44- }
29+ ArgumentNullException . ThrowIfNull ( element ) ;
4530
46- if ( characters == null )
47- {
48- throw new ArgumentNullException ( nameof ( characters ) ) ;
49- }
31+ ArgumentNullException . ThrowIfNull ( characters ) ;
5032
5133 return characters . Count ( character =>
5234 {
@@ -63,13 +45,12 @@ public static int CountCharacters([NotNull] this PlotElement element,
6345 } ) ;
6446 }
6547
66- [ NotNull ]
67- public static PlotElementTexts LastVersion ( [ NotNull ] this PlotElement e ) => e . Texts . OrderByDescending ( text => text . Version ) . First ( ) ;
48+ public static PlotElementTexts LastVersion ( this PlotElement e ) => e . Texts . OrderByDescending ( text => text . Version ) . First ( ) ;
6849
69- public static PlotElementTexts ? SpecificVersion ( [ NotNull ] this PlotElement e , int version ) => e . Texts . SingleOrDefault ( text => text . Version == version ) ;
50+ public static PlotElementTexts ? SpecificVersion ( this PlotElement e , int version ) => e . Texts . SingleOrDefault ( text => text . Version == version ) ;
7051
7152 //TODO consider return NUll if deleted
72- public static PlotElementTexts ? PublishedVersion ( [ NotNull ] this PlotElement e ) => e . Published != null ? e . SpecificVersion ( ( int ) e . Published ) : null ;
53+ public static PlotElementTexts ? PublishedVersion ( this PlotElement e ) => e . Published != null ? e . SpecificVersion ( ( int ) e . Published ) : null ;
7354
7455 public static PlotElementTexts ? PrevVersion ( this PlotElement e ) => e . Texts . OrderByDescending ( text => text . Version ) . Skip ( 1 ) . FirstOrDefault ( ) ;
7556}
0 commit comments