Created
February 13, 2019 15:45
-
-
Save mateo-leal/4a9ff28b2ed0bc48a828abe4c9684ea5 to your computer and use it in GitHub Desktop.
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
| /** | |
| * Creado el 1/12/2018 a las 11:40:51 a. m. <br> | |
| */ | |
| public class DoubleCast implements NumberCast { | |
| /* | |
| * (non-Javadoc) | |
| * @see co.com.quipux.audiencias.util.numbercast.NumberCast#cast(java.lang.Object) | |
| */ | |
| @Override | |
| public Number cast(Object o) { | |
| if (o instanceof String) { | |
| return Double.parseDouble((String) o); | |
| } | |
| return ((Number) o).doubleValue(); | |
| } | |
| } |
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
| /** | |
| * Creado el 1/12/2018 a las 11:41:37 a. m. <br> | |
| */ | |
| public class FloatCast implements NumberCast { | |
| /* | |
| * (non-Javadoc) | |
| * @see co.com.quipux.audiencias.util.numbercast.NumberCast#cast(java.lang.Object) | |
| */ | |
| @Override | |
| public Number cast(Object o) { | |
| if (o instanceof String) { | |
| return Float.parseFloat((String) o); | |
| } | |
| return ((Number) o).floatValue(); | |
| } | |
| } |
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
| /** | |
| * Creado el 1/12/2018 a las 11:39:54 a. m. <br> | |
| */ | |
| public class IntegerCast implements NumberCast { | |
| /* | |
| * (non-Javadoc) | |
| * @see co.com.quipux.audiencias.util.numbercast.NumberCast#cast(java.lang.Object) | |
| */ | |
| @Override | |
| public Number cast(Object o) { | |
| if (o instanceof String) { | |
| return Integer.parseInt((String) o); | |
| } | |
| return ((Number) o).intValue(); | |
| } | |
| } |
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
| /** | |
| * Creado el 1/12/2018 a las 11:37:03 a. m. <br> | |
| */ | |
| public class LongCast implements NumberCast { | |
| /* | |
| * (non-Javadoc) | |
| * @see co.com.quipux.audiencias.util.numbercast.NumberCast#cast(java.lang.Object) | |
| */ | |
| @Override | |
| public Number cast(Object o) { | |
| if (o instanceof String) { | |
| Long.parseLong((String) o); | |
| } | |
| return ((Number) o).longValue(); | |
| } | |
| } |
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
| /** | |
| * Creado el 1/12/2018 a las 11:34:08 a. m. <br> | |
| */ | |
| public interface NumberCast { | |
| /** | |
| * Transforma un número que implemente {@code java.lang.Number} en la | |
| * referencia de la implementación de {@code NumberCast}<br> | |
| * Creado el 1/12/2018 a las 11:32:00 a. m. <br> | |
| * @author <a href="mailto:mateo.leal@quipux.com">Mateo Leal</a> | |
| * @param o objecto a ser casteado | |
| * @return número | |
| */ | |
| Number cast(Object o); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment