List of usage examples for org.springframework.util Assert isInstanceOf
public static void isInstanceOf(Class<?> type, @Nullable Object obj, Supplier<String> messageSupplier)
From source file:org.apache.cxf.fediz.service.idp.util.WebUtils.java
public static HttpServletRequest getHttpServletRequest(final RequestContext context) { Assert.isInstanceOf(ServletExternalContext.class, context.getExternalContext(), "Cannot obtain HttpServletRequest from event of type: " + context.getExternalContext().getClass().getName()); return (HttpServletRequest) context.getExternalContext().getNativeRequest(); }
From source file:org.springmodules.validation.util.condition.range.PersonByAgeComparator.java
public int compare(Object o1, Object o2) { Assert.isInstanceOf(Person.class, o1, getClass().getName() + " can only compare Person objects"); Assert.isInstanceOf(Person.class, o2, getClass().getName() + " can only compare Person objects"); return compare((Person) o1, (Person) o2); }
From source file:io.curly.artifact.integration.event.CreatedArtifactEvent.java
/** * Create a new ApplicationEvent./* w w w. j a v a 2 s .c om*/ * * @param source the component that published the event (never {@code null}) */ public CreatedArtifactEvent(Object source) { super(source); Assert.isInstanceOf(Artifact.class, source, "The source must be a Artifact !! This will propagate errors through the chain!!"); }
From source file:org.springmodules.validation.valang.functions.ResolveFunction.java
protected Object doGetResult(Object target) throws Exception { Object value = getArguments()[0].getResult(target); Assert.isInstanceOf(String.class, value, "Argument of resolve method must be a string value or return a string value " + getTemplate().getAtLineString() + "!"); return new DefaultMessageSourceResolvable((String) value); }
From source file:io.curly.advisor.integration.event.CreatedReview.java
/** * Create a new ApplicationEvent.//from w ww . j a va2s . com * * @param source the component that published the event (never {@code null}) */ public CreatedReview(Object source) { super(source); Assert.isInstanceOf(Review.class, source, "Source must be instance of Review, it will cause cascading failure on events"); }
From source file:org.apache.cxf.fediz.service.idp.util.WebUtils.java
public static HttpServletResponse getHttpServletResponse(final RequestContext context) { Assert.isInstanceOf(ServletExternalContext.class, context.getExternalContext(), "Cannot obtain HttpServletResponse from event of type: " + context.getExternalContext().getClass().getName()); return (HttpServletResponse) context.getExternalContext().getNativeResponse(); }
From source file:org.springmodules.validation.valang.javascript.taglib.ValangJavaScriptTagUtils.java
/** * Inserts the valang validator from the provided controller into the model using the controller's name as the * validation rule's key./*w ww. jav a2s. com*/ * * @param controller * the controller that will provide the command name and validator * @param model * the model into which the validation rules will be placed * @throws IllegalArgumentException * if the controller does not specify a command name * @throws IllegalArgumentException * if the controller's validator is not an instance of * {@link org.springmodules.validation.valang.ValangValidator} */ public static void addValangRulesToModel(BaseCommandController controller, Map model) { Assert.hasText(controller.getCommandName(), "controller must define a command name"); Validator validator = controller.getValidator(); Assert.isInstanceOf(ValangValidator.class, validator, "controller's validator of class '" + (validator != null ? validator.getClass().getName() : "[null]") + "' must be an instance of 'ValangValidator'"); ValangValidator vv = (ValangValidator) validator; addValangRulesToModel(controller.getCommandName(), vv.getRules(), model); }
From source file:de.codecentric.boot.admin.discovery.EurekaServiceInstanceConverter.java
@Override protected URI getHealthUrl(ServiceInstance instance) { Assert.isInstanceOf(EurekaServiceInstance.class, instance, "serviceInstance must be of type EurekaServiceInstance"); InstanceInfo instanceInfo = ((EurekaServiceInstance) instance).getInstanceInfo(); String healthUrl = instanceInfo.getSecureHealthCheckUrl(); if (StringUtils.isEmpty(healthUrl)) { healthUrl = instanceInfo.getHealthCheckUrl(); }//from w w w. j a va2 s.c om return URI.create(healthUrl); }
From source file:com.gs.config.CustomFilterLogin.java
@Override public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException { Assert.isInstanceOf(HttpServletRequest.class, request, "Can only process HttpServletRequest"); Assert.isInstanceOf(HttpServletResponse.class, response, "Can only process HttpServletResponse"); HttpServletRequest httpRequest = (HttpServletRequest) request; HttpServletResponse httpResponse = (HttpServletResponse) response; // System.out.println("ESTOY EN CUSTOMFILTERLOGIN: "+httpRequest.getServletPath()); String path = httpRequest.getServletPath(); HttpSession session = httpRequest.getSession(false); if (session == null && !httpRequest.isRequestedSessionIdValid()) { String targetUrl = httpRequest.getContextPath() + "/login"; httpResponse.sendRedirect(httpResponse.encodeRedirectURL(targetUrl)); return;/*from ww w. j av a 2s .c om*/ } chain.doFilter(request, response); }