Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- boolean updateRequired = (currentValue == null && newValue != null);
- boolean deleteRequired = (currentValue != null && newValue == null);
- if(updateRequired || deleteRequired) {
- // ...
- }
- private static final boolean needToDoSomething(String currentValue, String newValue) {
- return currentValue == null && newValue != null || currentValue != null && newValue == null;
- }
- if (needToDoSomething(currentValue, newValue)) {
- ....
- }
- public enum EditState {
- ADDED, DELETED, MODIFIED, UNCHANGED;
- public static getState(String currentValue, String newValue) {
- if (currentValue == newValue) {
- // this covers null == null too
- return UNCHANGED;
- }
- if (currentValue != null && newValue == null) {
- return DELETED;
- }
- if (newValue != null && currentValue == null) {
- return ADDED;
- }
- return currentValue.equals(newValue) ? UNCHANGED : MODIFIED;
- }
- public boolean isStateChanging() {
- return this != UNCHANGED;
- }
- }
- EditState state = EditState.getState(currentValue, newValue);
- switch (state) {
- case UNCHANGED :
- .....
- case DELETED :
- .....
- ....
- }
- boolean updateRequired = (currentValue == null && newValue != null);
- if( insertRequired ){
- //doSomething
- }
- else if( deleteRequired ){
- //doSomething else
- }
- if ((currentValue == null) != (newValue == null)) {
- // ...
- }
- boolean isNewValueAssigned = newvalue != null;
- boolean isCurrentValueAssigned = currentValue != null;
- if (isNewValueAssigned ^ isCurrentValueAssigned) {
- //Play more Galaga
- //do More Work
- }
- boolean updateRequired = (newValue != null)
- boolean deleteRequired = (currentValue != null)
- if (updateRequired || deleteRequired) {
- //play Galaga
- //do some stuff
- }
- boolean needToDoSomething = currentValue == null ? newValue != null : newValue == null;
- if(needToDoSomething) {
- // ...
- }
- boolean updateRequired = (currentValue == null && newValue != null);
- boolean deleteRequired = (currentValue != null && newValue == null);
- if (updateRequired) {
- object.Update();
- } else if (deleteRequired) {
- object.Delete();
- }
- if (updateRequired) {
- object.Update();
- }
- if (deleteRequired) {
- object.Delete();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement