/** * Write the specified Object to a {@link Parcel}. * * @param object The Object to be written to the Parcel. * @param parcel The destination Parcel. * @param <T> The type of the Object. * * @throws PostmanException if there is no {@link Parceler} associated with the given type. */ public static <T> void writeToParcel(T object, Parcel parcel) throws PostmanException { @SuppressWarnings("unchecked") Parceler<T> parceler = getParcelerForClass((Class<T>) object.getClass()); parceler.writeToParcel(object, parcel); }
/** * Write the specified Object to a {@link Parcel}. * * @param object The Object to be written to the Parcel. * @param parcel The destination Parcel. * @param <T> The type of the Object. * * @throws PostmanException if there is no {@link Parceler} associated with the given type. */ public static <T> void writeToParcel(T object, Parcel parcel) throws PostmanException { @SuppressWarnings("unchecked") Parceler<T> parceler = getParcelerForClass((Class<T>) object.getClass()); parceler.writeToParcel(object, parcel); }
/** * Reads an object of the specified class from the given Parcel. * * @param clazz The class of the object to be read. * @param parcel The source Parcel. * @param <T> The type of the Object. * * @return A new instance of the specified type instantiated from the Parcel. * * @throws PostmanException if there is no {@link Parceler} associated with the given type. */ public static <T> T readFromParcel(Class<T> clazz, Parcel parcel) throws PostmanException { Parceler<T> parceler = getParcelerForClass(clazz); return parceler.readFromParcel(parcel); }
/** * Reads an object of the specified class from the given Parcel. * * @param clazz The class of the object to be read. * @param parcel The source Parcel. * @param <T> The type of the Object. * * @return A new instance of the specified type instantiated from the Parcel. * * @throws PostmanException if there is no {@link Parceler} associated with the given type. */ public static <T> T readFromParcel(Class<T> clazz, Parcel parcel) throws PostmanException { Parceler<T> parceler = getParcelerForClass(clazz); return parceler.readFromParcel(parcel); }
/** * Creates of new array of the specified type with the specified size. * * @param clazz The class associated with the type of array to create. * @param size The desired size of the array. * @param <T> The type of the array to create. * * @return A new array of the specified type with the specified size. * * @throws PostmanException if there is no {@link Parceler} associated with the given type. * @see Creator#newArray(int) */ public static <T> T[] newArray(Class<T> clazz, int size) throws PostmanException { Parceler<T> parceler = getParcelerForClass(clazz); return parceler.newArray(size); }
/** * Creates of new array of the specified type with the specified size. * * @param clazz The class associated with the type of array to create. * @param size The desired size of the array. * @param <T> The type of the array to create. * * @return A new array of the specified type with the specified size. * * @throws PostmanException if there is no {@link Parceler} associated with the given type. * @see Creator#newArray(int) */ public static <T> T[] newArray(Class<T> clazz, int size) throws PostmanException { Parceler<T> parceler = getParcelerForClass(clazz); return parceler.newArray(size); }