Many resources are needed to download a project. Please understand that we have to compensate our server costs. Thank you in advance. Project price only 1 $
You can buy this project and download/modify it how often you want.
/*
* Copyright (c) 2019 Oracle and/or its affiliates. All rights reserved.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.helidon.common.mapper;
import java.util.List;
import java.util.Optional;
import java.util.ServiceLoader;
import io.helidon.common.GenericType;
import io.helidon.common.Prioritized;
import io.helidon.common.mapper.spi.MapperProvider;
import io.helidon.common.serviceloader.HelidonServiceLoader;
/**
* Mapper manager of all configured mappers.
*
* To map a source to target, you can use either of the {@code map} methods defined in this interface,
* as they make sure that the mapping exists in either space.
*
*
If you call {@link #map(Object, Class, Class)} and no mapper is found for the class pair,
* the implementation calls the {@link #map(Object, io.helidon.common.GenericType, io.helidon.common.GenericType)} with
* {@link io.helidon.common.GenericType}s created for each parameters
*
If you call {@link #map(Object, io.helidon.common.GenericType, io.helidon.common.GenericType)} and no mapper is
* found for the {@link io.helidon.common.GenericType} pair, an attempt is to locate a mapper for
* the underlying class *IF* the generic type represents a simple class (e.g. not a generic type declaration)
*
*/
public interface MapperManager {
/**
* Create a fluent API builder to create a customized mapper manager.
*
* @return a new builder
*/
static Builder builder() {
return new Builder();
}
/**
* Create a mapper manager using only Java Service loader
* loaded {@link io.helidon.common.mapper.spi.MapperProvider MapperProviders}.
*
* @return create a new mapper manager from service loader
*/
static MapperManager create() {
return MapperManager.builder().build();
}
/**
* Create a fluent API builder to create a customized mapper manager based on the provided Helidon Service loader.
*
* @param serviceLoader fully configured service loader
* @return a new builder
*/
static Builder builder(HelidonServiceLoader serviceLoader) {
return MapperManager.builder()
.mapperProviders(serviceLoader);
}
/**
* Create a mapper manager using only the provided Helidon Service loader.
* loaded {@link io.helidon.common.mapper.spi.MapperProvider MapperProviders}.
*
* @param serviceLoader fully configured service loader
* @return create a new mapper manager from service loader
*/
static MapperManager create(HelidonServiceLoader serviceLoader) {
return MapperManager.builder()
.mapperProviders(serviceLoader)
.build();
}
/**
* Map from source to target.
*
* @param source object to map
* @param sourceType type of the source object (to locate the mapper)
* @param targetType type of the target object (to locate the mapper)
* @param