@Override @SuppressWarnings("unchecked") public <T> T unwrap(@Nullable Class<T> type) { if (type == null || !ValidatorFactory.class.isAssignableFrom(type)) { try { return super.unwrap(type); } catch (ValidationException ex) { // ignore - we'll try ValidatorFactory unwrapping next } } if (this.validatorFactory != null) { try { return this.validatorFactory.unwrap(type); } catch (ValidationException ex) { // ignore if just being asked for ValidatorFactory if (ValidatorFactory.class == type) { return (T) this.validatorFactory; } throw ex; } } throw new ValidationException("Cannot unwrap to " + type); }
@Override @SuppressWarnings("unchecked") public <T> T unwrap(@Nullable Class<T> type) { if (type == null || !ValidatorFactory.class.isAssignableFrom(type)) { try { return super.unwrap(type); } catch (ValidationException ex) { // ignore - we'll try ValidatorFactory unwrapping next } } if (this.validatorFactory != null) { try { return this.validatorFactory.unwrap(type); } catch (ValidationException ex) { // ignore if just being asked for ValidatorFactory if (ValidatorFactory.class == type) { return (T) this.validatorFactory; } throw ex; } } throw new ValidationException("Cannot unwrap to " + type); }
@Test public void testUnwrap() { Validator nativeValidator = validatorAdapter.unwrap(Validator.class); assertSame(this.nativeValidator, nativeValidator); }
@Test public void testUnwrap() { Validator nativeValidator = validatorAdapter.unwrap(Validator.class); assertSame(this.nativeValidator, nativeValidator); }
@Override @SuppressWarnings("unchecked") public <T> T unwrap(@Nullable Class<T> type) { if (type == null || !ValidatorFactory.class.isAssignableFrom(type)) { try { return super.unwrap(type); } catch (ValidationException ex) { // ignore - we'll try ValidatorFactory unwrapping next } } if (this.validatorFactory != null) { try { return this.validatorFactory.unwrap(type); } catch (ValidationException ex) { // ignore if just being asked for ValidatorFactory if (ValidatorFactory.class == type) { return (T) this.validatorFactory; } throw ex; } } throw new ValidationException("Cannot unwrap to " + type); }