Can you write a Java code in TypeScript that achieves the same functionality as the code below:
Class<?> meta = Object.class;
and
meta = Processor.class; // Processor is an interface
In TypeScript, what would be the equivalent of .class
? Specifically, in the case of an interface. If Processor were a class, I could simply remove .class
and it has worked for me so far.
Updated Example:
public interface ObjectProcessor {}
public interface StreamCloser {}
public interface Registry {
void register(Object value, Object metadata);
}
public class RegistryImpl implements Registry {
void register(Object value, Object metadata) {}
}
RegistryImpl registry = new RegistryImpl();
Object value = ?; //any value
Class<?> meta = Object.class;
if (value instanceof ObjectProcessor) {
meta = ObjectProcessor.class;
} else if (value instanceof StreamCloser) {
meta = StreamCloser.class;
}
registry.register(value, meta);