Details | Last modification | View Log | RSS feed
| Rev | Author | Line No. | Line |
|---|---|---|---|
| 795 | blopes | 1 | package br.com.kronus.core; |
| 2 | |||
| 3 | import java.util.List; |
||
| 4 | |||
| 5 | import org.apache.commons.lang3.StringUtils; |
||
| 6 | |||
| 7 | public class VerificadorUtil { |
||
| 8 | |||
| 9 | public static Object selecionarValorCondicional(Boolean condicao, Object valorSeVerdade, Object valorSeFalso) { |
||
| 10 | if (condicao) { |
||
| 11 | return valorSeVerdade; |
||
| 12 | } else { |
||
| 13 | return valorSeFalso; |
||
| 14 | } |
||
| 15 | } |
||
| 16 | |||
| 17 | public static boolean estaNulo(Object objeto) { |
||
| 18 | return objeto == null; |
||
| 19 | } |
||
| 20 | |||
| 21 | public static boolean naoEstaNulo(Object objeto) { |
||
| 22 | return objeto != null; |
||
| 23 | } |
||
| 24 | |||
| 25 | public static boolean estaVazio(Object valor) { |
||
| 26 | return StringUtils.isEmpty(valor.toString()); |
||
| 27 | } |
||
| 28 | |||
| 29 | public static boolean naoEstaNuloOuVazio(Object objeto) { |
||
| 30 | Boolean isNaoEstaNuloOuVazio = objeto != null && !StringUtils.isEmpty(objeto.toString()); |
||
| 31 | if (objeto instanceof List<?>) { |
||
| 32 | return isNaoEstaNuloOuVazio && !((List<?>) objeto).isEmpty(); |
||
| 33 | } |
||
| 34 | return isNaoEstaNuloOuVazio; |
||
| 35 | } |
||
| 36 | |||
| 37 | public static boolean estaNuloOuVazio(Object valor) { |
||
| 38 | return estaNulo(valor) || estaVazio(valor); |
||
| 39 | } |
||
| 40 | |||
| 41 | public static void verificarNulo(Object objeto, String mensagemErro) { |
||
| 42 | if (objeto == null) { |
||
| 43 | throw new RuntimeException(mensagemErro); |
||
| 44 | } |
||
| 45 | } |
||
| 46 | |||
| 47 | public static boolean isListaNulaOuVazia(List<? extends Object> lista) { |
||
| 48 | return estaNulo(lista) || isListaVazia(lista); |
||
| 49 | } |
||
| 50 | |||
| 51 | public static boolean isListaVazia(List<? extends Object> lista) { |
||
| 52 | return lista.isEmpty(); |
||
| 53 | } |
||
| 54 | |||
| 55 | public static boolean isListaComElementos(List<? extends Object> lista) { |
||
| 56 | return !isListaVazia(lista); |
||
| 57 | } |
||
| 58 | |||
| 59 | } |