I have an interface called Bar
and a generic class Foo
parameterized on a type that is a Bar
:
class Foo<B extends Bar> { }
My class has a general purpose constructor that takes a Class
and a Stream
:
class Foo<B extends Bar> {
B[] bs;
Foo(Class<B> clazz, Stream<B> stream) { // General ctor
bs = someFunctionOf(clazz, stream);
}
}
I'm trying to add a specialized constructor which is requires that its actual method parameter both is a Bar
and an enum
class such that I can call my general purpose constructor from the special constructor:
class Foo<B extends Bar> {
B[] bs;
Foo(Class<B> clazz, Stream<B> stream) { // General ctor
bs = someFunctionOf(clazz, stream);
}
// FIX THIS ----+
// |
// ˅
Foo(Class<Something> clazz) { // Special ctor
// Can we make this work so Something is a Bar and an enum
// and we can call the other constructor like this?
this(clazz, Arrays.stream(clazz.getEnumConstants());
}
}