jodd-proxetta/src/main/java/jodd/pathref/Pathref.java
@SuppressWarnings("unchecked")
	public <T> T continueWith(final Object currentInstance, final String methodName, final Class<T> target) {
		Class currentClass = currentInstance.getClass();

		Method method;

		try {
			method = currentClass.getDeclaredMethod(methodName);
		}
		catch (NoSuchMethodException e) {
			throw new PathrefException("Not a getter: " + methodName, e);
		}

		if (!ClassUtil.isBeanPropertyGetter(method)) {
			throw new PathrefException("Not a getter: " + methodName);
		}

		String getterName = ClassUtil.getBeanPropertyGetterName(method);

		append(getterName);

		if (ClassUtil.isTypeOf(target, List.class)) {
			final Class componentType =
				ClassUtil.getComponentType(method.getGenericReturnType(), currentClass, 0);

			if (componentType == null) {
				throw new PathrefException("Unknown component name for: " + methodName);
			}

			return (T) new ArrayList() {
				@Override
				public Object get(final int index) {
					if (index >= 0) {
						append("[" + index + "]");
					}
					return new Pathref<>(componentType, Pathref.this).to();
				}
			};
		}

		try {
			return new Pathref<>(target, this).to();
		}
		catch (Exception ex) {
			return null;
		}
	}
@SuppressWarnings("unchecked")
	public <T> T continueWith(final Object currentInstance, final String methodName, final Class<T> target) {
		Class currentClass = currentInstance.getClass();

		Method method;

		try {
			method = currentClass.getDeclaredMethod(methodName);
		}
		catch (NoSuchMethodException e) {
			throw new PathrefException("Not a getter: " + methodName, e);
		}

		if (!ClassUtil.isBeanPropertyGetter(method)) {
			throw new PathrefException("Not a getter: " + methodName);
		}

		String getterName = ClassUtil.getBeanPropertyGetterName(method);

		append(getterName);

		if (ClassUtil.isTypeOf(target, List.class)) {
			final Class componentType =
				ClassUtil.getComponentType(method.getGenericReturnType(), currentClass, 0);

			if (componentType == null) {
				throw new PathrefException("Unknown component name for: " + methodName);
			}

			return (T) new ArrayList() {
				@Override
				public Object get(final int index) {
					if (index >= 0) {
						append("[" + index + "]");
					}
					return new Pathref<>(componentType, Pathref.this).to();
				}
			};
		}

		try {
			return new Pathref<>(target, this).to();
		}
		catch (Exception ex) {
			return null;
		}
	}
@ SuppressWarnings ( "unchecked" ) public < T > T continueWith ( final Object currentInstance , final String methodName , final Class < T > target ) { Class currentClass = currentInstance . getClass ( ) ; Method method ; try { method = currentClass . getDeclaredMethod ( methodName ) ; } catch ( NoSuchMethodException e ) { throw new PathrefException ( "Not a getter: " + methodName , e ) ; } if ( ! ClassUtil . isBeanPropertyGetter ( method ) ) { throw new PathrefException ( "Not a getter: " + methodName ) ; } String getterName = ClassUtil . getBeanPropertyGetterName ( method ) ; append ( getterName ) ; if ( ClassUtil . isTypeOf ( target , List . class ) ) { final Class componentType = ClassUtil . getComponentType ( method . getGenericReturnType ( ) , currentClass , 0 ) ; if ( componentType == null ) { throw new PathrefException ( "Unknown component name for: " + methodName ) ; } return ( T ) new ArrayList ( ) { @ Override public Object get ( final int index ) { if ( index >= 0 ) { append ( "[" + index + "]" ) ; } return new Pathref <> ( componentType , Pathref . this ) . to ( ) ; } } ; } try { return new Pathref <> ( target , this ) . to ( ) ; } catch ( Exception ex ) { return null ; } }
Static factory of next target. It handles special cases of maps, sets
and lists. In case target can not be proxified (like for Java classes)
it returns <code>null</code>.
Static factory of next target . It handles special cases of maps sets and lists . In case target can not be proxified ( like for Java classes ) it returns <code > null< / code > .