org.springframework.util.Assert.state()

Here are the examples of the java api org.springframework.util.Assert.state() taken from open source projects. By voting up you can indicate which examples are most useful and appropriate.

1102 Examples 7

19 Source : LimiterInterceptor.java
with MIT License
from zidoshare

@Override
public void afterPropertiesSet() throws Exception {
    replacedert.state(getLimiterOperationSource() != null, "The 'limiterOperationSources' property is required: " + "If there are no limiter methods, then don't use a limiter aspect.");
    replacedert.state(getErrorHandler() != null, "The 'errorHandler' property is required");
    replacedert.state(limiter != null, "the 'limiter' property is required");
}

19 Source : MockServerRestTemplateCustomizer.java
with Apache License 2.0
from yuanmabiji

public MockRestServiceServer getServer() {
    replacedert.state(!this.servers.isEmpty(), "Unable to return a single MockRestServiceServer since " + "MockServerRestTemplateCustomizer has not been bound to " + "a RestTemplate");
    replacedert.state(this.servers.size() == 1, "Unable to return a single MockRestServiceServer since " + "MockServerRestTemplateCustomizer has been bound to " + "more than one RestTemplate");
    return this.servers.values().iterator().next();
}

19 Source : BasicJsonTester.java
with Apache License 2.0
from yuanmabiji

private void verify() {
    replacedert.state(this.loader != null, "Uninitialized BasicJsonTester");
}

19 Source : AbstractJsonMarshalTester.java
with Apache License 2.0
from yuanmabiji

private void verify() {
    replacedert.state(this.resourceLoadClreplaced != null, "Uninitialized JsonMarshalTester (ResourceLoadClreplaced is null)");
    replacedert.state(this.type != null, "Uninitialized JsonMarshalTester (Type is null)");
}

19 Source : HttpTunnelPayloadForwarder.java
with Apache License 2.0
from yuanmabiji

public void forward(HttpTunnelPayload payload) throws IOException {
    synchronized (this.monitor) {
        long seq = payload.getSequence();
        if (this.lastRequestSeq != seq - 1) {
            replacedert.state(this.queue.size() < MAXIMUM_QUEUE_SIZE, "Too many messages queued");
            this.queue.put(seq, payload);
            return;
        }
        payload.logOutgoing();
        payload.writeTo(this.targetChannel);
        this.lastRequestSeq = seq;
        HttpTunnelPayload queuedItem = this.queue.get(seq + 1);
        if (queuedItem != null) {
            forward(queuedItem);
        }
    }
}

19 Source : Restarter.java
with Apache License 2.0
from yuanmabiji

/**
 * Return the active {@link Restarter} instance. Cannot be called before
 * {@link #initialize(String[]) initialization}.
 * @return the restarter
 */
public static Restarter getInstance() {
    synchronized (INSTANCE_MONITOR) {
        replacedert.state(instance != null, "Restarter has not been initialized");
        return instance;
    }
}

19 Source : FileSystemWatcher.java
with Apache License 2.0
from yuanmabiji

private void checkNotStarted() {
    synchronized (this.monitor) {
        replacedert.state(this.watchThread == null, "FileSystemWatcher already started");
    }
}

19 Source : AutoConfigurationSorter.java
with Apache License 2.0
from yuanmabiji

private void doSortByAfterAnnotation(AutoConfigurationClreplacedes clreplacedes, List<String> toSort, Set<String> sorted, Set<String> processing, String current) {
    if (current == null) {
        current = toSort.remove(0);
    }
    processing.add(current);
    for (String after : clreplacedes.getClreplacedesRequestedAfter(current)) {
        replacedert.state(!processing.contains(after), "AutoConfigure cycle detected between " + current + " and " + after);
        if (!sorted.contains(after) && toSort.contains(after)) {
            doSortByAfterAnnotation(clreplacedes, toSort, sorted, processing, after);
        }
    }
    processing.remove(current);
    sorted.add(current);
}

19 Source : OnEnabledEndpointCondition.java
with Apache License 2.0
from yuanmabiji

private AnnotationAttributes getEndpointAttributes(ConditionContext context, AnnotatedTypeMetadata metadata) {
    replacedert.state(metadata instanceof MethodMetadata && metadata.isAnnotated(Bean.clreplaced.getName()), "OnEnabledEndpointCondition may only be used on @Bean methods");
    Clreplaced<?> endpointType = getEndpointType(context, (MethodMetadata) metadata);
    return getEndpointAttributes(endpointType);
}

19 Source : EndpointDiscoverer.java
with Apache License 2.0
from yuanmabiji

private void addExtensionBean(EndpointBean endpointBean, ExtensionBean extensionBean) {
    if (isExtensionExposed(endpointBean, extensionBean)) {
        replacedert.state(isEndpointExposed(endpointBean) || isEndpointFiltered(endpointBean), () -> "Endpoint bean '" + endpointBean.getBeanName() + "' cannot support the extension bean '" + extensionBean.getBeanName() + "'");
        endpointBean.addExtension(extensionBean);
    }
}

19 Source : ServletComponentHandler.java
with Apache License 2.0
from yuanmabiji

protected String[] extractUrlPatterns(Map<String, Object> attributes) {
    String[] value = (String[]) attributes.get("value");
    String[] urlPatterns = (String[]) attributes.get("urlPatterns");
    if (urlPatterns.length > 0) {
        replacedert.state(value.length == 0, "The urlPatterns and value attributes are mutually exclusive.");
        return urlPatterns;
    }
    return value;
}

19 Source : SessionStoreDirectory.java
with Apache License 2.0
from yuanmabiji

private void replacedertDirectory(boolean mkdirs, File dir) {
    replacedert.state(!mkdirs || dir.exists(), () -> "Session dir " + dir + " does not exist");
    replacedert.state(!dir.isFile(), () -> "Session dir " + dir + " points to a file");
}

19 Source : UndertowServletWebServerFactory.java
with Apache License 2.0
from yuanmabiji

private void createAccessLogDirectoryIfNecessary() {
    replacedert.state(this.accessLogDirectory != null, "Access log directory is not set");
    if (!this.accessLogDirectory.isDirectory() && !this.accessLogDirectory.mkdirs()) {
        throw new IllegalStateException("Failed to create access log directory '" + this.accessLogDirectory + "'");
    }
}

19 Source : ApplicationTemp.java
with Apache License 2.0
from yuanmabiji

/**
 * Return the directory to be used for application specific temp files.
 * @return the application temp directory
 */
public File getDir() {
    if (this.dir == null) {
        synchronized (this) {
            byte[] hash = generateHash(this.sourceClreplaced);
            this.dir = new File(getTempDirectory(), toHexString(hash));
            this.dir.mkdirs();
            replacedert.state(this.dir.exists(), () -> "Unable to create temp directory " + this.dir);
        }
    }
    return this.dir;
}

19 Source : GrpcAdviceDiscoverer.java
with MIT License
from yidongnan

public Set<Method> getAnnotatedMethods() {
    replacedert.state(annotatedMethods != null, "@GrpcExceptionHandler annotation scanning failed.");
    return annotatedMethods;
}

19 Source : GrpcAdviceDiscoverer.java
with MIT License
from yidongnan

public Map<String, Object> getAnnotatedBeans() {
    replacedert.state(annotatedBeans != null, "@GrpcAdvice annotation scanning failed.");
    return annotatedBeans;
}

19 Source : UploadServiceImpl.java
with MIT License
from wuyc

@Transactional
@Override
public void removeFile(Integer uploadId) {
    Upload upload = uploadDAO.selectById(uploadId);
    if (null == upload) {
        throw new NotFoundException("文件不存在");
    }
    String filename = upload.getFilename();
    File file = new File(properties.getUploadPath() + filename);
    boolean delete = file.delete();
    if (!delete) {
        throw new FileException("文件删除失败");
    }
    int row = uploadDAO.deleteById(uploadId);
    replacedert.state(row != 0, "文件删除失败");
}

19 Source : PageServiceImpl.java
with MIT License
from wuyc

@Transactional
@Override
public void removePage(Integer pageId) {
    pageMustExist(pageId);
    int row = postDAO.deleteById(pageId);
    // 删除页面的所以评论
    commentService.removeCommentByPostId(pageId);
    replacedert.state(row != 0, "页面删除失败");
}

19 Source : CommentServiceImpl.java
with MIT License
from wuyc

@Override
public void removeCommentByPostId(Integer postId) {
    int row = commentDAO.delete(new QueryWrapper<Comment>().eq("post_id", postId));
    replacedert.state(row != 0, "删除失败");
}

19 Source : CommentServiceImpl.java
with MIT License
from wuyc

@Transactional
@Override
public void removeComment(Integer id) {
    commentMustExist(id);
    int row = commentDAO.deleteById(id);
    replacedert.state(row != 0, "删除失败");
}

19 Source : TransportHandlingSockJsService.java
with MIT License
from Vip-Augus

public SockJsMessageCodec getMessageCodec() {
    replacedert.state(this.messageCodec != null, "A SockJsMessageCodec is required but not available: " + "Add Jackson to the clreplacedpath, or configure a custom SockJsMessageCodec.");
    return this.messageCodec;
}

19 Source : AbstractSockJsSession.java
with MIT License
from Vip-Augus

// Message sending
public final void sendMessage(WebSocketMessage<?> message) throws IOException {
    replacedert.state(!isClosed(), "Cannot send a message when session is closed");
    replacedert.isInstanceOf(TextMessage.clreplaced, message, "SockJS supports text messages only");
    sendMessageInternal(((TextMessage) message).getPayload());
}

19 Source : AbstractHttpSockJsSession.java
with MIT License
from Vip-Augus

@Override
public URI getUri() {
    URI uri = this.uri;
    replacedert.state(uri != null, "No initial request yet");
    return uri;
}

19 Source : AbstractTransportHandler.java
with MIT License
from Vip-Augus

public SockJsServiceConfig getServiceConfig() {
    replacedert.state(this.serviceConfig != null, "No SockJsServiceConfig available");
    return this.serviceConfig;
}

19 Source : SockJsClient.java
with MIT License
from Vip-Augus

/**
 * Return the SockJsMessageCodec to use.
 */
public SockJsMessageCodec getMessageCodec() {
    replacedert.state(this.messageCodec != null, "No SockJsMessageCodec set");
    return this.messageCodec;
}

19 Source : RestTemplateXhrTransport.java
with MIT License
from Vip-Augus

private static <T> T nonNull(@Nullable T result) {
    replacedert.state(result != null, "No result");
    return result;
}

19 Source : AbstractClientSockJsSession.java
with MIT License
from Vip-Augus

public void afterTransportClosed(@Nullable CloseStatus closeStatus) {
    CloseStatus cs = this.closeStatus;
    if (cs == null) {
        cs = closeStatus;
        this.closeStatus = closeStatus;
    }
    replacedert.state(cs != null, "CloseStatus not available");
    if (logger.isDebugEnabled()) {
        logger.debug("Transport closed with " + cs + " in " + this);
    }
    this.state = State.CLOSED;
    try {
        this.webSocketHandler.afterConnectionClosed(this, cs);
    } catch (Throwable ex) {
        logger.error("WebSocketHandler.afterConnectionClosed threw an exception", ex);
    }
}

19 Source : ServerEndpointRegistration.java
with MIT License
from Vip-Augus

public Endpoint getEndpoint() {
    if (this.endpoint != null) {
        return this.endpoint;
    } else {
        replacedert.state(this.endpointProvider != null, "No endpoint set");
        return this.endpointProvider.getHandler();
    }
}

19 Source : ServerEndpointExporter.java
with MIT License
from Vip-Augus

private void registerEndpoint(ServerEndpointConfig endpointConfig) {
    ServerContainer serverContainer = getServerContainer();
    replacedert.state(serverContainer != null, "No ServerContainer set");
    try {
        if (logger.isDebugEnabled()) {
            logger.debug("Registering ServerEndpointConfig: " + endpointConfig);
        }
        serverContainer.addEndpoint(endpointConfig);
    } catch (DeploymentException ex) {
        throw new IllegalStateException("Failed to register ServerEndpointConfig: " + endpointConfig, ex);
    }
}

19 Source : ServerEndpointExporter.java
with MIT License
from Vip-Augus

private void registerEndpoint(Clreplaced<?> endpointClreplaced) {
    ServerContainer serverContainer = getServerContainer();
    replacedert.state(serverContainer != null, "No ServerContainer set. Most likely the server's own WebSocket ServletContainerInitializer " + "has not run yet. Was the Spring ApplicationContext refreshed through a " + "org.springframework.web.context.ContextLoaderListener, " + "i.e. after the ServletContext has been fully initialized?");
    try {
        if (logger.isDebugEnabled()) {
            logger.debug("Registering @ServerEndpoint clreplaced: " + endpointClreplaced);
        }
        serverContainer.addEndpoint(endpointClreplaced);
    } catch (DeploymentException ex) {
        throw new IllegalStateException("Failed to register @ServerEndpoint clreplaced: " + endpointClreplaced, ex);
    }
}

19 Source : ServerEndpointExporter.java
with MIT License
from Vip-Augus

@Override
public void afterPropertiesSet() {
    replacedert.state(getServerContainer() != null, "javax.websocket.server.ServerContainer not available");
}

19 Source : JettyRequestUpgradeStrategy.java
with MIT License
from Vip-Augus

@Override
public void start() {
    if (!isRunning()) {
        this.running = true;
        try {
            if (this.factory == null) {
                this.factory = new WebSocketServerFactory(this.servletContext, this.policy);
            }
            this.factory.setCreator((request, response) -> {
                WebSocketHandlerContainer container = containerHolder.get();
                replacedert.state(container != null, "Expected WebSocketHandlerContainer");
                response.setAcceptedSubProtocol(container.getSelectedProtocol());
                response.setExtensions(container.getExtensionConfigs());
                return container.getHandler();
            });
            this.factory.start();
        } catch (Throwable ex) {
            throw new IllegalStateException("Unable to start Jetty WebSocketServerFactory", ex);
        }
    }
}

19 Source : SockJsServiceRegistration.java
with MIT License
from Vip-Augus

private TransportHandlingSockJsService createSockJsService() {
    replacedert.state(this.scheduler != null, "No TaskScheduler available");
    replacedert.state(this.transportHandlers.isEmpty() || this.transportHandlerOverrides.isEmpty(), "Specify either TransportHandlers or TransportHandler overrides, not both");
    return (!this.transportHandlers.isEmpty() ? new TransportHandlingSockJsService(this.scheduler, this.transportHandlers) : new DefaultSockJsService(this.scheduler, this.transportHandlerOverrides));
}

19 Source : StandardWebSocketSession.java
with MIT License
from Vip-Augus

@Override
public List<WebSocketExtension> getExtensions() {
    replacedert.state(this.extensions != null, "WebSocket session is not yet initialized");
    return this.extensions;
}

19 Source : JettyWebSocketSession.java
with MIT License
from Vip-Augus

@Override
public HttpHeaders getHandshakeHeaders() {
    replacedert.state(this.headers != null, "WebSocket session is not yet initialized");
    return this.headers;
}

19 Source : AbstractWebSocketSession.java
with MIT License
from Vip-Augus

protected final void checkNativeSessionInitialized() {
    replacedert.state(this.nativeSession != null, "WebSocket session is not yet initialized");
}

19 Source : XsltView.java
with MIT License
from Vip-Augus

/**
 * Return the TransformerFactory that this XsltView uses.
 * @return the TransformerFactory (never {@code null})
 */
protected final TransformerFactory getTransformerFactory() {
    replacedert.state(this.transformerFactory != null, "No TransformerFactory available");
    return this.transformerFactory;
}

19 Source : MarshallingView.java
with MIT License
from Vip-Augus

/**
 * Check whether the given value from the current view's model is eligible
 * for marshalling through the configured {@link Marshaller}.
 * <p>The default implementation calls {@link Marshaller#supports(Clreplaced)},
 * unwrapping a given {@link JAXBElement} first if applicable.
 * @param modelKey the value's key in the model (never {@code null})
 * @param value the value to check (never {@code null})
 * @return whether the given value is to be considered as eligible
 * @see Marshaller#supports(Clreplaced)
 */
protected boolean isEligibleForMarshalling(String modelKey, Object value) {
    replacedert.state(this.marshaller != null, "No Marshaller set");
    Clreplaced<?> clreplacedToCheck = value.getClreplaced();
    if (value instanceof JAXBElement) {
        clreplacedToCheck = ((JAXBElement<?>) value).getDeclaredType();
    }
    return this.marshaller.supports(clreplacedToCheck);
}

19 Source : UrlBasedViewResolver.java
with MIT License
from Vip-Augus

/**
 * Creates a new View instance of the specified view clreplaced and configures it.
 * Does <i>not</i> perform any lookup for pre-defined View instances.
 * <p>Spring lifecycle methods as defined by the bean container do not have to
 * be called here; those will be applied by the {@code loadView} method
 * after this method returns.
 * <p>Subclreplacedes will typically call {@code super.buildView(viewName)}
 * first, before setting further properties themselves. {@code loadView}
 * will then apply Spring lifecycle methods at the end of this process.
 * @param viewName the name of the view to build
 * @return the View instance
 * @throws Exception if the view couldn't be resolved
 * @see #loadView(String, java.util.Locale)
 */
protected AbstractUrlBasedView buildView(String viewName) throws Exception {
    Clreplaced<?> viewClreplaced = getViewClreplaced();
    replacedert.state(viewClreplaced != null, "No view clreplaced");
    AbstractUrlBasedView view = (AbstractUrlBasedView) BeanUtils.instantiateClreplaced(viewClreplaced);
    view.setUrl(getPrefix() + viewName + getSuffix());
    String contentType = getContentType();
    if (contentType != null) {
        view.setContentType(contentType);
    }
    view.setRequestContextAttribute(getRequestContextAttribute());
    view.setAttributesMap(getAttributesMap());
    Boolean exposePathVariables = getExposePathVariables();
    if (exposePathVariables != null) {
        view.setExposePathVariables(exposePathVariables);
    }
    Boolean exposeContextBeansAsAttributes = getExposeContextBeansAsAttributes();
    if (exposeContextBeansAsAttributes != null) {
        view.setExposeContextBeansAsAttributes(exposeContextBeansAsAttributes);
    }
    String[] exposedContextBeanNames = getExposedContextBeanNames();
    if (exposedContextBeanNames != null) {
        view.setExposedContextBeanNames(exposedContextBeanNames);
    }
    return view;
}

19 Source : TilesView.java
with MIT License
from Vip-Augus

@Override
public boolean checkResource(final Locale locale) throws Exception {
    replacedert.state(this.renderer != null, "No Renderer set");
    HttpServletRequest servletRequest = null;
    RequestAttributes requestAttributes = RequestContextHolder.getRequestAttributes();
    if (requestAttributes instanceof ServletRequestAttributes) {
        servletRequest = ((ServletRequestAttributes) requestAttributes).getRequest();
    }
    Request request = new ServletRequest(this.applicationContext, servletRequest, null) {

        @Override
        public Locale getRequestLocale() {
            return locale;
        }
    };
    return this.renderer.isRenderable(getUrl(), request);
}

19 Source : GroovyMarkupView.java
with MIT License
from Vip-Augus

/**
 * Return a template compiled by the configured Groovy Markup template engine
 * for the given view URL.
 */
protected Template getTemplate(String viewUrl) throws Exception {
    replacedert.state(this.engine != null, "No MarkupTemplateEngine set");
    try {
        return this.engine.createTemplateByPath(viewUrl);
    } catch (ClreplacedNotFoundException ex) {
        Throwable cause = (ex.getCause() != null ? ex.getCause() : ex);
        throw new NestedServletException("Could not find clreplaced while rendering Groovy Markup view with name '" + getUrl() + "': " + ex.getMessage() + "'", cause);
    }
}

19 Source : GroovyMarkupConfigurer.java
with MIT License
from Vip-Augus

protected ApplicationContext getApplicationContext() {
    replacedert.state(this.applicationContext != null, "No ApplicationContext set");
    return this.applicationContext;
}

19 Source : GroovyMarkupConfigurer.java
with MIT License
from Vip-Augus

public MarkupTemplateEngine getTemplateEngine() {
    replacedert.state(this.templateEngine != null, "No MarkupTemplateEngine set");
    return this.templateEngine;
}

19 Source : FreeMarkerView.java
with MIT License
from Vip-Augus

/**
 * Obtain the FreeMarker configuration for actual use.
 * @return the FreeMarker configuration (never {@code null})
 * @throws IllegalStateException in case of no Configuration object set
 * @since 5.0
 */
protected Configuration obtainConfiguration() {
    Configuration configuration = getConfiguration();
    replacedert.state(configuration != null, "No Configuration set");
    return configuration;
}

19 Source : AbstractPdfStamperView.java
with MIT License
from Vip-Augus

/**
 * Read the raw PDF resource into an iText PdfReader.
 * <p>The default implementation resolve the specified "url" property
 * as ApplicationContext resource.
 * @return the PdfReader instance
 * @throws IOException if resource access failed
 * @see #setUrl
 */
protected PdfReader readPdfResource() throws IOException {
    String url = getUrl();
    replacedert.state(url != null, "'url' not set");
    return new PdfReader(obtainApplicationContext().getResource(url).getInputStream());
}

19 Source : RequestContextAwareTag.java
with MIT License
from Vip-Augus

/**
 * Return the current RequestContext.
 */
protected final RequestContext getRequestContext() {
    replacedert.state(this.requestContext != null, "No current RequestContext");
    return this.requestContext;
}

19 Source : FormTag.java
with MIT License
from Vip-Augus

/**
 * Writes the given values as hidden fields.
 */
private void writeHiddenFields(@Nullable Map<String, String> hiddenFields) throws JspException {
    if (!CollectionUtils.isEmpty(hiddenFields)) {
        replacedert.state(this.tagWriter != null, "No TagWriter set");
        this.tagWriter.appendValue("<div>\n");
        for (String name : hiddenFields.keySet()) {
            this.tagWriter.appendValue("<input type=\"hidden\" ");
            this.tagWriter.appendValue("name=\"" + name + "\" value=\"" + hiddenFields.get(name) + "\" ");
            this.tagWriter.appendValue("/>\n");
        }
        this.tagWriter.appendValue("</div>");
    }
}

19 Source : AbstractMultiCheckedElementTag.java
with MIT License
from Vip-Augus

private void writeElementTag(TagWriter tagWriter, Object item, @Nullable Object value, @Nullable Object label, int itemIndex) throws JspException {
    tagWriter.startTag(getElement());
    if (itemIndex > 0) {
        Object resolvedDelimiter = evaluate("delimiter", getDelimiter());
        if (resolvedDelimiter != null) {
            tagWriter.appendValue(resolvedDelimiter.toString());
        }
    }
    tagWriter.startTag("input");
    String id = resolveId();
    replacedert.state(id != null, "Attribute 'id' is required");
    writeOptionalAttribute(tagWriter, "id", id);
    writeOptionalAttribute(tagWriter, "name", getName());
    writeOptionalAttributes(tagWriter);
    tagWriter.writeAttribute("type", getInputType());
    renderFromValue(item, value, tagWriter);
    tagWriter.endTag();
    tagWriter.startTag("label");
    tagWriter.writeAttribute("for", id);
    tagWriter.appendValue(convertToDisplayString(label));
    tagWriter.endTag();
    tagWriter.endTag();
}

19 Source : EscapeBodyTag.java
with MIT License
from Vip-Augus

/**
 * Read the unescaped body content from the page.
 * @return the original content
 * @throws IOException if reading failed
 */
protected String readBodyContent() throws IOException {
    replacedert.state(this.bodyContent != null, "No BodyContent set");
    return this.bodyContent.getString();
}

19 Source : EscapeBodyTag.java
with MIT License
from Vip-Augus

/**
 * Write the escaped body content to the page.
 * <p>Can be overridden in subclreplacedes, e.g. for testing purposes.
 * @param content the content to write
 * @throws IOException if writing failed
 */
protected void writeBodyContent(String content) throws IOException {
    replacedert.state(this.bodyContent != null, "No BodyContent set");
    this.bodyContent.getEnclosingWriter().print(content);
}

See More Examples