Last active
December 17, 2015 05:58
-
-
Save thaniaclair/5561289 to your computer and use it in GitHub Desktop.
Conversor de booleano.
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
| import org.eclipse.persistence.mappings.DatabaseMapping; | |
| import org.eclipse.persistence.mappings.converters.Converter; | |
| import org.eclipse.persistence.sessions.Session; | |
| public class BooleanConverter implements Converter { | |
| private static final long serialVersionUID = -8002966734017614459L; | |
| @Override | |
| public Object convertDataValueToObjectValue(Object arg0, Session arg1) { | |
| System.out.println("converting from data to object: " + arg0); | |
| String data = (String) arg0; | |
| return data.equals("S"); | |
| } | |
| @Override | |
| public Object convertObjectValueToDataValue(Object arg0, Session arg1) { | |
| System.out.println("converting from object to data: " + arg0); | |
| Boolean obj = (Boolean) arg0; | |
| return obj ? "S" : "N"; | |
| } | |
| @Override | |
| public void initialize(DatabaseMapping arg0, Session arg1) { | |
| } | |
| @Override | |
| public boolean isMutable() { | |
| return true; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment