I don’t know what types.DocumentType is, but I’m doing an integration of an sdk and I created a cordova plugin. the import from the sdk is like this:
JavaScript
x
import exemple.types.DocumentType;
example.open(DocumentType.RG_FRENTE, myListener);
Can I somehow pass RG_FRENTE dynamically as it is done in javascript?
Something like:
JavaScript
example.open(DocumentType[my_parameter], myListener);
Advertisement
Answer
This solution is only if DocumentType is enum class like below.
JavaScript
enum DocumentType {
RG_FRENTE,
RG_ETNERF;
}
You can directly get by the valueOf
method like below.
JavaScript
DocumentType docType = DocumentType.valueOf("RG_ETNERF");
Or like this, if you have it in variable.
JavaScript
String type = "RG_ETNERF";
DocumentType docType = DocumentType.valueOf(type);