This is an automated email from the ASF dual-hosted git repository. jamesbognar pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/juneau.git
commit b9247fbbfe266a6ad71fa0cba389ebaa92151169 Author: James Bognar <[email protected]> AuthorDate: Tue Jul 21 13:59:53 2026 -0400 TODO-276: CRTP-convert the atom bean family (10.0.0 breaking change) CommonEntry is now a self-typed root CommonEntry<SELF extends CommonEntry<SELF>>; removed 42 covariant setter-narrowing overrides across Feed/Entry/Source (fluent setters return the leaf type via the self-type instead of manual overrides). Marshalling is byte-identical; this is a source-visible generification of an exported bean family. Co-authored-by: Cursor <[email protected]> --- .../org/apache/juneau/bean/atom/CommonEntry.java | 66 +++++++++------- .../java/org/apache/juneau/bean/atom/Entry.java | 86 +-------------------- .../java/org/apache/juneau/bean/atom/Feed.java | 86 +-------------------- .../java/org/apache/juneau/bean/atom/Source.java | 88 +--------------------- 4 files changed, 40 insertions(+), 286 deletions(-) diff --git a/juneau-bean/juneau-bean-atom/src/main/java/org/apache/juneau/bean/atom/CommonEntry.java b/juneau-bean/juneau-bean-atom/src/main/java/org/apache/juneau/bean/atom/CommonEntry.java index 184ae7f9b0..1d1b5acbbb 100644 --- a/juneau-bean/juneau-bean-atom/src/main/java/org/apache/juneau/bean/atom/CommonEntry.java +++ b/juneau-bean/juneau-bean-atom/src/main/java/org/apache/juneau/bean/atom/CommonEntry.java @@ -54,8 +54,11 @@ import org.apache.juneau.marshall.xml.*; * <li class='link'><a class="doclink" href="https://juneau.apache.org/docs/topics/JuneauBeanAtom">juneau-bean-atom</a> * <li class='extlink'><a class="doclink" href="https://tools.ietf.org/html/rfc4287">RFC 4287 - The Atom Syndication Format</a> * </ul> + * + * @param <SELF> The self type for fluent setters. */ -public class CommonEntry extends Common { +@SuppressWarnings("java:S119") // 'SELF' (CRTP self-type) is intentional and clearer than a single-letter name. +public class CommonEntry<SELF extends CommonEntry<SELF>> extends Common { private Person[] authors; private Category[] categories; @@ -69,6 +72,11 @@ public class CommonEntry extends Common { /** Bean constructor. */ public CommonEntry() {} + @SuppressWarnings("unchecked") + private SELF self() { + return (SELF) this; + } + /** * Normal constructor. * @@ -186,15 +194,15 @@ public class CommonEntry extends Common { * <br>Can be <jk>null</jk> to unset the property. * @return This object */ - public CommonEntry setAuthors(Person...value) { + public SELF setAuthors(Person...value) { authors = cp(value); - return this; + return self(); } @Override /* Overridden from Common */ - public CommonEntry setBase(Object value) { + public SELF setBase(Object value) { super.setBase(value); - return this; + return self(); } /** @@ -208,9 +216,9 @@ public class CommonEntry extends Common { * <br>Can be <jk>null</jk> to unset the property. * @return This object */ - public CommonEntry setCategories(Category...value) { + public SELF setCategories(Category...value) { categories = cp(value); - return this; + return self(); } /** @@ -224,9 +232,9 @@ public class CommonEntry extends Common { * <br>Can be <jk>null</jk> to unset the property. * @return This object */ - public CommonEntry setContributors(Person...value) { + public SELF setContributors(Person...value) { contributors = cp(value); - return this; + return self(); } /** @@ -240,9 +248,9 @@ public class CommonEntry extends Common { * <br>Can be <jk>null</jk> to unset the property. * @return This object */ - public CommonEntry setId(Id value) { + public SELF setId(Id value) { id = value; - return this; + return self(); } /** @@ -256,15 +264,15 @@ public class CommonEntry extends Common { * <br>Can be <jk>null</jk> to unset the property. * @return This object. */ - public CommonEntry setId(String value) { + public SELF setId(String value) { setId(new Id(value)); - return this; + return self(); } @Override /* Overridden from Common */ - public CommonEntry setLang(String value) { + public SELF setLang(String value) { super.setLang(value); - return this; + return self(); } /** @@ -278,9 +286,9 @@ public class CommonEntry extends Common { * <br>Can be <jk>null</jk> to unset the property. * @return This object */ - public CommonEntry setLinks(Link...value) { + public SELF setLinks(Link...value) { links = cp(value); - return this; + return self(); } /** @@ -294,9 +302,9 @@ public class CommonEntry extends Common { * <br>Can be <jk>null</jk> to unset the property. * @return This object. */ - public CommonEntry setRights(String value) { + public SELF setRights(String value) { setRights(new Text().setText(value)); - return this; + return self(); } /** @@ -310,9 +318,9 @@ public class CommonEntry extends Common { * <br>Can be <jk>null</jk> to unset the property. * @return This object */ - public CommonEntry setRights(Text value) { + public SELF setRights(Text value) { rights = value; - return this; + return self(); } /** @@ -326,9 +334,9 @@ public class CommonEntry extends Common { * <br>Can be <jk>null</jk> to unset the property. * @return This object. */ - public CommonEntry setTitle(String value) { + public SELF setTitle(String value) { setTitle(new Text().setText(value)); - return this; + return self(); } /** @@ -342,9 +350,9 @@ public class CommonEntry extends Common { * <br>Can be <jk>null</jk> to unset the property. * @return This object */ - public CommonEntry setTitle(Text value) { + public SELF setTitle(Text value) { title = value; - return this; + return self(); } /** @@ -358,9 +366,9 @@ public class CommonEntry extends Common { * <br>Can be <jk>null</jk> to unset the property. * @return This object */ - public CommonEntry setUpdated(Calendar value) { + public SELF setUpdated(Calendar value) { updated = cloneOf(value); - return this; + return self(); } /** @@ -374,8 +382,8 @@ public class CommonEntry extends Common { * <br>Can be <jk>null</jk> to unset the property. * @return This object. */ - public CommonEntry setUpdated(String value) { + public SELF setUpdated(String value) { setUpdated(o(value).filter(x1 -> ! isBlank(x1)).map(x -> GranularZonedDateTime.of(value).getZonedDateTime()).map(GregorianCalendar::from).orElse(null)); - return this; + return self(); } } \ No newline at end of file diff --git a/juneau-bean/juneau-bean-atom/src/main/java/org/apache/juneau/bean/atom/Entry.java b/juneau-bean/juneau-bean-atom/src/main/java/org/apache/juneau/bean/atom/Entry.java index bb1be8b09a..b317e82f23 100644 --- a/juneau-bean/juneau-bean-atom/src/main/java/org/apache/juneau/bean/atom/Entry.java +++ b/juneau-bean/juneau-bean-atom/src/main/java/org/apache/juneau/bean/atom/Entry.java @@ -110,7 +110,7 @@ import org.apache.juneau.marshall.*; * </ul> */ @Marshalled(typeName = "entry") -public class Entry extends CommonEntry { +public class Entry extends CommonEntry<Entry> { private Content content; private Calendar published; @@ -202,24 +202,6 @@ public class Entry extends CommonEntry { */ public Text getSummary() { return summary; } - @Override /* Overridden from CommonEntry */ - public Entry setAuthors(Person...value) { - super.setAuthors(value); - return this; - } - - @Override /* Overridden from Common */ - public Entry setBase(Object value) { - super.setBase(value); - return this; - } - - @Override /* Overridden from CommonEntry */ - public Entry setCategories(Category...value) { - super.setCategories(value); - return this; - } - /** * Bean property setter: <property>content</property>. * @@ -261,36 +243,6 @@ public class Entry extends CommonEntry { return this; } - @Override /* Overridden from CommonEntry */ - public Entry setContributors(Person...value) { - super.setContributors(value); - return this; - } - - @Override /* Overridden from CommonEntry */ - public Entry setId(Id value) { - super.setId(value); - return this; - } - - @Override /* Overridden from CommonEntry */ - public Entry setId(String value) { - super.setId(value); - return this; - } - - @Override /* Overridden from Common */ - public Entry setLang(String value) { - super.setLang(value); - return this; - } - - @Override /* Overridden from CommonEntry */ - public Entry setLinks(Link...value) { - super.setLinks(value); - return this; - } - /** * Bean property setter: <property>published</property>. * @@ -335,18 +287,6 @@ public class Entry extends CommonEntry { return this; } - @Override /* Overridden from CommonEntry */ - public Entry setRights(String value) { - super.setRights(value); - return this; - } - - @Override /* Overridden from CommonEntry */ - public Entry setRights(Text value) { - super.setRights(value); - return this; - } - /** * Bean property setter: <property>source</property>. * @@ -414,28 +354,4 @@ public class Entry extends CommonEntry { summary = value; return this; } - - @Override /* Overridden from CommonEntry */ - public Entry setTitle(String value) { - super.setTitle(value); - return this; - } - - @Override /* Overridden from CommonEntry */ - public Entry setTitle(Text value) { - super.setTitle(value); - return this; - } - - @Override /* Overridden from CommonEntry */ - public Entry setUpdated(Calendar value) { - super.setUpdated(value); - return this; - } - - @Override /* Overridden from CommonEntry */ - public Entry setUpdated(String value) { - super.setUpdated(value); - return this; - } } \ No newline at end of file diff --git a/juneau-bean/juneau-bean-atom/src/main/java/org/apache/juneau/bean/atom/Feed.java b/juneau-bean/juneau-bean-atom/src/main/java/org/apache/juneau/bean/atom/Feed.java index 7212892bfa..87d08cbf3d 100644 --- a/juneau-bean/juneau-bean-atom/src/main/java/org/apache/juneau/bean/atom/Feed.java +++ b/juneau-bean/juneau-bean-atom/src/main/java/org/apache/juneau/bean/atom/Feed.java @@ -111,7 +111,7 @@ import org.apache.juneau.marshall.xml.*; * </ul> */ @Marshalled(typeName = "feed") -public class Feed extends CommonEntry { +public class Feed extends CommonEntry<Feed> { // @formatter:off private Generator generator; // atomGenerator? @@ -217,30 +217,6 @@ public class Feed extends CommonEntry { */ public Text getSubtitle() { return subtitle; } - @Override /* Overridden from CommonEntry */ - public Feed setAuthors(Person...value) { - super.setAuthors(value); - return this; - } - - @Override /* Overridden from Common */ - public Feed setBase(Object value) { - super.setBase(value); - return this; - } - - @Override /* Overridden from CommonEntry */ - public Feed setCategories(Category...value) { - super.setCategories(value); - return this; - } - - @Override /* Overridden from CommonEntry */ - public Feed setContributors(Person...value) { - super.setContributors(value); - return this; - } - /** * Bean property setter: <property>entries</property>. * @@ -326,30 +302,6 @@ public class Feed extends CommonEntry { return this; } - @Override /* Overridden from CommonEntry */ - public Feed setId(Id value) { - super.setId(value); - return this; - } - - @Override /* Overridden from CommonEntry */ - public Feed setId(String value) { - super.setId(value); - return this; - } - - @Override /* Overridden from Common */ - public Feed setLang(String value) { - super.setLang(value); - return this; - } - - @Override /* Overridden from CommonEntry */ - public Feed setLinks(Link...value) { - super.setLinks(value); - return this; - } - /** * Bean property setter: <property>logo</property>. * @@ -372,18 +324,6 @@ public class Feed extends CommonEntry { return this; } - @Override /* Overridden from CommonEntry */ - public Feed setRights(String value) { - super.setRights(value); - return this; - } - - @Override /* Overridden from CommonEntry */ - public Feed setRights(Text value) { - super.setRights(value); - return this; - } - /** * Bean property fluent setter: <property>subtitle</property>. * @@ -424,28 +364,4 @@ public class Feed extends CommonEntry { subtitle = value; return this; } - - @Override /* Overridden from CommonEntry */ - public Feed setTitle(String value) { - super.setTitle(value); - return this; - } - - @Override /* Overridden from CommonEntry */ - public Feed setTitle(Text value) { - super.setTitle(value); - return this; - } - - @Override /* Overridden from CommonEntry */ - public Feed setUpdated(Calendar value) { - super.setUpdated(value); - return this; - } - - @Override /* Overridden from CommonEntry */ - public Feed setUpdated(String value) { - super.setUpdated(value); - return this; - } } \ No newline at end of file diff --git a/juneau-bean/juneau-bean-atom/src/main/java/org/apache/juneau/bean/atom/Source.java b/juneau-bean/juneau-bean-atom/src/main/java/org/apache/juneau/bean/atom/Source.java index 487a3f562c..0d510b1710 100644 --- a/juneau-bean/juneau-bean-atom/src/main/java/org/apache/juneau/bean/atom/Source.java +++ b/juneau-bean/juneau-bean-atom/src/main/java/org/apache/juneau/bean/atom/Source.java @@ -16,8 +16,6 @@ */ package org.apache.juneau.bean.atom; -import java.util.*; - /** * Represents metadata from the source feed when an entry is copied from one feed to another. * @@ -90,7 +88,7 @@ import java.util.*; * <li class='extlink'><a class="doclink" href="https://tools.ietf.org/html/rfc4287">RFC 4287 - The Atom Syndication Format</a> * </ul> */ -public class Source extends CommonEntry { +public class Source extends CommonEntry<Source> { private Generator generator; private Icon icon; @@ -137,30 +135,6 @@ public class Source extends CommonEntry { */ public Text getSubtitle() { return subtitle; } - @Override /* Overridden from CommonEntry */ - public Source setAuthors(Person...value) { - super.setAuthors(value); - return this; - } - - @Override /* Overridden from Common */ - public Source setBase(Object value) { - super.setBase(value); - return this; - } - - @Override /* Overridden from CommonEntry */ - public Source setCategories(Category...value) { - super.setCategories(value); - return this; - } - - @Override /* Overridden from CommonEntry */ - public Source setContributors(Person...value) { - super.setContributors(value); - return this; - } - /** * Bean property setter: <property>generator</property>. * @@ -193,30 +167,6 @@ public class Source extends CommonEntry { return this; } - @Override /* Overridden from CommonEntry */ - public Source setId(Id value) { - super.setId(value); - return this; - } - - @Override /* Overridden from CommonEntry */ - public Source setId(String value) { - super.setId(value); - return this; - } - - @Override /* Overridden from Common */ - public Source setLang(String value) { - super.setLang(value); - return this; - } - - @Override /* Overridden from CommonEntry */ - public Source setLinks(Link...value) { - super.setLinks(value); - return this; - } - /** * Bean property setter: <property>logo</property>. * @@ -233,18 +183,6 @@ public class Source extends CommonEntry { return this; } - @Override /* Overridden from CommonEntry */ - public Source setRights(String value) { - super.setRights(value); - return this; - } - - @Override /* Overridden from CommonEntry */ - public Source setRights(Text value) { - super.setRights(value); - return this; - } - /** * Bean property fluent setter: <property>subtitle</property>. * @@ -276,28 +214,4 @@ public class Source extends CommonEntry { subtitle = value; return this; } - - @Override /* Overridden from CommonEntry */ - public Source setTitle(String value) { - super.setTitle(value); - return this; - } - - @Override /* Overridden from CommonEntry */ - public Source setTitle(Text value) { - super.setTitle(value); - return this; - } - - @Override /* Overridden from CommonEntry */ - public Source setUpdated(Calendar value) { - super.setUpdated(value); - return this; - } - - @Override /* Overridden from CommonEntry */ - public Source setUpdated(String value) { - super.setUpdated(value); - return this; - } } \ No newline at end of file
