当前位置: 首页>>代码示例>>Java>>正文


Java StringUtils.defaultIfEmpty方法代码示例

本文整理汇总了Java中org.apache.commons.lang3.StringUtils.defaultIfEmpty方法的典型用法代码示例。如果您正苦于以下问题:Java StringUtils.defaultIfEmpty方法的具体用法?Java StringUtils.defaultIfEmpty怎么用?Java StringUtils.defaultIfEmpty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在org.apache.commons.lang3.StringUtils的用法示例。


在下文中一共展示了StringUtils.defaultIfEmpty方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: shortenURL

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private void shortenURL(@NotNull MessageReceivedEvent event, String url) throws RateLimitException, DiscordException, MissingPermissionsException {
    if (!UrlValidator.getInstance().isValid(url)) {
        EventUtils.sendIncorrectUsageMessage(event.getClient(), event.getMessage().getChannel(), "ShortUrl", "URL is not a valid http/https URL!");
        return;
    }
    try {
        Url shortUrl = GoogleClientServiceFactory.getInstance().getUrlShortenerService()
                                                 .url()
                                                 .insert(new Url().setLongUrl(url))
                                                 .execute();

        @NotNull StringBuilder builder = new StringBuilder(StringUtils.defaultIfEmpty(shortUrl.getId(), "URL was removed by google."));

        if (shortUrl.getStatus() != null && !"OK".equalsIgnoreCase(shortUrl.getStatus())) {
            builder.append("\n")
                   .append("Attention:")
                   .append("   ")
                   .append(shortUrl.getStatus());
        }

        new MessageBuilder(event.getClient())
                .withChannel(event.getMessage().getChannel())
                .withContent("Short URL: ")
                .appendContent(builder.toString(), Styles.UNDERLINE)
                .appendContent("\n")
                .appendContent("Full URL: ")
                .appendContent(url, Styles.UNDERLINE)
                .send();

    } catch (IOException e) {
        logger.error("I/O Error during call to URLShortening service", e);
        new MessageBuilder(event.getClient())
                .withChannel(event.getMessage().getChannel())
                .withContent("Fail during google URL Shortening API Contact.")
                .send();
    }
}
 
开发者ID:ViniciusArnhold,项目名称:ProjectAltaria,代码行数:38,代码来源:GoogleCommandHandler.java

示例2: samlMetadataUIParserAction

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@ConditionalOnMissingBean(name = "samlMetadataUIParserAction")
@Bean
public Action samlMetadataUIParserAction() {
    final String parameter = StringUtils.defaultIfEmpty(casProperties.getSamlMetadataUi().getParameter(),
            SamlProtocolConstants.PARAMETER_ENTITY_ID);
    return new SamlMetadataUIParserAction(parameter, chainingSamlMetadataUIMetadataResolverAdapter(),
            serviceFactory, servicesManager);
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:9,代码来源:SamlMetadataUIConfiguration.java

示例3: doInternalExecute

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
protected Event doInternalExecute(final HttpServletRequest request, final HttpServletResponse response,
                                  final RequestContext context) throws Exception {

    boolean needFrontSlo = false;
    final List<LogoutRequest> logoutRequests = WebUtils.getLogoutRequests(context);
    if (logoutRequests != null) {
        needFrontSlo = logoutRequests
                .stream()
                .anyMatch(logoutRequest -> logoutRequest.getStatus() == LogoutRequestStatus.NOT_ATTEMPTED);
    }

    final String paramName = StringUtils.defaultIfEmpty(logoutProperties.getRedirectParameter(), CasProtocolConstants.PARAMETER_SERVICE);
    LOGGER.debug("Using parameter name [{}] to detect destination service, if any", paramName);
    final String service = request.getParameter(paramName);
    LOGGER.debug("Located target service [{}] for redirection after logout", paramName);

    if (logoutProperties.isFollowServiceRedirects() && StringUtils.isNotBlank(service)) {
        final Service webAppService = webApplicationServiceFactory.createService(service);
        final RegisteredService rService = this.servicesManager.findServiceBy(webAppService);

        if (rService != null && rService.getAccessStrategy().isServiceAccessAllowed()) {
            LOGGER.debug("Redirecting to service [{}]", service);
            WebUtils.putLogoutRedirectUrl(context, service);
        } else {
            LOGGER.warn("Cannot redirect to [{}] given the service is unauthorized to use CAS. "
                    + "Ensure the service is registered with CAS and is enabled to allowed access", service);
        }
    } else {
        LOGGER.debug("No target service is located for redirection after logout, or CAS is not allowed to follow redirects after logout");
    }

    // there are some front services to logout, perform front SLO
    if (needFrontSlo) {
        LOGGER.debug("Proceeding forward with front-channel single logout");
        return new Event(this, FRONT_EVENT);
    }
    LOGGER.debug("Moving forward to finish the logout process");
    return new Event(this, FINISH_EVENT);
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:41,代码来源:LogoutAction.java

示例4: getMessage

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public String getMessage() {
    String messageString = null;
    if (this.message instanceof String) {
        messageString = (String)this.message;
    } else if (this.message instanceof Profiler.Message) {
        Profiler.Message messageObject = (Profiler.Message)this.message;

        messageString = messageObject.getDetailedMessage();

    }

    return StringUtils.defaultIfEmpty(messageString, (String)null);
}
 
开发者ID:alibaba,项目名称:atlas,代码行数:14,代码来源:Profiler.java

示例5: valideerOnderhoudEigenPartij

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * Specifieke regel validatie voor het BRP bericht. Dit past niet niet in de 'generieke' valideer regels stap welke ook voor de GBA routes gebruikt
 * wordt. <br> LET OP! dit is een beetje suffe controle omdat het volgens koppelvlak meerdere partijen meegegeven kunnen worden terwijl ze eigenlijk
 * allemaal hetzelfde moeten zijn....
 */
@Bedrijfsregel(value = Regel.R2061)
private void valideerOnderhoudEigenPartij(final AfnemerindicatieVerzoek verzoek) throws StapException {
    final String zendendePartijCode = verzoek.getStuurgegevens().getZendendePartijCode();
    final String partijWaarvoorIndicatieGeplaatstWordt = verzoek.getAfnemerindicatie().getPartijCode();
    final String partijWaarvoorIndicatieGeplaatstWordt2 = StringUtils
            .defaultIfEmpty(verzoek.getDummyAfnemerCode(), zendendePartijCode);
    if (!StringUtils.equals(zendendePartijCode, partijWaarvoorIndicatieGeplaatstWordt)
            || !StringUtils.equals(zendendePartijCode, partijWaarvoorIndicatieGeplaatstWordt2)) {
        throw new StapMeldingException(Regel.R2061);
    }
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:17,代码来源:AfnemerindicatieVerzoekServiceImpl.java

示例6: schrijfWrapperAttributen

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private static void schrijfWrapperAttributen(final MetaRecord metaRecord, final MetaGroep metaGroep, final BerichtElement.Builder berichtElement,
                                             final Berichtgegevens berichtgegevens) {
    berichtElement.metBerichtElementAttribuut(
            BerichtElementAttribuut.maakBuilder(BerichtConstanten.VOORKOMEN_SLEUTEL, String.valueOf(metaRecord.getVoorkomensleutel())));
    if (berichtgegevens.isMutatiebericht() && berichtgegevens.getVerwerkingssoort(metaRecord) != null) {
        berichtElement.metBerichtElementAttribuut(
                BerichtElementAttribuut.maakBuilder(BerichtConstanten.VERWERKINGSSOORT, berichtgegevens.getVerwerkingssoort(metaRecord).getNaam()));
    }

    /*
      als het record deel uitmaakt van een inverse object
      dan moet objectsleutel ook weggeschreven worden.
     */
    final boolean isRecordVanInverseObject = ElementHelper.getObjectAssociatiecode(metaGroep.getParentObject().getObjectElement()) != null;
    if (isRecordVanInverseObject
            && Element.PERSOON_OUDER_OUDERSCHAP != metaGroep.getGroepElement().getElement()
            && Element.GERELATEERDEOUDER_OUDERSCHAP != metaGroep.getGroepElement().getElement()
            || metaGroep.getGroepElement().isIndicatie()) {
        //zet de sleutel
        final String sleutel = StringUtils.defaultIfEmpty(berichtgegevens.getVersleuteldeObjectSleutel(metaGroep.getParentObject()),
                String.valueOf(metaGroep.getParentObject().getObjectsleutel()));
        berichtElement.metBerichtElementAttribuut(
                BerichtElementAttribuut.maakBuilder(BerichtConstanten.OBJECT_SLEUTEL, sleutel));

        final String objecttype;
        if (metaGroep.getGroepElement().isIndicatie()) {
            //indicaties hebben verschillende objecttypen en worden ook als losse objecten getoond, het objecttype moet echter PersoonIndicatie zijn
            // voor alle indicaties
            objecttype = Element.PERSOON_INDICATIE.getElementWaarde().getXmlNaam();
        } else {
            objecttype = metaGroep.getParentObject().getObjectElement().getTypeObjectElement().getXmlNaam();
        }
        berichtElement.metBerichtElementAttribuut(BerichtElementAttribuut.maakBuilder(BerichtConstanten.OBJECTTYPE, objecttype));
    }
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:36,代码来源:BerichtGroepBuilder.java

示例7: getRequestPath

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * 获取请求路径
 */
public static String getRequestPath(HttpServletRequest request) {
    String servletPath = request.getServletPath();
    String pathInfo = StringUtils.defaultIfEmpty(request.getPathInfo(), "");
    return servletPath + pathInfo;
}
 
开发者ID:huhuics,项目名称:tauren,代码行数:9,代码来源:WebUtil.java

示例8: getName

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * @return Monitor name.
 */
@Override
public String getName() {
    return StringUtils.defaultIfEmpty(this.name, getClass().getSimpleName());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:8,代码来源:AbstractNamedMonitor.java

示例9: getName

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * @return Monitor name.
 */
public String getName() {
    return StringUtils.defaultIfEmpty(this.name, getClass().getSimpleName());
}
 
开发者ID:hsj-xiaokang,项目名称:springboot-shiro-cas-mybatis,代码行数:7,代码来源:AbstractNamedMonitor.java

示例10: lockingStrategy

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Bean
public LockingStrategy lockingStrategy() {
    final TicketRegistryProperties registry = casProperties.getTicket().getRegistry();
    final String uniqueId = StringUtils.defaultIfEmpty(casProperties.getHost().getName(), InetAddressUtils.getCasServerHostName());
    return new JpaLockingStrategy(registry.getCleaner().getAppId(), uniqueId, registry.getJpa().getJpaLockingTimeout());
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:7,代码来源:JpaTicketRegistryConfiguration.java

示例11: setCookieDomain

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
@Override
public void setCookieDomain(final String cookieDomain) {
    super.setCookieDomain(StringUtils.defaultIfEmpty(cookieDomain, null));
}
 
开发者ID:mrluo735,项目名称:cas-5.1.0,代码行数:5,代码来源:CookieRetrievingCookieGenerator.java

示例12: maakWrapperVoorObject

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
private BerichtElement.Builder maakWrapperVoorObject(final MetaObject metaObject) {
    final ObjectElement objectElement = metaObject.getObjectElement();
    final String objectElementNaam;
    final String objecttype;
    if (objectElement.isVanType(HUWELIJKGEREGISTREERD_PARTNERSCHAP)) {
        objectElementNaam = objectElement.getXmlNaam();
        //pak XML naam van relatie, het supertype
        //nog te doen ROOD-2021
        objecttype = ElementConstants.RELATIE.getXmlNaam();
    } else if (objectElement.isVanType(PERSOON_VERSTREKKINGSBEPERKING)) {
        //nog te doen ROOD-2021
        objectElementNaam = "verstrekkingsbeperking";
        objecttype = PERSOON_VERSTREKKINGSBEPERKING.getXmlNaam();
    } else {
        objectElementNaam = objectElement.getXmlNaam();
        objecttype = objectElement.getTypeObjectElement().getXmlNaam();
    }
    final BerichtElement.Builder berichtElement = BerichtElement.builder();
    berichtElement.metNaam(BerichtUtil.lowercaseFirst(objectElementNaam));
    //zet de sleutel
    final String sleutel = StringUtils.defaultIfEmpty(berichtgegevens.getVersleuteldeObjectSleutel(metaObject),
            String.valueOf(metaObject.getObjectsleutel()));
    berichtElement
            .metBerichtElementAttribuut(BerichtElementAttribuut.maakBuilder(BerichtConstanten.OBJECT_SLEUTEL, sleutel));
    berichtElement.metBerichtElementAttribuut(BerichtElementAttribuut.maakBuilder(BerichtConstanten.OBJECTTYPE, objecttype));
    if (berichtgegevens.isMutatiebericht()) {
        final Verwerkingssoort verwerkingssoort = berichtgegevens.getObjectVerwerkingssoort(metaObject);
        if (verwerkingssoort != null) {
            berichtElement
                    .metBerichtElementAttribuut(BerichtElementAttribuut.maakBuilder(BerichtConstanten.VERWERKINGSSOORT, verwerkingssoort.getNaam()));
        }
    }

    if (metaObject.getObjectElement().getElement() == Element.PERSOON && communicatieId != null) {
        berichtElement.metBerichtElementAttribuut(BerichtElementAttribuut.maakBuilder(BerichtConstanten.COMMUNICATIE_ID, communicatieId.toString()));
    }

    final String voorkomenSleutelBetrokkenheid = bepaalVoorkomenSleutelVoorBetrokkenheid(metaObject);
    if (voorkomenSleutelBetrokkenheid != null) {
        berichtElement.metBerichtElementAttribuut(BerichtElementAttribuut.maakBuilder(BerichtConstanten.VOORKOMEN_SLEUTEL, voorkomenSleutelBetrokkenheid));
    }
    return berichtElement;
}
 
开发者ID:MinBZK,项目名称:OperatieBRP,代码行数:44,代码来源:BerichtBuilder.java

示例13: value

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
public ChangeIncremental value(TextMarkupDocumentSection section, String schema, String objectName,
                               int changeIndex) {
    ChangeType changeType = getChangeType(section);
    boolean drop = section.isTogglePresent(TOGGLE_DROP_TABLE);

    String changeName = section.getAttr(ATTR_NAME);
    Validate.notNull(changeName, "Must define name parameter");

    MutableList<String> baselinedChanges = section.getAttr(ATTR_BASELINED_CHANGES) == null ? FastList.<String>newList() : trimmedTokensToList(
            section.getAttr(ATTR_BASELINED_CHANGES), ",");

    boolean active = !section.isTogglePresent(TOGGLE_INACTIVE);

    TextMarkupDocumentSection rollbackIfAlreadyDeployedSection = section.getSubsections().detect(
            Predicates.attributeEqual(TextMarkupDocumentSection.TO_NAME,
                    TextMarkupDocumentReader.TAG_ROLLBACK_IF_ALREADY_DEPLOYED));
    // in case the section exists but no content, mark it as an empty string so that changes can still get dropped from the audit log
    String rollbackIfAlreadyDeployedCommand = rollbackIfAlreadyDeployedSection == null ? null : StringUtils.defaultIfEmpty(rollbackIfAlreadyDeployedSection.getContent(), "");

    TextMarkupDocumentSection rollbackSection = section.getSubsections()
            .detect(Predicates.attributeEqual(TextMarkupDocumentSection.TO_NAME,
                    TextMarkupDocumentReader.TAG_ROLLBACK));
    String rollbackContent = rollbackSection == null ? null : rollbackSection.getContent();

    String content = section.getContent() == null ? "" : section.getContent();
    if (StringUtils.isEmpty(content)) {
        LOG.warn("WARNING: Empty change defined in [Table={}, Change={}]; please avoid empty changes or correct/remove if possible", objectName, changeName);
    }
    if (rollbackSection != null && StringUtils.isBlank(rollbackContent)) {
        LOG.warn("WARNING: Empty rollback script defined in [Table={}, Change={}], which will be ignored. Please remove, or add content (e.g. a dummy SQL update if you want to force a rollback)", objectName, changeName);
    }
    ChangeIncremental change = new ChangeIncremental(changeType, schema, objectName, changeName,
            changeIndex, this.contentHashStrategy.hashContent(content), content,
            rollbackIfAlreadyDeployedCommand, active);
    change.setRollbackContent(rollbackContent);
    change.setBaselinedChanges(baselinedChanges);
    change.setDrop(drop);
    change.setKeepIncrementalOrder(drop);

    String applyGrantsStr = section.getAttr(ATTR_APPLY_GRANTS);
    change.setApplyGrants(applyGrantsStr == null ? null : Boolean.valueOf(applyGrantsStr));
    change.setChangeset(section.getAttr(ATTR_CHANGESET));
    change.setParallelGroup(section.getAttr(ATTR_PARALLEL_GROUP));
    return change;
}
 
开发者ID:goldmansachs,项目名称:obevo,代码行数:46,代码来源:TableChangeParser.java

示例14: getAlias

import org.apache.commons.lang3.StringUtils; //导入方法依赖的package包/类
/**
 * 根据查询字段获取别名
 *
 * @param name
 * @return
 */
protected String getAlias(String name) {
    return StringUtils.defaultIfEmpty(aliasMap.get(name.toLowerCase()), name);
}
 
开发者ID:wolfboys,项目名称:opencron,代码行数:10,代码来源:MapResultTransFormer.java


注:本文中的org.apache.commons.lang3.StringUtils.defaultIfEmpty方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。