Changeset 88 for java/main/src/main/java/com/framsticks/util/Misc.java
- Timestamp:
- 06/30/13 12:48:20 (11 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
java/main/src/main/java/com/framsticks/util/Misc.java
r84 r88 1 1 package com.framsticks.util; 2 3 // import org.apache.log4j.Logger; 2 4 3 5 /** … … 5 7 */ 6 8 public class Misc { 9 // private static final Logger log = 10 // Logger.getLogger(Misc.class); 11 12 public static class WithType { 13 protected Object value; 14 15 /** 16 * @param value 17 */ 18 public WithType(Object value) { 19 this.value = value; 20 } 21 22 @Override 23 public String toString() { 24 if (value == null) { 25 return "null"; 26 } 27 return value + "(" + value.getClass() + ")"; 28 } 29 } 30 31 public static WithType withType(Object value) { 32 return new WithType(value); 33 } 34 7 35 public static boolean equals(Object a, Object b) { 36 // log.info("equality of " + withType(a) + " ? " + withType(b)); 8 37 if (a != null) { 9 38 return (b != null && a.equals(b)); … … 11 40 return b == null; 12 41 } 42 43 public static <T> T returnNotNull(T first, T second) { 44 if (first != null) { 45 return first; 46 } 47 return second; 48 } 49 50 public static <T> T throwIfNull(T value) { 51 if (value == null) { 52 throw new FramsticksException().msg("value should not be null"); 53 } 54 return value; 55 } 13 56 }
Note: See TracChangeset
for help on using the changeset viewer.