IKVM11  11
Java SE 11 Virtual Machine for .NET
Loading...
Searching...
No Matches
JavaUnqualifiedTypeName.cs
Go to the documentation of this file.
1using System;
2
4
6{
7
12 {
13
14 public static JavaUnqualifiedTypeName Empty => new(ReadOnlyMemory<char>.Empty);
15
16 public static implicit operator string(JavaUnqualifiedTypeName typeName) => typeName.ToString();
17 public static implicit operator JavaUnqualifiedTypeName(string typeName) => new(typeName);
18
19 public static implicit operator ReadOnlyMemory<char>(JavaUnqualifiedTypeName typeName) => typeName.value;
20 public static implicit operator JavaUnqualifiedTypeName(ReadOnlyMemory<char> typeName) => new(typeName);
21
22 public static bool operator ==(JavaUnqualifiedTypeName a, JavaUnqualifiedTypeName b) => a.value.Span.Equals(b.value.Span, StringComparison.Ordinal);
23 public static bool operator !=(JavaUnqualifiedTypeName a, JavaUnqualifiedTypeName b) => a.value.Span.Equals(b.value.Span, StringComparison.Ordinal) == false;
24
25 readonly ReadOnlyMemory<char> value;
26
32 this(value.AsMemory())
33 {
34 if (value is null)
35 throw new ArgumentNullException(nameof(value));
36 }
37
42 public JavaUnqualifiedTypeName(ReadOnlyMemory<char> value)
43 {
44 this.value = value;
45 }
46
50 public ReadOnlyMemory<char> Value => value;
51
55 public bool IsEmpty => value.IsEmpty;
56
60 public bool IsInnerClass => value.Span.LastIndexOf('$') != -1;
61
65 public bool IsNestedClass => value.Span.LastIndexOf('$') is int i && i != -1 && i + 1 < value.Length && char.IsNumber(value.Span[i + 1]) == false;
66
70 public bool IsAnonymousClass => value.Span.LastIndexOf('$') is int i && i != -1 && i + 1 < value.Length && value.Slice(i + 1).Span.OnlyNumbers();
71
75 public bool IsLocalClass => value.Span.LastIndexOf('$') is int i && i != -1 && i + 2 < value.Length && char.IsNumber(value.Span[i + 1]) && value.Slice(i + 1).Span.OnlyNumbers() == false;
76
82 public bool Equals(JavaUnqualifiedTypeName other) => value.Span.Equals(other.value.Span, StringComparison.Ordinal);
83
89 public override bool Equals(object obj) => false;
90
95 public override int GetHashCode() => value.Span.GetHashCodeExtension();
96
101 public override string ToString() => value.Span.ToString();
102
103 }
104
105}
Provides methods to parse a Java class name without package.
bool IsAnonymousClass
Returns true if this name represents an anonymous class.
override string ToString()
Returns a string instance of the type name.
bool IsInnerClass
Returns true if this name represents an inner class of another class.
bool IsEmpty
Returns true if this type name is empty.
static bool operator!=(JavaUnqualifiedTypeName a, JavaUnqualifiedTypeName b)
bool Equals(JavaUnqualifiedTypeName other)
Returns true if the two objects are equal.
bool IsLocalClass
Returns true if this name represents a local class.
ReadOnlyMemory< char > Value
Gets the underlying value of the type name.
static bool operator==(JavaUnqualifiedTypeName a, JavaUnqualifiedTypeName b)
JavaUnqualifiedTypeName(string value)
Initializes a new instance.
JavaUnqualifiedTypeName(ReadOnlyMemory< char > value)
Initializes a new instance.
bool IsNestedClass
Returns true if this name represents a nested class.
override bool Equals(object obj)
Returns true if the two objects are equal.
override int GetHashCode()
Gets the hash code of this type name.