public InstanceConfigAuditModel(String appId, String clusterName, String dataCenter, String clientIp, String configAppId, String configClusterName, String configNamespace, String releaseKey) { this.offerTime = new Date(); this.appId = appId; this.clusterName = clusterName; this.dataCenter = Strings.isNullOrEmpty(dataCenter) ? "" : dataCenter; this.ip = clientIp; this.configAppId = configAppId; this.configClusterName = configClusterName; this.configNamespace = configNamespace; this.releaseKey = releaseKey; }
public static boolean isBlank(String str) { return Strings.nullToEmpty(str).trim().isEmpty(); }
private static String trimEmptyToNull(String value) { return emptyToNull(nullToEmpty(value).trim()); }
private static String indentString(int indent) { return Strings.repeat(INDENT, indent); } }
@Nullable public static String emptyToNullIfNeeded(@Nullable String value) { //CHECKSTYLE.OFF: Regexp return replaceWithDefault() ? Strings.emptyToNull(value) : value; //CHECKSTYLE.ON: Regexp }
private static String indentString(int indent) { return Strings.repeat(" ", indent); }
public void testEmptyToNull() { assertNull(Strings.emptyToNull(null)); assertNull(Strings.emptyToNull("")); assertEquals("a", Strings.emptyToNull("a")); }
private void setTableName(String tableName) { checkArgument(!isNullOrEmpty(tableName), "tableName is null or empty string"); this.tableName = tableName; }
public static Set<String> parseClientTags(String clientTagsString) { Splitter splitter = Splitter.on(',').trimResults().omitEmptyStrings(); return ImmutableSet.copyOf(splitter.split(nullToEmpty(clientTagsString))); }
public PrestoNode(String nodeIdentifier, URI httpUri, NodeVersion nodeVersion, boolean coordinator) { nodeIdentifier = emptyToNull(nullToEmpty(nodeIdentifier).trim()); this.nodeIdentifier = requireNonNull(nodeIdentifier, "nodeIdentifier is null or empty"); this.httpUri = requireNonNull(httpUri, "httpUri is null"); this.nodeVersion = requireNonNull(nodeVersion, "nodeVersion is null"); this.coordinator = coordinator; }
private void print(Integer indentLevel, String value) { out.println(Strings.repeat(INDENT, indentLevel) + value); } }
public static Column fromMetastoreApiFieldSchema(FieldSchema fieldSchema) { return new Column(fieldSchema.getName(), HiveType.valueOf(fieldSchema.getType()), Optional.ofNullable(emptyToNull(fieldSchema.getComment()))); }
public MongoConnectorFactory(String name) { checkArgument(!isNullOrEmpty(name), "name is null or empty"); this.name = name; }
private Set<String> parseClientTags(HttpServletRequest servletRequest) { Splitter splitter = Splitter.on(',').trimResults().omitEmptyStrings(); return ImmutableSet.copyOf(splitter.split(nullToEmpty(servletRequest.getHeader(PRESTO_CLIENT_TAGS)))); }
public static Optional<String> defaultCredentialCachePath() { String value = nullToEmpty(System.getenv("KRB5CCNAME")); if (value.startsWith(FILE_PREFIX)) { value = value.substring(FILE_PREFIX.length()); } return Optional.ofNullable(emptyToNull(value)); } }
private void appendLine(String template, Object... arguments) { result.append(repeat("\t", level)).append(format(template + "\n", arguments)); } }
private void setType(String type) { checkArgument(!isNullOrEmpty(type), "type is null or empty string"); this.type = type; }
private Set<String> parseClientCapabilities(HttpServletRequest servletRequest) { Splitter splitter = Splitter.on(',').trimResults().omitEmptyStrings(); return ImmutableSet.copyOf(splitter.split(nullToEmpty(servletRequest.getHeader(PRESTO_CLIENT_CAPABILITIES)))); }
public static String preprocessQuery(Optional<String> catalog, Optional<String> schema, String query) throws QueryPreprocessorException { Duration timeout = DEFAULT_PREPROCESSOR_TIMEOUT; String timeoutEnvironment = nullToEmpty(System.getenv(ENV_PREPROCESSOR_TIMEOUT)).trim(); if (!timeoutEnvironment.isEmpty()) { timeout = Duration.valueOf(timeoutEnvironment); } String preprocessorCommand = System.getenv(ENV_PREPROCESSOR); if (emptyToNull(preprocessorCommand) == null) { return query; } return preprocessQuery(catalog, schema, query, ImmutableList.of("/bin/sh", "-c", preprocessorCommand), timeout); }
private static String align(String s, int maxWidth, int padding, boolean right) { int width = consoleWidth(s); checkState(width <= maxWidth, "string width is greater than max width"); String large = repeat(" ", (maxWidth - width) + padding); String small = repeat(" ", padding); return right ? (large + s + small) : (small + s + large); }