Returns the cell value casted to the specified class.

@param clazz the expected class
@param <T>   the return type
@return the cell value casted to the specified class
488330
public <T> T getValue(Class<T> clazz) {
        if (this.cellValue == null) {
            return null;
        } else {
            if(Number.class.isAssignableFrom(cellValue.getClass())){
                return null;
            }else{
                return (T) this.cellValue;
            }

        }
    }
47784
public <T> T getInstanceFromParsedArgs(Class<T> clazz) {
        if (!registeredClasses.contains(clazz)) {
            throw new IllegalArgumentException("Class not registered: " + clazz);
        }
        try {
            T obj = clazz.newInstance();
            for (Field field : clazz.getFields()) {
                if (field.isAnnotationPresent(Opt.class)) {
                    String value = fieldValueMap.get(field);
                    if (value != null) {
                        setField(obj, field, value);
                    }
                }
            }
            return obj;
        } catch (IllegalAccessException e) {
            throw new RuntimeException(e);
        } catch (InstantiationException e) {
            throw new RuntimeException(e);
        }
    }
574018
public static <T> Class<T> getClass(final T object) {

    if (object == null) {
      return null;
    }
    @SuppressWarnings("unchecked")
    Class<T> clazz = (Class<T>) object.getClass();
    return clazz;
  }
285807
public <T extends Extension> T getExtension(Class<T> clazz) {
        if (clazz != null) {
            Extension extension = extensionsMap.get(clazz);
            if (extension != null) {
                return clazz.cast(extension);
            }
        }
        return null;
    }
248935
public static Class toArrayClass(Class clazz) {
	return java.lang.reflect.Array.newInstance(clazz, 0).getClass();
    }
392850
public static <T> T getBean(Class<T> clazz) throws ReflectionException {
      return parameterizeObject(Reflect.onClass(clazz).create().<T>get());
   }
680994
@SuppressWarnings("unchecked")
    private static <T> T cast(Object obj, Class<T> clazz) {
        if (obj == null) {
            return null;
        }
        if (clazz == null) {
            throw new IllegalArgumentException("parameter 'Class<T> clazz' is not allowed to be null.");
        }
        if (clazz.isEnum() && obj instanceof String) {
            Class<Enum> enumClazz = (Class<Enum>) clazz;
            return (T) Enum.valueOf(enumClazz, obj.toString());
        }
        if (clazz.isPrimitive()) {
            if (clazz == Integer.TYPE) {
                clazz = (Class<T>) Integer.class;
            } else if (clazz == Long.TYPE) {
                clazz = (Class<T>) Long.class;
            } else if (clazz == Short.TYPE) {
                clazz = (Class<T>) Short.class;
            } else if (clazz == Double.TYPE) {
                clazz = (Class<T>) Double.class;
            } else if (clazz == Float.TYPE) {
                clazz = (Class<T>) Float.class;
            } else if (clazz == Character.TYPE) {
                clazz = (Class<T>) Character.class;
            } else if (clazz == Byte.TYPE) {
                clazz = (Class<T>) Byte.class;
            } else if (clazz == Boolean.TYPE) {
                clazz = (Class<T>) Boolean.class;
            }
        }
        return clazz.cast(obj);
    }
1206106
public static CassandraType getCassandraDataTypeClass(Class clazz)
    {
        if(clazz.isEnum()){
            return CassandraType.STRING;
        }
        return typeToClazz.get(clazz);
    }
469512
public static byte[] getBytes(Object value, Class<?> clazz)
    {
        if (clazz.isAssignableFrom(String.class))
        {
            return Bytes.toBytes(value.toString());
        }
        else if (clazz.equals(int.class) || clazz.isAssignableFrom(Integer.class))
        {
            return Bytes.toBytes(value instanceof Integer ? (Integer) value : new Integer(value.toString()));
        }
        else if (clazz.equals(long.class) || clazz.isAssignableFrom(Long.class))
        {
            return Bytes.toBytes(value instanceof Long ? (Long) value : new Long(value.toString()));
        }
        else if (clazz.equals(boolean.class) || clazz.isAssignableFrom(Boolean.class))
        {
            return Bytes.toBytes(value instanceof Boolean ? (Boolean) value : new Boolean(value.toString()));
        }
        else if (clazz.equals(double.class) || clazz.isAssignableFrom(Double.class))
        {
            return Bytes.toBytes(value instanceof Double ? (Double) value : new Double(value.toString()));
        }
        else if (clazz.equals(float.class) || clazz.isAssignableFrom(Float.class))
        {
            return Bytes.toBytes(value instanceof Float ? (Float) value : new Float(value.toString()));
        }
        else if (clazz.equals(short.class) || clazz.isAssignableFrom(Short.class))
        {
            return Bytes.toBytes(value instanceof Short ? (Short) value : new Short(value.toString()));
        }
        else if (clazz.equals(BigDecimal.class))
        {
            return Bytes.toBytes(value instanceof BigDecimal ? (BigDecimal) value : new BigDecimal(value.toString()));
        }
        else
        {
            if (value.getClass().isAssignableFrom(String.class))
            {
                value = PropertyAccessorFactory.getPropertyAccessor(clazz).fromString(clazz, value.toString());
            }
            return PropertyAccessorFactory.getPropertyAccessor(clazz).toBytes(value);
        }
    }
43977
protected Constructor<?> getConstructor(Class<?> clazz, Class<?> paramClass) {
        for (Constructor<?> c : clazz.getConstructors()) {
            Class<?>[] paramTypes = c.getParameterTypes();
            if (paramTypes.length != 1) {
                continue;
            }
            if (paramTypes[0].equals(paramClass)) {
                return c;
            }
        }
        return null;
    }
94039
public static Object getDefaultValue(Class<?> clazz) {
		if (clazz.isPrimitive()) {
			if (long.class == clazz) {
				return 0L;
			} else if (int.class == clazz) {
				return 0;
			} else if (short.class == clazz) {
				return (short) 0;
			} else if (char.class == clazz) {
				return (char) 0;
			} else if (byte.class == clazz) {
				return (byte) 0;
			} else if (double.class == clazz) {
				return 0D;
			} else if (float.class == clazz) {
				return 0f;
			} else if (boolean.class == clazz) {
				return false;
			}
		}

		return null;
	}
247018
public static Class<? extends Object> resolveCellType(Cell c) {
        switch (c.getCellType()) {
            case CELL_TYPE_BLANK: { return Object.class; }
            case CELL_TYPE_BOOLEAN: { return Boolean.class; }
            case CELL_TYPE_NUMERIC: { return Double.class; }
            case CELL_TYPE_FORMULA: case CELL_TYPE_STRING: case CELL_TYPE_ERROR: { return String.class; }
            default: { throw new CalculationEngineException(String.format("Cell's type %s is not supported.", c.getCellType())); }
        }
    }
673482
public static <T> ObjectName getObjectName(final Class<T> clazz)
        {
        final String domain = clazz.getPackage().getName();
        final String className = clazz.getSimpleName();
        final String objectName = domain+":type="+className;
        LOG.debug("Returning object name: {}", objectName);
        try
            {
            return new ObjectName(objectName);
            }
        catch (final MalformedObjectNameException e)
            {
            // This should never, ever happen.
            LOG.error("Invalid ObjectName: "+objectName, e);
            throw new RuntimeException("Could not create ObjectName?", e);
            }
        }
154272
public static String getTypeValue(Class<? extends WindupFrame> clazz)
    {
        TypeValue typeValueAnnotation = clazz.getAnnotation(TypeValue.class);
        if (typeValueAnnotation == null)
            throw new IllegalArgumentException("Class " + clazz.getCanonicalName() + " lacks a @TypeValue annotation");

        return typeValueAnnotation.value();
    }
502730
private AbstractManagedType getType(Class clazz, boolean isIdClass)
    {
        if (clazz != null && !clazz.equals(Object.class))
        {
            return processInternal(clazz, isIdClass);
        }
        return null;
    }
17413
public <T extends ICalProperty> T getProperty(Class<T> clazz) {
		return clazz.cast(properties.first(clazz));
	}
320087
protected Object getValue(String name, Class<?> clz, Object v, ClassLoader cl) throws Exception
   {
      if (v instanceof String)
      {
         String substituredValue = getSubstitutionValue((String)v);

         if (clz.equals(String.class))
         {
            v = substituredValue;
         }
         else if (clz.equals(byte.class) || clz.equals(Byte.class))
         {
            if (substituredValue != null && !substituredValue.trim().equals(""))
               v = Byte.valueOf(substituredValue);
         }
         else if (clz.equals(short.class) || clz.equals(Short.class))
         {
            if (substituredValue != null && !substituredValue.trim().equals(""))
               v = Short.valueOf(substituredValue);
         }
         else if (clz.equals(int.class) || clz.equals(Integer.class))
         {
            if (substituredValue != null && !substituredValue.trim().equals(""))
               v = Integer.valueOf(substituredValue);
         }
         else if (clz.equals(long.class) || clz.equals(Long.class))
         {
            if (substituredValue != null && !substituredValue.trim().equals(""))
               v = Long.valueOf(substituredValue);
         }
         else if (clz.equals(float.class) || clz.equals(Float.class))
         {
            if (substituredValue != null && !substituredValue.trim().equals(""))
               v = Float.valueOf(substituredValue);
         }
         else if (clz.equals(double.class) || clz.equals(Double.class))
         {
            if (substituredValue != null && !substituredValue.trim().equals(""))
               v = Double.valueOf(substituredValue);
         }
         else if (clz.equals(boolean.class) || clz.equals(Boolean.class))
         {
            if (substituredValue != null && !substituredValue.trim().equals(""))
               v = Boolean.valueOf(substituredValue);
         }
         else if (clz.equals(char.class) || clz.equals(Character.class))
         {
            if (substituredValue != null && !substituredValue.trim().equals(""))
               v = Character.valueOf(substituredValue.charAt(0));
         }
         else if (clz.equals(InetAddress.class))
         {
            v = InetAddress.getByName(substituredValue);
         }
         else if (clz.equals(Class.class))
         {
            v = Class.forName(substituredValue, true, cl);
         }
         else if (clz.equals(Properties.class))
         {
            Properties prop = new Properties();

            StringTokenizer st = new StringTokenizer(substituredValue, " ,");
            while (st.hasMoreTokens())
            {
               String token = st.nextToken();
               String key = "";
               String value = "";

               int index = token.indexOf("=");
               if (index != -1)
               {
                  key = token.substring(0, index);

                  if (token.length() > index + 1)
                     value = token.substring(index + 1);
               }
               else
               {
                  key = token;
               }

               if (!"".equals(key))
                  prop.setProperty(key, value);
            }

            v = prop;
         }
         else
         {
            try
            {
               Constructor<?> constructor = SecurityActions.getConstructor(clz, String.class);
               v = constructor.newInstance(substituredValue);
            }
            catch (Throwable t)
            {
               // Try static String valueOf method
               try
               {
                  Method valueOf = SecurityActions.getMethod(clz, "valueOf", String.class);
                  v = valueOf.invoke((Object)null, substituredValue);
               }
               catch (Throwable inner)
               {
                  throw new IllegalArgumentException("Unknown property resolution for property " + name);
               }
            }
         }
      }

      return v;
   }