1 package org.hibernate.util; 3 4 import java.util.Map ; 5 import java.util.Set ; 6 7 import org.hibernate.AssertionFailure; 8 9 public final class LinkedHashCollectionHelper { 10 11 private static final Class SET_CLASS; 12 private static final Class MAP_CLASS; 13 static { 14 Class setClass; 15 Class mapClass; 16 try { 17 setClass = Class.forName("java.util.LinkedHashSet"); 18 mapClass = Class.forName("java.util.LinkedHashMap"); 19 } 20 catch (ClassNotFoundException cnfe) { 21 setClass = null; 22 mapClass = null; 23 } 24 SET_CLASS = setClass; 25 MAP_CLASS = mapClass; 26 } 27 28 public static Set createLinkedHashSet() { 29 try { 30 return (Set ) SET_CLASS.newInstance(); 31 } 32 catch (Exception e) { 33 throw new AssertionFailure("Could not instantiate LinkedHashSet", e); 34 } 35 } 36 37 public static Map createLinkedHashMap() { 38 try { 39 return (Map ) MAP_CLASS.newInstance(); 40 } 41 catch (Exception e) { 42 throw new AssertionFailure("Could not instantiate LinkedHashMap", e); 43 } 44 } 45 46 private LinkedHashCollectionHelper() {} 47 48 } 49 50 51 52 53 54 55 | Popular Tags |