Created
January 7, 2020 20:36
-
-
Save ColadaFF/055e3214dc76538e2fa2aaf17cdf448a to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import com.google.common.base.Preconditions; | |
import lombok.EqualsAndHashCode; | |
import lombok.ToString; | |
import java.math.BigDecimal; | |
@ToString | |
@EqualsAndHashCode | |
public class Price { | |
// factory | |
public static Price of(BigDecimal value){ | |
return new Price(value); | |
} | |
private final BigDecimal value; | |
private Price(BigDecimal value) { | |
Preconditions.checkNotNull(value, "El valor no puede ser nulo"); | |
Preconditions.checkArgument(value.compareTo(BigDecimal.ZERO) != -1, "El valor no puede ser negativo"); | |
this.value = value; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment