Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package com.vertigo.resolver.apple.entity;
- import java.time.LocalDate;
- import java.util.ArrayList;
- import java.util.List;
- import java.util.Objects;
- import java.util.Optional;
- import javax.annotation.Generated;
- /**
- * Corresponds to {@code vertigo_apple_epf_db.public.song}
- */
- @SuppressWarnings({"all"})
- @Generated({"Immutables.generator", "AbstractSong"})
- public final class Song implements AbstractSong {
- private final SongId songId;
- private final String name;
- private final String titleVersion;
- private final String searchTerms;
- private final Integer parentalAdvisoryId;
- private final String artistDisplayName;
- private final String collectionDisplayName;
- private final String viewUrl;
- private final LocalDate originalReleaseDate;
- private final LocalDate itunesReleaseDate;
- private final String trackLength;
- private final String copyright;
- private final String pLine;
- private final String previewUrl;
- private final String previewLength;
- private final Long exportDate;
- private Song(
- SongId songId,
- String name,
- String titleVersion,
- String searchTerms,
- Integer parentalAdvisoryId,
- String artistDisplayName,
- String collectionDisplayName,
- String viewUrl,
- LocalDate originalReleaseDate,
- LocalDate itunesReleaseDate,
- String trackLength,
- String copyright,
- String pLine,
- String previewUrl,
- String previewLength,
- Long exportDate) {
- this.songId = songId;
- this.name = name;
- this.titleVersion = titleVersion;
- this.searchTerms = searchTerms;
- this.parentalAdvisoryId = parentalAdvisoryId;
- this.artistDisplayName = artistDisplayName;
- this.collectionDisplayName = collectionDisplayName;
- this.viewUrl = viewUrl;
- this.originalReleaseDate = originalReleaseDate;
- this.itunesReleaseDate = itunesReleaseDate;
- this.trackLength = trackLength;
- this.copyright = copyright;
- this.pLine = pLine;
- this.previewUrl = previewUrl;
- this.previewLength = previewLength;
- this.exportDate = exportDate;
- }
- /**
- * @return The value of the {@code songId} attribute
- */
- @Override
- public SongId songId() {
- return songId;
- }
- /**
- * @return The value of the {@code name} attribute
- */
- @Override
- public String name() {
- return name;
- }
- /**
- * @return The value of the {@code titleVersion} attribute
- */
- @Override
- public Optional<String> titleVersion() {
- return Optional.ofNullable(titleVersion);
- }
- /**
- * @return The value of the {@code searchTerms} attribute
- */
- @Override
- public Optional<String> searchTerms() {
- return Optional.ofNullable(searchTerms);
- }
- /**
- * @return The value of the {@code parentalAdvisoryId} attribute
- */
- @Override
- public Integer parentalAdvisoryId() {
- return parentalAdvisoryId;
- }
- /**
- * @return The value of the {@code artistDisplayName} attribute
- */
- @Override
- public String artistDisplayName() {
- return artistDisplayName;
- }
- /**
- * @return The value of the {@code collectionDisplayName} attribute
- */
- @Override
- public String collectionDisplayName() {
- return collectionDisplayName;
- }
- /**
- * @return The value of the {@code viewUrl} attribute
- */
- @Override
- public String viewUrl() {
- return viewUrl;
- }
- /**
- * @return The value of the {@code originalReleaseDate} attribute
- */
- @Override
- public LocalDate originalReleaseDate() {
- return originalReleaseDate;
- }
- /**
- * @return The value of the {@code itunesReleaseDate} attribute
- */
- @Override
- public LocalDate itunesReleaseDate() {
- return itunesReleaseDate;
- }
- /**
- * @return The value of the {@code trackLength} attribute
- */
- @Override
- public String trackLength() {
- return trackLength;
- }
- /**
- * @return The value of the {@code copyright} attribute
- */
- @Override
- public String copyright() {
- return copyright;
- }
- /**
- * @return The value of the {@code pLine} attribute
- */
- @Override
- public String pLine() {
- return pLine;
- }
- /**
- * @return The value of the {@code previewUrl} attribute
- */
- @Override
- public String previewUrl() {
- return previewUrl;
- }
- /**
- * @return The value of the {@code previewLength} attribute
- */
- @Override
- public String previewLength() {
- return previewLength;
- }
- /**
- * @return The value of the {@code exportDate} attribute
- */
- @Override
- public Long exportDate() {
- return exportDate;
- }
- /**
- * Copy the current immutable object by setting a value for the {@link AbstractSong#songId() songId} attribute.
- * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
- * @param value A new value for songId
- * @return A modified copy of the {@code this} object
- */
- public final Song withSongId(SongId value) {
- if (this.songId == value) return this;
- SongId newValue = Objects.requireNonNull(value, "songId");
- return new Song(
- newValue,
- this.name,
- this.titleVersion,
- this.searchTerms,
- this.parentalAdvisoryId,
- this.artistDisplayName,
- this.collectionDisplayName,
- this.viewUrl,
- this.originalReleaseDate,
- this.itunesReleaseDate,
- this.trackLength,
- this.copyright,
- this.pLine,
- this.previewUrl,
- this.previewLength,
- this.exportDate);
- }
- /**
- * Copy the current immutable object by setting a value for the {@link AbstractSong#name() name} attribute.
- * An equals check used to prevent copying of the same value by returning {@code this}.
- * @param value A new value for name
- * @return A modified copy of the {@code this} object
- */
- public final Song withName(String value) {
- if (this.name.equals(value)) return this;
- String newValue = Objects.requireNonNull(value, "name");
- return new Song(
- this.songId,
- newValue,
- this.titleVersion,
- this.searchTerms,
- this.parentalAdvisoryId,
- this.artistDisplayName,
- this.collectionDisplayName,
- this.viewUrl,
- this.originalReleaseDate,
- this.itunesReleaseDate,
- this.trackLength,
- this.copyright,
- this.pLine,
- this.previewUrl,
- this.previewLength,
- this.exportDate);
- }
- /**
- * Copy the current immutable object by setting a <i>present</i> value for the optional {@link AbstractSong#titleVersion() titleVersion} attribute.
- * @param value The value for titleVersion
- * @return A modified copy of {@code this} object
- */
- public final Song withTitleVersion(String value) {
- String newValue = Objects.requireNonNull(value, "titleVersion");
- if (Objects.equals(this.titleVersion, newValue)) return this;
- return new Song(
- this.songId,
- this.name,
- newValue,
- this.searchTerms,
- this.parentalAdvisoryId,
- this.artistDisplayName,
- this.collectionDisplayName,
- this.viewUrl,
- this.originalReleaseDate,
- this.itunesReleaseDate,
- this.trackLength,
- this.copyright,
- this.pLine,
- this.previewUrl,
- this.previewLength,
- this.exportDate);
- }
- /**
- * Copy the current immutable object by setting an optional value for the {@link AbstractSong#titleVersion() titleVersion} attribute.
- * An equality check is used on inner nullable value to prevent copying of the same value by returning {@code this}.
- * @param optional A value for titleVersion
- * @return A modified copy of {@code this} object
- */
- public final Song withTitleVersion(Optional<String> optional) {
- String value = optional.orElse(null);
- if (Objects.equals(this.titleVersion, value)) return this;
- return new Song(
- this.songId,
- this.name,
- value,
- this.searchTerms,
- this.parentalAdvisoryId,
- this.artistDisplayName,
- this.collectionDisplayName,
- this.viewUrl,
- this.originalReleaseDate,
- this.itunesReleaseDate,
- this.trackLength,
- this.copyright,
- this.pLine,
- this.previewUrl,
- this.previewLength,
- this.exportDate);
- }
- /**
- * Copy the current immutable object by setting a <i>present</i> value for the optional {@link AbstractSong#searchTerms() searchTerms} attribute.
- * @param value The value for searchTerms
- * @return A modified copy of {@code this} object
- */
- public final Song withSearchTerms(String value) {
- String newValue = Objects.requireNonNull(value, "searchTerms");
- if (Objects.equals(this.searchTerms, newValue)) return this;
- return new Song(
- this.songId,
- this.name,
- this.titleVersion,
- newValue,
- this.parentalAdvisoryId,
- this.artistDisplayName,
- this.collectionDisplayName,
- this.viewUrl,
- this.originalReleaseDate,
- this.itunesReleaseDate,
- this.trackLength,
- this.copyright,
- this.pLine,
- this.previewUrl,
- this.previewLength,
- this.exportDate);
- }
- /**
- * Copy the current immutable object by setting an optional value for the {@link AbstractSong#searchTerms() searchTerms} attribute.
- * An equality check is used on inner nullable value to prevent copying of the same value by returning {@code this}.
- * @param optional A value for searchTerms
- * @return A modified copy of {@code this} object
- */
- public final Song withSearchTerms(Optional<String> optional) {
- String value = optional.orElse(null);
- if (Objects.equals(this.searchTerms, value)) return this;
- return new Song(
- this.songId,
- this.name,
- this.titleVersion,
- value,
- this.parentalAdvisoryId,
- this.artistDisplayName,
- this.collectionDisplayName,
- this.viewUrl,
- this.originalReleaseDate,
- this.itunesReleaseDate,
- this.trackLength,
- this.copyright,
- this.pLine,
- this.previewUrl,
- this.previewLength,
- this.exportDate);
- }
- /**
- * Copy the current immutable object by setting a value for the {@link AbstractSong#parentalAdvisoryId() parentalAdvisoryId} attribute.
- * An equals check used to prevent copying of the same value by returning {@code this}.
- * @param value A new value for parentalAdvisoryId
- * @return A modified copy of the {@code this} object
- */
- public final Song withParentalAdvisoryId(Integer value) {
- if (this.parentalAdvisoryId.equals(value)) return this;
- Integer newValue = Objects.requireNonNull(value, "parentalAdvisoryId");
- return new Song(
- this.songId,
- this.name,
- this.titleVersion,
- this.searchTerms,
- newValue,
- this.artistDisplayName,
- this.collectionDisplayName,
- this.viewUrl,
- this.originalReleaseDate,
- this.itunesReleaseDate,
- this.trackLength,
- this.copyright,
- this.pLine,
- this.previewUrl,
- this.previewLength,
- this.exportDate);
- }
- /**
- * Copy the current immutable object by setting a value for the {@link AbstractSong#artistDisplayName() artistDisplayName} attribute.
- * An equals check used to prevent copying of the same value by returning {@code this}.
- * @param value A new value for artistDisplayName
- * @return A modified copy of the {@code this} object
- */
- public final Song withArtistDisplayName(String value) {
- if (this.artistDisplayName.equals(value)) return this;
- String newValue = Objects.requireNonNull(value, "artistDisplayName");
- return new Song(
- this.songId,
- this.name,
- this.titleVersion,
- this.searchTerms,
- this.parentalAdvisoryId,
- newValue,
- this.collectionDisplayName,
- this.viewUrl,
- this.originalReleaseDate,
- this.itunesReleaseDate,
- this.trackLength,
- this.copyright,
- this.pLine,
- this.previewUrl,
- this.previewLength,
- this.exportDate);
- }
- /**
- * Copy the current immutable object by setting a value for the {@link AbstractSong#collectionDisplayName() collectionDisplayName} attribute.
- * An equals check used to prevent copying of the same value by returning {@code this}.
- * @param value A new value for collectionDisplayName
- * @return A modified copy of the {@code this} object
- */
- public final Song withCollectionDisplayName(String value) {
- if (this.collectionDisplayName.equals(value)) return this;
- String newValue = Objects.requireNonNull(value, "collectionDisplayName");
- return new Song(
- this.songId,
- this.name,
- this.titleVersion,
- this.searchTerms,
- this.parentalAdvisoryId,
- this.artistDisplayName,
- newValue,
- this.viewUrl,
- this.originalReleaseDate,
- this.itunesReleaseDate,
- this.trackLength,
- this.copyright,
- this.pLine,
- this.previewUrl,
- this.previewLength,
- this.exportDate);
- }
- /**
- * Copy the current immutable object by setting a value for the {@link AbstractSong#viewUrl() viewUrl} attribute.
- * An equals check used to prevent copying of the same value by returning {@code this}.
- * @param value A new value for viewUrl
- * @return A modified copy of the {@code this} object
- */
- public final Song withViewUrl(String value) {
- if (this.viewUrl.equals(value)) return this;
- String newValue = Objects.requireNonNull(value, "viewUrl");
- return new Song(
- this.songId,
- this.name,
- this.titleVersion,
- this.searchTerms,
- this.parentalAdvisoryId,
- this.artistDisplayName,
- this.collectionDisplayName,
- newValue,
- this.originalReleaseDate,
- this.itunesReleaseDate,
- this.trackLength,
- this.copyright,
- this.pLine,
- this.previewUrl,
- this.previewLength,
- this.exportDate);
- }
- /**
- * Copy the current immutable object by setting a value for the {@link AbstractSong#originalReleaseDate() originalReleaseDate} attribute.
- * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
- * @param value A new value for originalReleaseDate
- * @return A modified copy of the {@code this} object
- */
- public final Song withOriginalReleaseDate(LocalDate value) {
- if (this.originalReleaseDate == value) return this;
- LocalDate newValue = Objects.requireNonNull(value, "originalReleaseDate");
- return new Song(
- this.songId,
- this.name,
- this.titleVersion,
- this.searchTerms,
- this.parentalAdvisoryId,
- this.artistDisplayName,
- this.collectionDisplayName,
- this.viewUrl,
- newValue,
- this.itunesReleaseDate,
- this.trackLength,
- this.copyright,
- this.pLine,
- this.previewUrl,
- this.previewLength,
- this.exportDate);
- }
- /**
- * Copy the current immutable object by setting a value for the {@link AbstractSong#itunesReleaseDate() itunesReleaseDate} attribute.
- * A shallow reference equality check is used to prevent copying of the same value by returning {@code this}.
- * @param value A new value for itunesReleaseDate
- * @return A modified copy of the {@code this} object
- */
- public final Song withItunesReleaseDate(LocalDate value) {
- if (this.itunesReleaseDate == value) return this;
- LocalDate newValue = Objects.requireNonNull(value, "itunesReleaseDate");
- return new Song(
- this.songId,
- this.name,
- this.titleVersion,
- this.searchTerms,
- this.parentalAdvisoryId,
- this.artistDisplayName,
- this.collectionDisplayName,
- this.viewUrl,
- this.originalReleaseDate,
- newValue,
- this.trackLength,
- this.copyright,
- this.pLine,
- this.previewUrl,
- this.previewLength,
- this.exportDate);
- }
- /**
- * Copy the current immutable object by setting a value for the {@link AbstractSong#trackLength() trackLength} attribute.
- * An equals check used to prevent copying of the same value by returning {@code this}.
- * @param value A new value for trackLength
- * @return A modified copy of the {@code this} object
- */
- public final Song withTrackLength(String value) {
- if (this.trackLength.equals(value)) return this;
- String newValue = Objects.requireNonNull(value, "trackLength");
- return new Song(
- this.songId,
- this.name,
- this.titleVersion,
- this.searchTerms,
- this.parentalAdvisoryId,
- this.artistDisplayName,
- this.collectionDisplayName,
- this.viewUrl,
- this.originalReleaseDate,
- this.itunesReleaseDate,
- newValue,
- this.copyright,
- this.pLine,
- this.previewUrl,
- this.previewLength,
- this.exportDate);
- }
- /**
- * Copy the current immutable object by setting a value for the {@link AbstractSong#copyright() copyright} attribute.
- * An equals check used to prevent copying of the same value by returning {@code this}.
- * @param value A new value for copyright
- * @return A modified copy of the {@code this} object
- */
- public final Song withCopyright(String value) {
- if (this.copyright.equals(value)) return this;
- String newValue = Objects.requireNonNull(value, "copyright");
- return new Song(
- this.songId,
- this.name,
- this.titleVersion,
- this.searchTerms,
- this.parentalAdvisoryId,
- this.artistDisplayName,
- this.collectionDisplayName,
- this.viewUrl,
- this.originalReleaseDate,
- this.itunesReleaseDate,
- this.trackLength,
- newValue,
- this.pLine,
- this.previewUrl,
- this.previewLength,
- this.exportDate);
- }
- /**
- * Copy the current immutable object by setting a value for the {@link AbstractSong#pLine() pLine} attribute.
- * An equals check used to prevent copying of the same value by returning {@code this}.
- * @param value A new value for pLine
- * @return A modified copy of the {@code this} object
- */
- public final Song withPLine(String value) {
- if (this.pLine.equals(value)) return this;
- String newValue = Objects.requireNonNull(value, "pLine");
- return new Song(
- this.songId,
- this.name,
- this.titleVersion,
- this.searchTerms,
- this.parentalAdvisoryId,
- this.artistDisplayName,
- this.collectionDisplayName,
- this.viewUrl,
- this.originalReleaseDate,
- this.itunesReleaseDate,
- this.trackLength,
- this.copyright,
- newValue,
- this.previewUrl,
- this.previewLength,
- this.exportDate);
- }
- /**
- * Copy the current immutable object by setting a value for the {@link AbstractSong#previewUrl() previewUrl} attribute.
- * An equals check used to prevent copying of the same value by returning {@code this}.
- * @param value A new value for previewUrl
- * @return A modified copy of the {@code this} object
- */
- public final Song withPreviewUrl(String value) {
- if (this.previewUrl.equals(value)) return this;
- String newValue = Objects.requireNonNull(value, "previewUrl");
- return new Song(
- this.songId,
- this.name,
- this.titleVersion,
- this.searchTerms,
- this.parentalAdvisoryId,
- this.artistDisplayName,
- this.collectionDisplayName,
- this.viewUrl,
- this.originalReleaseDate,
- this.itunesReleaseDate,
- this.trackLength,
- this.copyright,
- this.pLine,
- newValue,
- this.previewLength,
- this.exportDate);
- }
- /**
- * Copy the current immutable object by setting a value for the {@link AbstractSong#previewLength() previewLength} attribute.
- * An equals check used to prevent copying of the same value by returning {@code this}.
- * @param value A new value for previewLength
- * @return A modified copy of the {@code this} object
- */
- public final Song withPreviewLength(String value) {
- if (this.previewLength.equals(value)) return this;
- String newValue = Objects.requireNonNull(value, "previewLength");
- return new Song(
- this.songId,
- this.name,
- this.titleVersion,
- this.searchTerms,
- this.parentalAdvisoryId,
- this.artistDisplayName,
- this.collectionDisplayName,
- this.viewUrl,
- this.originalReleaseDate,
- this.itunesReleaseDate,
- this.trackLength,
- this.copyright,
- this.pLine,
- this.previewUrl,
- newValue,
- this.exportDate);
- }
- /**
- * Copy the current immutable object by setting a value for the {@link AbstractSong#exportDate() exportDate} attribute.
- * An equals check used to prevent copying of the same value by returning {@code this}.
- * @param value A new value for exportDate
- * @return A modified copy of the {@code this} object
- */
- public final Song withExportDate(Long value) {
- if (this.exportDate.equals(value)) return this;
- Long newValue = Objects.requireNonNull(value, "exportDate");
- return new Song(
- this.songId,
- this.name,
- this.titleVersion,
- this.searchTerms,
- this.parentalAdvisoryId,
- this.artistDisplayName,
- this.collectionDisplayName,
- this.viewUrl,
- this.originalReleaseDate,
- this.itunesReleaseDate,
- this.trackLength,
- this.copyright,
- this.pLine,
- this.previewUrl,
- this.previewLength,
- newValue);
- }
- /**
- * This instance is equal to all instances of {@code Song} 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 Song
- && equalTo((Song) another);
- }
- private boolean equalTo(Song another) {
- return songId.equals(another.songId)
- && name.equals(another.name)
- && Objects.equals(titleVersion, another.titleVersion)
- && Objects.equals(searchTerms, another.searchTerms)
- && parentalAdvisoryId.equals(another.parentalAdvisoryId)
- && artistDisplayName.equals(another.artistDisplayName)
- && collectionDisplayName.equals(another.collectionDisplayName)
- && viewUrl.equals(another.viewUrl)
- && originalReleaseDate.equals(another.originalReleaseDate)
- && itunesReleaseDate.equals(another.itunesReleaseDate)
- && trackLength.equals(another.trackLength)
- && copyright.equals(another.copyright)
- && pLine.equals(another.pLine)
- && previewUrl.equals(another.previewUrl)
- && previewLength.equals(another.previewLength)
- && exportDate.equals(another.exportDate);
- }
- /**
- * Computes a hash code from attributes: {@code songId}, {@code name}, {@code titleVersion}, {@code searchTerms}, {@code parentalAdvisoryId}, {@code artistDisplayName}, {@code collectionDisplayName}, {@code viewUrl}, {@code originalReleaseDate}, {@code itunesReleaseDate}, {@code trackLength}, {@code copyright}, {@code pLine}, {@code previewUrl}, {@code previewLength}, {@code exportDate}.
- * @return hashCode value
- */
- @Override
- public int hashCode() {
- int h = 31;
- h = h * 17 + songId.hashCode();
- h = h * 17 + name.hashCode();
- h = h * 17 + Objects.hashCode(titleVersion);
- h = h * 17 + Objects.hashCode(searchTerms);
- h = h * 17 + parentalAdvisoryId.hashCode();
- h = h * 17 + artistDisplayName.hashCode();
- h = h * 17 + collectionDisplayName.hashCode();
- h = h * 17 + viewUrl.hashCode();
- h = h * 17 + originalReleaseDate.hashCode();
- h = h * 17 + itunesReleaseDate.hashCode();
- h = h * 17 + trackLength.hashCode();
- h = h * 17 + copyright.hashCode();
- h = h * 17 + pLine.hashCode();
- h = h * 17 + previewUrl.hashCode();
- h = h * 17 + previewLength.hashCode();
- h = h * 17 + exportDate.hashCode();
- return h;
- }
- /**
- * Prints the immutable value {@code Song} with attribute values.
- * @return A string representation of the value
- */
- @Override
- public String toString() {
- StringBuilder builder = new StringBuilder("Song{");
- builder.append("songId=").append(songId);
- builder.append(", ");
- builder.append("name=").append(name);
- if (titleVersion != null) {
- builder.append(", ");
- builder.append("titleVersion=").append(titleVersion);
- }
- if (searchTerms != null) {
- builder.append(", ");
- builder.append("searchTerms=").append(searchTerms);
- }
- builder.append(", ");
- builder.append("parentalAdvisoryId=").append(parentalAdvisoryId);
- builder.append(", ");
- builder.append("artistDisplayName=").append(artistDisplayName);
- builder.append(", ");
- builder.append("collectionDisplayName=").append(collectionDisplayName);
- builder.append(", ");
- builder.append("viewUrl=").append(viewUrl);
- builder.append(", ");
- builder.append("originalReleaseDate=").append(originalReleaseDate);
- builder.append(", ");
- builder.append("itunesReleaseDate=").append(itunesReleaseDate);
- builder.append(", ");
- builder.append("trackLength=").append(trackLength);
- builder.append(", ");
- builder.append("copyright=").append(copyright);
- builder.append(", ");
- builder.append("pLine=").append(pLine);
- builder.append(", ");
- builder.append("previewUrl=").append(previewUrl);
- builder.append(", ");
- builder.append("previewLength=").append(previewLength);
- builder.append(", ");
- builder.append("exportDate=").append(exportDate);
- return builder.append("}").toString();
- }
- /**
- * Creates an immutable copy of a {@link AbstractSong} 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 Song instance
- */
- public static Song copy(AbstractSong instance) {
- if (instance instanceof Song) {
- return (Song) instance;
- }
- return Song.builder()
- .from(instance)
- .build();
- }
- /**
- * Creates a builder for {@link Song Song}.
- * @return A new Song builder
- */
- public static Song.Builder builder() {
- return new Song.Builder();
- }
- /**
- * Builds instances of type {@link Song Song}.
- * Initialize attributes and then invoke the {@link #build()} method to create an
- * immutable instance.
- * <p><em>{@code Builder} is not thread-safe and generally should not be stored in a field or collection,
- * but instead used immediately to create instances.</em>
- */
- public static final class Builder {
- private static final long INIT_BIT_SONG_ID = 0x1L;
- private static final long INIT_BIT_NAME = 0x2L;
- private static final long INIT_BIT_PARENTAL_ADVISORY_ID = 0x4L;
- private static final long INIT_BIT_ARTIST_DISPLAY_NAME = 0x8L;
- private static final long INIT_BIT_COLLECTION_DISPLAY_NAME = 0x10L;
- private static final long INIT_BIT_VIEW_URL = 0x20L;
- private static final long INIT_BIT_ORIGINAL_RELEASE_DATE = 0x40L;
- private static final long INIT_BIT_ITUNES_RELEASE_DATE = 0x80L;
- private static final long INIT_BIT_TRACK_LENGTH = 0x100L;
- private static final long INIT_BIT_COPYRIGHT = 0x200L;
- private static final long INIT_BIT_P_LINE = 0x400L;
- private static final long INIT_BIT_PREVIEW_URL = 0x800L;
- private static final long INIT_BIT_PREVIEW_LENGTH = 0x1000L;
- private static final long INIT_BIT_EXPORT_DATE = 0x2000L;
- private long initBits = 0x3fffL;
- private SongId songId;
- private String name;
- private String titleVersion;
- private String searchTerms;
- private Integer parentalAdvisoryId;
- private String artistDisplayName;
- private String collectionDisplayName;
- private String viewUrl;
- private LocalDate originalReleaseDate;
- private LocalDate itunesReleaseDate;
- private String trackLength;
- private String copyright;
- private String pLine;
- private String previewUrl;
- private String previewLength;
- private Long exportDate;
- private Builder() {
- }
- /**
- * Fill a builder with attribute values from the provided {@code AbstractSong} instance.
- * Regular attribute values will be replaced with those from the given instance.
- * Absent optional values will not replace present values.
- * @param instance The instance from which to copy values
- * @return {@code this} builder for use in a chained invocation
- */
- public final Builder from(AbstractSong instance) {
- Objects.requireNonNull(instance, "instance");
- songId(instance.songId());
- name(instance.name());
- Optional<String> titleVersionOptional = instance.titleVersion();
- if (titleVersionOptional.isPresent()) {
- titleVersion(titleVersionOptional);
- }
- Optional<String> searchTermsOptional = instance.searchTerms();
- if (searchTermsOptional.isPresent()) {
- searchTerms(searchTermsOptional);
- }
- parentalAdvisoryId(instance.parentalAdvisoryId());
- artistDisplayName(instance.artistDisplayName());
- collectionDisplayName(instance.collectionDisplayName());
- viewUrl(instance.viewUrl());
- originalReleaseDate(instance.originalReleaseDate());
- itunesReleaseDate(instance.itunesReleaseDate());
- trackLength(instance.trackLength());
- copyright(instance.copyright());
- pLine(instance.pLine());
- previewUrl(instance.previewUrl());
- previewLength(instance.previewLength());
- exportDate(instance.exportDate());
- return this;
- }
- /**
- * Initializes the value for the {@link AbstractSong#songId() songId} attribute.
- * @param songId The value for songId
- * @return {@code this} builder for use in a chained invocation
- */
- public final Builder songId(SongId songId) {
- this.songId = Objects.requireNonNull(songId, "songId");
- initBits &= ~INIT_BIT_SONG_ID;
- return this;
- }
- /**
- * Initializes the value for the {@link AbstractSong#name() name} attribute.
- * @param name The value for name
- * @return {@code this} builder for use in a chained invocation
- */
- public final Builder name(String name) {
- this.name = Objects.requireNonNull(name, "name");
- initBits &= ~INIT_BIT_NAME;
- return this;
- }
- /**
- * Initializes the optional value {@link AbstractSong#titleVersion() titleVersion} to titleVersion.
- * @param titleVersion The value for titleVersion
- * @return {@code this} builder for chained invocation
- */
- public final Builder titleVersion(String titleVersion) {
- this.titleVersion = Objects.requireNonNull(titleVersion, "titleVersion");
- return this;
- }
- /**
- * Initializes the optional value {@link AbstractSong#titleVersion() titleVersion} to titleVersion.
- * @param titleVersion The value for titleVersion
- * @return {@code this} builder for use in a chained invocation
- */
- public final Builder titleVersion(Optional<String> titleVersion) {
- this.titleVersion = titleVersion.orElse(null);
- return this;
- }
- /**
- * Initializes the optional value {@link AbstractSong#searchTerms() searchTerms} to searchTerms.
- * @param searchTerms The value for searchTerms
- * @return {@code this} builder for chained invocation
- */
- public final Builder searchTerms(String searchTerms) {
- this.searchTerms = Objects.requireNonNull(searchTerms, "searchTerms");
- return this;
- }
- /**
- * Initializes the optional value {@link AbstractSong#searchTerms() searchTerms} to searchTerms.
- * @param searchTerms The value for searchTerms
- * @return {@code this} builder for use in a chained invocation
- */
- public final Builder searchTerms(Optional<String> searchTerms) {
- this.searchTerms = searchTerms.orElse(null);
- return this;
- }
- /**
- * Initializes the value for the {@link AbstractSong#parentalAdvisoryId() parentalAdvisoryId} attribute.
- * @param parentalAdvisoryId The value for parentalAdvisoryId
- * @return {@code this} builder for use in a chained invocation
- */
- public final Builder parentalAdvisoryId(Integer parentalAdvisoryId) {
- this.parentalAdvisoryId = Objects.requireNonNull(parentalAdvisoryId, "parentalAdvisoryId");
- initBits &= ~INIT_BIT_PARENTAL_ADVISORY_ID;
- return this;
- }
- /**
- * Initializes the value for the {@link AbstractSong#artistDisplayName() artistDisplayName} attribute.
- * @param artistDisplayName The value for artistDisplayName
- * @return {@code this} builder for use in a chained invocation
- */
- public final Builder artistDisplayName(String artistDisplayName) {
- this.artistDisplayName = Objects.requireNonNull(artistDisplayName, "artistDisplayName");
- initBits &= ~INIT_BIT_ARTIST_DISPLAY_NAME;
- return this;
- }
- /**
- * Initializes the value for the {@link AbstractSong#collectionDisplayName() collectionDisplayName} attribute.
- * @param collectionDisplayName The value for collectionDisplayName
- * @return {@code this} builder for use in a chained invocation
- */
- public final Builder collectionDisplayName(String collectionDisplayName) {
- this.collectionDisplayName = Objects.requireNonNull(collectionDisplayName, "collectionDisplayName");
- initBits &= ~INIT_BIT_COLLECTION_DISPLAY_NAME;
- return this;
- }
- /**
- * Initializes the value for the {@link AbstractSong#viewUrl() viewUrl} attribute.
- * @param viewUrl The value for viewUrl
- * @return {@code this} builder for use in a chained invocation
- */
- public final Builder viewUrl(String viewUrl) {
- this.viewUrl = Objects.requireNonNull(viewUrl, "viewUrl");
- initBits &= ~INIT_BIT_VIEW_URL;
- return this;
- }
- /**
- * Initializes the value for the {@link AbstractSong#originalReleaseDate() originalReleaseDate} attribute.
- * @param originalReleaseDate The value for originalReleaseDate
- * @return {@code this} builder for use in a chained invocation
- */
- public final Builder originalReleaseDate(LocalDate originalReleaseDate) {
- this.originalReleaseDate = Objects.requireNonNull(originalReleaseDate, "originalReleaseDate");
- initBits &= ~INIT_BIT_ORIGINAL_RELEASE_DATE;
- return this;
- }
- /**
- * Initializes the value for the {@link AbstractSong#itunesReleaseDate() itunesReleaseDate} attribute.
- * @param itunesReleaseDate The value for itunesReleaseDate
- * @return {@code this} builder for use in a chained invocation
- */
- public final Builder itunesReleaseDate(LocalDate itunesReleaseDate) {
- this.itunesReleaseDate = Objects.requireNonNull(itunesReleaseDate, "itunesReleaseDate");
- initBits &= ~INIT_BIT_ITUNES_RELEASE_DATE;
- return this;
- }
- /**
- * Initializes the value for the {@link AbstractSong#trackLength() trackLength} attribute.
- * @param trackLength The value for trackLength
- * @return {@code this} builder for use in a chained invocation
- */
- public final Builder trackLength(String trackLength) {
- this.trackLength = Objects.requireNonNull(trackLength, "trackLength");
- initBits &= ~INIT_BIT_TRACK_LENGTH;
- return this;
- }
- /**
- * Initializes the value for the {@link AbstractSong#copyright() copyright} attribute.
- * @param copyright The value for copyright
- * @return {@code this} builder for use in a chained invocation
- */
- public final Builder copyright(String copyright) {
- this.copyright = Objects.requireNonNull(copyright, "copyright");
- initBits &= ~INIT_BIT_COPYRIGHT;
- return this;
- }
- /**
- * Initializes the value for the {@link AbstractSong#pLine() pLine} attribute.
- * @param pLine The value for pLine
- * @return {@code this} builder for use in a chained invocation
- */
- public final Builder pLine(String pLine) {
- this.pLine = Objects.requireNonNull(pLine, "pLine");
- initBits &= ~INIT_BIT_P_LINE;
- return this;
- }
- /**
- * Initializes the value for the {@link AbstractSong#previewUrl() previewUrl} attribute.
- * @param previewUrl The value for previewUrl
- * @return {@code this} builder for use in a chained invocation
- */
- public final Builder previewUrl(String previewUrl) {
- this.previewUrl = Objects.requireNonNull(previewUrl, "previewUrl");
- initBits &= ~INIT_BIT_PREVIEW_URL;
- return this;
- }
- /**
- * Initializes the value for the {@link AbstractSong#previewLength() previewLength} attribute.
- * @param previewLength The value for previewLength
- * @return {@code this} builder for use in a chained invocation
- */
- public final Builder previewLength(String previewLength) {
- this.previewLength = Objects.requireNonNull(previewLength, "previewLength");
- initBits &= ~INIT_BIT_PREVIEW_LENGTH;
- return this;
- }
- /**
- * Initializes the value for the {@link AbstractSong#exportDate() exportDate} attribute.
- * @param exportDate The value for exportDate
- * @return {@code this} builder for use in a chained invocation
- */
- public final Builder exportDate(Long exportDate) {
- this.exportDate = Objects.requireNonNull(exportDate, "exportDate");
- initBits &= ~INIT_BIT_EXPORT_DATE;
- return this;
- }
- /**
- * Builds a new {@link Song Song}.
- * @return An immutable instance of Song
- * @throws java.lang.IllegalStateException if any required attributes are missing
- */
- public Song build() {
- if (initBits != 0) {
- throw new IllegalStateException(formatRequiredAttributesMessage());
- }
- return new Song(
- songId,
- name,
- titleVersion,
- searchTerms,
- parentalAdvisoryId,
- artistDisplayName,
- collectionDisplayName,
- viewUrl,
- originalReleaseDate,
- itunesReleaseDate,
- trackLength,
- copyright,
- pLine,
- previewUrl,
- previewLength,
- exportDate);
- }
- private String formatRequiredAttributesMessage() {
- List<String> attributes = new ArrayList<String>();
- if ((initBits & INIT_BIT_SONG_ID) != 0) attributes.add("songId");
- if ((initBits & INIT_BIT_NAME) != 0) attributes.add("name");
- if ((initBits & INIT_BIT_PARENTAL_ADVISORY_ID) != 0) attributes.add("parentalAdvisoryId");
- if ((initBits & INIT_BIT_ARTIST_DISPLAY_NAME) != 0) attributes.add("artistDisplayName");
- if ((initBits & INIT_BIT_COLLECTION_DISPLAY_NAME) != 0) attributes.add("collectionDisplayName");
- if ((initBits & INIT_BIT_VIEW_URL) != 0) attributes.add("viewUrl");
- if ((initBits & INIT_BIT_ORIGINAL_RELEASE_DATE) != 0) attributes.add("originalReleaseDate");
- if ((initBits & INIT_BIT_ITUNES_RELEASE_DATE) != 0) attributes.add("itunesReleaseDate");
- if ((initBits & INIT_BIT_TRACK_LENGTH) != 0) attributes.add("trackLength");
- if ((initBits & INIT_BIT_COPYRIGHT) != 0) attributes.add("copyright");
- if ((initBits & INIT_BIT_P_LINE) != 0) attributes.add("pLine");
- if ((initBits & INIT_BIT_PREVIEW_URL) != 0) attributes.add("previewUrl");
- if ((initBits & INIT_BIT_PREVIEW_LENGTH) != 0) attributes.add("previewLength");
- if ((initBits & INIT_BIT_EXPORT_DATE) != 0) attributes.add("exportDate");
- return "Cannot build Song, some of required attributes are not set " + attributes;
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement