elye
10/24/2019, 2:27 AM@MapKey(unwrapValue = false)
@interface MyKey {
String name();
Class<?> implementingClass();
int[] thresholds();
}
I can instantiate it
final class MyKeyImpl implements MyKey {
private final String name;
private final Class<?> implementingClass;
private final int[] thresholds;
MyKeyImpl(
String name,
Class<?> implementingClass,
int[] thresholds) {
this.name = name;
this.implementingClass = implementingClass;
this.thresholds = thresholds.clone();
}
@Override
public Class<? extends MyKey> annotationType() { return MyKey.class; }
@Override
public String name() { return name; }
@Override
public Class<?> implementingClass() { return implementingClass; }
@Override
public int[] thresholds() { return thresholds.clone();}
}
If I convert it to Kotlin
@MapKey(unwrapValue = false)
internal annotation class MyKey(val name: String, val implementingClass: KClass<*>, val thresholds: IntArray)
The below converted Kotlin code is not working.
internal class MyKeyImpl(
private val name: String,
private val implementingClass: Class<*>,
thresholds: IntArray) : MyKey {
private val thresholds: IntArray
init { this.thresholds = thresholds.clone() }
override fun annotationType(): Class<out MyKey> { return MyKey::class.java }
override fun name(): String { return name }
override fun implementingClass(): Class<*> { return implementingClass }
override fun thresholds(): IntArray { return thresholds.clone() }
}
bodiam
10/24/2019, 5:51 AMelye
10/24/2019, 11:16 AMMyKey
is final, and can’t be instantiated.Evan R.
10/24/2019, 1:03 PMkarelpeeters
10/24/2019, 1:31 PMEvan R.
10/24/2019, 1:42 PMcedric
10/24/2019, 5:23 PMcedric
10/24/2019, 5:23 PMkarelpeeters
10/24/2019, 5:30 PM