Package: PropertiesParametersResolver
PropertiesParametersResolver
name | instruction | branch | complexity | line | method | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
PropertiesParametersResolver(Field) |
|
|
|
|
|
||||||||||||||||||||
getKeyType() |
|
|
|
|
|
||||||||||||||||||||
getPropertyIdentifierType() |
|
|
|
|
|
||||||||||||||||||||
getPropertyValueType() |
|
|
|
|
|
||||||||||||||||||||
getValueType() |
|
|
|
|
|
||||||||||||||||||||
static {...} |
|
|
|
|
|
Coverage
1: /*
2: * JOPA
3: * Copyright (C) 2024 Czech Technical University in Prague
4: *
5: * This library is free software; you can redistribute it and/or
6: * modify it under the terms of the GNU Lesser General Public
7: * License as published by the Free Software Foundation; either
8: * version 3.0 of the License, or (at your option) any later version.
9: *
10: * This library is distributed in the hope that it will be useful,
11: * but WITHOUT ANY WARRANTY; without even the implied warranty of
12: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13: * Lesser General Public License for more details.
14: *
15: * You should have received a copy of the GNU Lesser General Public
16: * License along with this library.
17: */
18: package cz.cvut.kbss.jopa.model.metamodel;
19:
20: import java.lang.reflect.*;
21:
22: class PropertiesParametersResolver {
23:
24: private final java.lang.reflect.Type keyType;
25: private final java.lang.reflect.Type valueType;
26:
27: PropertiesParametersResolver(Field propertiesField) {
28: final ParameterizedType typeSpec = (ParameterizedType) propertiesField.getGenericType();
29:• assert typeSpec.getActualTypeArguments().length == 2;
30: this.keyType = typeSpec.getActualTypeArguments()[0];
31: this.valueType = typeSpec.getActualTypeArguments()[1];
32: }
33:
34: java.lang.reflect.Type getKeyType() {
35: return keyType;
36: }
37:
38: java.lang.reflect.Type getValueType() {
39: return valueType;
40: }
41:
42: Class<?> getPropertyIdentifierType() {
43:• assert keyType instanceof Class;
44: return (Class<?>) keyType;
45: }
46:
47: Class<?> getPropertyValueType() {
48:• assert valueType instanceof ParameterizedType;
49: final ParameterizedType type = (ParameterizedType) valueType;
50:• assert type.getActualTypeArguments().length == 1;
51:• assert type.getActualTypeArguments()[0] instanceof Class;
52: return (Class<?>) type.getActualTypeArguments()[0];
53: }
54: }