Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
package org.eclipse.serializer.persistence.binary.types;

/*-
* #%L
* Eclipse Serializer Persistence Binary
* %%
* Copyright (C) 2023 - 2026 MicroStream Software
* %%
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
* #L%
*/

import org.eclipse.serializer.persistence.types.PersistenceLegacyTypeHandlerSupplier;

public interface BinaryLegacyTypeHandlerSupplier<T> extends PersistenceLegacyTypeHandlerSupplier<Binary, T>
{

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
package org.eclipse.serializer.persistence.types;

/*-
* #%L
* Eclipse Serializer Persistence
* %%
* Copyright (C) 2023 - 2026 MicroStream Software
* %%
* This program and the accompanying materials are made
* available under the terms of the Eclipse Public License 2.0
* which is available at https://www.eclipse.org/legal/epl-2.0/
*
* SPDX-License-Identifier: EPL-2.0
* #L%
*/

/**
* Classes implementing this interface must supply a PersistenceLegacyTypeHandler
*
* @param <D> Persitence implementation type
* @param <T> Class&lt;?&gt; of the legacy type
*/
public interface PersistenceLegacyTypeHandlerSupplier<D,T>
{
PersistenceLegacyTypeHandler<D,T> getLegacyTypeHandler();
}
Original file line number Diff line number Diff line change
Expand Up @@ -338,6 +338,18 @@ private <T> PersistenceLegacyTypeHandler<D, T> lookupCustomHandlerByTypeId(
return null;
}

validateLegacyTypeHandler(type, legacyTypeDefinition, legacyTypeHandlerbyId);

return legacyTypeHandlerbyId;
}



private <T> void validateLegacyTypeHandler(
final Class<?> type,
final PersistenceTypeDefinition legacyTypeDefinition,
final PersistenceLegacyTypeHandler<D, T> legacyTypeHandlerbyId)
{
// validate if the found handler with matching explicit typeId also has matching type and structure
if(type != null && type != legacyTypeDefinition.type()
|| !PersistenceTypeDescription.equalStructure(legacyTypeHandlerbyId, legacyTypeDefinition)
Expand All @@ -347,8 +359,6 @@ private <T> PersistenceLegacyTypeHandler<D, T> lookupCustomHandlerByTypeId(
"Type handler structure mismatch for " + legacyTypeDefinition.toTypeIdentifier()
);
}

return legacyTypeHandlerbyId;
}

private <T> PersistenceLegacyTypeHandler<D, T> lookupCustomHandlerByStructure(
Expand Down Expand Up @@ -378,6 +388,16 @@ public <T> PersistenceLegacyTypeHandler<D, T> ensureLegacyTypeHandler(
final PersistenceTypeHandler<D, T> currentTypeHandler
)
{
//check for supplied handler
if(currentTypeHandler instanceof PersistenceLegacyTypeHandlerSupplier supplier)
{
@SuppressWarnings("unchecked")
PersistenceLegacyTypeHandler<D, T> legacyTypeHandler = supplier.getLegacyTypeHandler();
validateLegacyTypeHandler(legacyTypeDefinition.type(), legacyTypeDefinition, legacyTypeHandler);
return legacyTypeHandler.initialize(legacyTypeDefinition.typeId());
}


// check for a custom handler with matching structure
final PersistenceLegacyTypeHandler<D, T> customHandler = this.lookupCustomHandler(legacyTypeDefinition);
if(customHandler != null)
Expand Down