I want to design a class that serves as a wrapper around any other class. Let's call this wrapper class Virtual
and it is used as follows:
val x: String = "foo"
val y: Virtual[String] = new Virtual(x)
// any method that can be called on x can also be called on y,
// i.e., Virtual[String] <: String
// example:
y.toUpperCase // will change the wrapped string to an upper case
This is what I have so far:
class Virtual[T](obj: T) extends T {
// any Virtual specific methods here
}
Extending the type parameter does not seem to do the trick...
In other words: How can I ensure that the methods exposed by the class wrapped by Virtual are also exposed by the Virtual class itself?