org.springframework.util.StringUtils.hasLength()

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

312 Examples 7

19 View Source File : DevToolsHomePropertiesPostProcessor.java
License : Apache License 2.0
Project Creator : yuanmabiji

protected File getHomeFolder() {
    String home = System.getProperty("user.home");
    if (StringUtils.hasLength(home)) {
        return new File(home);
    }
    return null;
}

19 View Source File : RepositoryConfigurationFactory.java
License : Apache License 2.0
Project Creator : yuanmabiji

private static File getM2HomeDirectory() {
    String mavenRoot = System.getProperty("maven.home");
    if (StringUtils.hasLength(mavenRoot)) {
        return new File(mavenRoot);
    }
    return new File(System.getProperty("user.home"), ".m2");
}

private File getDefaultM2HomeDirectory() {
    String mavenRoot = System.getProperty("maven.home");
    if (StringUtils.hasLength(mavenRoot)) {
        return new File(mavenRoot);
    }
    return new File(System.getProperty("user.home"), ".m2");
}

19 View Source File : Shell.java
License : Apache License 2.0
Project Creator : yuanmabiji

private void runInputLoop() throws Exception {
    String line;
    while ((line = this.consoleReader.readLine(getPrompt())) != null) {
        while (line.endsWith("\\")) {
            line = line.substring(0, line.length() - 1);
            line += this.consoleReader.readLine("> ");
        }
        if (StringUtils.hasLength(line)) {
            String[] args = this.argumentDelimiter.parseArguments(line);
            this.commandRunner.runAndHandleErrors(args);
        }
    }
}

19 View Source File : AtomikosJtaConfiguration.java
License : Apache License 2.0
Project Creator : yuanmabiji

private String getLogBaseDir() {
    if (StringUtils.hasLength(this.jtaProperties.getLogDir())) {
        return this.jtaProperties.getLogDir();
    }
    File home = new ApplicationHome().getDir();
    return new File(home, "transaction-logs").getAbsolutePath();
}

19 View Source File : JerseyAutoConfiguration.java
License : Apache License 2.0
Project Creator : yuanmabiji

private void resolveApplicationPath() {
    if (StringUtils.hasLength(this.jersey.getApplicationPath())) {
        this.path = parseApplicationPath(this.jersey.getApplicationPath());
    } else {
        this.path = findApplicationPath(AnnotationUtils.findAnnotation(this.config.getApplication().getClreplaced(), ApplicationPath.clreplaced));
    }
}

19 View Source File : DataSourceProperties.java
License : Apache License 2.0
Project Creator : yuanmabiji

/**
 * Determine the name to used based on this configuration.
 * @return the database name to use or {@code null}
 * @since 2.0.0
 */
public String determineDatabaseName() {
    if (this.generateUniqueName) {
        if (this.uniqueName == null) {
            this.uniqueName = UUID.randomUUID().toString();
        }
        return this.uniqueName;
    }
    if (StringUtils.hasLength(this.name)) {
        return this.name;
    }
    if (this.embeddedDatabaseConnection != EmbeddedDatabaseConnection.NONE) {
        return "testdb";
    }
    return null;
}

19 View Source File : DelegatingApplicationContextInitializer.java
License : Apache License 2.0
Project Creator : yuanmabiji

private List<Clreplaced<?>> getInitializerClreplacedes(ConfigurableEnvironment env) {
    String clreplacedNames = env.getProperty(PROPERTY_NAME);
    List<Clreplaced<?>> clreplacedes = new ArrayList<>();
    if (StringUtils.hasLength(clreplacedNames)) {
        for (String clreplacedName : StringUtils.tokenizeToStringArray(clreplacedNames, ",")) {
            clreplacedes.add(getInitializerClreplaced(clreplacedName));
        }
    }
    return clreplacedes;
}

19 View Source File : ServletUriComponentsBuilder.java
License : MIT License
Project Creator : Vip-Augus

/**
 * Remove any path extension from the {@link HttpServletRequest#getRequestURI()
 * requestURI}. This method must be invoked before any calls to {@link #path(String)}
 * or {@link #pathSegment(String...)}.
 * <pre>
 * GET http://www.foo.com/rest/books/6.json
 *
 * ServletUriComponentsBuilder builder = ServletUriComponentsBuilder.fromRequestUri(this.request);
 * String ext = builder.removePathExtension();
 * String uri = builder.path("/pages/1.{ext}").buildAndExpand(ext).toUriString();
 * replacedertEquals("http://www.foo.com/rest/books/6/pages/1.json", result);
 * </pre>
 * @return the removed path extension for possible re-use, or {@code null}
 * @since 4.0
 */
@Nullable
public String removePathExtension() {
    String extension = null;
    if (this.originalPath != null) {
        extension = UriUtils.extractFileExtension(this.originalPath);
        if (StringUtils.hasLength(extension)) {
            int end = this.originalPath.length() - (extension.length() + 1);
            replacePath(this.originalPath.substring(0, end));
        }
        this.originalPath = null;
    }
    return extension;
}

19 View Source File : HierarchicalUriComponents.java
License : MIT License
Project Creator : Vip-Augus

// Other functionality
@Override
public String toUriString() {
    StringBuilder uriBuilder = new StringBuilder();
    if (getScheme() != null) {
        uriBuilder.append(getScheme()).append(':');
    }
    if (this.userInfo != null || this.host != null) {
        uriBuilder.append("//");
        if (this.userInfo != null) {
            uriBuilder.append(this.userInfo).append('@');
        }
        if (this.host != null) {
            uriBuilder.append(this.host);
        }
        if (getPort() != -1) {
            uriBuilder.append(':').append(this.port);
        }
    }
    String path = getPath();
    if (StringUtils.hasLength(path)) {
        if (uriBuilder.length() != 0 && path.charAt(0) != PATH_DELIMITER) {
            uriBuilder.append(PATH_DELIMITER);
        }
        uriBuilder.append(path);
    }
    String query = getQuery();
    if (query != null) {
        uriBuilder.append('?').append(query);
    }
    if (getFragment() != null) {
        uriBuilder.append('#').append(getFragment());
    }
    return uriBuilder.toString();
}

19 View Source File : DefaultServerHttpRequestBuilder.java
License : MIT License
Project Creator : Vip-Augus

private URI getUriToUse() {
    if (this.uriPath == null) {
        return this.uri;
    }
    StringBuilder uriBuilder = new StringBuilder();
    if (this.uri.getScheme() != null) {
        uriBuilder.append(this.uri.getScheme()).append(':');
    }
    if (this.uri.getRawUserInfo() != null || this.uri.getHost() != null) {
        uriBuilder.append("//");
        if (this.uri.getRawUserInfo() != null) {
            uriBuilder.append(this.uri.getRawUserInfo()).append('@');
        }
        if (this.uri.getHost() != null) {
            uriBuilder.append(this.uri.getHost());
        }
        if (this.uri.getPort() != -1) {
            uriBuilder.append(':').append(this.uri.getPort());
        }
    }
    if (StringUtils.hasLength(this.uriPath)) {
        uriBuilder.append(this.uriPath);
    }
    if (this.uri.getRawQuery() != null) {
        uriBuilder.append('?').append(this.uri.getRawQuery());
    }
    if (this.uri.getRawFragment() != null) {
        uriBuilder.append('#').append(this.uri.getRawFragment());
    }
    try {
        return new URI(uriBuilder.toString());
    } catch (URISyntaxException ex) {
        throw new IllegalStateException("Invalid URI path: \"" + this.uriPath + "\"", ex);
    }
}

19 View Source File : MessageHeaderAccessor.java
License : MIT License
Project Creator : Vip-Augus

/**
 * Removes all headers provided via array of 'headerPatterns'.
 * <p>As the name suggests, array may contain simple matching patterns for header
 * names. Supported pattern styles are: "xxx*", "*xxx", "*xxx*" and "xxx*yyy".
 */
public void removeHeaders(String... headerPatterns) {
    List<String> headersToRemove = new ArrayList<>();
    for (String pattern : headerPatterns) {
        if (StringUtils.hasLength(pattern)) {
            if (pattern.contains("*")) {
                headersToRemove.addAll(getMatchingHeaderNames(pattern, this.headers));
            } else {
                headersToRemove.add(pattern);
            }
        }
    }
    for (String headerToRemove : headersToRemove) {
        removeHeader(headerToRemove);
    }
}

19 View Source File : AbstractErrors.java
License : MIT License
Project Creator : Vip-Augus

/**
 * Transform the given field into its full path,
 * regarding the nested path of this instance.
 */
protected String fixedField(@Nullable String field) {
    if (StringUtils.hasLength(field)) {
        return getNestedPath() + canonicalFieldName(field);
    } else {
        String path = getNestedPath();
        return (path.endsWith(Errors.NESTED_PATH_SEPARATOR) ? path.substring(0, path.length() - NESTED_PATH_SEPARATOR.length()) : path);
    }
}

19 View Source File : DisposableBeanAdapter.java
License : MIT License
Project Creator : Vip-Augus

/**
 * Check whether the given bean has any kind of destroy method to call.
 * @param bean the bean instance
 * @param beanDefinition the corresponding bean definition
 */
public static boolean hasDestroyMethod(Object bean, RootBeanDefinition beanDefinition) {
    if (bean instanceof DisposableBean || bean instanceof AutoCloseable) {
        return true;
    }
    String destroyMethodName = beanDefinition.getDestroyMethodName();
    if (AbstractBeanDefinition.INFER_METHOD.equals(destroyMethodName)) {
        return (ClreplacedUtils.hasMethod(bean.getClreplaced(), CLOSE_METHOD_NAME) || ClreplacedUtils.hasMethod(bean.getClreplaced(), SHUTDOWN_METHOD_NAME));
    }
    return StringUtils.hasLength(destroyMethodName);
}

19 View Source File : DeprecatedBeanWarner.java
License : MIT License
Project Creator : Vip-Augus

/**
 * Logs a warning for a bean annotated with {@link Deprecated @Deprecated}.
 * @param beanName the name of the deprecated bean
 * @param beanType the user-specified type of the deprecated bean
 * @param beanDefinition the definition of the deprecated bean
 */
protected void logDeprecatedBean(String beanName, Clreplaced<?> beanType, BeanDefinition beanDefinition) {
    StringBuilder builder = new StringBuilder();
    builder.append(beanType);
    builder.append(" ['");
    builder.append(beanName);
    builder.append('\'');
    String resourceDescription = beanDefinition.getResourceDescription();
    if (StringUtils.hasLength(resourceDescription)) {
        builder.append(" in ");
        builder.append(resourceDescription);
    }
    builder.append("] has been deprecated");
    writeToLog(builder.toString());
}

19 View Source File : AbstractAutoProxyCreator.java
License : MIT License
Project Creator : Vip-Augus

/**
 * Build a cache key for the given bean clreplaced and bean name.
 * <p>Note: As of 4.2.3, this implementation does not return a concatenated
 * clreplaced/name String anymore but rather the most efficient cache key possible:
 * a plain bean name, prepended with {@link BeanFactory#FACTORY_BEAN_PREFIX}
 * in case of a {@code FactoryBean}; or if no bean name specified, then the
 * given bean {@code Clreplaced} as-is.
 * @param beanClreplaced the bean clreplaced
 * @param beanName the bean name
 * @return the cache key for the given clreplaced and name
 */
protected Object getCacheKey(Clreplaced<?> beanClreplaced, @Nullable String beanName) {
    if (StringUtils.hasLength(beanName)) {
        return (FactoryBean.clreplaced.isreplacedignableFrom(beanClreplaced) ? BeanFactory.FACTORY_BEAN_PREFIX + beanName : beanName);
    } else {
        return beanClreplaced;
    }
}

19 View Source File : DependencyResolver.java
License : Apache License 2.0
Project Creator : spring-projects-experimental

private File getM2RepoDirectory() {
    String mavenRoot = System.getProperty("maven.repo.local");
    if (StringUtils.hasLength(mavenRoot)) {
        return new File(mavenRoot);
    }
    return new File(getDefaultM2HomeDirectory(), "repository");
}

19 View Source File : AbstractGatewayRSocket.java
License : Apache License 2.0
Project Creator : spring-cloud-incubator

protected String getMetricName(GatewayExchange exchange, String suffix) {
    StringBuilder name = new StringBuilder("forward.");
    name.append(exchange.getType().getKey());
    if (StringUtils.hasLength(suffix)) {
        name.append(".");
        name.append(suffix);
    }
    return name.toString();
}

19 View Source File : FeignClientFactoryBean.java
License : Apache License 2.0
Project Creator : spring-cloud

private String cleanPath() {
    String path = this.path.trim();
    if (StringUtils.hasLength(path)) {
        if (!path.startsWith("/")) {
            path = "/" + path;
        }
        if (path.endsWith("/")) {
            path = path.substring(0, path.length() - 1);
        }
    }
    return path;
}

19 View Source File : GoogleManagedAccount.java
License : Apache License 2.0
Project Creator : spinnaker

private InputStream getInputStream() throws FileNotFoundException {
    if (StringUtils.hasLength(jsonPath)) {
        if (jsonPath.startsWith("clreplacedpath:")) {
            return getClreplaced().getResourcereplacedtream(jsonPath.replace("clreplacedpath:", ""));
        } else {
            return new FileInputStream(new File(jsonPath));
        }
    } else {
        return null;
    }
}

19 View Source File : BrokerReportController.java
License : GNU Affero General Public License v3.0
Project Creator : spacious-team

private BrokerNameAndReport getBrokerReport(MultipartFile report, String providedByBroker) throws IOException {
    if (StringUtils.hasLength(providedByBroker)) {
        return getReportOfKnownBroker(report, providedByBroker);
    } else {
        return getReportOfUnknownBroker(report);
    }
}

19 View Source File : ServletUriComponentsBuilder.java
License : Apache License 2.0
Project Creator : SourceHot

/**
 * Remove any path extension from the {@link HttpServletRequest#getRequestURI()
 * requestURI}. This method must be invoked before any calls to {@link #path(String)}
 * or {@link #pathSegment(String...)}.
 * <pre>
 * GET http://www.foo.example/rest/books/6.json
 *
 * ServletUriComponentsBuilder builder = ServletUriComponentsBuilder.fromRequestUri(this.request);
 * String ext = builder.removePathExtension();
 * String uri = builder.path("/pages/1.{ext}").buildAndExpand(ext).toUriString();
 * replacedertEquals("http://www.foo.example/rest/books/6/pages/1.json", result);
 * </pre>
 * @return the removed path extension for possible re-use, or {@code null}
 * @since 4.0
 */
@Nullable
public String removePathExtension() {
    String extension = null;
    if (this.originalPath != null) {
        extension = UriUtils.extractFileExtension(this.originalPath);
        if (StringUtils.hasLength(extension)) {
            int end = this.originalPath.length() - (extension.length() + 1);
            replacePath(this.originalPath.substring(0, end));
        }
        this.originalPath = null;
    }
    return extension;
}

19 View Source File : AbstractAutoProxyCreator.java
License : Apache License 2.0
Project Creator : SourceHot

/**
 * Build a cache key for the given bean clreplaced and bean name.
 * <p>Note: As of 4.2.3, this implementation does not return a concatenated
 * clreplaced/name String anymore but rather the most efficient cache key possible: a plain bean
 * name, prepended with {@link BeanFactory#FACTORY_BEAN_PREFIX} in case of a {@code
 * FactoryBean}; or if no bean name specified, then the given bean {@code Clreplaced} as-is.
 *
 * @param beanClreplaced the bean clreplaced
 * @param beanName  the bean name
 *
 * @return the cache key for the given clreplaced and name
 */
protected Object getCacheKey(Clreplaced<?> beanClreplaced, @Nullable String beanName) {
    if (StringUtils.hasLength(beanName)) {
        return (FactoryBean.clreplaced.isreplacedignableFrom(beanClreplaced) ? BeanFactory.FACTORY_BEAN_PREFIX + beanName : beanName);
    } else {
        return beanClreplaced;
    }
}

19 View Source File : NarayanaConfiguration.java
License : Apache License 2.0
Project Creator : snowdrop

private File getLogDir() {
    if (StringUtils.hasLength(this.jtaProperties.getLogDir())) {
        return new File(this.jtaProperties.getLogDir());
    }
    File home = new ApplicationHome().getDir();
    return new File(home, "transaction-logs");
}

19 View Source File : ServiceAssert.java
License : MIT License
Project Creator : leecho

private static void replacedignableCheckFailed(Clreplaced<?> superType, Clreplaced<?> subType, Integer code, String msg) {
    String result = "";
    boolean defaultMessage = true;
    if (StringUtils.hasLength(msg)) {
        if (endsWithSeparator(msg)) {
            result = msg + " ";
        } else {
            result = messageWithTypeName(msg, subType);
            defaultMessage = false;
        }
    }
    if (defaultMessage) {
        result = result + (subType + " is not replacedignable to " + superType);
    }
    throw new ServiceException(code, result);
}

19 View Source File : ServiceAssert.java
License : MIT License
Project Creator : leecho

private static void instanceCheckFailed(Clreplaced<?> type, Object obj, String msg) {
    String clreplacedName = (obj != null ? obj.getClreplaced().getName() : "null");
    String result = "";
    boolean defaultMessage = true;
    if (StringUtils.hasLength(msg)) {
        if (endsWithSeparator(msg)) {
            result = msg + " ";
        } else {
            result = messageWithTypeName(msg, clreplacedName);
            defaultMessage = false;
        }
    }
    if (defaultMessage) {
        result = result + ("Object of clreplaced [" + clreplacedName + "] must be an instance of " + type);
    }
    throw new IllegalArgumentException(result);
}

19 View Source File : ServiceAssert.java
License : MIT License
Project Creator : leecho

private static void replacedignableCheckFailed(Clreplaced<?> superType, @Nullable Clreplaced<?> subType, @Nullable ErrorMessage msg) {
    String result = "";
    boolean defaultMessage = true;
    if (StringUtils.hasLength(msg.getMessage())) {
        if (endsWithSeparator(msg.getMessage())) {
            result = msg + " ";
        } else {
            result = messageWithTypeName(msg.getMessage(), subType);
            defaultMessage = false;
        }
    }
    if (defaultMessage) {
        result = result + (subType + " is not replacedignable to " + superType);
    }
    throw new IllegalArgumentException(result);
}

19 View Source File : ServiceAssert.java
License : MIT License
Project Creator : leecho

private static void instanceCheckFailed(Clreplaced<?> type, @Nullable Object obj, @Nullable ErrorMessage msg) {
    String clreplacedName = (obj != null ? obj.getClreplaced().getName() : "null");
    String result = "";
    boolean defaultMessage = true;
    if (StringUtils.hasLength(msg.getMessage())) {
        if (endsWithSeparator(msg.getMessage())) {
            result = msg + " ";
        } else {
            result = messageWithTypeName(msg.getMessage(), clreplacedName);
            defaultMessage = false;
        }
    }
    if (defaultMessage) {
        result = result + ("Object of clreplaced [" + clreplacedName + "] must be an instance of " + type);
    }
    throw new IllegalArgumentException(result);
}

19 View Source File : ControllerClassNameHandlerMapping.java
License : Apache License 2.0
Project Creator : langtianya

/**
 * Specify a prefix to prepend to the path generated from the controller name.
 * <p>Default is a plain slash ("/"). A path like "/mymodule" can be specified
 * in order to have controller path mappings prefixed with that path, e.g.
 * "/mymodule/buyform" instead of "/buyform" for the clreplaced name "BuyForm".
 */
public void setPathPrefix(String prefixPath) {
    this.pathPrefix = prefixPath;
    if (StringUtils.hasLength(this.pathPrefix)) {
        if (!this.pathPrefix.startsWith("/")) {
            this.pathPrefix = "/" + this.pathPrefix;
        }
        if (this.pathPrefix.endsWith("/")) {
            this.pathPrefix = this.pathPrefix.substring(0, this.pathPrefix.length() - 1);
        }
    }
}

19 View Source File : HttpEntityMethodProcessor.java
License : Apache License 2.0
Project Creator : langtianya

private boolean isETagNotModified(List<String> ifNoneMatch, String etag) {
    if (StringUtils.hasLength(etag)) {
        for (String clientETag : ifNoneMatch) {
            // Compare weak/strong ETags as per https://tools.ietf.org/html/rfc7232#section-2.3
            if (StringUtils.hasLength(clientETag) && (clientETag.replaceFirst("^W/", "").equals(etag.replaceFirst("^W/", "")))) {
                return true;
            }
        }
    }
    return false;
}

19 View Source File : MockHttpServletRequest.java
License : Apache License 2.0
Project Creator : langtianya

private void updateContentTypeHeader() {
    if (StringUtils.hasLength(this.contentType)) {
        StringBuilder sb = new StringBuilder(this.contentType);
        if (!this.contentType.toLowerCase().contains(CHARSET_PREFIX) && StringUtils.hasLength(this.characterEncoding)) {
            sb.append(";").append(CHARSET_PREFIX).append(this.characterEncoding);
        }
        doAddHeaderValue(CONTENT_TYPE_HEADER, sb.toString(), true);
    }
}

19 View Source File : HierarchicalUriComponents.java
License : Apache License 2.0
Project Creator : langtianya

// other functionality
/**
 * Returns a URI string from this {@code UriComponents} instance.
 */
@Override
public String toUriString() {
    StringBuilder uriBuilder = new StringBuilder();
    if (getScheme() != null) {
        uriBuilder.append(getScheme());
        uriBuilder.append(':');
    }
    if (this.userInfo != null || this.host != null) {
        uriBuilder.append("//");
        if (this.userInfo != null) {
            uriBuilder.append(this.userInfo);
            uriBuilder.append('@');
        }
        if (this.host != null) {
            uriBuilder.append(host);
        }
        if (getPort() != -1) {
            uriBuilder.append(':');
            uriBuilder.append(port);
        }
    }
    String path = getPath();
    if (StringUtils.hasLength(path)) {
        if (uriBuilder.length() != 0 && path.charAt(0) != PATH_DELIMITER) {
            uriBuilder.append(PATH_DELIMITER);
        }
        uriBuilder.append(path);
    }
    String query = getQuery();
    if (query != null) {
        uriBuilder.append('?');
        uriBuilder.append(query);
    }
    if (getFragment() != null) {
        uriBuilder.append('#');
        uriBuilder.append(getFragment());
    }
    return uriBuilder.toString();
}

19 View Source File : Jaxb2Marshaller.java
License : Apache License 2.0
Project Creator : langtianya

/**
 * Return the JAXBContext used by this marshaller, lazily building it if necessary.
 */
public JAXBContext getJaxbContext() {
    if (this.jaxbContext != null) {
        return this.jaxbContext;
    }
    synchronized (this.jaxbContextMonitor) {
        if (this.jaxbContext == null) {
            try {
                if (StringUtils.hasLength(this.contextPath)) {
                    this.jaxbContext = createJaxbContextFromContextPath();
                } else if (!ObjectUtils.isEmpty(this.clreplacedesToBeBound)) {
                    this.jaxbContext = createJaxbContextFromClreplacedes();
                } else if (!ObjectUtils.isEmpty(this.packagesToScan)) {
                    this.jaxbContext = createJaxbContextFromPackages();
                }
            } catch (JAXBException ex) {
                throw convertJaxbException(ex);
            }
        }
        return this.jaxbContext;
    }
}

19 View Source File : MessageHeaderAccessor.java
License : Apache License 2.0
Project Creator : langtianya

/**
 * Removes all headers provided via array of 'headerPatterns'.
 * <p>As the name suggests, array may contain simple matching patterns for header
 * names. Supported pattern styles are: "xxx*", "*xxx", "*xxx*" and "xxx*yyy".
 */
public void removeHeaders(String... headerPatterns) {
    List<String> headersToRemove = new ArrayList<String>();
    for (String pattern : headerPatterns) {
        if (StringUtils.hasLength(pattern)) {
            if (pattern.contains("*")) {
                headersToRemove.addAll(getMatchingHeaderNames(pattern, this.headers));
            } else {
                headersToRemove.add(pattern);
            }
        }
    }
    for (String headerToRemove : headersToRemove) {
        removeHeader(headerToRemove);
    }
}

19 View Source File : AbstractErrors.java
License : Apache License 2.0
Project Creator : langtianya

/**
 * Transform the given field into its full path,
 * regarding the nested path of this instance.
 */
protected String fixedField(String field) {
    if (StringUtils.hasLength(field)) {
        return getNestedPath() + canonicalFieldName(field);
    } else {
        String path = getNestedPath();
        return (path.endsWith(Errors.NESTED_PATH_SEPARATOR) ? path.substring(0, path.length() - NESTED_PATH_SEPARATOR.length()) : path);
    }
}

19 View Source File : DisposableBeanAdapter.java
License : Apache License 2.0
Project Creator : langtianya

/**
 * Check whether the given bean has any kind of destroy method to call.
 * @param bean the bean instance
 * @param beanDefinition the corresponding bean definition
 */
public static boolean hasDestroyMethod(Object bean, RootBeanDefinition beanDefinition) {
    if (bean instanceof DisposableBean || closeableInterface.isInstance(bean)) {
        return true;
    }
    String destroyMethodName = beanDefinition.getDestroyMethodName();
    if (AbstractBeanDefinition.INFER_METHOD.equals(destroyMethodName)) {
        return ClreplacedUtils.hasMethod(bean.getClreplaced(), CLOSE_METHOD_NAME);
    }
    return StringUtils.hasLength(destroyMethodName);
}

19 View Source File : AbstractAutoProxyCreator.java
License : Apache License 2.0
Project Creator : langtianya

/**
 * Build a cache key for the given bean clreplaced and bean name.
 * <p>Note: As of 4.2.3, this implementation does not return a concatenated
 * clreplaced/name String anymore but rather the most efficient cache key possible:
 * a plain bean name, prepended with {@link BeanFactory#FACTORY_BEAN_PREFIX}
 * in case of a {@code FactoryBean}; or if no bean name specified, then the
 * given bean {@code Clreplaced} as-is.
 * @param beanClreplaced the bean clreplaced
 * @param beanName the bean name
 * @return the cache key for the given clreplaced and name
 */
protected Object getCacheKey(Clreplaced<?> beanClreplaced, String beanName) {
    if (StringUtils.hasLength(beanName)) {
        return (FactoryBean.clreplaced.isreplacedignableFrom(beanClreplaced) ? BeanFactory.FACTORY_BEAN_PREFIX + beanName : beanName);
    } else {
        return beanClreplaced;
    }
}

19 View Source File : DataSourceProperties.java
License : Apache License 2.0
Project Creator : hello-shf

/**
 * Determine the name to used based on this configuration.
 *
 * @return the database name to use or {@code null}
 * @since 2.0.0
 */
public String determineDatabaseName() {
    if (this.generateUniqueName) {
        if (this.uniqueName == null) {
            this.uniqueName = UUID.randomUUID().toString();
        }
        return this.uniqueName;
    }
    if (StringUtils.hasLength(this.name)) {
        return this.name;
    }
    if (this.embeddedDatabaseConnection != EmbeddedDatabaseConnection.NONE) {
        return "testdb";
    }
    return null;
}

19 View Source File : WxApiResultException.java
License : Apache License 2.0
Project Creator : FastBootWeixin

public static boolean hasException(String result) {
    if (StringUtils.hasLength(result)) {
        // 包含错误码但是错误码不是0
        if (result.contains(WX_API_RESULT_ERRCODE) && !result.contains(WX_API_RESULT_SUCCESS)) {
            return true;
        }
    }
    return false;
}

19 View Source File : YamlUtils.java
License : Apache License 2.0
Project Creator : dyc87112

public static void yamlToProperties(Properties props, Map<String, Object> map, String path) {
    for (Map.Entry<String, Object> entry : map.entrySet()) {
        String key = entry.getKey();
        if (StringUtils.hasLength(path))
            key = path + "." + key;
        Object val = entry.getValue();
        if (val instanceof Map) {
            yamlToProperties(props, (Map<String, Object>) val, key);
        } else if (val instanceof List) {
            int index = 0;
            for (Object v : (List) val) {
                props.put(key + "[" + index + "]", v == null ? "" : v.toString());
                index++;
            }
        } else {
            props.put(key, val == null ? "" : val.toString());
        }
    }
}

19 View Source File : AwsSecretsManagerPropertySources.java
License : Apache License 2.0
Project Creator : awspring

protected String getContext(String prefix, String context) {
    if (StringUtils.hasLength(prefix)) {
        return prefix + "/" + context;
    }
    return context;
}

19 View Source File : AnalyzeableTransaction.java
License : Apache License 2.0
Project Creator : adorsys

public String getPurpose() {
    if (StringUtils.hasLength(getRemittanceInformationStructured())) {
        return normalize(getRemittanceInformationStructured());
    }
    if (StringUtils.hasLength(getRemittanceInformationUnstructured())) {
        return normalize(getRemittanceInformationUnstructured());
    }
    return null;
}

18 View Source File : BitronixJtaConfiguration.java
License : Apache License 2.0
Project Creator : yuanmabiji

private File getLogBaseDir() {
    if (StringUtils.hasLength(this.jtaProperties.getLogDir())) {
        return new File(this.jtaProperties.getLogDir());
    }
    File home = new ApplicationHome().getDir();
    return new File(home, "transaction-logs");
}

18 View Source File : JndiConnectionFactoryAutoConfiguration.java
License : Apache License 2.0
Project Creator : yuanmabiji

@Bean
public ConnectionFactory connectionFactory() throws NamingException {
    if (StringUtils.hasLength(this.properties.getJndiName())) {
        return this.jndiLocatorDelegate.lookup(this.properties.getJndiName(), ConnectionFactory.clreplaced);
    }
    return findJndiConnectionFactory();
}

18 View Source File : SpringBootCondition.java
License : Apache License 2.0
Project Creator : yuanmabiji

private StringBuilder getLogMessage(String clreplacedOrMethodName, ConditionOutcome outcome) {
    StringBuilder message = new StringBuilder();
    message.append("Condition ");
    message.append(ClreplacedUtils.getShortName(getClreplaced()));
    message.append(" on ");
    message.append(clreplacedOrMethodName);
    message.append(outcome.isMatch() ? " matched" : " did not match");
    if (StringUtils.hasLength(outcome.getMessage())) {
        message.append(" due to ");
        message.append(outcome.getMessage());
    }
    return message;
}

18 View Source File : PropertiesMeterFilter.java
License : Apache License 2.0
Project Creator : yuanmabiji

private <T> T doLookup(Map<String, T> values, Id id, Supplier<T> defaultValue) {
    String name = id.getName();
    while (StringUtils.hasLength(name)) {
        T result = values.get(name);
        if (result != null) {
            return result;
        }
        int lastDot = name.lastIndexOf('.');
        name = (lastDot != -1) ? name.substring(0, lastDot) : "";
    }
    return defaultValue.get();
}

18 View Source File : LoggingSystem.java
License : Apache License 2.0
Project Creator : yuanmabiji

/**
 * Detect and return the logging system in use. Supports Logback and Java Logging.
 * @param clreplacedLoader the clreplacedloader
 * @return the logging system
 */
public static LoggingSystem get(ClreplacedLoader clreplacedLoader) {
    String loggingSystem = System.getProperty(SYSTEM_PROPERTY);
    if (StringUtils.hasLength(loggingSystem)) {
        if (NONE.equals(loggingSystem)) {
            return new NoOpLoggingSystem();
        }
        return get(clreplacedLoader, loggingSystem);
    }
    return SYSTEMS.entrySet().stream().filter((entry) -> ClreplacedUtils.isPresent(entry.getKey(), clreplacedLoader)).map((entry) -> get(clreplacedLoader, entry.getValue())).findFirst().orElseThrow(() -> new IllegalStateException("No suitable logging system located"));
}

18 View Source File : AbstractLoggingSystem.java
License : Apache License 2.0
Project Creator : yuanmabiji

@Override
public void initialize(LoggingInitializationContext initializationContext, String configLocation, LogFile logFile) {
    if (StringUtils.hasLength(configLocation)) {
        initializeWithSpecificConfig(initializationContext, configLocation, logFile);
        return;
    }
    initializeWithConventions(initializationContext, logFile);
}

18 View Source File : AnsiPropertySource.java
License : Apache License 2.0
Project Creator : yuanmabiji

@Override
public Object getProperty(String name) {
    if (StringUtils.hasLength(name)) {
        for (MappedEnum<?> mappedEnum : MAPPED_ENUMS) {
            if (name.startsWith(mappedEnum.getPrefix())) {
                String enumName = name.substring(mappedEnum.getPrefix().length());
                for (Enum<?> ansiEnum : mappedEnum.getEnums()) {
                    if (ansiEnum.name().equals(enumName)) {
                        if (this.encode) {
                            return AnsiOutput.encode((AnsiElement) ansiEnum);
                        }
                        return ansiEnum;
                    }
                }
            }
        }
    }
    return null;
}

18 View Source File : SubProtocolWebSocketHandler.java
License : MIT License
Project Creator : Vip-Augus

/**
 * Find a {@link SubProtocolHandler} for the given session.
 * @param session the {@code WebSocketSession} to find a handler for
 */
protected final SubProtocolHandler findProtocolHandler(WebSocketSession session) {
    String protocol = null;
    try {
        protocol = session.getAcceptedProtocol();
    } catch (Exception ex) {
        // Shouldn't happen
        logger.error("Failed to obtain session.getAcceptedProtocol(): " + "will use the default protocol handler (if configured).", ex);
    }
    SubProtocolHandler handler;
    if (StringUtils.hasLength(protocol)) {
        handler = this.protocolHandlerLookup.get(protocol);
        if (handler == null) {
            throw new IllegalStateException("No handler for '" + protocol + "' among " + this.protocolHandlerLookup);
        }
    } else {
        if (this.defaultProtocolHandler != null) {
            handler = this.defaultProtocolHandler;
        } else if (this.protocolHandlers.size() == 1) {
            handler = this.protocolHandlers.iterator().next();
        } else {
            throw new IllegalStateException("Multiple protocol handlers configured and " + "no protocol was negotiated. Consider configuring a default SubProtocolHandler.");
        }
    }
    return handler;
}

See More Examples