Last active
February 27, 2018 10:32
-
-
Save l-ray/724ee7bf3a7faaa33603 to your computer and use it in GitHub Desktop.
Find all properties of an gosu entity
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
uses gw.lang.reflect.IPropertyInfo | |
var propertyList = entity.Entity.TypeInfo.Properties.toArray() | |
propertyList = propertyList.sort( \ elt1, elt2 -> elt1.toString() < elt2.toString()) | |
propertyList = propertyList.where( \ elt -> elt.toString().matches(".*[a-z]+.*")) | |
propertyList = propertyList.where( \ elt -> not ((elt as IPropertyInfo).Hidden or (elt as IPropertyInfo).Internal)) | |
print("Found entity properties ("+propertyList.Count+"):") | |
for(myProperty in propertyList) { | |
var isArrayAlike = (myProperty as IPropertyInfo).FeatureType.Interfaces?.first() | |
?.toString()?.startsWith("java.util.Collection") or (myProperty as IPropertyInfo).FeatureType.Array | |
print(myProperty.toString() + (isArrayAlike ? "[]" : "" )) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment