@Override public String getNodeId() { return emptyToNull((String)fields.get(MessageInput.FIELD_NODE_ID)); } }
private static String trimEmptyToNull(String value) { return emptyToNull(nullToEmpty(value).trim()); }
public Component(String uuid, @Nullable String key, @Nullable String name) { this.uuid = requireNonNull(emptyToNull(uuid), "uuid can't be null nor empty"); this.key = emptyToNull(key); this.name = emptyToNull(name); }
public static String cut(String s, String splitChar, int index) { if (s == null || splitChar == null || index < 0) { return null; } final String[] parts = s.split(Pattern.quote(splitChar)); if (parts.length <= index) { return null; } return emptyToNull(parts[index]); }
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; }
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)); } }
/** * Returns the given string if it is nonempty; {@code null} otherwise. * This method should only be used at places where null to empty conversion is * irrelevant to null handling of the data. * * @param string the string to test and possibly return * * @return {@code string} itself if it is nonempty; {@code null} if it is * empty or null */ @Nullable public static String emptyToNullNonDruidDataString(@Nullable String string) { //CHECKSTYLE.OFF: Regexp return Strings.emptyToNull(string); //CHECKSTYLE.ON: Regexp }
private static DateTimeZone buildTimeZone(Object timeZoneId) { if (timeZoneId instanceof String) { try { final String timeZoneString = (String) timeZoneId; final String zoneId = firstNonNull(emptyToNull(timeZoneString.trim()), "Etc/UTC"); return DateTimeZone.forID(zoneId); } catch (IllegalArgumentException e) { return DEFAULT_TIME_ZONE; } } else { return DEFAULT_TIME_ZONE; } }
@Nullable public static String emptyToNullIfNeeded(@Nullable String value) { //CHECKSTYLE.OFF: Regexp return replaceWithDefault() ? Strings.emptyToNull(value) : value; //CHECKSTYLE.ON: Regexp }
@JsonCreator public static MatchingType valueOfOrDefault(String name) { return (emptyToNull(name) == null ? DEFAULT : valueOf(name)); } }
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); }
@Override public String create(UserDto user) { UserDto userDto = requireNonNull(user, "User cannot be null"); return hash(requireNonNull(emptyToNull(userDto.getEmail()), "Email cannot be null")); }
public void testEmptyToNull() { assertNull(Strings.emptyToNull(null)); assertNull(Strings.emptyToNull("")); assertEquals("a", Strings.emptyToNull("a")); }
@CheckForNull private String getAssignee(Request request) { String assignee = emptyToNull(request.param(PARAM_ASSIGNEE)); if (ASSIGN_TO_ME_VALUE.equals(assignee) || BooleanUtils.isTrue(request.paramAsBoolean(DEPRECATED_PARAM_ME))) { return userSession.getLogin(); } return assignee; }
public static Column fromMetastoreApiFieldSchema(FieldSchema fieldSchema) { return new Column(fieldSchema.getName(), HiveType.valueOf(fieldSchema.getType()), Optional.ofNullable(emptyToNull(fieldSchema.getComment()))); }
private Users.User.Builder formatUser(UserDto user) { Users.User.Builder builder = Users.User.newBuilder() .setLogin(user.getLogin()) .setName(nullToEmpty(user.getName())) .setActive(user.isActive()); ofNullable(emptyToNull(user.getEmail())).ifPresent(email -> builder.setAvatar(avatarFactory.create(user))); return builder; }
private SearchUsersResponse.User toUser(UserDto user, boolean isSelected) { SearchUsersResponse.User.Builder builder = SearchUsersResponse.User.newBuilder() .setLogin(user.getLogin()) .setName(user.getName()) .setSelected(isSelected); ofNullable(emptyToNull(user.getEmail())).ifPresent(e -> builder.setAvatar(avatarResolver.create(user))); return builder .build(); }
private AddMemberWsResponse buildResponse(UserDto user, int groups) { AddMemberWsResponse.Builder response = AddMemberWsResponse.newBuilder(); User.Builder wsUser = User.newBuilder() .setLogin(user.getLogin()) .setName(user.getName()) .setGroupCount(groups); ofNullable(emptyToNull(user.getEmail())).ifPresent(text -> wsUser.setAvatar(avatarResolver.create(user))); response.setUser(wsUser); return response.build(); }
private static ActiveRule convert(ScannerReport.ActiveRule input, Rule rule) { RuleKey key = RuleKey.of(input.getRuleRepository(), input.getRuleKey()); Map<String, String> params = new HashMap<>(input.getParamsByKeyMap()); long updatedAt = input.getUpdatedAt(); return new ActiveRule(key, input.getSeverity().name(), params, updatedAt == 0 ? input.getCreatedAt() : updatedAt, rule.getPluginKey(), emptyToNull(input.getQProfileKey())); } }
private static CreateWsResponse buildResponse(UserDto userDto) { CreateWsResponse.User.Builder userBuilder = CreateWsResponse.User.newBuilder() .setLogin(userDto.getLogin()) .setName(userDto.getName()) .setActive(userDto.isActive()) .setLocal(userDto.isLocal()) .addAllScmAccounts(userDto.getScmAccountsAsList()); ofNullable(emptyToNull(userDto.getEmail())).ifPresent(userBuilder::setEmail); return CreateWsResponse.newBuilder().setUser(userBuilder).build(); }