Record Class ChallengeDTO
java.lang.Object
java.lang.Record
org.ntnu.idi.idatt2106.sparesti.sparestibackend.dto.challenge.ChallengeDTO
- Record Components:
id
- Id of challengetitle
- Titlesaved
- Saved amounttarget
- Target amountperPurchase
- Per unit pricecompletion
- Completion percentagedescription
- DescriptioncreatedOn
- Created on datecompletedOn
- Completed on datedue
- Due datetype
- Type of challenge
- All Implemented Interfaces:
Serializable
public record ChallengeDTO(@NotNull(message="ID cannot be null") Long id, @NotNull(message="Title cannot be null") @NotBlank(message="Title cannot be blank") String title, @NotNull(message="Saved amount cannot be null") @PositiveOrZero(message="Saved amount cannot be negative") BigDecimal saved, @NotNull(message="Target amount cannot be null") @PositiveOrZero(message="Target amount cannot be negative") BigDecimal target, @NotNull(message="Per purchase amount cannot be null") @Positive(message="Per purchase amount cannot be less than or equal to zero") BigDecimal perPurchase, @NotNull(message="Completion amount cannot be null") @PositiveOrZero(message="Completion amount cannot be negative") BigDecimal completion, @NotNull(message="Description cannot be null") @NotBlank(message="Description cannot be blank") String description, @Past(message="Created date must be in the past") ZonedDateTime createdOn, ZonedDateTime completedOn, @Future(message="Due date must be in the future") ZonedDateTime due, @NotNull(message="Type cannot be null") String type)
extends Record
implements Serializable
DTO for
Challenge
- See Also:
-
Constructor Summary
ConstructorsConstructorDescriptionChallengeDTO
(@NotNull(message="ID cannot be null") Long id, @NotNull(message="Title cannot be null") @NotBlank(message="Title cannot be blank") String title, @NotNull(message="Saved amount cannot be null") @PositiveOrZero(message="Saved amount cannot be negative") BigDecimal saved, @NotNull(message="Target amount cannot be null") @PositiveOrZero(message="Target amount cannot be negative") BigDecimal target, @NotNull(message="Per purchase amount cannot be null") @Positive(message="Per purchase amount cannot be less than or equal to zero") BigDecimal perPurchase, @NotNull(message="Completion amount cannot be null") @PositiveOrZero(message="Completion amount cannot be negative") BigDecimal completion, @NotNull(message="Description cannot be null") @NotBlank(message="Description cannot be blank") String description, @Past(message="Created date must be in the past") ZonedDateTime createdOn, ZonedDateTime completedOn, @Future(message="Due date must be in the future") ZonedDateTime due, @NotNull(message="Type cannot be null") String type) Creates an instance of aChallengeDTO
record class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecompletedOn
record component.@NotNull(message="Completion amount cannot be null") @PositiveOrZero(message="Completion amount cannot be negative") BigDecimal
Returns the value of thecompletion
record component.@Past(message="Created date must be in the past") ZonedDateTime
Returns the value of thecreatedOn
record component.@NotNull(message="Description cannot be null") @NotBlank(message="Description cannot be blank") String
Returns the value of thedescription
record component.@Future(message="Due date must be in the future") ZonedDateTime
due()
Returns the value of thedue
record component.final boolean
Indicates whether some other object is "equal to" this one.final int
hashCode()
Returns a hash code value for this object.@NotNull(message="ID cannot be null") Long
id()
Returns the value of theid
record component.@NotNull(message="Per purchase amount cannot be null") @Positive(message="Per purchase amount cannot be less than or equal to zero") BigDecimal
Returns the value of theperPurchase
record component.@NotNull(message="Saved amount cannot be null") @PositiveOrZero(message="Saved amount cannot be negative") BigDecimal
saved()
Returns the value of thesaved
record component.@NotNull(message="Target amount cannot be null") @PositiveOrZero(message="Target amount cannot be negative") BigDecimal
target()
Returns the value of thetarget
record component.@NotNull(message="Title cannot be null") @NotBlank(message="Title cannot be blank") String
title()
Returns the value of thetitle
record component.final String
toString()
Returns a string representation of this record class.@NotNull(message="Type cannot be null") String
type()
Returns the value of thetype
record component.
-
Constructor Details
-
ChallengeDTO
public ChallengeDTO(@NotNull(message="ID cannot be null") @NotNull(message="ID cannot be null") Long id, @NotNull(message="Title cannot be null") @NotBlank(message="Title cannot be blank") @NotNull(message="Title cannot be null") @NotBlank(message="Title cannot be blank") String title, @NotNull(message="Saved amount cannot be null") @PositiveOrZero(message="Saved amount cannot be negative") @NotNull(message="Saved amount cannot be null") @PositiveOrZero(message="Saved amount cannot be negative") BigDecimal saved, @NotNull(message="Target amount cannot be null") @PositiveOrZero(message="Target amount cannot be negative") @NotNull(message="Target amount cannot be null") @PositiveOrZero(message="Target amount cannot be negative") BigDecimal target, @NotNull(message="Per purchase amount cannot be null") @Positive(message="Per purchase amount cannot be less than or equal to zero") @NotNull(message="Per purchase amount cannot be null") @Positive(message="Per purchase amount cannot be less than or equal to zero") BigDecimal perPurchase, @NotNull(message="Completion amount cannot be null") @PositiveOrZero(message="Completion amount cannot be negative") @NotNull(message="Completion amount cannot be null") @PositiveOrZero(message="Completion amount cannot be negative") BigDecimal completion, @NotNull(message="Description cannot be null") @NotBlank(message="Description cannot be blank") @NotNull(message="Description cannot be null") @NotBlank(message="Description cannot be blank") String description, @Past(message="Created date must be in the past") @Past(message="Created date must be in the past") ZonedDateTime createdOn, ZonedDateTime completedOn, @Future(message="Due date must be in the future") @Future(message="Due date must be in the future") ZonedDateTime due, @NotNull(message="Type cannot be null") @NotNull(message="Type cannot be null") String type) Creates an instance of aChallengeDTO
record class.- Parameters:
id
- the value for theid
record componenttitle
- the value for thetitle
record componentsaved
- the value for thesaved
record componenttarget
- the value for thetarget
record componentperPurchase
- the value for theperPurchase
record componentcompletion
- the value for thecompletion
record componentdescription
- the value for thedescription
record componentcreatedOn
- the value for thecreatedOn
record componentcompletedOn
- the value for thecompletedOn
record componentdue
- the value for thedue
record componenttype
- the value for thetype
record component
-
-
Method Details
-
toString
Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components. -
hashCode
public final int hashCode()Returns a hash code value for this object. The value is derived from the hash code of each of the record components. -
equals
Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. All components in this record class are compared withObjects::equals(Object,Object)
. -
id
Returns the value of theid
record component.- Returns:
- the value of the
id
record component
-
title
@NotNull(message="Title cannot be null") @NotBlank(message="Title cannot be blank") public @NotNull(message="Title cannot be null") @NotBlank(message="Title cannot be blank") String title()Returns the value of thetitle
record component.- Returns:
- the value of the
title
record component
-
saved
@NotNull(message="Saved amount cannot be null") @PositiveOrZero(message="Saved amount cannot be negative") public @NotNull(message="Saved amount cannot be null") @PositiveOrZero(message="Saved amount cannot be negative") BigDecimal saved()Returns the value of thesaved
record component.- Returns:
- the value of the
saved
record component
-
target
@NotNull(message="Target amount cannot be null") @PositiveOrZero(message="Target amount cannot be negative") public @NotNull(message="Target amount cannot be null") @PositiveOrZero(message="Target amount cannot be negative") BigDecimal target()Returns the value of thetarget
record component.- Returns:
- the value of the
target
record component
-
perPurchase
@NotNull(message="Per purchase amount cannot be null") @Positive(message="Per purchase amount cannot be less than or equal to zero") public @NotNull(message="Per purchase amount cannot be null") @Positive(message="Per purchase amount cannot be less than or equal to zero") BigDecimal perPurchase()Returns the value of theperPurchase
record component.- Returns:
- the value of the
perPurchase
record component
-
completion
@NotNull(message="Completion amount cannot be null") @PositiveOrZero(message="Completion amount cannot be negative") public @NotNull(message="Completion amount cannot be null") @PositiveOrZero(message="Completion amount cannot be negative") BigDecimal completion()Returns the value of thecompletion
record component.- Returns:
- the value of the
completion
record component
-
description
@NotNull(message="Description cannot be null") @NotBlank(message="Description cannot be blank") public @NotNull(message="Description cannot be null") @NotBlank(message="Description cannot be blank") String description()Returns the value of thedescription
record component.- Returns:
- the value of the
description
record component
-
createdOn
@Past(message="Created date must be in the past") public @Past(message="Created date must be in the past") ZonedDateTime createdOn()Returns the value of thecreatedOn
record component.- Returns:
- the value of the
createdOn
record component
-
completedOn
Returns the value of thecompletedOn
record component.- Returns:
- the value of the
completedOn
record component
-
due
@Future(message="Due date must be in the future") public @Future(message="Due date must be in the future") ZonedDateTime due()Returns the value of thedue
record component.- Returns:
- the value of the
due
record component
-
type
@NotNull(message="Type cannot be null") public @NotNull(message="Type cannot be null") String type()Returns the value of thetype
record component.- Returns:
- the value of the
type
record component
-