Get the size of a primitive type.

@param clz
@throws IllegalArgumentException If the class is not primitive type.
@return
177285
public static int sizeOf(Class<?> clz) throws IllegalArgumentException {
    switch (clz.getName()) {
    case "int":
      return Integer.BYTES;
    case "short":
      return Short.BYTES;
    case "long":
      return Long.BYTES;
    case "double":
      return Double.BYTES;
    case "float":
      return Float.BYTES;
    case "boolean":
      return 1;
    case "char":
      return Character.BYTES;
    case "byte":
      return 1;
    default:
      throw new IllegalArgumentException("Not a primitive type.");
    }
  }
545219
private static int sizeofPrimitiveType(final Class type) {
        if (type == int.class) {
            return INT_FIELD_SIZE;
        } else if (type == long.class) {
            return LONG_FIELD_SIZE;
        } else if (type == short.class) {
            return SHORT_FIELD_SIZE;
        } else if (type == byte.class) {
            return BYTE_FIELD_SIZE;
        } else if (type == boolean.class) {
            return BOOLEAN_FIELD_SIZE;
        } else if (type == char.class) {
            return CHAR_FIELD_SIZE;
        } else if (type == double.class) {
            return DOUBLE_FIELD_SIZE;
        } else if (type == float.class) {
            return FLOAT_FIELD_SIZE;
        } else {
            throw new IllegalArgumentException("not primitive: " + type);
        }
    }
561376
public <T extends DajlabModelInterface> T get(Class<T> clazz) {

		T ret = null;
		try {
			ret = (T) dajlab.get(clazz.getName());
		} catch (ClassCastException e) {
			e.printStackTrace();
		}
		return ret;
	}
481752
public long size()
                    throws ObjectManagerException
    {
        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.entry(this, cclass,
                        "size");

        //TODO Need to include toBeDeleted.
        long listLength = size; // For return;

        if (Tracing.isAnyTracingEnabled() && trace.isEntryEnabled())
            trace.exit(this, cclass,
                       "size",
                       "returns listLength=" + listLength + "(int)");
        return listLength;
    }
8977
public IntegerSize getIntegerSize()
    {
        load_once();
        if (_value_type != IonType.INT || _v.isNull())
        {
            return null;
        }
        return _Private_ScalarConversions.getIntegerSize(_v.getAuthoritativeType());
    }
81369
public static Type getDeclaredBeanType(Class<?> clazz) {
        Type[] actualTypeArguments = Reflections.getActualTypeArguments(clazz);
        if (actualTypeArguments.length == 1) {
            return actualTypeArguments[0];
        } else {
            return null;
        }
    }
1230275
public static int getSize(String descriptor) {
		int size = 0;
		int descriptorpos = 1; // start after the '('
		char ch;
		while ((ch = descriptor.charAt(descriptorpos)) != ')') {
			switch (ch) {
				case '[':
					size++;
					// jump to end of array, could be [[[[I
					while (descriptor.charAt(++descriptorpos) == '[') {
						;
					}
					if (descriptor.charAt(descriptorpos) == 'L') {
						descriptorpos = descriptor.indexOf(';', descriptorpos) + 1;
					}
					else {
						// Just a primitive array
						descriptorpos++;
					}
					break;
				case 'L':
					size++;
					// jump to end of 'L' signature
					descriptorpos = descriptor.indexOf(';', descriptorpos) + 1;
					break;
				case 'J':
					size = size + 2;
					descriptorpos++;
					break;
				case 'D':
					size = size + 2;
					descriptorpos++;
					break;
				case 'F':
				case 'B':
				case 'S':
				case 'I':
				case 'Z':
				case 'C':
					size++;
					descriptorpos++;
					break;
				default:
					throw new IllegalStateException("Unexpected character in descriptor: " + ch);
			}
		}
		return size;
	}
67700
@Override
  public int size() {
    int size = 0;
    for (E e = first; e != null; e = getNext(e)) {
      size++;
    }
    return size;
  }
335474
public static int size(Object list) {
        if (list == null)
            return 0;
        if (list instanceof List)
            return ((List<?>) list).size();
        return 1;
    }
30269
public static Type getGenericClassType(Object instance, Class<?> clazz, int position) {
    Class<?> type = instance.getClass();
    while (type != Object.class) {
      if (type.getGenericSuperclass() instanceof ParameterizedType) {
        ParameterizedType genericSuperclass = (ParameterizedType) type.getGenericSuperclass();
        if (genericSuperclass.getRawType() == clazz) {
          return genericSuperclass.getActualTypeArguments()[position];
        } else {
          type = type.getSuperclass();
        }
      } else {
        type = type.getSuperclass();
      }
    }
    return null;
  }
505504
@Override
    public <C extends Collection<?>> Expression<Integer> size(Expression<C> arg0)
    {
        // TODO Auto-generated method stub
        return null;
    }
571883
@Override
    public int size() {
        Node h = putStack.get();
        int putStackSize = h == null ? 0 : h.size;
        return putStackSize + takeStackSize.get();
    }
917698
public int getBatchSize()
    {
        if (isBatch())
        {
            String batchSize = getProperty(PersistenceProperties.KUNDERA_BATCH_SIZE);
            int batch_Size = Integer.valueOf(batchSize);
            if (batch_Size == 0)
            {
                throw new IllegalArgumentException("kundera.batch.size property must be numeric and > 0");
            }
            return batch_Size;
        }

        return 0;
    }
1329622
private static int deepInstanceSize(Class<?> clazz)
    {
        if (clazz.isArray()) {
            throw new IllegalArgumentException(format("Cannot determine size of %s because it contains an array", clazz.getSimpleName()));
        }
        if (clazz.isInterface()) {
            throw new IllegalArgumentException(format("%s is an interface", clazz.getSimpleName()));
        }
        if (Modifier.isAbstract(clazz.getModifiers())) {
            throw new IllegalArgumentException(format("%s is abstract", clazz.getSimpleName()));
        }
        if (!clazz.getSuperclass().equals(Object.class)) {
            throw new IllegalArgumentException(format("Cannot determine size of a subclass. %s extends from %s", clazz.getSimpleName(), clazz.getSuperclass().getSimpleName()));
        }

        int size = ClassLayout.parseClass(clazz).instanceSize();
        for (Field field : clazz.getDeclaredFields()) {
            if (!field.getType().isPrimitive()) {
                size += deepInstanceSize(field.getType());
            }
        }
        return size;
    }
190281
public static int getArraySize(final Object object, final Class<?> componentType) {

        ArgUtils.notNull(componentType, "componentType");

        if(object == null) {
            return 0;
        }

        if(!object.getClass().isArray()) {
            throw new IllegalArgumentException(String.format("args0 is not arrays : %s.", object.getClass().getName()));
        }

        if(!componentType.isPrimitive()) {
            return ((Object[])object).length;
        }

        if(componentType.equals(boolean.class)) {
            return ((boolean[]) object).length;

        } else if(componentType.equals(char.class)) {
            return ((char[]) object).length;

        } else if(componentType.equals(byte.class)) {
            return ((byte[]) object).length;

        } else if(componentType.equals(short.class)) {
            return ((short[]) object).length;

        } else if(componentType.equals(int.class)) {
            return ((int[]) object).length;

        } else if(componentType.equals(long.class)) {
            return ((long[]) object).length;

        } else if(componentType.equals(float.class)) {
            return ((byte[]) object).length;

        } else if(componentType.equals(double.class)) {
            return ((byte[]) object).length;

        }

        throw new IllegalArgumentException(String.format("not support primitive type : %s.", componentType.getName()));
    }
631675
public static int getSize (Object[] list)
    {
        int size = 0;
        for (int ii = 0, nn = (list == null) ? 0 : list.length; ii < nn; ii++) {
            if (list[ii] != null) {
                size++;
            }
        }
        return size;
    }
204172
public static boolean returnTypeIs(final Method m, final Class<?> clazz) {
	return clazz.equals(toClass(m.getGenericReturnType()));
    }