@SuppressWarnings("unchecked")
	public static Inflector<ContainerRequestContext, Response> appSettingsHandler(final App a) {
		return new Inflector<ContainerRequestContext, Response>() {
			public Response apply(ContainerRequestContext ctx) {
				App app = (a != null) ? a : getPrincipalApp();
				String key = pathParam("key", ctx);
				if (app != null) {
					if (PUT.equals(ctx.getMethod())) {
						Response resp = getEntity(ctx.getEntityStream(), Map.class);
						if (resp.getStatusInfo() == Response.Status.OK) {
							Map<String, Object> setting = (Map<String, Object>) resp.getEntity();
							if (!StringUtils.isBlank(key) && setting.containsKey("value")) {
								app.addSetting(key, setting.get("value"));
							} else {
								app.clearSettings().addAllSettings(setting);
							}
							app.update();
							return Response.ok().build();
						} else {
							return getStatusResponse(Response.Status.BAD_REQUEST);
						}
					} else if (DELETE.equals(ctx.getMethod())) {
						app.removeSetting(key);
						app.update();
						return Response.ok().build();
					} else {
						if (StringUtils.isBlank(key)) {
							return Response.ok(app.getSettings()).build();
						} else {
							return Response.ok(Collections.singletonMap("value", app.getSetting(key))).build();
						}
					}
				}
				return getStatusResponse(Response.Status.FORBIDDEN, "Not allowed.");
			}
		};
	}
@ SuppressWarnings ( "unchecked" ) public static Inflector < ContainerRequestContext , Response > appSettingsHandler ( final App a ) { return new Inflector < ContainerRequestContext , Response > ( ) { public Response apply ( ContainerRequestContext ctx ) { App app = ( a != null ) ? a : getPrincipalApp ( ) ; String key = pathParam ( "key" , ctx ) ; if ( app != null ) { if ( PUT . equals ( ctx . getMethod ( ) ) ) { Response resp = getEntity ( ctx . getEntityStream ( ) , Map . class ) ; if ( resp . getStatusInfo ( ) == Response . Status . OK ) { Map < String , Object > setting = ( Map < String , Object > ) resp . getEntity ( ) ; if ( ! StringUtils . isBlank ( key ) && setting . containsKey ( "value" ) ) { app . addSetting ( key , setting . get ( "value" ) ) ; } else { app . clearSettings ( ) . addAllSettings ( setting ) ; } app . update ( ) ; return Response . ok ( ) . build ( ) ; } else { return getStatusResponse ( Response . Status . BAD_REQUEST ) ; } } else if ( DELETE . equals ( ctx . getMethod ( ) ) ) { app . removeSetting ( key ) ; app . update ( ) ; return Response . ok ( ) . build ( ) ; } else { if ( StringUtils . isBlank ( key ) ) { return Response . ok ( app . getSettings ( ) ) . build ( ) ; } else { return Response . ok ( Collections . singletonMap ( "value" , app . getSetting ( key ) ) ) . build ( ) ; } } } return getStatusResponse ( Response . Status . FORBIDDEN , "Not allowed." ) ; } } ; }
@param a {@link App}
@return response