/** * Increase this descriptor's nesting level. * @see MethodParameter#increaseNestingLevel() */ public void increaseNestingLevel() { this.nestingLevel++; this.resolvableType = null; if (this.methodParameter != null) { this.methodParameter.increaseNestingLevel(); } }
/** * Increase this descriptor's nesting level. * @see MethodParameter#increaseNestingLevel() */ public void increaseNestingLevel() { this.nestingLevel++; this.resolvableType = null; if (this.methodParameter != null) { this.methodParameter.increaseNestingLevel(); } }
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { // Rely on default serialization; just initialize state after deserialization. ois.defaultReadObject(); // Restore reflective handles (which are unfortunately not serializable) try { if (this.fieldName != null) { this.field = this.declaringClass.getDeclaredField(this.fieldName); } else { if (this.methodName != null) { this.methodParameter = new MethodParameter( this.declaringClass.getDeclaredMethod(this.methodName, this.parameterTypes), this.parameterIndex); } else { this.methodParameter = new MethodParameter( this.declaringClass.getDeclaredConstructor(this.parameterTypes), this.parameterIndex); } for (int i = 1; i < this.nestingLevel; i++) { this.methodParameter.increaseNestingLevel(); } } } catch (Throwable ex) { throw new IllegalStateException("Could not find original class structure", ex); } }
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { // Rely on default serialization; just initialize state after deserialization. ois.defaultReadObject(); // Restore reflective handles (which are unfortunately not serializable) try { if (this.fieldName != null) { this.field = this.declaringClass.getDeclaredField(this.fieldName); } else { if (this.methodName != null) { this.methodParameter = new MethodParameter( this.declaringClass.getDeclaredMethod(this.methodName, this.parameterTypes), this.parameterIndex); } else { this.methodParameter = new MethodParameter( this.declaringClass.getDeclaredConstructor(this.parameterTypes), this.parameterIndex); } for (int i = 1; i < this.nestingLevel; i++) { this.methodParameter.increaseNestingLevel(); } } } catch (Throwable ex) { throw new IllegalStateException("Could not find original class structure", ex); } }
@Test public void forMethodParameterWithNesting() throws Exception { Method method = Methods.class.getMethod("nested", Map.class); MethodParameter methodParameter = MethodParameter.forExecutable(method, 0); methodParameter.increaseNestingLevel(); ResolvableType type = ResolvableType.forMethodParameter(methodParameter); assertThat(type.resolve(), equalTo((Class) Map.class)); assertThat(type.getGeneric(0).resolve(), equalTo((Class) Byte.class)); assertThat(type.getGeneric(1).resolve(), equalTo((Class) Long.class)); }
@Test public void forMethodParameterWithNestingAndLevels() throws Exception { Method method = Methods.class.getMethod("nested", Map.class); MethodParameter methodParameter = MethodParameter.forExecutable(method, 0); methodParameter.increaseNestingLevel(); methodParameter.setTypeIndexForCurrentLevel(0); ResolvableType type = ResolvableType.forMethodParameter(methodParameter); assertThat(type.resolve(), equalTo((Class) Map.class)); assertThat(type.getGeneric(0).resolve(), equalTo((Class) String.class)); assertThat(type.getGeneric(1).resolve(), equalTo((Class) Integer.class)); }
public void increaseNestingLevel() { this.nestingLevel++; if (this.methodParameter != null) { this.methodParameter.increaseNestingLevel(); } }
private void readObject(ObjectInputStream ois) throws IOException, ClassNotFoundException { // Rely on default serialization; just initialize state after deserialization. ois.defaultReadObject(); // Restore reflective handles (which are unfortunately not serializable) try { if (this.fieldName != null) { this.field = this.declaringClass.getDeclaredField(this.fieldName); } else { if (this.methodName != null) { this.methodParameter = new MethodParameter( this.declaringClass.getDeclaredMethod(this.methodName, this.parameterTypes), this.parameterIndex); } else { this.methodParameter = new MethodParameter( this.declaringClass.getDeclaredConstructor(this.parameterTypes), this.parameterIndex); } for (int i = 1; i < this.nestingLevel; i++) { this.methodParameter.increaseNestingLevel(); } } } catch (Throwable ex) { throw new IllegalStateException("Could not find original class structure", ex); } }
@Override protected AbstractDescriptor nested(Class<?> type, int typeIndex) { MethodParameter methodParameter = new MethodParameter(this.methodParameter); methodParameter.increaseNestingLevel(); methodParameter.setTypeIndexForCurrentLevel(typeIndex); return new ParameterDescriptor(type, methodParameter); }
@Override protected AbstractDescriptor nested(Class<?> type, int typeIndex) { MethodParameter methodParameter = new MethodParameter(this.methodParameter); methodParameter.increaseNestingLevel(); methodParameter.setTypeIndexForCurrentLevel(typeIndex); return new BeanPropertyDescriptor(type, this.property, methodParameter, this.annotations); }
String indexedPropertyName = buildIndexedPropertyName(propertyName, i); if (methodParam != null) { methodParam.increaseNestingLevel();
@Override public Mono<Object> resolveArgument(MethodParameter param, BindingContext bindingContext, ServerWebExchange exchange) { ResolvableType entityType = ResolvableType.forMethodParameter(param); MethodParameter bodyParameter = new MethodParameter(param); bodyParameter.increaseNestingLevel(); return readBody(bodyParameter, false, bindingContext, exchange) .map(body -> createHttpEntity(body, entityType, exchange)) .defaultIfEmpty(createHttpEntity(null, entityType, exchange)); }
String keyedPropertyName = buildKeyedPropertyName(propertyName, key); if (methodParam != null) { methodParam.increaseNestingLevel(); methodParam.setTypeIndexForCurrentLevel(0);
returnValueMono = Mono.from(adapter.toPublisher(optionalValue)); bodyType = new MethodParameter(result.getReturnTypeSource()); bodyType.increaseNestingLevel(); bodyType.increaseNestingLevel(); bodyType.increaseNestingLevel();