Java Object Type Case castObject(Object ob)

Here you can find the source of castObject(Object ob)

Description

Reads an object from an input and converts it to the appropriate type.

License

Open Source License

Parameter

Parameter Description
T The type of object to return.
ob The object to cast.

Return

The casted object.

Declaration

@SuppressWarnings("unchecked")
public static <T> T castObject(Object ob) 

Method Source Code

//package com.java2s;

public class Main {
    /**//from www . j  a  v a 2s  .  c  o m
     * Reads an object from an input and converts it to the appropriate type.
     *
     * @param <T> The type of object to return.
     * @param ob  The object to cast.
     *
     * @return The casted object.
     */
    @SuppressWarnings("unchecked")
    public static <T> T castObject(Object ob) {
        return (T) ob;
    }
}

Related

  1. castNonNullArray( T [] arr)
  2. castNullableParameterTo(String parameterName, T value, Class requiredType)
  3. castNumber(Number num, Class clazz)
  4. castObject(Class clazz, Object object)
  5. castObject(Object fromObj, Class toClass)
  6. castOrDefault(Class type, Object value, T defaultValue, boolean allowNull)
  7. castOrDefault(Object o, Class type, T def)
  8. castOrNull(Object o, Class clazz)
  9. castOrNull(Object o, Class cls)