Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,96 @@
* @param format Maps to {@code $format} in the template. Nullable.
* @param recording Maps to {@code $recording} in the template. Nullable.
*/
public record InsertAlbum(
String name,
LocalDate released,
AlbumFormat format,
RecordingInfo recording
) implements Statement<InsertAlbum.Output> {
public final class InsertAlbum implements Statement<InsertAlbum.Output> {

private final String name;
private final LocalDate released;
private final AlbumFormat format;
private final RecordingInfo recording;

public InsertAlbum(String name, LocalDate released, AlbumFormat format, RecordingInfo recording) {
this.name = name;
this.released = released;
this.format = format;
this.recording = recording;
}

public String name() {
return name;
}

public LocalDate released() {
return released;
}

public AlbumFormat format() {
return format;
}

public RecordingInfo recording() {
return recording;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof InsertAlbum)) return false;
InsertAlbum that = (InsertAlbum) o;
return java.util.Objects.equals(name, that.name) &&
java.util.Objects.equals(released, that.released) &&
java.util.Objects.equals(format, that.format) &&
java.util.Objects.equals(recording, that.recording);
}

@Override
public int hashCode() {
return java.util.Objects.hash(name, released, format, recording);
}

@Override
public String toString() {
return "InsertAlbum[name=" + name +
", released=" + released +
", format=" + format +
", recording=" + recording + "]";
}

// -------------------------------------------------------------------------
// Result type
// -------------------------------------------------------------------------

/** Result of the statement parameterised by {@link Input}. */
public record Output(
/** Maps to the {@code id} result-set column. */
long id
) {}
public static final class Output {

private final long id;

Output(long id) {
this.id = id;
}

/** Maps to the {@code id} result-set column. */
public long id() {
return id;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof Output)) return false;
Output that = (Output) o;
return id == that.id;
}

@Override
public int hashCode() {
return java.util.Objects.hash(id);
}

@Override
public String toString() {
return "Output[id=" + id + "]";
}
}

// -------------------------------------------------------------------------
// Statement implementation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,36 @@
*
* @param format Maps to {@code $format} in the template. Nullable.
*/
public record SelectAlbumByFormat(AlbumFormat format)
implements Statement<SelectAlbumByFormat.Output> {
public final class SelectAlbumByFormat implements Statement<SelectAlbumByFormat.Output> {

private final AlbumFormat format;

public SelectAlbumByFormat(AlbumFormat format) {
this.format = format;
}

public AlbumFormat format() {
return format;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof SelectAlbumByFormat)) return false;
SelectAlbumByFormat that = (SelectAlbumByFormat) o;
return java.util.Objects.equals(format, that.format);
}

@Override
public int hashCode() {
return java.util.Objects.hash(format);
}

@Override
public String toString() {
return "SelectAlbumByFormat[format=" + format + "]";
}


// -------------------------------------------------------------------------
// Result type
Expand All @@ -50,18 +78,60 @@ public static final class Output extends ArrayList<OutputRow> {
}

/** Row of {@link Output}. */
public record OutputRow(
/** Maps to the {@code id} result-set column. */
long id,
/** Maps to the {@code name} result-set column. */
String name,
/** Maps to the {@code released} result-set column. Nullable. */
LocalDate released,
/** Maps to the {@code format} result-set column. Nullable. */
AlbumFormat format,
/** Maps to the {@code recording} result-set column. Nullable. */
RecordingInfo recording
) {}
public static final class OutputRow {

private final long id;
private final String name;
private final LocalDate released;
private final AlbumFormat format;
private final RecordingInfo recording;

OutputRow(long id, String name, LocalDate released, AlbumFormat format, RecordingInfo recording) {
this.id = id;
this.name = name;
this.released = released;
this.format = format;
this.recording = recording;
}

/** Maps to the {@code id} result-set column. */
public long id() { return id; }
/** Maps to the {@code name} result-set column. */
public String name() { return name; }
/** Maps to the {@code released} result-set column. Nullable. */
public LocalDate released() { return released; }
/** Maps to the {@code format} result-set column. Nullable. */
public AlbumFormat format() { return format; }
/** Maps to the {@code recording} result-set column. Nullable. */
public RecordingInfo recording() { return recording; }

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof OutputRow)) return false;
OutputRow that = (OutputRow) o;
return id == that.id &&
java.util.Objects.equals(name, that.name) &&
java.util.Objects.equals(released, that.released) &&
java.util.Objects.equals(format, that.format) &&
java.util.Objects.equals(recording, that.recording);
}

@Override
public int hashCode() {
return java.util.Objects.hash(id, name, released, format, recording);
}

@Override
public String toString() {
return "OutputRow[id=" + id +
", name=" + name +
", released=" + released +
", format=" + format +
", recording=" + recording + "]";
}
}


// -------------------------------------------------------------------------
// Statement implementation
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,36 @@
*
* @param artist Maps to {@code $artist} in the template. Nullable.
*/
public record SelectGenreByArtist(Integer artist)
implements Statement<SelectGenreByArtist.Output> {
public final class SelectGenreByArtist implements Statement<SelectGenreByArtist.Output> {

private final Integer artist;

public SelectGenreByArtist(Integer artist) {
this.artist = artist;
}

public Integer artist() {
return artist;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof SelectGenreByArtist)) return false;
SelectGenreByArtist that = (SelectGenreByArtist) o;
return java.util.Objects.equals(artist, that.artist);
}

@Override
public int hashCode() {
return java.util.Objects.hash(artist);
}

@Override
public String toString() {
return "SelectGenreByArtist[artist=" + artist + "]";
}


// -------------------------------------------------------------------------
// Result type
Expand All @@ -44,12 +72,40 @@ public static final class Output extends ArrayList<OutputRow> {
}

/** Row of {@link Output}. */
public record OutputRow(
/** Maps to the {@code id} result-set column. */
int id,
/** Maps to the {@code name} result-set column. */
String name
) {}
public static final class OutputRow {

private final int id;
private final String name;

OutputRow(int id, String name) {
this.id = id;
this.name = name;
}

/** Maps to the {@code id} result-set column. */
public int id() { return id; }
/** Maps to the {@code name} result-set column. */
public String name() { return name; }

@Override
public boolean equals(Object o) {
if (this == o) return true;
if (!(o instanceof OutputRow)) return false;
OutputRow that = (OutputRow) o;
return id == that.id && java.util.Objects.equals(name, that.name);
}

@Override
public int hashCode() {
return java.util.Objects.hash(id, name);
}

@Override
public String toString() {
return "OutputRow[id=" + id + ", name=" + name + "]";
}
}


// -------------------------------------------------------------------------
// Statement implementation
Expand Down
Loading