/
TypeMapperComponent.java
87 lines (78 loc) · 2.91 KB
/
TypeMapperComponent.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
/**
*
* Copyright (c) 2006-2016, Speedment, Inc. 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 com.speedment.generator.component;
import com.speedment.internal.common.injector.annotation.InjectorKey;
import com.speedment.runtime.annotation.Api;
import com.speedment.runtime.component.Component;
import com.speedment.runtime.config.Column;
import com.speedment.runtime.config.mapper.TypeMapper;
import com.speedment.runtime.internal.config.mapper.IdentityTypeMapper;
import java.util.Optional;
import java.util.function.Supplier;
import java.util.stream.Stream;
/**
* Stores the currently installed {@link TypeMapper TypeMappers}.
*
* @author Emil Forslund
* @since 2.2.0
*/
@Api(version = "3.0")
@InjectorKey(TypeMapperComponent.class)
public interface TypeMapperComponent extends Component {
@Override
default Class<TypeMapperComponent> getComponentClass() {
return TypeMapperComponent.class;
}
/**
* Installs the specified type mapper in this component.
*
* @param databaseType the type to install it for
* @param typeMapperSupplier the constructor for a mapper to install
*/
void install(Class<?> databaseType, Supplier<TypeMapper<?, ?>> typeMapperSupplier);
/**
* Streams over all the type mappers installed in this component.
*
* @param databaseType the type to get mappers for
* @return all mappers
*/
Stream<TypeMapper<?, ?>> mapFrom(Class<?> databaseType);
/**
* Streams over all the installed type mappers.
*
* @return stream of type mappers
*/
Stream<TypeMapper<?, ?>> stream();
/**
* Retrieve and return the type mapper with the specified absolute class
* name. If it is not installed, return an empty optional.
*
* @param absoluteClassName the name as returned by {@code Class.getName()}
* @return the type mapper or empty
*/
Optional<TypeMapper<?, ?>> get(String absoluteClassName);
/**
* Returns the mapper class that will be used to generate a java
* representation of the database types. If no type mapper is
* specified, then an {@link IdentityTypeMapper} will be created
* and returned.
*
* @param column the column to retrieve the type mapper for
* @return the mapper class
*/
TypeMapper<?, ?> get(Column column);
}