List of usage examples for org.springframework.util Assert notEmpty
public static void notEmpty(@Nullable Map<?, ?> map, Supplier<String> messageSupplier)
From source file:org.springframework.web.reactive.result.view.AbstractView.java
/** * Set the supported media types for this view. * Default is "text/html;charset=UTF-8". *//* w w w .j a va 2 s . c om*/ public void setSupportedMediaTypes(@Nullable List<MediaType> supportedMediaTypes) { Assert.notEmpty(supportedMediaTypes, "MediaType List must not be empty"); this.mediaTypes.clear(); if (supportedMediaTypes != null) { this.mediaTypes.addAll(supportedMediaTypes); } }
From source file:org.springframework.web.servlet.function.RequestPredicates.java
/** * Return a {@code RequestPredicate} that tests if the request's * {@linkplain ServerRequest.Headers#contentType() content type} is * {@linkplain MediaType#includes(MediaType) included} by any of the given media types. * @param mediaTypes the media types to match the request's content type against * @return a predicate that tests the request's content type against the given media types *//*from w w w . j a v a 2 s . co m*/ public static RequestPredicate contentType(MediaType... mediaTypes) { Assert.notEmpty(mediaTypes, "'mediaTypes' must not be empty"); return new ContentTypePredicate(mediaTypes); }
From source file:org.springframework.web.servlet.function.RequestPredicates.java
/** * Return a {@code RequestPredicate} that tests if the request's * {@linkplain ServerRequest.Headers#accept() accept} header is * {@linkplain MediaType#isCompatibleWith(MediaType) compatible} with any of the given media types. * @param mediaTypes the media types to match the request's accept header against * @return a predicate that tests the request's accept header against the given media types *///ww w.j a v a 2 s. co m public static RequestPredicate accept(MediaType... mediaTypes) { Assert.notEmpty(mediaTypes, "'mediaTypes' must not be empty"); return new AcceptPredicate(mediaTypes); }
From source file:org.springframework.web.servlet.mvc.method.annotation.AbstractMessageConverterMethodArgumentResolver.java
/** * Constructor with converters and {@code Request~} and {@code ResponseBodyAdvice}. * @since 4.2/*w w w . j a va 2 s . co m*/ */ public AbstractMessageConverterMethodArgumentResolver(List<HttpMessageConverter<?>> converters, @Nullable List<Object> requestResponseBodyAdvice) { Assert.notEmpty(converters, "'messageConverters' must not be empty"); this.messageConverters = converters; this.allSupportedMediaTypes = getAllSupportedMediaTypes(converters); this.advice = new RequestResponseBodyAdviceChain(requestResponseBodyAdvice); }
From source file:org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitterReturnValueHandler.java
/** * Simple constructor with reactive type support based on a default instance of * {@link ReactiveAdapterRegistry},/*from www. j a v a 2 s . c o m*/ * {@link org.springframework.core.task.SyncTaskExecutor}, and * {@link ContentNegotiationManager} with an Accept header strategy. */ public ResponseBodyEmitterReturnValueHandler(List<HttpMessageConverter<?>> messageConverters) { Assert.notEmpty(messageConverters, "HttpMessageConverter List must not be empty"); this.messageConverters = messageConverters; this.reactiveHandler = new ReactiveTypeHandler(); }
From source file:org.springframework.web.servlet.mvc.method.annotation.ResponseBodyEmitterReturnValueHandler.java
/** * Complete constructor with pluggable "reactive" type support. * * @param messageConverters converters to write emitted objects with * @param reactiveRegistry for reactive return value type support * @param executor for blocking I/O writes of items emitted from reactive types * @param manager for detecting streaming media types * * @since 5.0/* w w w . java2 s . c o m*/ */ public ResponseBodyEmitterReturnValueHandler(List<HttpMessageConverter<?>> messageConverters, ReactiveAdapterRegistry reactiveRegistry, TaskExecutor executor, ContentNegotiationManager manager) { Assert.notEmpty(messageConverters, "HttpMessageConverter List must not be empty"); this.messageConverters = messageConverters; this.reactiveHandler = new ReactiveTypeHandler(reactiveRegistry, executor, manager); }
From source file:org.springframework.web.servlet.mvc.method.annotation.support.AbstractMessageConverterMethodArgumentResolver.java
public AbstractMessageConverterMethodArgumentResolver(List<HttpMessageConverter<?>> messageConverters) { Assert.notEmpty(messageConverters, "'messageConverters' must not be empty"); this.messageConverters = messageConverters; this.allSupportedMediaTypes = getAllSupportedMediaTypes(messageConverters); }
From source file:org.springframework.web.socket.sockjs.client.SockJsClient.java
/** * Create a {@code SockJsClient} with the given transports. * <p>If the list includes an {@link XhrTransport} (or more specifically an * implementation of {@link InfoReceiver}) the instance is used to initialize * the {@link #setInfoReceiver(InfoReceiver) infoReceiver} property, or * otherwise is defaulted to {@link RestTemplateXhrTransport}. * @param transports the (non-empty) list of transports to use *//*from w ww . j a v a 2 s. c o m*/ public SockJsClient(List<Transport> transports) { Assert.notEmpty(transports, "No transports provided"); this.transports = new ArrayList<>(transports); this.infoReceiver = initInfoReceiver(transports); if (jackson2Present) { this.messageCodec = new Jackson2SockJsMessageCodec(); } }
From source file:org.springframework.ws.samples.airline.service.impl.AirlineServiceImpl.java
@Transactional(readOnly = false, rollbackFor = { NoSuchFlightException.class, NoSeatAvailableException.class, NoSuchFrequentFlyerException.class }) public Ticket bookFlight(String flightNumber, DateTime departureTime, List<Passenger> passengers) throws NoSuchFlightException, NoSeatAvailableException, NoSuchFrequentFlyerException { Assert.notEmpty(passengers, "No passengers given"); if (logger.isDebugEnabled()) { logger.debug("Booking flight '" + flightNumber + "' on '" + departureTime + "' for " + passengers); }//from w ww. j a v a 2s. c om Flight flight = flightDao.getFlight(flightNumber, departureTime); if (flight == null) { throw new NoSuchFlightException(flightNumber, departureTime); } else if (flight.getSeatsAvailable() < passengers.size()) { throw new NoSeatAvailableException(flight); } Ticket ticket = new Ticket(); ticket.setIssueDate(new LocalDate()); ticket.setFlight(flight); for (Passenger passenger : passengers) { // frequent flyer service is not required if (passenger instanceof FrequentFlyer && frequentFlyerSecurityService != null) { String username = ((FrequentFlyer) passenger).getUsername(); Assert.hasLength(username, "No username specified"); FrequentFlyer frequentFlyer = frequentFlyerSecurityService.getFrequentFlyer(username); frequentFlyer.addMiles(flight.getMiles()); ticket.addPassenger(frequentFlyer); } else { ticket.addPassenger(passenger); } } flight.substractSeats(passengers.size()); flightDao.update(flight); ticketDao.save(ticket); return ticket; }
From source file:org.springframework.xd.dirt.module.ModuleDeployer.java
private Module createCompositeModule(CompositeModuleDeploymentRequest compositeRequest, ModuleOptions moduleOptionsForComposite) { List<ModuleDeploymentRequest> children = compositeRequest.getChildren(); Assert.notEmpty(children, "child module list must not be empty"); List<Module> childrenModules = new ArrayList<Module>(children.size()); for (ModuleDeploymentRequest childRequest : children) { ModuleOptions narrowedModuleOptions = new PrefixNarrowingModuleOptions(moduleOptionsForComposite, childRequest.getModule()); childrenModules.add(createModule(childRequest, narrowedModuleOptions)); }// w w w . ja va 2s .co m String group = compositeRequest.getGroup(); int index = compositeRequest.getIndex(); String sourceChannelName = compositeRequest.getSourceChannelName(); String sinkChannelName = compositeRequest.getSinkChannelName(); DeploymentMetadata deploymentMetadata = new DeploymentMetadata(group, index, sourceChannelName, sinkChannelName); String moduleName = compositeRequest.getModule(); ModuleType moduleType = compositeRequest.getType(); return new CompositeModule(moduleName, moduleType, childrenModules, deploymentMetadata); }