private String tryToGetClientIp(HttpServletRequest request) { String forwardedFor = request.getHeader("X-FORWARDED-FOR"); if (!Strings.isNullOrEmpty(forwardedFor)) { return X_FORWARDED_FOR_SPLITTER.splitToList(forwardedFor).get(0); } return request.getRemoteAddr(); } }
public OrchestrationShardingSchema(final String value) { if (value.contains(".")) { List<String> values = Splitter.on(".").splitToList(value); schemaName = values.get(0); dataSourceName = values.get(1); } else { schemaName = ShardingConstant.LOGIC_SCHEMA_NAME; dataSourceName = value; } } }
/** * The key to be displayed to user, doesn't contain information on branches */ public String getKey() { List<String> split = BRANCH_OR_PULL_REQUEST_SPLITTER.splitToList(kee); return split.size() == 2 ? split.get(0) : kee; }
protected List<String> splitStackedFields(String stackedFieldsParam) { if (stackedFieldsParam == null || stackedFieldsParam.isEmpty()) { return Collections.emptyList(); } return Splitter.on(',').trimResults().omitEmptyStrings().splitToList(stackedFieldsParam); } }
private static boolean isValidDataNode(final String dataNodeStr) { return dataNodeStr.contains(DELIMITER) && 2 == Splitter.on(DELIMITER).splitToList(dataNodeStr).size(); }
private ShardingEncryptorStrategy getShardingEncryptorStrategy(final ShardingEncryptor shardingEncryptor) { return Strings.isNullOrEmpty(assistedQueryColumns) ? new ShardingEncryptorStrategy(Splitter.on(",").trimResults().splitToList(columns), shardingEncryptor) : new ShardingEncryptorStrategy(Splitter.on(",").trimResults().splitToList(columns), Splitter.on(",").trimResults().splitToList(assistedQueryColumns), shardingEncryptor); } }
@JsonCreator public ResourceGroupIdTemplate(String fullId) { List<String> segments = Splitter.on(".").splitToList(requireNonNull(fullId, "fullId is null")); checkArgument(!segments.isEmpty(), "Resource group id is empty"); this.segments = segments.stream() .map(ResourceGroupNameTemplate::new) .collect(Collectors.toList()); }
@Config("jmx.dump-tables") public JmxConnectorConfig setDumpTables(String tableNames) { this.dumpTables = Splitter.on(Pattern.compile("(?<!\\\\),")) // match "," not preceded by "\" .omitEmptyStrings() .splitToList(tableNames) .stream() .map(part -> part.replace("\\,", ",")) // unescape all escaped commas .collect(Collectors.toSet()); return this; }
@Override public Iterable<List<String>> convertRecord(String outputSchema, String inputRecord, WorkUnitState workUnit) throws DataConversionException { List<String> convertedRecord = this.shouldTrimResults ? this.splitter.omitEmptyStrings().trimResults().splitToList(inputRecord) : this.splitter.splitToList(inputRecord); return new SingleRecordIterable<>(convertedRecord); } }
@Test public void split() { List<String> result = MoreStringUtil.split("192.168.0.1", '.', 4); assertThat(result).hasSize(4).containsSequence("192", "168", "0", "1"); result = MoreStringUtil.split("192.168..1", '.', 4); assertThat(result).hasSize(3).containsSequence("192", "168", "1"); result = MoreStringUtil.split("192.168.0.", '.', 4); assertThat(result).hasSize(3).containsSequence("192", "168", "0"); assertThat(MoreStringUtil.split(null, '.', 4)).isNull(); assertThat(MoreStringUtil.split("", '.', 4)).hasSize(0); Splitter splitter =MoreStringUtil.charsSplitter("/\\").omitEmptyStrings(); result = splitter.splitToList("/a/b/c"); assertThat(result).hasSize(3).containsSequence("a", "b", "c"); result = splitter.splitToList("\\a\\b\\c"); assertThat(result).hasSize(3).containsSequence( "a", "b", "c"); }
@Config("hive.config.resources") public HiveClientConfig setResourceConfigFiles(String files) { this.resourceConfigFiles = Splitter.on(',').trimResults().omitEmptyStrings().splitToList(files); return this; }
/** * Does the domain name match one of the "wildcard" patterns (e.g. {@code "*.ar"})? If a {@code * desiredType} is specified, the wildcard pattern must also match that type. */ private static boolean matchesWildcardSuffixType( Optional<PublicSuffixType> desiredType, String domain) { List<String> pieces = DOT_SPLITTER.limit(2).splitToList(domain); return pieces.size() == 2 && matchesType( desiredType, Optional.fromNullable(PublicSuffixPatterns.UNDER.get(pieces.get(1)))); }
/** * Constructs a data node with well-formatted string. * * @param dataNode string of data node. use {@code .} to split data source name and table name. */ public DataNode(final String dataNode) { if (!isValidDataNode(dataNode)) { throw new ShardingConfigurationException("Invalid format for actual data nodes: '%s'", dataNode); } List<String> segments = Splitter.on(DELIMITER).splitToList(dataNode); dataSourceName = segments.get(0); tableName = segments.get(1); }
@PathVariable String clusterName, @PathVariable String namespaceName, HttpServletResponse res) { List<String> fileNameSplit = Splitter.on(".").splitToList(namespaceName); String fileName = fileNameSplit.size() <= 1 ? Joiner.on(".") .join(namespaceName, ConfigFileFormat.Properties.getValue()) : namespaceName; NamespaceBO namespaceBO = namespaceService.loadNamespaceBO(appId, Env.fromString
private String tryToGetClientIp(HttpServletRequest request) { String forwardedFor = request.getHeader("X-FORWARDED-FOR"); if (!Strings.isNullOrEmpty(forwardedFor)) { return X_FORWARDED_FOR_SPLITTER.splitToList(forwardedFor).get(0); } return request.getRemoteAddr(); }
private Collection<SQLSegmentExtractor> createExtractors(final String sqlExtractorRuleRefs, final ExtractorRuleDefinition extractorRuleDefinition) { Collection<SQLSegmentExtractor> result = new LinkedList<>(); if (sqlExtractorRuleRefs != null) { for (String each : Splitter.on(',').trimResults().splitToList(sqlExtractorRuleRefs)) { result.add(extractorRuleDefinition.getRules().get(each)); } } return result; }
public QualifiedName getShadowTestTablePrefix() { return QualifiedName.of(Splitter.on(".").splitToList(shadowTestTablePrefix)); }
private static SchemaTableName parseTableName(String schemaTableName) { checkArgument(!isNullOrEmpty(schemaTableName), "schemaTableName is null or is empty"); List<String> parts = Splitter.on('.').splitToList(schemaTableName); checkArgument(parts.size() == 2, "Invalid schemaTableName: %s", schemaTableName); return new SchemaTableName(parts.get(0), parts.get(1)); } }
/** * @return the pull request id. It will be null when the component is not on a pull request */ @CheckForNull public String getPullRequest() { List<String> split = PULL_REQUEST_SPLITTER.splitToList(kee); return split.size() == 2 ? split.get(1) : null; }
private static Function<PropertyDto, Notification> toWsNotification(Notification.Builder notification, Map<String, OrganizationDto> organizationsByUuid, Map<Long, ComponentDto> projectsById) { return property -> { notification.clear(); List<String> propertyKey = Splitter.on(".").splitToList(property.getKey()); notification.setType(propertyKey.get(1)); notification.setChannel(propertyKey.get(2)); ofNullable(property.getResourceId()).ifPresent(componentId -> populateProjectFields(notification, componentId, organizationsByUuid, projectsById)); return notification.build(); }; }