Created
July 13, 2011 20:40
-
-
Save ganine/1081268 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
public List<ValidacaoException> validar() throws Exception { | |
List<ValidacaoException> problemas = new ArrayList<ValidacaoException>(); | |
for (Method method : this.getClass().getDeclaredMethods()) { | |
if (method.getName().startsWith("validar") && !method.getName().equals("validar")) { | |
try { | |
method.invoke(this); | |
} catch (InvocationTargetException e) { | |
problemas.add((ValidacaoException) e.getCause()); | |
} catch (Exception e) { | |
throw e; | |
} | |
} | |
} | |
return problemas; | |
} | |
public void validarFaixaDeValores() throws ValidacaoException { | |
if (valorInicial != null && valorFinal != null && valorInicial.compareTo(valorFinal) > 0) throw new ValidacaoException("valor.inicial.maior.que.final"); | |
} | |
public void validarPeriodo() throws ValidacaoException { | |
if (dataInicial != null && dataFinal != null && dataInicial.after(dataFinal)) throw new ValidacaoException("data.inicial.maior.que.final"); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment