Class NotNullPattern<T>
Defines the pattern matching on any non-null instance of the provided type.
public sealed record NotNullPattern<T> : Pattern<T?>, IEquatable<Pattern>, IEquatable<Pattern<T?>>, IEquatable<NotNullPattern<T>>
Type Parameters
TThe type of values to match.
- Inheritance
-
Pattern<T>NotNullPattern<T>
- Implements
-
IEquatable<Pattern<T>>
- Inherited Members
Constructors
NotNullPattern()
public NotNullPattern()
Properties
EqualityContract
protected override Type EqualityContract { get; }
Property Value
Instance
Gets the singleton instance of the NotNullPattern<T> class.
public static NotNullPattern<T> Instance { get; }
Property Value
Methods
Equals(NotNullPattern<T>?)
public bool Equals(NotNullPattern<T>? other)
Parameters
otherNotNullPattern<T>
Returns
Equals(Pattern<T?>?)
public override sealed bool Equals(Pattern<T?>? other)
Parameters
otherPattern<T>
Returns
Equals(object?)
public override bool Equals(object? obj)
Parameters
objobject
Returns
Format(IndentedTextWriter)
Serializes the pattern to a readable string.
public override void Format(IndentedTextWriter writer)
Parameters
writerIndentedTextWriterThe output stream.
GetHashCode()
public override int GetHashCode()
Returns
Match(T?, MatchingContext)
Attempts to match the provided input to the pattern.
public override IMatchNode<T?>? Match(T? input, MatchingContext context)
Parameters
inputTThe input to match.
contextMatchingContextThe context in which to match the pattern to.
Returns
- IMatchNode<T>
When successful, returns the root node of the match tree, otherwise
null.
PrintMembers(StringBuilder)
protected override bool PrintMembers(StringBuilder builder)
Parameters
builderStringBuilder
Returns
Operators
operator ==(NotNullPattern<T>?, NotNullPattern<T>?)
public static bool operator ==(NotNullPattern<T>? left, NotNullPattern<T>? right)
Parameters
leftNotNullPattern<T>rightNotNullPattern<T>
Returns
operator !=(NotNullPattern<T>?, NotNullPattern<T>?)
public static bool operator !=(NotNullPattern<T>? left, NotNullPattern<T>? right)
Parameters
leftNotNullPattern<T>rightNotNullPattern<T>