Skip to content

io microsphere io Serializers

github-actions[bot] edited this page Mar 21, 2026 · 1 revision

Serializers

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

Source: microsphere-java-core/src/main/java/io/microsphere/io/Serializers.java

Overview

A utility class for managing and retrieving Serializer instances.

This class provides methods to load serializers via SPI (Service Provider Interface), retrieve the most compatible serializer for a given type, and get serializers based on priority.

Example Usage

`Serializers serializers = new Serializers();
serializers.loadSPI(); // Load all available serializers from SPI

// Get the highest priority serializer for String
Serializer highestPrioritySerializer = serializers.getHighestPriority(String.class);

// Get the lowest priority serializer for String
Serializer lowestPrioritySerializer = serializers.getLowestPriority(String.class);

// Get the most compatible serializer for String
Serializer compatibleSerializer = serializers.getMostCompatible(String.class);
`

Declaration

public class Serializers

Author: Mercy

Version Information

  • Introduced in: 1.0.0
  • Current Project Version: 0.1.10-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

Examples

Serializers serializers = new Serializers();
serializers.loadSPI(); // Load all available serializers from SPI

// Get the highest priority serializer for String
Serializer<String> highestPrioritySerializer = serializers.getHighestPriority(String.class);

// Get the lowest priority serializer for String
Serializer<String> lowestPrioritySerializer = serializers.getLowestPriority(String.class);

// Get the most compatible serializer for String
Serializer<?> compatibleSerializer = serializers.getMostCompatible(String.class);

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.io.Serializers;

API Reference

Public Methods

Method Description
loadSPI
getMostCompatible Get the most compatible instance of Serializer by the specified deserialized type
getHighestPriority Get the highest priority instance of Serializer by the specified serialized type
getLowestPriority Get the lowest priority instance of Serializer by the specified serialized type
get Get all instances of Serializer by the specified serialized type

Method Details

getMostCompatible

public Serializer<?> getMostCompatible(Class<?> serializedType)

Get the most compatible instance of Serializer by the specified deserialized type

getHighestPriority

public <S> Serializer<S> getHighestPriority(Class<S> serializedType)

Get the highest priority instance of Serializer by the specified serialized type

getLowestPriority

public <S> Serializer<S> getLowestPriority(Class<S> serializedType)

Get the lowest priority instance of Serializer by the specified serialized type

get

public <S> List<Serializer<S>> get(Class<S> serializedType)

Get all instances of Serializer by the specified serialized type


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

Home

java-annotations

java-core

jdk-tools

lang-model

annotation-processor

java-test

Clone this wiki locally