From b3c0989d9b0147e851ee63ce428c48967dd3e1b8 Mon Sep 17 00:00:00 2001 From: mishako Date: Sat, 23 Mar 2019 08:03:08 +0100 Subject: [PATCH] Add support for RSS pubDate Closes #15 --- .../rome/common/parser/DateTimeParser.java | 32 +++++++ .../rome/common/parser/IntParser.java | 2 + .../rome/common/parser/StringParser.java | 2 + .../rometools/rome/common/xml/XmlPath.java | 10 ++- .../com/rometools/rome/model/Enclosure.java | 64 ++++++------- .../java/com/rometools/rome/model/Feed.java | 90 ++++++++++++------- .../java/com/rometools/rome/model/Image.java | 2 +- .../java/com/rometools/rome/model/Item.java | 85 ++++++++++++------ .../rome/xml/GeneratedXmlBindings.java | 43 +++++---- .../java/com/rometools/rome/RomeTest.java | 4 + .../resources/com/rometools/rome/test.xml | 3 + .../factory/generator/EntityGenerator.java | 5 +- .../rome/factory/generator/Field.java | 7 +- .../rome/factory/generator/ModelMerger.java | 17 ++-- .../rome/factory/generator/ModelPath.java | 64 +++++++++++++ .../factory/generator/ParserGenerator.java | 33 +++---- .../rometools/rome/factory/schema/Rss.java | 26 ++++-- .../rometools/rome/factory/xml/DataPoint.java | 23 +++-- .../rome/factory/xml/EntityBinding.java | 22 +++-- .../rome/factory/xml/ModelLocation.java | 56 ------------ .../rome/factory/xml/XmlModelDefinition.java | 5 +- 21 files changed, 378 insertions(+), 217 deletions(-) create mode 100755 throwaway-prototype/common/src/main/java/com/rometools/rome/common/parser/DateTimeParser.java create mode 100755 throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/generator/ModelPath.java delete mode 100755 throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/xml/ModelLocation.java diff --git a/throwaway-prototype/common/src/main/java/com/rometools/rome/common/parser/DateTimeParser.java b/throwaway-prototype/common/src/main/java/com/rometools/rome/common/parser/DateTimeParser.java new file mode 100755 index 0000000..fcd9b7c --- /dev/null +++ b/throwaway-prototype/common/src/main/java/com/rometools/rome/common/parser/DateTimeParser.java @@ -0,0 +1,32 @@ +package com.rometools.rome.common.parser; + +import com.rometools.rome.common.value.DateTimeValue; +import java.time.ZonedDateTime; +import java.time.format.DateTimeFormatter; + +public class DateTimeParser implements Parser { + + public static final DateTimeParser INSTANCE = new DateTimeParser(); + + private static DateTimeFormatter formatter = + DateTimeFormatter.ofPattern("EEE, dd MMM yyyy HH:mm:ss z"); + + @Override + public Class getResultClass() { + return DateTimeValue.class; + } + + @Override + public DateTimeValue parse(String input) { + if (input.isEmpty()) { + return DateTimeValue.none(); + } + + return DateTimeValue.of(ZonedDateTime.parse(input, formatter)); + } + + @Override + public DateTimeValue none() { + return DateTimeValue.none(); + } +} diff --git a/throwaway-prototype/common/src/main/java/com/rometools/rome/common/parser/IntParser.java b/throwaway-prototype/common/src/main/java/com/rometools/rome/common/parser/IntParser.java index c159a1c..20c3cfb 100755 --- a/throwaway-prototype/common/src/main/java/com/rometools/rome/common/parser/IntParser.java +++ b/throwaway-prototype/common/src/main/java/com/rometools/rome/common/parser/IntParser.java @@ -4,6 +4,8 @@ public class IntParser implements Parser { + public static final IntParser INSTANCE = new IntParser(); + @Override public Class getResultClass() { return IntValue.class; diff --git a/throwaway-prototype/common/src/main/java/com/rometools/rome/common/parser/StringParser.java b/throwaway-prototype/common/src/main/java/com/rometools/rome/common/parser/StringParser.java index 32b49ab..e251a82 100755 --- a/throwaway-prototype/common/src/main/java/com/rometools/rome/common/parser/StringParser.java +++ b/throwaway-prototype/common/src/main/java/com/rometools/rome/common/parser/StringParser.java @@ -4,6 +4,8 @@ public class StringParser implements Parser { + public static final StringParser INSTANCE = new StringParser(); + @Override public Class getResultClass() { return StringValue.class; diff --git a/throwaway-prototype/common/src/main/java/com/rometools/rome/common/xml/XmlPath.java b/throwaway-prototype/common/src/main/java/com/rometools/rome/common/xml/XmlPath.java index fc9eacb..b884e0c 100755 --- a/throwaway-prototype/common/src/main/java/com/rometools/rome/common/xml/XmlPath.java +++ b/throwaway-prototype/common/src/main/java/com/rometools/rome/common/xml/XmlPath.java @@ -3,10 +3,13 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; +import java.util.Comparator; import java.util.List; import java.util.Objects; -public class XmlPath { +public class XmlPath implements Comparable { + + private static final Comparator COMPARATOR = Comparator.comparing(XmlPath::toString); public static final XmlPath ROOT = new XmlPath(Collections.emptyList(), false); @@ -88,4 +91,9 @@ public String toString() { return "/" + String.join("/", hierarchy); } } + + @Override + public int compareTo(XmlPath other) { + return COMPARATOR.compare(this, other); + } } diff --git a/throwaway-prototype/core/src/main/java/com/rometools/rome/model/Enclosure.java b/throwaway-prototype/core/src/main/java/com/rometools/rome/model/Enclosure.java index 91b6311..193fc7b 100644 --- a/throwaway-prototype/core/src/main/java/com/rometools/rome/model/Enclosure.java +++ b/throwaway-prototype/core/src/main/java/com/rometools/rome/model/Enclosure.java @@ -12,27 +12,27 @@ @Generated( value = "com.rometools.rome.factory.generator.EntityGenerator", - date = "2019-03-22T07:00:47.743Z" + date = "2019-03-23T07:02:53.931Z" ) public class Enclosure { - private final String url; + private final Integer length; private final String type; - private final Integer length; + private final String url; - Enclosure(final String url, final String type, final Integer length) { - this.url = url; - this.type = type; + Enclosure(final Integer length, final String type, final String url) { this.length = length; + this.type = type; + this.url = url; } - public StringValue getUrl() { - return StringValue.ofNullable(url); + public IntValue getLength() { + return IntValue.ofNullable(length); } - public boolean hasUrl() { - return url != null; + public boolean hasLength() { + return length != null; } public StringValue getType() { @@ -43,12 +43,12 @@ public boolean hasType() { return type != null; } - public IntValue getLength() { - return IntValue.ofNullable(length); + public StringValue getUrl() { + return StringValue.ofNullable(url); } - public boolean hasLength() { - return length != null; + public boolean hasUrl() { + return url != null; } public static Builder builder() { @@ -66,39 +66,39 @@ public boolean equals(final Object other) { } Enclosure that = (Enclosure) other; - return Objects.equals(url, that.url) + return Objects.equals(length, that.length) && Objects.equals(type, that.type) - && Objects.equals(length, that.length); + && Objects.equals(url, that.url); } @Override public String toString() { StringBuilder result = new StringBuilder(); result.append("{"); - result.append("\"url\":"); - result.append("\"" + url + "\""); + result.append("\"length\":"); + result.append(String.valueOf(length)); result.append(",\"type\":"); result.append("\"" + type + "\""); - result.append(",\"length\":"); - result.append(String.valueOf(length)); + result.append(",\"url\":"); + result.append("\"" + url + "\""); result.append("}"); return result.toString(); } public static class Builder { - private String url; + private Integer length; private String type; - private Integer length; + private String url; - public Builder setUrl(final String url) { - this.url = url; + public Builder setLength(final Integer length) { + this.length = length; return this; } - public Builder clearUrl() { - this.url = null; + public Builder clearLength() { + this.length = null; return this; } @@ -112,21 +112,21 @@ public Builder clearType() { return this; } - public Builder setLength(final Integer length) { - this.length = length; + public Builder setUrl(final String url) { + this.url = url; return this; } - public Builder clearLength() { - this.length = null; + public Builder clearUrl() { + this.url = null; return this; } public Enclosure build() { return new Enclosure( - url, + length, type, - length + url ); } } diff --git a/throwaway-prototype/core/src/main/java/com/rometools/rome/model/Feed.java b/throwaway-prototype/core/src/main/java/com/rometools/rome/model/Feed.java index dd2c994..47554a5 100644 --- a/throwaway-prototype/core/src/main/java/com/rometools/rome/model/Feed.java +++ b/throwaway-prototype/core/src/main/java/com/rometools/rome/model/Feed.java @@ -1,10 +1,12 @@ package com.rometools.rome.model; +import com.rometools.rome.common.value.DateTimeValue; import com.rometools.rome.common.value.StringValue; import java.lang.Object; import java.lang.Override; import java.lang.String; import java.lang.StringBuilder; +import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -12,22 +14,34 @@ @Generated( value = "com.rometools.rome.factory.generator.EntityGenerator", - date = "2019-03-22T07:00:47.695Z" + date = "2019-03-23T07:02:53.899Z" ) public class Feed { + private final String description; + private final Image image; private final List itemList; - private final String title; + private final ZonedDateTime published; - private final String description; + private final String title; - Feed(final Image image, final List itemList, final String title, final String description) { + Feed(final String description, final Image image, final List itemList, + final ZonedDateTime published, final String title) { + this.description = description; this.image = image; this.itemList = itemList; + this.published = published; this.title = title; - this.description = description; + } + + public StringValue getDescription() { + return StringValue.ofNullable(description); + } + + public boolean hasDescription() { + return description != null; } public Image getImage() { @@ -59,20 +73,20 @@ public Item getFirstItem() { return itemList.get(0); } - public StringValue getTitle() { - return StringValue.ofNullable(title); + public DateTimeValue getPublished() { + return DateTimeValue.ofNullable(published); } - public boolean hasTitle() { - return title != null; + public boolean hasPublished() { + return published != null; } - public StringValue getDescription() { - return StringValue.ofNullable(description); + public StringValue getTitle() { + return StringValue.ofNullable(title); } - public boolean hasDescription() { - return description != null; + public boolean hasTitle() { + return title != null; } public static Builder builder() { @@ -90,36 +104,51 @@ public boolean equals(final Object other) { } Feed that = (Feed) other; - return Objects.equals(image, that.image) + return Objects.equals(description, that.description) + && Objects.equals(image, that.image) && Objects.equals(itemList, that.itemList) - && Objects.equals(title, that.title) - && Objects.equals(description, that.description); + && Objects.equals(published, that.published) + && Objects.equals(title, that.title); } @Override public String toString() { StringBuilder result = new StringBuilder(); result.append("{"); - result.append("\"image\":"); + result.append("\"description\":"); + result.append("\"" + description + "\""); + result.append(",\"image\":"); result.append(String.valueOf(image)); result.append(",\"itemList\":"); result.append(String.valueOf(itemList)); + result.append(",\"published\":"); + result.append(String.valueOf(published)); result.append(",\"title\":"); result.append("\"" + title + "\""); - result.append(",\"description\":"); - result.append("\"" + description + "\""); result.append("}"); return result.toString(); } public static class Builder { + private String description; + private Image image; private List itemList; + private ZonedDateTime published; + private String title; - private String description; + public Builder setDescription(final String description) { + this.description = description; + return this; + } + + public Builder clearDescription() { + this.description = null; + return this; + } public Builder setImage(final Image image) { this.image = image; @@ -154,32 +183,33 @@ public Builder clearItemList() { return this; } - public Builder setTitle(final String title) { - this.title = title; + public Builder setPublished(final ZonedDateTime published) { + this.published = published; return this; } - public Builder clearTitle() { - this.title = null; + public Builder clearPublished() { + this.published = null; return this; } - public Builder setDescription(final String description) { - this.description = description; + public Builder setTitle(final String title) { + this.title = title; return this; } - public Builder clearDescription() { - this.description = null; + public Builder clearTitle() { + this.title = null; return this; } public Feed build() { return new Feed( + description, image, itemList, - title, - description + published, + title ); } } diff --git a/throwaway-prototype/core/src/main/java/com/rometools/rome/model/Image.java b/throwaway-prototype/core/src/main/java/com/rometools/rome/model/Image.java index c46a2cf..cda547d 100644 --- a/throwaway-prototype/core/src/main/java/com/rometools/rome/model/Image.java +++ b/throwaway-prototype/core/src/main/java/com/rometools/rome/model/Image.java @@ -10,7 +10,7 @@ @Generated( value = "com.rometools.rome.factory.generator.EntityGenerator", - date = "2019-03-22T07:00:47.726Z" + date = "2019-03-23T07:02:53.925Z" ) public class Image { private final String url; diff --git a/throwaway-prototype/core/src/main/java/com/rometools/rome/model/Item.java b/throwaway-prototype/core/src/main/java/com/rometools/rome/model/Item.java index 113e138..d9db8a3 100644 --- a/throwaway-prototype/core/src/main/java/com/rometools/rome/model/Item.java +++ b/throwaway-prototype/core/src/main/java/com/rometools/rome/model/Item.java @@ -1,10 +1,12 @@ package com.rometools.rome.model; +import com.rometools.rome.common.value.DateTimeValue; import com.rometools.rome.common.value.StringValue; import java.lang.Object; import java.lang.Override; import java.lang.String; import java.lang.StringBuilder; +import java.time.ZonedDateTime; import java.util.ArrayList; import java.util.List; import java.util.Objects; @@ -12,22 +14,25 @@ @Generated( value = "com.rometools.rome.factory.generator.EntityGenerator", - date = "2019-03-22T07:00:47.734Z" + date = "2019-03-23T07:02:53.941Z" ) public class Item { private final String description; + private final List enclosureList; + private final String link; - private final List enclosureList; + private final ZonedDateTime published; private final String title; - Item(final String description, final String link, final List enclosureList, - final String title) { + Item(final String description, final List enclosureList, final String link, + final ZonedDateTime published, final String title) { this.description = description; - this.link = link; this.enclosureList = enclosureList; + this.link = link; + this.published = published; this.title = title; } @@ -39,14 +44,6 @@ public boolean hasDescription() { return description != null; } - public StringValue getLink() { - return StringValue.ofNullable(link); - } - - public boolean hasLink() { - return link != null; - } - public List getEnclosureList() { if (enclosureList == null) { return new ArrayList<>(); @@ -65,6 +62,22 @@ public Enclosure getFirstEnclosure() { return enclosureList.get(0); } + public StringValue getLink() { + return StringValue.ofNullable(link); + } + + public boolean hasLink() { + return link != null; + } + + public DateTimeValue getPublished() { + return DateTimeValue.ofNullable(published); + } + + public boolean hasPublished() { + return published != null; + } + public StringValue getTitle() { return StringValue.ofNullable(title); } @@ -89,8 +102,9 @@ public boolean equals(final Object other) { Item that = (Item) other; return Objects.equals(description, that.description) - && Objects.equals(link, that.link) && Objects.equals(enclosureList, that.enclosureList) + && Objects.equals(link, that.link) + && Objects.equals(published, that.published) && Objects.equals(title, that.title); } @@ -100,10 +114,12 @@ public String toString() { result.append("{"); result.append("\"description\":"); result.append("\"" + description + "\""); - result.append(",\"link\":"); - result.append("\"" + link + "\""); result.append(",\"enclosureList\":"); result.append(String.valueOf(enclosureList)); + result.append(",\"link\":"); + result.append("\"" + link + "\""); + result.append(",\"published\":"); + result.append(String.valueOf(published)); result.append(",\"title\":"); result.append("\"" + title + "\""); result.append("}"); @@ -113,9 +129,11 @@ public String toString() { public static class Builder { private String description; + private List enclosureList; + private String link; - private List enclosureList; + private ZonedDateTime published; private String title; @@ -129,16 +147,6 @@ public Builder clearDescription() { return this; } - public Builder setLink(final String link) { - this.link = link; - return this; - } - - public Builder clearLink() { - this.link = null; - return this; - } - public Builder setEnclosureList(final List enclosureList) { this.enclosureList = enclosureList; return this; @@ -162,6 +170,26 @@ public Builder clearEnclosureList() { return this; } + public Builder setLink(final String link) { + this.link = link; + return this; + } + + public Builder clearLink() { + this.link = null; + return this; + } + + public Builder setPublished(final ZonedDateTime published) { + this.published = published; + return this; + } + + public Builder clearPublished() { + this.published = null; + return this; + } + public Builder setTitle(final String title) { this.title = title; return this; @@ -175,8 +203,9 @@ public Builder clearTitle() { public Item build() { return new Item( description, - link, enclosureList, + link, + published, title ); } diff --git a/throwaway-prototype/core/src/main/java/com/rometools/rome/xml/GeneratedXmlBindings.java b/throwaway-prototype/core/src/main/java/com/rometools/rome/xml/GeneratedXmlBindings.java index e510591..9a4eb40 100644 --- a/throwaway-prototype/core/src/main/java/com/rometools/rome/xml/GeneratedXmlBindings.java +++ b/throwaway-prototype/core/src/main/java/com/rometools/rome/xml/GeneratedXmlBindings.java @@ -1,5 +1,6 @@ package com.rometools.rome.xml; +import com.rometools.rome.common.parser.DateTimeParser; import com.rometools.rome.common.parser.IntParser; import com.rometools.rome.common.parser.StringParser; import com.rometools.rome.common.xml.XmlPath; @@ -18,7 +19,7 @@ @Generated( value = "com.rometools.rome.factory.generator.ParserGenerator", - date = "2019-03-22T07:00:47.826Z" + date = "2019-03-23T07:02:53.961Z" ) public class GeneratedXmlBindings { public static final Map> BUILDER_MAPPING = new HashMap<>(); @@ -30,37 +31,41 @@ public class GeneratedXmlBindings { public static final Map> SETTER_MAPPING = new HashMap<>(); static { + BUILDER_MAPPING.put(XmlPath.create("/rss"), Feed::builder); + BUILD_MAPPING.put(XmlPath.create("/rss"), b -> ((Feed.Builder) b).build()); BUILDER_MAPPING.put(XmlPath.create("/rss/channel/image"), Image::builder); BUILD_MAPPING.put(XmlPath.create("/rss/channel/image"), b -> ((Image.Builder) b).build()); PARENT_MAPPING.put(XmlPath.create("/rss/channel/image"), XmlPath.create("/rss")); SETTER_MAPPING.put(XmlPath.create("/rss/channel/image"), (b, v) -> ((Feed.Builder) b).setImage((Image) v)); - BUILDER_MAPPING.put(XmlPath.create("/rss"), Feed::builder); - BUILD_MAPPING.put(XmlPath.create("/rss"), b -> ((Feed.Builder) b).build()); - BUILDER_MAPPING.put(XmlPath.create("/rss/channel/item/enclosure"), Enclosure::builder); - BUILD_MAPPING.put(XmlPath.create("/rss/channel/item/enclosure"), b -> ((Enclosure.Builder) b).build()); - PARENT_MAPPING.put(XmlPath.create("/rss/channel/item/enclosure"), XmlPath.create("/rss/channel/item")); - SETTER_MAPPING.put(XmlPath.create("/rss/channel/item/enclosure"), (b, v) -> ((Item.Builder) b).addEnclosure((Enclosure) v)); BUILDER_MAPPING.put(XmlPath.create("/rss/channel/item"), Item::builder); BUILD_MAPPING.put(XmlPath.create("/rss/channel/item"), b -> ((Item.Builder) b).build()); PARENT_MAPPING.put(XmlPath.create("/rss/channel/item"), XmlPath.create("/rss")); SETTER_MAPPING.put(XmlPath.create("/rss/channel/item"), (b, v) -> ((Feed.Builder) b).addItem((Item) v)); - PARENT_MAPPING.put(XmlPath.create("/rss/channel/item/title"), XmlPath.create("/rss/channel/item")); - SETTER_MAPPING.put(XmlPath.create("/rss/channel/item/title"), (b, v) -> ((Item.Builder) b).setTitle(new StringParser().parse((String) v).asNullable())); - PARENT_MAPPING.put(XmlPath.create("/rss/channel/item/enclosure/@url"), XmlPath.create("/rss/channel/item/enclosure")); - SETTER_MAPPING.put(XmlPath.create("/rss/channel/item/enclosure/@url"), (b, v) -> ((Enclosure.Builder) b).setUrl(new StringParser().parse((String) v).asNullable())); - PARENT_MAPPING.put(XmlPath.create("/rss/channel/item/description"), XmlPath.create("/rss/channel/item")); - SETTER_MAPPING.put(XmlPath.create("/rss/channel/item/description"), (b, v) -> ((Item.Builder) b).setDescription(new StringParser().parse((String) v).asNullable())); + BUILDER_MAPPING.put(XmlPath.create("/rss/channel/item/enclosure"), Enclosure::builder); + BUILD_MAPPING.put(XmlPath.create("/rss/channel/item/enclosure"), b -> ((Enclosure.Builder) b).build()); + PARENT_MAPPING.put(XmlPath.create("/rss/channel/item/enclosure"), XmlPath.create("/rss/channel/item")); + SETTER_MAPPING.put(XmlPath.create("/rss/channel/item/enclosure"), (b, v) -> ((Item.Builder) b).addEnclosure((Enclosure) v)); + PARENT_MAPPING.put(XmlPath.create("/rss/channel/description"), XmlPath.create("/rss")); + SETTER_MAPPING.put(XmlPath.create("/rss/channel/description"), (b, v) -> ((Feed.Builder) b).setDescription(new StringParser().parse((String) v).asNullable())); PARENT_MAPPING.put(XmlPath.create("/rss/channel/image/url"), XmlPath.create("/rss/channel/image")); SETTER_MAPPING.put(XmlPath.create("/rss/channel/image/url"), (b, v) -> ((Image.Builder) b).setUrl(new StringParser().parse((String) v).asNullable())); - PARENT_MAPPING.put(XmlPath.create("/rss/channel/title"), XmlPath.create("/rss")); - SETTER_MAPPING.put(XmlPath.create("/rss/channel/title"), (b, v) -> ((Feed.Builder) b).setTitle(new StringParser().parse((String) v).asNullable())); + PARENT_MAPPING.put(XmlPath.create("/rss/channel/item/description"), XmlPath.create("/rss/channel/item")); + SETTER_MAPPING.put(XmlPath.create("/rss/channel/item/description"), (b, v) -> ((Item.Builder) b).setDescription(new StringParser().parse((String) v).asNullable())); PARENT_MAPPING.put(XmlPath.create("/rss/channel/item/enclosure/@length"), XmlPath.create("/rss/channel/item/enclosure")); SETTER_MAPPING.put(XmlPath.create("/rss/channel/item/enclosure/@length"), (b, v) -> ((Enclosure.Builder) b).setLength(new IntParser().parse((String) v).asNullable())); - PARENT_MAPPING.put(XmlPath.create("/rss/channel/item/link"), XmlPath.create("/rss/channel/item")); - SETTER_MAPPING.put(XmlPath.create("/rss/channel/item/link"), (b, v) -> ((Item.Builder) b).setLink(new StringParser().parse((String) v).asNullable())); PARENT_MAPPING.put(XmlPath.create("/rss/channel/item/enclosure/@type"), XmlPath.create("/rss/channel/item/enclosure")); SETTER_MAPPING.put(XmlPath.create("/rss/channel/item/enclosure/@type"), (b, v) -> ((Enclosure.Builder) b).setType(new StringParser().parse((String) v).asNullable())); - PARENT_MAPPING.put(XmlPath.create("/rss/channel/description"), XmlPath.create("/rss")); - SETTER_MAPPING.put(XmlPath.create("/rss/channel/description"), (b, v) -> ((Feed.Builder) b).setDescription(new StringParser().parse((String) v).asNullable())); + PARENT_MAPPING.put(XmlPath.create("/rss/channel/item/enclosure/@url"), XmlPath.create("/rss/channel/item/enclosure")); + SETTER_MAPPING.put(XmlPath.create("/rss/channel/item/enclosure/@url"), (b, v) -> ((Enclosure.Builder) b).setUrl(new StringParser().parse((String) v).asNullable())); + PARENT_MAPPING.put(XmlPath.create("/rss/channel/item/link"), XmlPath.create("/rss/channel/item")); + SETTER_MAPPING.put(XmlPath.create("/rss/channel/item/link"), (b, v) -> ((Item.Builder) b).setLink(new StringParser().parse((String) v).asNullable())); + PARENT_MAPPING.put(XmlPath.create("/rss/channel/item/pubDate"), XmlPath.create("/rss/channel/item")); + SETTER_MAPPING.put(XmlPath.create("/rss/channel/item/pubDate"), (b, v) -> ((Item.Builder) b).setPublished(new DateTimeParser().parse((String) v).asNullable())); + PARENT_MAPPING.put(XmlPath.create("/rss/channel/item/title"), XmlPath.create("/rss/channel/item")); + SETTER_MAPPING.put(XmlPath.create("/rss/channel/item/title"), (b, v) -> ((Item.Builder) b).setTitle(new StringParser().parse((String) v).asNullable())); + PARENT_MAPPING.put(XmlPath.create("/rss/channel/pubDate"), XmlPath.create("/rss")); + SETTER_MAPPING.put(XmlPath.create("/rss/channel/pubDate"), (b, v) -> ((Feed.Builder) b).setPublished(new DateTimeParser().parse((String) v).asNullable())); + PARENT_MAPPING.put(XmlPath.create("/rss/channel/title"), XmlPath.create("/rss")); + SETTER_MAPPING.put(XmlPath.create("/rss/channel/title"), (b, v) -> ((Feed.Builder) b).setTitle(new StringParser().parse((String) v).asNullable())); } } diff --git a/throwaway-prototype/core/src/test/java/com/rometools/rome/RomeTest.java b/throwaway-prototype/core/src/test/java/com/rometools/rome/RomeTest.java index af1e4e7..fef2e8b 100755 --- a/throwaway-prototype/core/src/test/java/com/rometools/rome/RomeTest.java +++ b/throwaway-prototype/core/src/test/java/com/rometools/rome/RomeTest.java @@ -8,6 +8,7 @@ import com.rometools.rome.model.Feed; import com.rometools.rome.model.Image; import com.rometools.rome.model.Item; +import java.time.ZonedDateTime; import org.junit.Test; public class RomeTest { @@ -18,11 +19,13 @@ public void test() throws Exception { Feed.builder() .setTitle("Test feed title") .setDescription("Test feed description") + .setPublished(ZonedDateTime.parse("1970-01-01T00:00:00Z[UTC]")) .setImage(Image.builder().setUrl("https://test.example.com/image.png").build()) .addItem( Item.builder() .setTitle("Test item title 1") .setDescription("Test item description 1") + .setPublished(ZonedDateTime.parse("1970-01-01T00:00:01Z[UTC]")) .setLink("https://test.example.com/item-link-1") .addEnclosure( Enclosure.builder() @@ -35,6 +38,7 @@ public void test() throws Exception { Item.builder() .setTitle("Test item title 2") .setDescription("Test item description 2") + .setPublished(ZonedDateTime.parse("1970-01-01T00:00:02Z[UTC]")) .setLink("https://test.example.com/item-link-2") .addEnclosure( Enclosure.builder() diff --git a/throwaway-prototype/core/src/test/resources/com/rometools/rome/test.xml b/throwaway-prototype/core/src/test/resources/com/rometools/rome/test.xml index ba486e7..56bc3a8 100755 --- a/throwaway-prototype/core/src/test/resources/com/rometools/rome/test.xml +++ b/throwaway-prototype/core/src/test/resources/com/rometools/rome/test.xml @@ -3,18 +3,21 @@ Test feed title Test feed description + Thu, 01 Jan 1970 00:00:00 UTC https://test.example.com/image.png Test item title 1 Test item description 1 + Thu, 01 Jan 1970 00:00:01 UTC https://test.example.com/item-link-1 Test item title 2 Test item description 2 + Thu, 01 Jan 1970 00:00:02 UTC https://test.example.com/item-link-2 diff --git a/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/generator/EntityGenerator.java b/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/generator/EntityGenerator.java index c33bdb4..d6836f0 100755 --- a/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/generator/EntityGenerator.java +++ b/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/generator/EntityGenerator.java @@ -7,6 +7,7 @@ import com.squareup.javapoet.TypeName; import com.squareup.javapoet.TypeSpec; import java.time.Instant; +import java.util.TreeSet; import javax.annotation.Generated; import javax.lang.model.element.Modifier; @@ -54,8 +55,10 @@ public TypeSpec generate() { .addStatement("$T result = new $T()", StringBuilder.class, StringBuilder.class) .addStatement("result.append($S)", "{"); + TreeSet fields = new TreeSet<>(entity.getFields()); + boolean isFirst = true; - for (Field field : entity.getFields()) { + for (Field field : fields) { new FieldGenerator( modelGenerator, field, diff --git a/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/generator/Field.java b/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/generator/Field.java index ee6588b..2caa275 100644 --- a/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/generator/Field.java +++ b/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/generator/Field.java @@ -1,6 +1,6 @@ package com.rometools.rome.factory.generator; -public class Field { +public class Field implements Comparable { private String name; private Class type; @@ -39,4 +39,9 @@ public boolean isValue() { public boolean isEntity() { return type == null; } + + @Override + public int compareTo(Field other) { + return this.name.compareTo(other.name); + } } diff --git a/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/generator/ModelMerger.java b/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/generator/ModelMerger.java index 3ff6228..67ff68f 100644 --- a/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/generator/ModelMerger.java +++ b/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/generator/ModelMerger.java @@ -2,7 +2,6 @@ import com.rometools.rome.factory.xml.DataPoint; import com.rometools.rome.factory.xml.EntityBinding; -import com.rometools.rome.factory.xml.ModelLocation; import com.rometools.rome.factory.xml.XmlModelDefinition; import java.util.HashMap; import java.util.HashSet; @@ -14,13 +13,13 @@ public class ModelMerger { public static Model merge(XmlModelDefinition... models) { XmlModelDefinition model = models[0]; // Only one for now. - Map> parentToChildren = new HashMap<>(); + Map> parentToChildren = new HashMap<>(); model .getEntityBindings() .forEach( entityBinding -> { - ModelLocation parent = entityBinding.getModelLocation().parent(); + ModelPath parent = entityBinding.getModelPath().parent(); if (parent != null) { if (!parentToChildren.containsKey(parent)) { parentToChildren.put(parent, new HashSet<>()); @@ -29,13 +28,13 @@ public static Model merge(XmlModelDefinition... models) { } }); - Map> parentToDatapoints = new HashMap<>(); + Map> parentToDatapoints = new HashMap<>(); model .getDataPoints() .forEach( dataPoint -> { - ModelLocation parent = dataPoint.getModelLocation().parent(); + ModelPath parent = dataPoint.getModelPath().parent(); if (!parentToDatapoints.containsKey(parent)) { parentToDatapoints.put(parent, new HashSet<>()); } @@ -44,18 +43,18 @@ public static Model merge(XmlModelDefinition... models) { Set result = new HashSet<>(); - Set entityLocations = new HashSet<>(); + Set entityLocations = new HashSet<>(); entityLocations.addAll(parentToChildren.keySet()); entityLocations.addAll(parentToDatapoints.keySet()); - for (ModelLocation entityLocation : entityLocations) { + for (ModelPath entityLocation : entityLocations) { Set fields = new HashSet<>(); if (parentToDatapoints.containsKey(entityLocation)) { for (DataPoint dataPoint : parentToDatapoints.get(entityLocation)) { fields.add( Field.valueField( - dataPoint.getModelLocation().name(), + dataPoint.getModelPath().name(), dataPoint.getParser().getResultClass(), dataPoint.getOneOrMany())); } @@ -65,7 +64,7 @@ public static Model merge(XmlModelDefinition... models) { for (EntityBinding entityBinding : parentToChildren.get(entityLocation)) { fields.add( Field.objectField( - entityBinding.getModelLocation().name(), entityBinding.getOneOrMany())); + entityBinding.getModelPath().name(), entityBinding.getOneOrMany())); } } diff --git a/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/generator/ModelPath.java b/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/generator/ModelPath.java new file mode 100755 index 0000000..c9d8e5a --- /dev/null +++ b/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/generator/ModelPath.java @@ -0,0 +1,64 @@ +package com.rometools.rome.factory.generator; + +import java.util.Arrays; +import java.util.Comparator; +import java.util.List; +import java.util.Objects; + +public class ModelPath implements Comparable { + + private static final Comparator COMPARATOR = Comparator.comparing(ModelPath::toString); + + private List hierarchy; + + private ModelPath(List hierarchy) { + this.hierarchy = hierarchy; + } + + public static ModelPath create(String hierarchy) { + return new ModelPath(Arrays.asList(hierarchy.substring(1).split("/"))); + } + + public ModelPath parent() { + if (hierarchy.size() == 1) { + return null; + } + + return new ModelPath(hierarchy.subList(0, hierarchy.size() - 1)); + } + + public String name() { + return hierarchy.get(hierarchy.size() - 1); + } + + public boolean isTopLevel() { + return hierarchy.size() == 1; + } + + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + ModelPath modelPath = (ModelPath) o; + return Objects.equals(hierarchy, modelPath.hierarchy); + } + + @Override + public int hashCode() { + return Objects.hash(hierarchy); + } + + @Override + public String toString() { + return "/" + String.join("/", hierarchy); + } + + @Override + public int compareTo(ModelPath other) { + return COMPARATOR.compare(this, other); + } +} diff --git a/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/generator/ParserGenerator.java b/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/generator/ParserGenerator.java index 614a71e..28c5406 100755 --- a/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/generator/ParserGenerator.java +++ b/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/generator/ParserGenerator.java @@ -6,7 +6,6 @@ import com.rometools.rome.common.xml.XmlPath; import com.rometools.rome.factory.xml.DataPoint; import com.rometools.rome.factory.xml.EntityBinding; -import com.rometools.rome.factory.xml.ModelLocation; import com.rometools.rome.factory.xml.XmlModelDefinition; import com.squareup.javapoet.AnnotationSpec; import com.squareup.javapoet.ClassName; @@ -21,6 +20,7 @@ import java.time.Instant; import java.util.HashMap; import java.util.Map; +import java.util.TreeSet; import java.util.function.BiFunction; import java.util.function.Function; import java.util.function.Supplier; @@ -42,9 +42,9 @@ public ParserGenerator(XmlModelDefinition model, Path targetDirectory) { } public void generate() { - Map modelPathToXmlPath = + Map modelPathToXmlPath = model.getEntityBindings().stream() - .collect(Collectors.toMap(EntityBinding::getModelLocation, EntityBinding::getXmlPath)); + .collect(Collectors.toMap(EntityBinding::getModelPath, EntityBinding::getXmlPath)); TypeSpec.Builder type = TypeSpec.classBuilder(ClassName.get(PACKAGE, "GeneratedXmlBindings")) @@ -112,58 +112,61 @@ public void generate() { CodeBlock.Builder staticBlock = CodeBlock.builder(); - for (EntityBinding entityBinding : model.getEntityBindings()) { + TreeSet entityBindings = new TreeSet<>(model.getEntityBindings()); + + for (EntityBinding entityBinding : entityBindings) { staticBlock.addStatement( "BUILDER_MAPPING.put($T.create($S), $T::builder)", XmlPath.class, entityBinding.getXmlPath().toString(), - ClassName.get(MODEL_PACKAGE, simpleClassName(entityBinding.getModelLocation().name()))); + ClassName.get(MODEL_PACKAGE, simpleClassName(entityBinding.getModelPath().name()))); staticBlock.addStatement( "BUILD_MAPPING.put($T.create($S), b -> (($T.Builder) b).build())", XmlPath.class, entityBinding.getXmlPath().toString(), - ClassName.get(MODEL_PACKAGE, simpleClassName(entityBinding.getModelLocation().name()))); + ClassName.get(MODEL_PACKAGE, simpleClassName(entityBinding.getModelPath().name()))); - if (!entityBinding.getModelLocation().isTopLevel()) { + if (!entityBinding.getModelPath().isTopLevel()) { staticBlock.addStatement( "PARENT_MAPPING.put($T.create($S), $T.create($S))", XmlPath.class, entityBinding.getXmlPath().toString(), XmlPath.class, - modelPathToXmlPath.get(entityBinding.getModelLocation().parent()).toString()); + modelPathToXmlPath.get(entityBinding.getModelPath().parent()).toString()); staticBlock.addStatement( "SETTER_MAPPING.put($T.create($S), (b, v) -> (($T.Builder) b).$L(($T) v))", XmlPath.class, entityBinding.getXmlPath().toString(), ClassName.get( - MODEL_PACKAGE, simpleClassName(entityBinding.getModelLocation().parent().name())), + MODEL_PACKAGE, simpleClassName(entityBinding.getModelPath().parent().name())), joinNames( entityBinding.getOneOrMany() == OneOrMany.ONE ? "set" : "add", - entityBinding.getModelLocation().name()), - ClassName.get(MODEL_PACKAGE, simpleClassName(entityBinding.getModelLocation().name()))); + entityBinding.getModelPath().name()), + ClassName.get(MODEL_PACKAGE, simpleClassName(entityBinding.getModelPath().name()))); } } - for (DataPoint dataPoint : model.getDataPoints()) { + TreeSet dataPoints = new TreeSet<>(model.getDataPoints()); + for (DataPoint dataPoint : dataPoints) { staticBlock.addStatement( "PARENT_MAPPING.put($T.create($S), $T.create($S))", XmlPath.class, dataPoint.getXmlPath().toString(), XmlPath.class, - modelPathToXmlPath.get(dataPoint.getModelLocation().parent()).toString()); + modelPathToXmlPath.get(dataPoint.getModelPath().parent()).toString()); staticBlock.addStatement( "SETTER_MAPPING.put($T.create($S), (b, v) -> (($T.Builder) b).$L(new $T().parse(($T) v).asNullable()))", XmlPath.class, dataPoint.getXmlPath().toString(), ClassName.get( - MODEL_PACKAGE, simpleClassName(dataPoint.getModelLocation().parent().name())), + MODEL_PACKAGE, simpleClassName(dataPoint.getModelPath().parent().name())), joinNames( dataPoint.getOneOrMany() == OneOrMany.ONE ? "set" : "add", - dataPoint.getModelLocation().name()), + dataPoint.getModelPath().name()), ClassName.get(dataPoint.getParser().getClass()), ClassName.get(String.class)); } diff --git a/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/schema/Rss.java b/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/schema/Rss.java index 7ce0e99..b44a90d 100755 --- a/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/schema/Rss.java +++ b/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/schema/Rss.java @@ -1,5 +1,6 @@ package com.rometools.rome.factory.schema; +import com.rometools.rome.common.parser.DateTimeParser; import com.rometools.rome.common.parser.IntParser; import com.rometools.rome.common.parser.StringParser; import com.rometools.rome.factory.generator.OneOrMany; @@ -9,34 +10,41 @@ public class Rss { public static XmlModelDefinition model() { return XmlModelDefinition.builder("rss") - .addDataPoint("/rss/channel/title", "/feed/title", new StringParser(), OneOrMany.ONE) + .addDataPoint("/rss/channel/title", "/feed/title", StringParser.INSTANCE, OneOrMany.ONE) .addDataPoint( - "/rss/channel/description", "/feed/description", new StringParser(), OneOrMany.ONE) + "/rss/channel/description", "/feed/description", StringParser.INSTANCE, OneOrMany.ONE) .addDataPoint( - "/rss/channel/image/url", "/feed/image/url", new StringParser(), OneOrMany.ONE) + "/rss/channel/pubDate", "/feed/published", DateTimeParser.INSTANCE, OneOrMany.ONE) .addDataPoint( - "/rss/channel/item/title", "/feed/item/title", new StringParser(), OneOrMany.ONE) + "/rss/channel/image/url", "/feed/image/url", StringParser.INSTANCE, OneOrMany.ONE) + .addDataPoint( + "/rss/channel/item/title", "/feed/item/title", StringParser.INSTANCE, OneOrMany.ONE) .addDataPoint( "/rss/channel/item/description", "/feed/item/description", - new StringParser(), + StringParser.INSTANCE, + OneOrMany.ONE) + .addDataPoint( + "/rss/channel/item/pubDate", + "/feed/item/published", + DateTimeParser.INSTANCE, OneOrMany.ONE) .addDataPoint( - "/rss/channel/item/link", "/feed/item/link", new StringParser(), OneOrMany.ONE) + "/rss/channel/item/link", "/feed/item/link", StringParser.INSTANCE, OneOrMany.ONE) .addDataPoint( "/rss/channel/item/enclosure/@url", "/feed/item/enclosure/url", - new StringParser(), + StringParser.INSTANCE, OneOrMany.ONE) .addDataPoint( "/rss/channel/item/enclosure/@length", "/feed/item/enclosure/length", - new IntParser(), + IntParser.INSTANCE, OneOrMany.ONE) .addDataPoint( "/rss/channel/item/enclosure/@type", "/feed/item/enclosure/type", - new StringParser(), + StringParser.INSTANCE, OneOrMany.ONE) .addEntityBinding("/rss", "/feed", OneOrMany.ONE) .addEntityBinding("/rss/channel/image", "/feed/image", OneOrMany.ONE) diff --git a/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/xml/DataPoint.java b/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/xml/DataPoint.java index e4b41af..839e88b 100755 --- a/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/xml/DataPoint.java +++ b/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/xml/DataPoint.java @@ -2,19 +2,23 @@ import com.rometools.rome.common.parser.Parser; import com.rometools.rome.common.xml.XmlPath; +import com.rometools.rome.factory.generator.ModelPath; import com.rometools.rome.factory.generator.OneOrMany; +import java.util.Comparator; -public class DataPoint { +public class DataPoint implements Comparable { + + private static final Comparator COMPARATOR = + Comparator.comparing(DataPoint::getXmlPath).thenComparing(DataPoint::getModelPath); private XmlPath xmlPath; - private ModelLocation modelLocation; + private ModelPath modelPath; private Parser parser; private OneOrMany oneOrMany; - public DataPoint( - XmlPath xmlPath, ModelLocation modelLocation, Parser parser, OneOrMany oneOrMany) { + public DataPoint(XmlPath xmlPath, ModelPath modelPath, Parser parser, OneOrMany oneOrMany) { this.xmlPath = xmlPath; - this.modelLocation = modelLocation; + this.modelPath = modelPath; this.parser = parser; this.oneOrMany = oneOrMany; } @@ -23,8 +27,8 @@ public XmlPath getXmlPath() { return xmlPath; } - public ModelLocation getModelLocation() { - return modelLocation; + public ModelPath getModelPath() { + return modelPath; } public Parser getParser() { @@ -34,4 +38,9 @@ public Parser getParser() { public OneOrMany getOneOrMany() { return oneOrMany; } + + @Override + public int compareTo(DataPoint other) { + return COMPARATOR.compare(this, other); + } } diff --git a/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/xml/EntityBinding.java b/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/xml/EntityBinding.java index af56cc2..f209aff 100755 --- a/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/xml/EntityBinding.java +++ b/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/xml/EntityBinding.java @@ -1,17 +1,22 @@ package com.rometools.rome.factory.xml; import com.rometools.rome.common.xml.XmlPath; +import com.rometools.rome.factory.generator.ModelPath; import com.rometools.rome.factory.generator.OneOrMany; +import java.util.Comparator; -public class EntityBinding { +public class EntityBinding implements Comparable { + + private static final Comparator COMPARATOR = + Comparator.comparing(EntityBinding::getXmlPath).thenComparing(EntityBinding::getModelPath); private final OneOrMany oneOrMany; private XmlPath xmlPath; - private ModelLocation modelLocation; + private ModelPath modelPath; - public EntityBinding(XmlPath xmlPath, ModelLocation modelLocation, OneOrMany oneOrMany) { + public EntityBinding(XmlPath xmlPath, ModelPath modelPath, OneOrMany oneOrMany) { this.xmlPath = xmlPath; - this.modelLocation = modelLocation; + this.modelPath = modelPath; this.oneOrMany = oneOrMany; } @@ -19,11 +24,16 @@ public XmlPath getXmlPath() { return xmlPath; } - public ModelLocation getModelLocation() { - return modelLocation; + public ModelPath getModelPath() { + return modelPath; } public OneOrMany getOneOrMany() { return oneOrMany; } + + @Override + public int compareTo(EntityBinding other) { + return COMPARATOR.compare(this, other); + } } diff --git a/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/xml/ModelLocation.java b/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/xml/ModelLocation.java deleted file mode 100755 index 9cff659..0000000 --- a/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/xml/ModelLocation.java +++ /dev/null @@ -1,56 +0,0 @@ -package com.rometools.rome.factory.xml; - -import java.util.Arrays; -import java.util.List; -import java.util.Objects; - -public class ModelLocation { - - public List hierarchy; - - private ModelLocation(List hierarchy) { - this.hierarchy = hierarchy; - } - - public static ModelLocation create(String hierarchy) { - return new ModelLocation(Arrays.asList(hierarchy.substring(1).split("/"))); - } - - public ModelLocation parent() { - if (hierarchy.size() == 1) { - return null; - } - - return new ModelLocation(hierarchy.subList(0, hierarchy.size() - 1)); - } - - public String name() { - return hierarchy.get(hierarchy.size() - 1); - } - - public boolean isTopLevel() { - return hierarchy.size() == 1; - } - - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - ModelLocation modelLocation = (ModelLocation) o; - return Objects.equals(hierarchy, modelLocation.hierarchy); - } - - @Override - public int hashCode() { - return Objects.hash(hierarchy); - } - - @Override - public String toString() { - return "/" + String.join("/", hierarchy); - } -} diff --git a/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/xml/XmlModelDefinition.java b/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/xml/XmlModelDefinition.java index 417f064..09d4875 100755 --- a/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/xml/XmlModelDefinition.java +++ b/throwaway-prototype/factory/src/main/java/com/rometools/rome/factory/xml/XmlModelDefinition.java @@ -2,6 +2,7 @@ import com.rometools.rome.common.parser.Parser; import com.rometools.rome.common.xml.XmlPath; +import com.rometools.rome.factory.generator.ModelPath; import com.rometools.rome.factory.generator.OneOrMany; import java.util.HashSet; import java.util.Set; @@ -49,14 +50,14 @@ public Builder addDataPoint( String xmlPath, String modelLocation, Parser parser, OneOrMany oneOrMany) { dataPoints.add( new DataPoint( - XmlPath.create(xmlPath), ModelLocation.create(modelLocation), parser, oneOrMany)); + XmlPath.create(xmlPath), ModelPath.create(modelLocation), parser, oneOrMany)); return this; } public Builder addEntityBinding(String xmlPath, String modelLocation, OneOrMany oneOrMany) { entityBindings.add( new EntityBinding( - XmlPath.create(xmlPath), ModelLocation.create(modelLocation), oneOrMany)); + XmlPath.create(xmlPath), ModelPath.create(modelLocation), oneOrMany)); return this; }