sdk/src/com/socialize/google/gson/internal/ConstructorConstructor.java
@SuppressWarnings("unchecked") // use runtime checks to guarantee that 'T' is what it is
  private <T> ObjectConstructor<T> newDefaultImplementationConstructor(Class<? super T> rawType) {
    if (Collection.class.isAssignableFrom(rawType)) {
      if (SortedSet.class.isAssignableFrom(rawType)) {
        return new ObjectConstructor<T>() {
          public T construct() {
            return (T) new TreeSet<Object>();
          }
        };
      } else if (Set.class.isAssignableFrom(rawType)) {
        return new ObjectConstructor<T>() {
          public T construct() {
            return (T) new LinkedHashSet<Object>();
          }
        };
      } else if (Queue.class.isAssignableFrom(rawType)) {
        return new ObjectConstructor<T>() {
          public T construct() {
            return (T) new LinkedList<Object>();
          }
        };
      } else {
        return new ObjectConstructor<T>() {
          public T construct() {
            return (T) new ArrayList<Object>();
          }
        };
      }
    }

    if (Map.class.isAssignableFrom(rawType)) {
      return new ObjectConstructor<T>() {
        public T construct() {
          return (T) new LinkedHashMap<Object, Object>();
        }
      };
      // TODO: SortedMap ?
    }

    return null;
  }
@SuppressWarnings("unchecked") // use runtime checks to guarantee that 'T' is what it is
  private <T> ObjectConstructor<T> newDefaultImplementationConstructor(Class<? super T> rawType) {
    if (Collection.class.isAssignableFrom(rawType)) {
      if (SortedSet.class.isAssignableFrom(rawType)) {
        return new ObjectConstructor<T>() {
          public T construct() {
            return (T) new TreeSet<Object>();
          }
        };
      } else if (Set.class.isAssignableFrom(rawType)) {
        return new ObjectConstructor<T>() {
          public T construct() {
            return (T) new LinkedHashSet<Object>();
          }
        };
      } else if (Queue.class.isAssignableFrom(rawType)) {
        return new ObjectConstructor<T>() {
          public T construct() {
            return (T) new LinkedList<Object>();
          }
        };
      } else {
        return new ObjectConstructor<T>() {
          public T construct() {
            return (T) new ArrayList<Object>();
          }
        };
      }
    }

    if (Map.class.isAssignableFrom(rawType)) {
      return new ObjectConstructor<T>() {
        public T construct() {
          return (T) new LinkedHashMap<Object, Object>();
        }
      };
      // TODO: SortedMap ?
    }

    return null;
  }
@ SuppressWarnings ( "unchecked" ) // use runtime checks to guarantee that 'T' is what it is private < T > ObjectConstructor < T > newDefaultImplementationConstructor ( Class < ? super T > rawType ) { if ( Collection . class . isAssignableFrom ( rawType ) ) { if ( SortedSet . class . isAssignableFrom ( rawType ) ) { return new ObjectConstructor < T > ( ) { public T construct ( ) { return ( T ) new TreeSet < Object > ( ) ; } } ; } else if ( Set . class . isAssignableFrom ( rawType ) ) { return new ObjectConstructor < T > ( ) { public T construct ( ) { return ( T ) new LinkedHashSet < Object > ( ) ; } } ; } else if ( Queue . class . isAssignableFrom ( rawType ) ) { return new ObjectConstructor < T > ( ) { public T construct ( ) { return ( T ) new LinkedList < Object > ( ) ; } } ; } else { return new ObjectConstructor < T > ( ) { public T construct ( ) { return ( T ) new ArrayList < Object > ( ) ; } } ; } } if ( Map . class . isAssignableFrom ( rawType ) ) { return new ObjectConstructor < T > ( ) { public T construct ( ) { return ( T ) new LinkedHashMap < Object , Object > ( ) ; } } ; // TODO: SortedMap ? } return null ; }
Constructors for common interface types like Map and List and their
subytpes.
Constructors for common interface types like Map and List and their subytpes .