Created
          March 12, 2012 10:09 
        
      - 
      
 - 
        
Save osmanizbat/2021027 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
    
  
  
    
  | if(foo == null || bar == null || baz == null || qux == null){ | |
| ... | |
| } | |
| vs. | |
| if(ObjectUtils.anyNull(foo, bar, baz, qux)){ | |
| ... | |
| } | 
  
    
      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
    
  
  
    
  | if(obj.equals(foo) || obj.equals(bar) || obj.equals(baz) || obj.equals(qux)){ | |
| ... | |
| } | |
| vs. | |
| if(ObjectUtils.equalsAny(obj, foo, bar, baz, qux)){ | |
| ... | |
| } | 
  
    
      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
    
  
  
    
  | public class ObjectUtils { | |
| public static boolean equalsAny(Object obj, Object... others) { | |
| for (Object other: others) { | |
| if (obj.equals(other)) | |
| return true; | |
| } | |
| return false; | |
| } | |
| public static boolean anyNull(Object... objects) { | |
| for (Object o: objects) { | |
| if (o == null) | |
| return true; | |
| } | |
| return false; | |
| } | |
| } | 
  
    Sign up for free
    to join this conversation on GitHub.
    Already have an account?
    Sign in to comment