Skip to content

io microsphere util SizeUtils

github-actions[bot] edited this page Jul 29, 2026 · 1 revision

SizeUtils

Type: Class | Module: microsphere-java-core | Package: io.microsphere.util | Since: 1.0.0

Source: microsphere-java-core/src/main/java/io/microsphere/util/SizeUtils.java

Overview

The utilities class for Size

Declaration

public abstract class SizeUtils implements Utils

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.3.16-SNAPSHOT

Version Compatibility

This component is tested and compatible with the following Java versions:

Java Version Status
Java 8 ✅ Compatible
Java 11 ✅ Compatible
Java 17 ✅ Compatible
Java 21 ✅ Compatible
Java 25 ✅ Compatible

Usage

Maven Dependency

Add the following dependency to your pom.xml:

<dependency>
    <groupId>io.github.microsphere-projects</groupId>
    <artifactId>microsphere-java-core</artifactId>
    <version>${microsphere-java.version}</version>
</dependency>

Tip: Use the BOM (microsphere-java-dependencies) for consistent version management. See the Getting Started guide.

Import

import io.microsphere.util.SizeUtils;

API Reference

Public Methods

Method Description
bytesSize The size in bytes of an unbounded type.

Method Details

bytesSize

public static int bytesSize(Class<?> type)

The size in bytes of an unbounded type. / public static final int UNBOUND_BYTES_SIZE = -1;

/** The size in bytes of boolean type. / public static final int BOOLEAN_BYTES_SIZE = 1;

/** The size in bytes of byte type. / public static final int BYTE_BYTES_SIZE = Byte.BYTES;

/** The size in bytes of short type. / public static final int SHORT_BYTES_SIZE = Short.BYTES;

/** The size in bytes of char type. / public static final int CHAR_BYTES_SIZE = Character.BYTES;

/** The size in bytes of int type. / public static final int INTEGER_BYTES_SIZE = Integer.BYTES;

/** The size in bytes of float type. / public static final int FLOAT_BYTES_SIZE = Float.BYTES;

/** The size in bytes of long type. / public static final int LONG_BYTES_SIZE = Long.BYTES;

/** The size in bytes of double type. / public static final int DOUBLE_BYTES_SIZE = Double.BYTES;

private static final Map, Integer> BYTES_SIZE_MAP = ofMap( boolean.class, BOOLEAN_BYTES_SIZE, byte.class, BYTE_BYTES_SIZE, short.class, SHORT_BYTES_SIZE, char.class, CHAR_BYTES_SIZE, int.class, INTEGER_BYTES_SIZE, float.class, FLOAT_BYTES_SIZE, long.class, LONG_BYTES_SIZE, double.class, DOUBLE_BYTES_SIZE, Boolean.class, BOOLEAN_BYTES_SIZE, Byte.class, BYTE_BYTES_SIZE, Short.class, SHORT_BYTES_SIZE, Character.class, CHAR_BYTES_SIZE, Integer.class, INTEGER_BYTES_SIZE, Float.class, FLOAT_BYTES_SIZE, Long.class, LONG_BYTES_SIZE, Double.class, DOUBLE_BYTES_SIZE );

/** Returns the size in bytes of the specified type.

See Also

  • Utils

This documentation was auto-generated from the source code of microsphere-java.

Home

annotation-processor

java-annotations

java-core

java-test

jdk-tools

lang-model

Clone this wiki locally