/** * Copy the current immutable object with elements that replace the content of {@link CChangelogType#releases() releases}. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param elements An iterable of releases elements to set * @return A modified copy of {@code this} object */ public final CChangelog withReleases(Iterable<? extends CRelease> elements) { if (this.releases == elements) return this; List<CRelease> newValue = createUnmodifiableList(false, createSafeList(elements, true, false)); return new CChangelog(this, this.project, newValue, this.ticketSystems); }
private CChangelog( String project, Iterable<? extends CRelease> releases, Map<String, ? extends URI> ticketSystems) { this.project = Objects.requireNonNull(project, "project"); this.releases = createUnmodifiableList(false, createSafeList(releases, true, false)); this.ticketSystems = createUnmodifiableMap(true, false, ticketSystems); }
/** * This instance is equal to all instances of {@code CChangelog} that have equal attribute values. * @return {@code true} if {@code this} is equal to {@code another} instance */ @Override public boolean equals(Object another) { if (this == another) return true; return another instanceof CChangelog && equalTo((CChangelog) another); }
/** * Copy the current immutable object by replacing the {@link CChangelogType#ticketSystems() ticketSystems} map with the specified map. * Nulls are not permitted as keys or values. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param entries The entries to be added to the ticketSystems map * @return A modified copy of {@code this} object */ public final CChangelog withTicketSystems(Map<String, ? extends URI> entries) { if (this.ticketSystems == entries) return this; Map<String, URI> newValue = createUnmodifiableMap(true, false, entries); return new CChangelog(this, this.project, this.releases, newValue); }
root.setAttribute("project", changelog.project().value()); doc.createElementNS(this.schema_uri, "c:ticket-systems"); changelog.releases().forEach( (version, release) -> this.writeRelease(doc, releases, version, release)); changelog.ticketSystems().forEach( (name, ticket_uri) -> this.writeTicketSystem(doc, ticket_systems, name, ticket_uri));
@Override public void write( final CChangelog changelog) throws IOException { Objects.requireNonNull(changelog, "Changelog"); try { final DocumentBuilder doc_builder = this.doc_factory.newDocumentBuilder(); final Document doc = doc_builder.newDocument(); final Element root = doc.createElementNS(XHTML_NS, "table"); root.setAttribute( "summary", "Changes for project " + changelog.project().value()); root.setAttribute("class", "changelog"); for (final CRelease release : changelog.releases().values().reverse()) { this.writeRelease(changelog, doc, root, release); } doc.appendChild(root); this.serializeDocument(doc); } catch (final ParserConfigurationException e) { throw new IOException(e); } }
final CRelease r) final Map<String, URI> ticket_systems = c.ticketSystems(); line.setLength(0); if (config.showDates()) { line.append(c.project()); line.append(" "); line.append(r.version().toVersionString());
e_root.appendChild(e_updated); for (final CRelease r : changelog.releases().values().reverse()) { this.writeRelease(changelog, doc, e_root, r);
.append(changelog.project().value()) .append(" ") .append(r.version().toVersionString())
/** * Creates an immutable copy of a {@link CChangelogType} value. * Uses accessors to get values to initialize the new immutable instance. * If an instance is already immutable, it is returned as is. * @param instance The instance to copy * @return A copied immutable CChangelog instance */ public static CChangelog copyOf(CChangelogType instance) { if (instance instanceof CChangelog) { return (CChangelog) instance; } return CChangelog.builder() .from(instance) .build(); }
/** * Construct a new immutable {@code CChangelog} instance. * @param project The value for the {@code project} attribute * @param releases The value for the {@code releases} attribute * @param ticketSystems The value for the {@code ticketSystems} attribute * @return An immutable CChangelog instance */ public static CChangelog of(String project, Iterable<? extends CRelease> releases, Map<String, ? extends URI> ticketSystems) { return new CChangelog(project, releases, ticketSystems); }
private static Node transformTicket( final CChangelog changelog, final Document doc, final CRelease release, final CTicketID ticket) { final CTicketSystem ticket_system = changelog.ticketSystems().get(release.ticketSystemID()).get(); final Element a = doc.createElement("a"); final String ticket_val = ticket.value(); final URI target = URI.create(ticket_system.uri().toString() + ticket_val); a.setAttribute("href", target.toString()); a.setTextContent(ticket_val); return a; }
/** * Construct a new immutable {@code CChangelog} instance. * @param project The value for the {@code project} attribute * @param releases The value for the {@code releases} attribute * @param ticketSystems The value for the {@code ticketSystems} attribute * @return An immutable CChangelog instance */ public static CChangelog of(String project, List<CRelease> releases, Map<String, URI> ticketSystems) { return of(project, (Iterable<? extends CRelease>) releases, ticketSystems); }
final CRelease r) final Map<String, URI> ticket_systems = c.ticketSystems(); line.setLength(0); if (config.showDates()) { line.append(c.project()); line.append(" "); line.append(r.version().toVersionString());
/** * Serialize the given changelog to plain text. * * @param c The changelog * @param config The writer configuration * @param out The writer */ public static void writeChangelog( final CChangelog c, final CChangelogTextWriterConfiguration config, final PrintWriter out) { NullCheck.notNull(c, "Changelog"); NullCheck.notNull(config, "Configuration"); NullCheck.notNull(out, "Output"); final StringBuilder line = new StringBuilder(); for (final CRelease r : c.releases()) { final Optional<CVersionType> release_opt = config.release(); final boolean show; if (release_opt.isPresent()) { show = Objects.equals(r.version(), release_opt.get()); } else { show = true; } if (show) { showRelease(c, config, out, line, r); } } out.flush(); }
private void writeRelease( final CChangelog changelog, final Document doc, final Element releases, final CRelease release) { row( doc, releases, this.date_terse_formatter.format(release.date().toLocalDate()), List.of(doc.createTextNode( new StringBuilder() .append("Release: ") .append(changelog.project().value()) .append(" ") .append(release.version().toVersionString()) .toString()))); for (final CChange change : release.changes()) { row( doc, releases, this.date_terse_formatter.format(change.date().toLocalDate()), this.transformChange(changelog, doc, release, change)); } }
/** * Copy the current immutable object by replacing the {@link CChangelogType#ticketSystems() ticketSystems} map with the specified map. * Nulls are not permitted as keys or values. * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}. * @param entries The entries to be added to the ticketSystems map * @return A modified copy of {@code this} object */ public final CChangelog withTicketSystems(Map<String, ? extends URI> entries) { if (this.ticketSystems == entries) return this; Map<String, URI> newValue = createUnmodifiableMap(true, false, entries); return new CChangelog(this, this.project, this.releases, newValue); }
/** * Creates an immutable copy of a {@link CChangelogType} value. * Uses accessors to get values to initialize the new immutable instance. * If an instance is already immutable, it is returned as is. * @param instance The instance to copy * @return A copied immutable CChangelog instance */ public static CChangelog copyOf(CChangelogType instance) { if (instance instanceof CChangelog) { return (CChangelog) instance; } return CChangelog.builder() .from(instance) .build(); }
/** * Construct a new immutable {@code CChangelog} instance. * @param project The value for the {@code project} attribute * @param releases The value for the {@code releases} attribute * @param ticketSystems The value for the {@code ticketSystems} attribute * @return An immutable CChangelog instance */ public static CChangelog of(String project, Iterable<? extends CRelease> releases, Map<String, ? extends URI> ticketSystems) { return new CChangelog(project, releases, ticketSystems); }
/** * Construct a new immutable {@code CChangelog} instance. * @param project The value for the {@code project} attribute * @param releases The value for the {@code releases} attribute * @param ticketSystems The value for the {@code ticketSystems} attribute * @return An immutable CChangelog instance */ public static CChangelog of(String project, List<CRelease> releases, Map<String, URI> ticketSystems) { return of(project, (Iterable<? extends CRelease>) releases, ticketSystems); }