net.binis.codegen.map.Mapper Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of code-generator-core Show documentation
Show all versions of code-generator-core Show documentation
Binis Code Generation Core Classes
package net.binis.codegen.map;
/*-
* #%L
* code-generator-core
* %%
* Copyright (C) 2021 - 2024 Binis Belev
* %%
* 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.
* #L%
*/
import net.binis.codegen.factory.CodeFactory;
import net.binis.codegen.map.builder.SourceMappingBuilder;
import net.binis.codegen.map.executor.DefaultMapperExecutor;
import net.binis.codegen.map.executor.LambdaMapperExecutor;
import net.binis.codegen.map.executor.MappingBuilderExecutor;
import java.util.List;
import java.util.function.BiFunction;
public class Mapper {
static {
CodeFactory.registerType(MapperFactory.class, CodeFactory.singleton(new DefaultMapperExecutor()));
}
public static T map(Object source, Class destination) {
return CodeFactory.create(MapperFactory.class).map(source, destination);
}
public static T map(Object source, T destination) {
return CodeFactory.create(MapperFactory.class).map(source, destination);
}
public static T map(Object source, Class destination, MappingStrategy strategy) {
return CodeFactory.create(MapperFactory.class).map(source, destination, strategy);
}
public static T map(Object source, T destination, MappingStrategy strategy) {
return CodeFactory.create(MapperFactory.class).map(source, destination, strategy);
}
public static T map(Object source, Class destination, K key) {
return CodeFactory.create(MapperFactory.class).map(source, destination, key);
}
public static T map(Object source, T destination, K key) {
return CodeFactory.create(MapperFactory.class).map(source, destination, key);
}
public static T convert(Object source, Class destination, MappingStrategy strategy) {
return CodeFactory.create(MapperFactory.class).convert(source, destination, strategy);
}
public static T convert(Object source, Class destination, MappingStrategy strategy, Object... params) {
return CodeFactory.create(MapperFactory.class).convert(source, destination, strategy, params);
}
public static T convert(Object source, T destination, MappingStrategy strategy) {
return CodeFactory.create(MapperFactory.class).convert(source, destination, strategy);
}
public static T convert(Object source, Class destination, K key) {
return CodeFactory.create(MapperFactory.class).convert(source, destination, key);
}
public static T convert(Object source, T destination, K key) {
return CodeFactory.create(MapperFactory.class).convert(source, destination, key);
}
public static T convert(Object source, Class destination) {
return CodeFactory.create(MapperFactory.class).convert(source, destination);
}
public static T convert(Object source, Class destination, Object... params) {
return CodeFactory.create(MapperFactory.class).convert(source, destination, params);
}
public static T convert(Object source, T destination) {
return CodeFactory.create(MapperFactory.class).convert(source, destination);
}
public static void registerMapper(Mapping mapping) {
CodeFactory.create(MapperFactory.class).registerMapper(mapping);
}
public static void registerMapper(Class source, Class destination, MappingStrategy strategy, K key, BiFunction func) {
CodeFactory.create(MapperFactory.class).registerMapper(new LambdaMapperExecutor(source, destination, false, false, strategy, func), key);
}
public static void registerMapperClass(Class source, Class destination, MappingStrategy strategy, K key, BiFunction, D> func) {
CodeFactory.create(MapperFactory.class).registerMapper(new LambdaMapperExecutor(source, destination, true, false, strategy, func), key);
}
public static void registerProducerMapper(Class source, Class destination, MappingStrategy strategy, K key, BiFunction func) {
CodeFactory.create(MapperFactory.class).registerMapper(new LambdaMapperExecutor(source, destination, false, true, strategy, func), key);
}
public static void registerProducerMapperClass(Class source, Class destination, MappingStrategy strategy, K key, BiFunction, D> func) {
CodeFactory.create(MapperFactory.class).registerMapper(new LambdaMapperExecutor(source, destination, true, true, strategy, func), key);
}
public static void registerMapper(Class source, Class destination, MappingStrategy strategy, BiFunction func) {
CodeFactory.create(MapperFactory.class).registerMapper(new LambdaMapperExecutor(source, destination, false, false, strategy, func));
}
public static void registerMapperClass(Class source, Class destination, MappingStrategy strategy, BiFunction, D> func) {
CodeFactory.create(MapperFactory.class).registerMapper(new LambdaMapperExecutor(source, destination, true, false, strategy, func));
}
public static void registerProducerMapper(Class source, Class destination, MappingStrategy strategy, BiFunction func) {
CodeFactory.create(MapperFactory.class).registerMapper(new LambdaMapperExecutor(source, destination, false, true, strategy, func));
}
public static void registerProducerMapperClass(Class source, Class destination, MappingStrategy strategy, BiFunction, D> func) {
CodeFactory.create(MapperFactory.class).registerMapper(new LambdaMapperExecutor(source, destination, true, true, strategy, func));
}
public static void registerMapperKey(Class source, Class destination, K key, BiFunction func) {
CodeFactory.create(MapperFactory.class).registerMapper(new LambdaMapperExecutor(source, destination, false, false, MappingStrategy.GETTERS_SETTERS, func), key);
}
public static void registerMapperClassKey(Class source, Class destination, K key, BiFunction, D> func) {
CodeFactory.create(MapperFactory.class).registerMapper(new LambdaMapperExecutor(source, destination, true, false, MappingStrategy.GETTERS_SETTERS, func), key);
}
public static void registerProducerMapperKey(Class source, Class destination, K key, BiFunction func) {
CodeFactory.create(MapperFactory.class).registerMapper(new LambdaMapperExecutor(source, destination, false, true, MappingStrategy.GETTERS_SETTERS, func), key);
}
public static void registerProducerMapperClassKey(Class source, Class destination, K key, BiFunction, D> func) {
CodeFactory.create(MapperFactory.class).registerMapper(new LambdaMapperExecutor(source, destination, true, true, MappingStrategy.GETTERS_SETTERS, func), key);
}
public static void registerMapper(Class source, Class destination, BiFunction func) {
registerMapper(source, destination, MappingStrategy.GETTERS_SETTERS, func);
}
public static void registerMapperClass(Class source, Class destination, BiFunction, D> func) {
registerMapperClass(source, destination, MappingStrategy.GETTERS_SETTERS, func);
}
public static void registerProducerMapper(Class source, Class destination, BiFunction func) {
registerProducerMapper(source, destination, MappingStrategy.GETTERS_SETTERS, func);
}
public static void registerProducerMapperClass(Class source, Class destination, BiFunction, D> func) {
registerProducerMapperClass(source, destination, MappingStrategy.GETTERS_SETTERS, func);
}
public static List> findMappings(Class source, Class destination) {
return CodeFactory.create(MapperFactory.class).findMappings(source, destination);
}
public static SourceMappingBuilder map() {
return new MappingBuilderExecutor();
}
private Mapper() {
//Do nothing
}
}