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


Java Strings.emptyToNull方法代码示例

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


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

示例1: getStaticMethodName

import com.google.common.base.Strings; //导入方法依赖的package包/类
@Nullable
private static String getStaticMethodName(ExecutableElement element) {
  GlideOption glideOption =
      element.getAnnotation(GlideOption.class);
  String result = glideOption != null ? glideOption.staticMethodName() : null;
  return Strings.emptyToNull(result);
}
 
开发者ID:weiwenqiang,项目名称:GitHub,代码行数:8,代码来源:RequestOptionsGenerator.java

示例2: edit

import com.google.common.base.Strings; //导入方法依赖的package包/类
void edit(HttpSource data) {
    if (data != null) {
        textField.setValue(Strings.nullToEmpty(data.getName()));
        urlField.setValue(Strings.nullToEmpty(data.getUrl()));
        enabledField.setValue(data.isEnabled());
        discoveryEnabledField.setValue(data.isDiscoveryEnabled());
        languageField.setValue(Strings.nullToEmpty(data.getLanguage()));
        timezoneField.setValue(Strings.nullToEmpty(data.getTimezone()));
        urlRecrawlDelayField.setConvertedValue(data.getUrlRecrawlDelayInSecs());
        sitemapRecrawlDelayField.setConvertedValue(data.getSitemapRecrawlDelayInSecs());
        feedRecrawlDelayField.setConvertedValue(data.getFeedRecrawlDelayInSecs());
        urlsField.setValue(Utils.listToText(data.getUrls()));
        feedsField.setValue(Utils.listToText(data.getFeeds()));
        sitemapsField.setValue(Utils.listToText(data.getSitemaps()));
        categoriesField.setValue(Utils.listToText(data.getCategories()));
        appIdsField.setValue(Utils.listToText(data.getAppIds()));
        appIdsField.setInputPrompt("One appId per line.");
        urlFiltersField.setValue(Utils.listToText(data.getUrlFilters()));
        urlFiltersField.setInputPrompt("e.g. +^http://www.tokenmill.lt/.*\ne.g. -.*apache.*");
        urlNormalizersField.setValue(Utils.listToText(data.getUrlNormalizers()));
        urlNormalizersField.setInputPrompt("e.g. a-->>b");
        titleSelectorsField.setValue(Utils.listToText(data.getTitleSelectors()));
        textSelectorsField.setValue(Utils.listToText(data.getTextSelectors()));
        textNormalizerField.setValue(Utils.listToText(data.getTextNormalizers()));
        textNormalizerField.setInputPrompt("e.g. a-->>b");
        dateSelectorsField.setValue(Utils.listToText(data.getDateSelectors()));
        dateFormatsField.setValue(Utils.listToText(data.getDateFormats()));
        dateFormatsField.setInputPrompt("'Posted' MMMM dd, yyyy");
        dateRegexpsField.setValue(Utils.listToText(data.getDateRegexps()));
        dateRegexpsField.setInputPrompt("before date (.*) after");
        if (Strings.emptyToNull(data.getUrl()) == null) {
            urlField.focus();
        } else {
            textField.focus();
        }
    }
    LOG.info("Showing form for item '{}'", data != null ? data.getUrl() : null);
    setVisible(data != null);
}
 
开发者ID:tokenmill,项目名称:crawling-framework,代码行数:40,代码来源:HttpSourceForm.java

示例3: CentralDogmaBeanConfig

import com.google.common.base.Strings; //导入方法依赖的package包/类
/**
 * Creates a new instance.
 *
 * @param project the Central Dogma project name
 * @param repository the Central Dogma repository name
 * @param path the path of the file in Central Dogma
 * @param jsonPath the JSON path expression that will be evaluated when retrieving the file
 */
public CentralDogmaBeanConfig(@Nullable String project, @Nullable String repository,
                              @Nullable String path, @Nullable String jsonPath) {

    this.project = Strings.emptyToNull(project);
    this.repository = Strings.emptyToNull(repository);
    this.path = Strings.emptyToNull(path);
    this.jsonPath = Strings.emptyToNull(jsonPath);

    if (this.path != null) {
        validateFilePath(this.path, "path");
    }
}
 
开发者ID:line,项目名称:centraldogma,代码行数:21,代码来源:CentralDogmaBeanConfig.java

示例4: CentralDogmaBeanConfigBuilder

import com.google.common.base.Strings; //导入方法依赖的package包/类
/**
 * Creates a new builder from the properties of a {@link CentralDogmaBean} annotation.
 */
public CentralDogmaBeanConfigBuilder(CentralDogmaBean config) {
    project = Strings.emptyToNull(config.project());
    repository = Strings.emptyToNull(config.repository());
    path = Strings.emptyToNull(config.path());
    jsonPath = Strings.emptyToNull(config.jsonPath());
}
 
开发者ID:line,项目名称:centraldogma,代码行数:10,代码来源:CentralDogmaBeanConfigBuilder.java

示例5: newNameResolver

import com.google.common.base.Strings; //导入方法依赖的package包/类
@Nullable
@Override
public ConsulNameResolver newNameResolver(final URI targetUri, final Attributes params) {
    if (!SCHEME.equals(targetUri.getScheme())) {
        return null;
    }

    final String targetPath = checkNotNull(targetUri.getPath(), "targetPath");
    checkArgument(targetPath.startsWith("/"));

    final String serviceName = targetPath.substring(1);
    checkArgument(serviceName.length() > 0, "serviceName");

    String consulHost = targetUri.getHost();
    if (Strings.isNullOrEmpty(consulHost)) {
        consulHost = DEFAULT_HOST;
    }

    int consulPort = targetUri.getPort();
    if (consulPort == -1) {
        consulPort = DEFAULT_PORT;
    }

    final String tag = Strings.emptyToNull(targetUri.getFragment());

    final ConsulClient consulClient = ConsulClientManager.getInstance(consulHost, consulPort);

    return new ConsulNameResolver(
            consulClient /* CatalogClient */,
            consulClient /* KeyValueClient */,
            serviceName,
            Optional.ofNullable(tag),
            GrpcUtil.TIMER_SERVICE,
            GrpcUtil.SHARED_CHANNEL_EXECUTOR
    );
}
 
开发者ID:indeedeng-alpha,项目名称:indeed-grpc-java,代码行数:37,代码来源:ConsulNameResolverProvider.java

示例6: of

import com.google.common.base.Strings; //导入方法依赖的package包/类
/**
 * Returns an instance of {@link ProtoTypeMap} based on the given FileDescriptorProto instances.
 *
 * @param fileDescriptorProtos the full collection of files descriptors from the code generator request
 */
public static ProtoTypeMap of(@Nonnull Collection<DescriptorProtos.FileDescriptorProto> fileDescriptorProtos) {
    Preconditions.checkNotNull(fileDescriptorProtos, "fileDescriptorProtos");
    Preconditions.checkArgument(!fileDescriptorProtos.isEmpty(), "fileDescriptorProtos.isEmpty()");

    final ImmutableMap.Builder<String, String> types = ImmutableMap.builder();

    for (final DescriptorProtos.FileDescriptorProto fileDescriptor : fileDescriptorProtos) {
        final DescriptorProtos.FileOptions fileOptions = fileDescriptor.getOptions();

        final String protoPackage = fileDescriptor.hasPackage() ? "." + fileDescriptor.getPackage() : "";
        final String javaPackage = Strings.emptyToNull(
                fileOptions.hasJavaPackage() ?
                        fileOptions.getJavaPackage() :
                        fileDescriptor.getPackage());
        final String enclosingClassName =
                fileOptions.getJavaMultipleFiles() ?
                        null :
                        getJavaOuterClassname(fileDescriptor, fileOptions);



        fileDescriptor.getEnumTypeList().forEach(
            e -> types.put(
                    protoPackage + "." + e.getName(),
                    toJavaTypeName(e.getName(), enclosingClassName, javaPackage)));

        fileDescriptor.getMessageTypeList().forEach(
            m -> types.put(
                    protoPackage + "." + m.getName(),
                    toJavaTypeName(m.getName(), enclosingClassName, javaPackage)));
    }

    return new ProtoTypeMap(types.build());
}
 
开发者ID:salesforce,项目名称:grpc-java-contrib,代码行数:40,代码来源:ProtoTypeMap.java

示例7: buildOduCltAnnotation

import com.google.common.base.Strings; //导入方法依赖的package包/类
private SparseAnnotations buildOduCltAnnotation(OFPortDesc port) {
    SparseAnnotations annotations = null;
    String portName = Strings.emptyToNull(port.getName());
    if (portName != null) {
        annotations = DefaultAnnotations.builder()
                .set(AnnotationKeys.PORT_NAME, portName)
                .set(AnnotationKeys.STATIC_PORT, Boolean.TRUE.toString()).build();
    }
    return annotations;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:11,代码来源:OpenFlowDeviceProvider.java

示例8: makePortAnnotation

import com.google.common.base.Strings; //导入方法依赖的package包/类
/**
 * Creates an annotation for the port name if one is available.
 *
 * @param portName the port name
 * @param portMac  the port mac
 * @return annotation containing the port name if one is found,
 * null otherwise
 */
private SparseAnnotations makePortAnnotation(String portName, String portMac) {
    SparseAnnotations annotations = null;
    String pName = Strings.emptyToNull(portName);
    String pMac = Strings.emptyToNull(portMac);
    if (portName != null) {
        annotations = DefaultAnnotations.builder()
                .set(AnnotationKeys.PORT_NAME, pName)
                .set(AnnotationKeys.PORT_MAC, pMac).build();
    }
    return annotations;
}
 
开发者ID:shlee89,项目名称:athena,代码行数:20,代码来源:OpenFlowDeviceProvider.java

示例9: getName

import com.google.common.base.Strings; //导入方法依赖的package包/类
public String getName() {
    return Strings.emptyToNull(name);
}
 
开发者ID:changja88,项目名称:Udacity_Gradle,代码行数:4,代码来源:Person.java

示例10: getOwnName

import com.google.common.base.Strings; //导入方法依赖的package包/类
public String getOwnName() {
    return Strings.emptyToNull(prefs.getString(PREFS_KEY_OWN_NAME, "").trim());
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:4,代码来源:Configuration.java

示例11: getTrustedPeerHost

import com.google.common.base.Strings; //导入方法依赖的package包/类
public String getTrustedPeerHost() {
    return Strings.emptyToNull(prefs.getString(PREFS_KEY_TRUSTED_PEER, "").trim());
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:4,代码来源:Configuration.java

示例12: handleGo

import com.google.common.base.Strings; //导入方法依赖的package包/类
private void handleGo() {
    final String oldPassword = Strings.emptyToNull(oldPasswordView.getText().toString().trim());
    final String newPassword = Strings.emptyToNull(newPasswordView.getText().toString().trim());

    if (oldPassword != null && newPassword != null)
        log.info("changing spending password");
    else if (newPassword != null)
        log.info("setting spending password");
    else if (oldPassword != null)
        log.info("removing spending password");
    else
        throw new IllegalStateException();

    state = State.CRYPTING;
    updateView();

    backgroundHandler.post(new Runnable() {
        @Override
        public void run() {
            // For the old key, we use the key crypter that was used to derive the password in the first
            // place.
            final KeyParameter oldKey = oldPassword != null ? wallet.getKeyCrypter().deriveKey(oldPassword) : null;

            // For the new key, we create a new key crypter according to the desired parameters.
            final KeyCrypterScrypt keyCrypter = new KeyCrypterScrypt(application.scryptIterationsTarget());
            final KeyParameter newKey = newPassword != null ? keyCrypter.deriveKey(newPassword) : null;

            handler.post(new Runnable() {
                @Override
                public void run() {
                    if (wallet.isEncrypted()) {
                        if (oldKey == null) {
                            log.info("wallet is encrypted, but did not provide spending password");
                            state = State.INPUT;
                            oldPasswordView.requestFocus();
                        } else {
                            try {
                                wallet.decrypt(oldKey);

                                state = State.DONE;
                                log.info("wallet successfully decrypted");
                            } catch (final KeyCrypterException x) {
                                log.info("wallet decryption failed: " + x.getMessage());
                                badPasswordView.setVisibility(View.VISIBLE);
                                state = State.INPUT;
                                oldPasswordView.requestFocus();
                            }
                        }
                    }

                    if (newKey != null && !wallet.isEncrypted()) {
                        wallet.encrypt(keyCrypter, newKey);

                        log.info(
                                "wallet successfully encrypted, using key derived by new spending password ({} scrypt iterations)",
                                keyCrypter.getScryptParameters().getN());
                        state = State.DONE;
                    }

                    updateView();

                    if (state == State.DONE) {
                        application.backupWallet();
                        delayedDismiss();
                    }
                }

                private void delayedDismiss() {
                    handler.postDelayed(new Runnable() {
                        @Override
                        public void run() {
                            dismiss();
                        }
                    }, 2000);
                }
            });
        }
    });
}
 
开发者ID:guodroid,项目名称:okwallet,代码行数:80,代码来源:EncryptKeysDialogFragment.java


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