get Singleton
Lookup a singleton entity by name. If the singleton entity does not exist it indicates a fundamental implementation problem,
therefore a non-catchable PanicException will be thrown, and the app intentionally crashes.
The reason behind this drastic behaviour is to avoid mismatch between server and client.
It is still possible to avoid the PanicException by looking up simplet types before calling this method like in the
following code snippet:
Note that OData singleton entities are represented by entity sets where {@link com.sap.cloud.mobile.kotlin.odata.EntitySet#isSingleton EntitySet.isSingleton} is true.
- Example checking if a ingleton entity exists:
open fun checkSingletonExistsExample(): kotlin.Unit { val csdlDocument = this.service.metadata; if (csdlDocument.singletons.has("Microsoft.OData.Service.Sample.TrippinInMemory.Models.Container/Me")) { Ignore.valueOf_any(csdlDocument.getSingleton("Microsoft.OData.Service.Sample.TrippinInMemory.Models.Container/Me")); } else { // The entity set Microsoft.OData.Service.Sample.TrippinInMemory.Models.Container/Me does not exists, add logic to handle the issue/throw an Exception, etc.. } }
- See Also:
-
{@link com.sap.cloud.mobile.kotlin.odata.csdl.CsdlDocument#entitySets CsdlDocument.entitySets}, for looking up sets that might not exist.
Return
The entity set, which must exist.
Parameters
Name of the entity set to be returned.