1 package org.kuali.common.util.validate; 2 3 import java.util.Map; 4 5 import org.junit.Test; 6 import org.kuali.common.util.ReflectionUtils; 7 8 import com.google.common.base.Optional; 9 10 public class OptionalAssignableTest { 11 12 @Test 13 public void test() { 14 try { 15 Optional<String> absent = Optional.absent(); 16 Optional<String> present = Optional.of("foo"); 17 System.out.println(" absent = " + absent.getClass().getCanonicalName()); 18 System.out.println("present = " + present.getClass().getCanonicalName()); 19 System.out.println(" absent instanceof Optional is " + (absent instanceof Optional)); 20 System.out.println("present instanceof Optional is " + (present instanceof Optional)); 21 System.out.println(" absent.getClass() == Optional.class is " + (absent.getClass() == Optional.class)); 22 System.out.println("present.getClass() == Optional.class is " + (present.getClass() == Optional.class)); 23 System.out.println("Optional.class.isAssignableFrom(present.getClass()) is " + (Optional.class.isAssignableFrom(present.getClass()))); 24 System.out.println("Optional.class.isAssignableFrom(absent.getClass()) is " + (Optional.class.isAssignableFrom(absent.getClass()))); 25 26 System.out.println(); 27 System.out.println(ReflectionUtils.isImmutableGuavaMap(Map.class)); 28 System.out.println(); 29 30 } catch (Exception e) { 31 e.printStackTrace(); 32 } 33 34 } 35 36 }