'java.lang.Class' provides 'isRecord' method which returns true if and only if this class is a record class, otherwise false.
Signature
public boolean isRecord()
Point.java
package com.sample.app.reflections;
public record Point(int x, int y) {
}
RecordTypeCheck.java
package com.sample.app.reflections;
public class RecordTypeCheck {
public static void main(String[] args) {
boolean isRecord = Point.class.isRecord();
System.out.println("Is Point record type? " + isRecord);
}
}
Output
Is Point record type? true
References
No comments:
Post a Comment