This file contains hidden or 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
public CustomValidtor implements Validator { | |
public void validate(Object currentForm, Errors validationErrors) { | |
//O spring já espera que você mexa na referência de Errors passada com argumento e isso muda tudo. | |
if(...) { | |
validationErrors.rejectValue("fieldName","customKey", "defaultMessage"); | |
} | |
} | |
} | |
///// simulando o spring validator |
This file contains hidden or 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
public class CaracteristicaRequest implements CriadorCaracteristica{ | |
new Produto(...., caracteristicasRequest) | |
} | |
public Produto(@NotNull Usuario usuario, | |
@NotNull Categoria categoria, | |
@NotEmpty String nome, | |
@Min(value = 1) BigDecimal valor, | |
@Min(value = 0) int quantidade, | |
@NotEmpty @Length(max = 1000) String descricao, |
This file contains hidden or 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
public SomeClass(StateParameter parameter) { | |
/* se você criou essa classe e espera que o construtor seja chamado de outra determinada classe, pq não deixar isso claro | |
* e ajudar a próxima pessoa? | |
*/ | |
//inclusive a linguagem podia abraçar e garantir o acoplamento em compilação | |
ForceSiteCall.from(Other.class); | |
//como você sabe o ponto de chamada, fica mais aberto você mexer no estado alheio. A ideia é ficar mais claro que essa classe só foi criada para ser usada naquele outro lugar. | |
parameter.chanceState(); |
OlderNewer