use of com.hazelcast.test.starter.constructor.EnumConstructor in project hazelcast by hazelcast.
the class EnumConstructorTest method testConstructor.
@Test
public void testConstructor() {
EnumConstructor constructor = new EnumConstructor(TestEnum.class);
assertEquals(TestEnum.FOO, constructor.createNew(TestEnum.FOO));
assertEquals(TestEnum.BAR, constructor.createNew(TestEnum.BAR));
}
use of com.hazelcast.test.starter.constructor.EnumConstructor in project hazelcast by hazelcast.
the class HazelcastProxyFactory method construct.
private static Object construct(Class<?> clazz, Object delegate) {
ConstructorFunction<Object, Object> constructorFunction = CONSTRUCTORS.applyIfAbsent(clazz, input -> {
String className = input.getName();
Constructor<ConstructorFunction<Object, Object>> constructor = NO_PROXYING_WHITELIST.get(className);
if (constructor != null) {
try {
return constructor.newInstance(input);
} catch (Exception e) {
throw new IllegalStateException(e);
}
} else if (input.isEnum()) {
return new EnumConstructor(input);
}
throw new UnsupportedOperationException("Cannot construct target object for target " + input + " on classloader " + input.getClassLoader());
});
return constructorFunction.createNew(delegate);
}
Aggregations