VMware Cloud Community
mcfadyenj
Hot Shot
Hot Shot
Jump to solution

print object types

is it possible to return and objects type

I am aware of the

if (blah instanceof  string == true)

but I would like to do something like

System.debug ("your object type is : " + blah.objectype)

output expected would be

  your object type is: string

the reason I need this is I have a couple of instances where I believe I am passing in the correct object types but the actions are failing based on instanceof error handling detecting the wrong object types.

I believe the objects are of the correct type but I can't prove or disprove it.

Reply
0 Kudos
1 Solution

Accepted Solutions
tschoergez
Leadership
Leadership
Jump to solution

usually there is the System.getObjectType()-method. But unfotunately it does not work always (don't know if bug or by-design ).

But you can just log-out the object itself, and it will show you the type.

Example (both):

var custSpec = new VcCustomizationSpec();
custSpec.identity = new VcCustomizationIdentitySettings();
System.debug(System.getObjectType(custSpec));
System.debug(custSpec);

gives:

[2011-04-29 08:33:16.664] [D] null
[2011-04-29 08:33:16.665] [D] DynamicWrapper (Instance) : [VcCustomizationSpec]-[class com.vmware.vim.vi4.CustomizationSpec] -- VALUE : com.vmware.vim.vi4.CustomizationSpec@2...

Regards,

Joerg

View solution in original post

Reply
0 Kudos
2 Replies
cdecanini_
VMware Employee
VMware Employee
Jump to solution

Hi,

Use System.getObjectType(blah);

You can also use System.getObjectClassName(blah) -> This fixes Joerg null issue.

Christophe.

If my answer resolved or helped you, please mark it as Correct or Helpful to award points. Thank you! Visit http://www.vcoteam.info & http://blogs.vmware.com/orchestrator for vCenter Orchestrator tips and tutorials - @vCOTeam on Twitter
tschoergez
Leadership
Leadership
Jump to solution

usually there is the System.getObjectType()-method. But unfotunately it does not work always (don't know if bug or by-design ).

But you can just log-out the object itself, and it will show you the type.

Example (both):

var custSpec = new VcCustomizationSpec();
custSpec.identity = new VcCustomizationIdentitySettings();
System.debug(System.getObjectType(custSpec));
System.debug(custSpec);

gives:

[2011-04-29 08:33:16.664] [D] null
[2011-04-29 08:33:16.665] [D] DynamicWrapper (Instance) : [VcCustomizationSpec]-[class com.vmware.vim.vi4.CustomizationSpec] -- VALUE : com.vmware.vim.vi4.CustomizationSpec@2...

Regards,

Joerg

Reply
0 Kudos