private synchronized Application createChartistJSFApplication(final Application application) {
		Application newApplication = application;

		while (!(newApplication instanceof ChartistJSFApplication) && newApplication instanceof ApplicationWrapper) {
			newApplication = ((ApplicationWrapper) newApplication).getWrapped();
		}

		if (!(newApplication instanceof ChartistJSFApplication)) {
			newApplication = new ChartistJSFApplication(application);
		}

		this.application = newApplication;
		return this.application;
	}
private synchronized Application createChartistJSFApplication ( final Application application ) { Application newApplication = application ; while ( ! ( newApplication instanceof ChartistJSFApplication ) && newApplication instanceof ApplicationWrapper ) { newApplication = ( ( ApplicationWrapper ) newApplication ) . getWrapped ( ) ; } if ( ! ( newApplication instanceof ChartistJSFApplication ) ) { newApplication = new ChartistJSFApplication ( application ) ; } this . application = newApplication ; return this . application ; }
If the given application not an instance of {@link ChartistJSFApplication}, nor wraps the {@link ChartistJSFApplication}, then
it will be wrapped by a new instance of {@link ChartistJSFApplication} and set as the current instance and returned.
Additionally, it will check if all Application implementations properly extend from ApplicationWrapper.