Java Utililty Methods Object Create

List of utility methods to do Object Create

Description

The list of methods to do Object Create are organized into topic(s).

Method

Tas(Class clazz, I instance)
as
return clazz.cast(instance);
Tas(Class cls, Object o)
Returns the specified object as the specified class or returns null if the cast is not supported.
if (cls.isInstance(o)) {
    return cls.cast(o);
return null;
Tas(Class t, Object o)
as
return t.isInstance(o) ? t.cast(o) : null;
Tas(Class targetClass, Object entity)
Casts entity to targetClass or return null, if it is impossible
T result = null;
if ((entity != null) && targetClass.isAssignableFrom(entity.getClass())) {
    result = (T) entity;
return result;
Tas(Class type, Object value)
as
if (type.isInstance(value)) {
    return type.cast(value);
return null;
Tas(Class type, U o)
if o is of the given type, returns o cast to it; otherwise returns null.
if (type.isInstance(o)) {
    return (T) o;
return null;
Tas(Object cst)
as
return (T) cst;
Tas(Object instance, Class clazz)
as
if (clazz.isAssignableFrom(instance.getClass())) {
    return clazz.cast(instance);
return null;
Tas(Object o)
as
return (T) o;
Tas(Object o, Class clazz)
Attempts to cast to the specified type, returns null if not castable.
if (o == null)
    return null;
if (!clazz.isAssignableFrom(o.getClass()))
    return null;
return (T) o;