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 aChallengeDTOrecord class. -
Method Summary
Modifier and TypeMethodDescriptionReturns the value of thecompletedOnrecord component.@NotNull(message="Completion amount cannot be null") @PositiveOrZero(message="Completion amount cannot be negative") BigDecimalReturns the value of thecompletionrecord component.@Past(message="Created date must be in the past") ZonedDateTimeReturns the value of thecreatedOnrecord component.@NotNull(message="Description cannot be null") @NotBlank(message="Description cannot be blank") StringReturns the value of thedescriptionrecord component.@Future(message="Due date must be in the future") ZonedDateTimedue()Returns the value of theduerecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.@NotNull(message="ID cannot be null") Longid()Returns the value of theidrecord component.@NotNull(message="Per purchase amount cannot be null") @Positive(message="Per purchase amount cannot be less than or equal to zero") BigDecimalReturns the value of theperPurchaserecord component.@NotNull(message="Saved amount cannot be null") @PositiveOrZero(message="Saved amount cannot be negative") BigDecimalsaved()Returns the value of thesavedrecord component.@NotNull(message="Target amount cannot be null") @PositiveOrZero(message="Target amount cannot be negative") BigDecimaltarget()Returns the value of thetargetrecord component.@NotNull(message="Title cannot be null") @NotBlank(message="Title cannot be blank") Stringtitle()Returns the value of thetitlerecord component.final StringtoString()Returns a string representation of this record class.@NotNull(message="Type cannot be null") Stringtype()Returns the value of thetyperecord 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 aChallengeDTOrecord class.- Parameters:
id- the value for theidrecord componenttitle- the value for thetitlerecord componentsaved- the value for thesavedrecord componenttarget- the value for thetargetrecord componentperPurchase- the value for theperPurchaserecord componentcompletion- the value for thecompletionrecord componentdescription- the value for thedescriptionrecord componentcreatedOn- the value for thecreatedOnrecord componentcompletedOn- the value for thecompletedOnrecord componentdue- the value for theduerecord componenttype- the value for thetyperecord 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 theidrecord component.- Returns:
- the value of the
idrecord 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 thetitlerecord component.- Returns:
- the value of the
titlerecord 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 thesavedrecord component.- Returns:
- the value of the
savedrecord 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 thetargetrecord component.- Returns:
- the value of the
targetrecord 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 theperPurchaserecord component.- Returns:
- the value of the
perPurchaserecord 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 thecompletionrecord component.- Returns:
- the value of the
completionrecord 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 thedescriptionrecord component.- Returns:
- the value of the
descriptionrecord 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 thecreatedOnrecord component.- Returns:
- the value of the
createdOnrecord component
-
completedOn
Returns the value of thecompletedOnrecord component.- Returns:
- the value of the
completedOnrecord 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 theduerecord component.- Returns:
- the value of the
duerecord component
-
type
@NotNull(message="Type cannot be null") public @NotNull(message="Type cannot be null") String type()Returns the value of thetyperecord component.- Returns:
- the value of the
typerecord component
-