Java Code Examples for java.util.StringJoiner#toString()

The following examples show how to use java.util.StringJoiner#toString() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: SubschoolToken.java    From pcgen with GNU Lesser General Public License v2.1 6 votes vote down vote up
@Override
public String[] unparse(LoadContext context, Spell spell)
{
	Changes<String> changes = context.getObjectContext().getListChanges(spell, ListKey.SPELL_SUBSCHOOL);
	if (changes == null || changes.isEmpty())
	{
		return null;
	}
	StringJoiner joiner = new StringJoiner(Constants.PIPE);
	if (changes.includesGlobalClear())
	{
		joiner.add(Constants.LST_DOT_CLEAR);
	}
	if (changes.hasAddedItems())
	{
		changes.getAdded().forEach(added -> joiner.add(Objects.requireNonNull(added)));
	}
	return new String[]{joiner.toString()};
}
 
Example 2
Source File: SageHotspotApplicationConfig.java    From hmftools with GNU General Public License v3.0 5 votes vote down vote up
@NotNull
static SageHotspotApplicationConfig createConfig(@NotNull final CommandLine cmd) throws ParseException {
    final StringJoiner missingJoiner = new StringJoiner(", ");
    final String codingRegions = parameter(cmd, CODING_REGIONS, missingJoiner);
    final String tumorBamPath = parameter(cmd, TUMOR_BAM, missingJoiner);
    final String referenceBamPath = parameter(cmd, REFERENCE_BAM, missingJoiner);
    final String refGenomePath = parameter(cmd, REF_GENOME, missingJoiner);
    final String outputVCF = parameter(cmd, OUT_PATH, missingJoiner);
    final String normal = parameter(cmd, REFERENCE, missingJoiner);
    final String tumor = parameter(cmd, TUMOR, missingJoiner);
    final String knownHotspotPath = parameter(cmd, KNOWN_HOTSPOTS, missingJoiner);
    final String missing = missingJoiner.toString();

    if (!missing.isEmpty()) {
        throw new ParseException("Missing the following parameters: " + missing);
    }

    return ImmutableSageHotspotApplicationConfig.builder()
            .tumor(tumor)
            .normal(normal)
            .outputFile(outputVCF)
            .tumorBamPath(tumorBamPath)
            .refGenomePath(refGenomePath)
            .codingRegionBedPath(codingRegions)
            .referenceBamPath(referenceBamPath)
            .knownHotspotPath(knownHotspotPath)
            .minTumorReads(defaultIntValue(cmd, MIN_TUMOR_READS, DEFAULT_MIN_TUMOR_READS))
            .minBaseQuality(defaultIntValue(cmd, MIN_BASE_QUALITY, DEFAULT_MIN_BASE_QUALITY))
            .minSnvVAF(defaultDoubleValue(cmd, MIN_SNV_VAF, DEFAULT_MIN_SNV_VAF))
            .minIndelVAF(defaultDoubleValue(cmd, MIN_INDEL_VAF, DEFAULT_MIN_INDEL_VAF))
            .minMappingQuality(defaultIntValue(cmd, MIN_MAPPING_QUALITY, DEFAULT_MIN_MAPPING_QUALITY))
            .minSnvQuality(defaultIntValue(cmd, MIN_SNV_QUALITY, DEFAULT_MIN_SNV_QUALITY))
            .minIndelQuality(defaultIntValue(cmd, MIN_INDEL_QUALITY, DEFAULT_MIN_INDEL_QUALITY))
            .maxHetBinomialLikelihood(defaultDoubleValue(cmd, MAX_HET_BINOMIAL_LIKELIHOOD, DEFAULT_MAX_HET_BINOMIAL_LIKELIHOOD))
            .build();
}
 
Example 3
Source File: SpannerKeyIdConverter.java    From spring-cloud-gcp with Apache License 2.0 5 votes vote down vote up
@Override
public String toRequestId(Serializable source, Class<?> entityType) {
	Key id = (Key) source;
	StringJoiner stringJoiner = new StringJoiner(getUrlIdSeparator());
	id.getParts().forEach((p) -> stringJoiner.add(p.toString()));
	return stringJoiner.toString();
}
 
Example 4
Source File: AnnotationsInheritanceOrderRedefinitionTest.java    From dragonwell8_jdk with GNU General Public License v2.0 5 votes vote down vote up
private static String toSimpleString(Annotation[] anns) {
    StringJoiner joiner = new StringJoiner(", ");
    for (Annotation ann : anns) {
        joiner.add(toSimpleString(ann));
    }
    return joiner.toString();
}
 
Example 5
Source File: MetricNames.java    From attic-polygene-java with Apache License 2.0 5 votes vote down vote up
/**
 * Build a Metric name for the given Module, Method and optional fragments.
 *
 * @param module Module
 * @param method Method
 * @param fragments Name fragments
 * @return Metric name
 */
public static String nameFor( Module module, Method method, String... fragments )
{
    StringJoiner joiner = new StringJoiner( "." )
            .add( module.layer().name() )
            .add( module.name() )
            .add( className( method.getDeclaringClass() ) )
            .add( method.getName() );
    for( String fragment : fragments )
    {
        joiner.add( fragment );
    }
    return joiner.toString();
}
 
Example 6
Source File: JsonSchemaUtils.java    From KaiZen-OpenAPI-Editor with Eclipse Public License 1.0 5 votes vote down vote up
public static String getHumanFriendlyText(JsonNode swaggerSchemaNode, final String defaultValue) {
    String schemaTitle = getSchemaTitle(swaggerSchemaNode);
    if (schemaTitle != null) {
        return schemaTitle;
    }
    // nested array
    if (swaggerSchemaNode.get("items") != null) {
        return getHumanFriendlyText(swaggerSchemaNode.get("items"), defaultValue);
    }
    // "$ref":"#/definitions/headerParameterSubSchema"
    JsonNode ref = swaggerSchemaNode.get("$ref");
    if (ref != null) {
        return getLabelForRef(ref.asText());
    }
    // Auxiliary oneOf in "oneOf": [ { "$ref": "#/definitions/securityRequirement" }]
    JsonNode oneOf = swaggerSchemaNode.get("oneOf");
    if (oneOf != null) {
        if (oneOf instanceof ArrayNode) {
            ArrayNode arrayNode = (ArrayNode) oneOf;
            if (arrayNode.size() > 0) {
                List<String> labels = new ArrayList<>();
                arrayNode.elements().forEachRemaining(el -> labels.add(getHumanFriendlyText(el, defaultValue)));
                StringJoiner joiner = new StringJoiner(", ", "[", "]");
                labels.forEach(joiner::add);
                return joiner.toString();
            }
        }
    }
    return defaultValue;
}
 
Example 7
Source File: SearchRenderer.java    From sample-apps with Apache License 2.0 5 votes vote down vote up
static String buildPageTitle(Map<String, String> properties) {
    StringJoiner sj = new StringJoiner(" and ");
    if (properties.containsKey("q") && properties.get("q").length() > 0) {
        sj.add("'" + properties.get("q") + "'");
    }
    return "Results for " + sj.toString() + "";
}
 
Example 8
Source File: MetricSample.java    From cruise-control with BSD 2-Clause "Simplified" License 5 votes vote down vote up
@Override
public String toString() {
  MetricDef metricDef = metricDefForToString();
  if (metricDef == null) {
    return String.format("{entity=%s,sampleTime=%d,metrics=%s}", _entity, _sampleTime, _valuesByMetricId);
  } else {
    StringJoiner sj = new StringJoiner(",", "{", "}");
    sj.add(String.format("entity=(%s)", _entity));
    sj.add(String.format("sampleTime=%d", _sampleTime));
    for (MetricInfo metricInfo : metricDefForToString().all()) {
      sj.add(String.format("%s=%.3f", metricInfo.name(), _valuesByMetricId.get(metricInfo.id())));
    }
    return sj.toString();
  }
}
 
Example 9
Source File: CollectingErrorEventHandler.java    From validator with Apache License 2.0 5 votes vote down vote up
public String getErrorDescription() {
    final StringJoiner joiner = new StringJoiner("\n");
    this.errors.forEach(e -> joiner
            .add(e.getSeverityCode().value() + " " + e.getMessage() + " At row " + e.getRowNumber() + " at pos "
                    + e.getColumnNumber()));
    return joiner.toString();
}
 
Example 10
Source File: ClientServerTest.java    From jdk8u_jdk with GNU General Public License v2.0 5 votes vote down vote up
SaslPeer(String host, String mechanism, String authId, String... qops) {
    this.host = host;
    this.mechanism = mechanism;

    StringJoiner sj = new StringJoiner(",");
    for (String q : qops) {
        sj.add(q);
    }
    qop = sj.toString();

    callback = new TestCallbackHandler(USER_ID, PASSWD, host, authId);
}
 
Example 11
Source File: GeneratedFilmCategoryImpl.java    From hol-streams with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
    final StringJoiner sj = new StringJoiner(", ", "{ ", " }");
    sj.add("filmId = "     + Objects.toString(getFilmId()));
    sj.add("categoryId = " + Objects.toString(getCategoryId()));
    sj.add("lastUpdate = " + Objects.toString(getLastUpdate()));
    return "FilmCategoryImpl " + sj.toString();
}
 
Example 12
Source File: SyndesisServerContainer.java    From syndesis with Apache License 2.0 5 votes vote down vote up
private String getJavaOptionString() {
    StringJoiner stringJoiner = new StringJoiner(" -D", "-D", "");
    stringJoiner.setEmptyValue("");
    javaOptions.entrySet().stream().map(entry -> entry.getKey() + "=" + entry.getValue()).forEach(stringJoiner::add);

    String optionString = stringJoiner.toString();
    if (enableDebug) {
        return optionString + String.format(" -agentlib:jdwp=transport=dt_socket,server=y,suspend=y,address=%s", SyndesisTestEnvironment.getDebugPort());
    }

    return optionString;
}
 
Example 13
Source File: DefaultDependencyDescriptor.java    From thorntail with Apache License 2.0 5 votes vote down vote up
/**
 * String representation of this descriptor.
 */
@Override
public String toString() {
    StringJoiner joiner = new StringJoiner(":");
    joiner.add(groupId).add(artifactId).add(classifier == null ? "" : classifier).add(type).add(version);
    return "[" + scope + "] " + joiner.toString();
}
 
Example 14
Source File: SelectClauseComposer.java    From atlas with Apache License 2.0 5 votes vote down vote up
private String getJoinedQuotedStr(String[] elements) {
    StringJoiner joiner = new StringJoiner(",");
    Arrays.stream(elements)
          .map(x -> x.contains("'") ? "\"" + x + "\"" : "'" + x + "'")
          .forEach(joiner::add);
    return joiner.toString();
}
 
Example 15
Source File: GeneratedAccountImpl.java    From speedment-secure-rest-example with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
    final StringJoiner sj = new StringJoiner(", ", "{ ", " }");
    sj.add("id = "       + Objects.toString(getId()));
    sj.add("username = " + Objects.toString(getUsername()));
    sj.add("password = " + Objects.toString(getPassword()));
    sj.add("role = "     + Objects.toString(getRole()));
    return "AccountImpl " + sj.toString();
}
 
Example 16
Source File: SelectList.java    From FHIR with Apache License 2.0 5 votes vote down vote up
@Override
public String toString() {
    StringJoiner joiner = new StringJoiner(", ");
    for(SelectItem selectItem : items) {
        joiner.add(selectItem.toString());
    }
    return joiner.toString();
}
 
Example 17
Source File: MetricNames.java    From attic-polygene-java with Apache License 2.0 5 votes vote down vote up
/**
 * Build a Metric name for the given fragments.
 *
 * @param fragments Name fragments
 * @return Metric name
 */
public static String nameFor( String... fragments )
{
    StringJoiner joiner = new StringJoiner( "." );
    for( String fragment : fragments )
    {
        joiner.add( fragment );
    }
    return joiner.toString();
}
 
Example 18
Source File: AqlUtils.java    From spring-data with Apache License 2.0 5 votes vote down vote up
public static String buildLimitClause(final Pageable pageable) {
	if (pageable.isUnpaged()) {
		return "";
	}

	final StringJoiner clause = new StringJoiner(", ", "LIMIT ", "");
	clause.add(String.valueOf(pageable.getOffset()));
	clause.add(String.valueOf(pageable.getPageSize()));
	return clause.toString();
}
 
Example 19
Source File: FrameSet.java    From OpenCue with Apache License 2.0 4 votes vote down vote up
/**
 * Return a String representation of a frame range based on a list of literal integer frame IDs.
 * @param frames  List of integers representing frame IDs,
 * @return        String representation of a frameset, e.g. '1-10,12-100x2'
 */
private String framesToFrameRanges(ImmutableList<Integer> frames) {
    int l = frames.size();
    if (l == 0) {
        return "";
    } else if (l == 1) {
        return String.valueOf(frames.get(0));
    }

    StringJoiner resultBuilder = new StringJoiner(",");

    int curr_count = 1;
    int curr_step = 0;
    int new_step = 0;
    int curr_start = frames.get(0);
    int curr_frame = frames.get(0);
    int last_frame = frames.get(0);

    for (int i = 1; i < frames.size(); i++) {
        curr_frame = frames.get(i);

        if (curr_step == 0) {
            curr_step = curr_frame - curr_start;
        }
        new_step = curr_frame - last_frame;
        if (curr_step == new_step) {
            last_frame = curr_frame;
            curr_count += 1;
        } else if (curr_count == 2 && curr_step != 1) {
            resultBuilder.add(String.valueOf(curr_start));
            curr_step = 0;
            curr_start = last_frame;
            last_frame = curr_frame;
        } else {
            resultBuilder.add(buildFrangePart(curr_start, last_frame, curr_step));
            curr_step = 0;
            curr_start = curr_frame;
            last_frame = curr_frame;
            curr_count = 1;
        }
    }
    if (curr_count == 2 && curr_step != 1) {
        resultBuilder.add(String.valueOf(curr_start));
        resultBuilder.add(String.valueOf(curr_frame));
    } else {
        resultBuilder.add(buildFrangePart(curr_start, curr_frame, curr_step));
    }

    return resultBuilder.toString();
}
 
Example 20
Source File: ListTag.java    From Nukkit with GNU General Public License v3.0 4 votes vote down vote up
@Override
public String toString() {
    StringJoiner joiner = new StringJoiner(",\n\t");
    list.forEach(tag -> joiner.add(tag.toString().replace("\n", "\n\t")));
    return "ListTag '" + this.getName() + "' (" + list.size() + " entries of type " + Tag.getTagName(type) + ") {\n\t" + joiner.toString() + "\n}";
}