Skip to content

Commit

Permalink
Updated Koryphe version to 1.5.0-RC1 (gchq#1830)
Browse files Browse the repository at this point in the history
* Updated Koryphe version to 1.5.0-RC1
  • Loading branch information
p013570 authored Jul 13, 2018
1 parent ff0152d commit 69324d9
Show file tree
Hide file tree
Showing 4 changed files with 29 additions and 10 deletions.
2 changes: 1 addition & 1 deletion NOTICES
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ and their licenses, below. For information on the dependencies of these dependen
projects below.


Koryphe (uk.gov.gchq.koryphe:koryphe:1.4.0):
Koryphe (uk.gov.gchq.koryphe:koryphe:1.5.0-RC1):

- Apache License, Version 2.0

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonSetter;
import com.fasterxml.jackson.databind.BeanDescription;
import com.fasterxml.jackson.databind.JavaType;
import com.fasterxml.jackson.databind.ObjectMapper;
Expand Down Expand Up @@ -104,15 +105,33 @@ public static Map<String, String> getSerialisedFieldClasses(final String classNa
Type genericType = null;
if (null != builder) {
final String methodName = buildMethodPrefix + propName;
Method matchedMethod = null;
for (final Method method : builder.getMethods()) {
if (methodName.equalsIgnoreCase(method.getName())) {
final Type[] params = method.getGenericParameterTypes();
if (null != params && 1 == params.length) {
genericType = params[0];
final JsonSetter jsonSetter = method.getAnnotation(JsonSetter.class);
if (null != jsonSetter && propName.equals(jsonSetter.value())) {
matchedMethod = method;
break;
}
final JsonProperty jsonProperty = method.getAnnotation(JsonProperty.class);
if (null != jsonProperty && propName.equals(jsonProperty.value())) {
matchedMethod = method;
break;
}
if (null == matchedMethod) {
matchedMethod = method;
} else if (builder.equals(method.getReturnType())) {
// Checks for overridden methods
matchedMethod = method;
}
}
break;
}
}
if (null != matchedMethod) {
genericType = matchedMethod.getGenericParameterTypes()[0];
}
}
if (null == genericType && null != creator) {
for (final Parameter parameter : creator.getParameters()) {
Expand Down Expand Up @@ -177,7 +196,7 @@ public static String getFieldTypeString(final Class<?> clazz, final Type typeArg

if (type instanceof TypeVariable) {
final TypeVariable tv = (TypeVariable) type;
final GenericDeclaration genericDeclaration = ((TypeVariable) type).getGenericDeclaration();
final GenericDeclaration genericDeclaration = tv.getGenericDeclaration();
if (null != clazz && genericDeclaration instanceof Class) {
final Map<TypeVariable<?>, Type> typeArgs = TypeUtils.getTypeArguments(clazz, (Class) genericDeclaration);
if (null != typeArgs) {
Expand All @@ -189,9 +208,8 @@ public static String getFieldTypeString(final Class<?> clazz, final Type typeArg
}

if (null == typeName) {
if (null != ((TypeVariable) type).getBounds()
&& 1 == ((TypeVariable) type).getBounds().length) {
typeName = ((TypeVariable) type).getBounds()[0].getTypeName();
if (null != tv.getBounds() && 1 == tv.getBounds().length) {
typeName = tv.getBounds()[0].getTypeName();
} else {
typeName = type.getTypeName();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,8 +110,8 @@ public void testInRange() {
// Given
final String className = InRange.class.getName();
final Map<String, String> expectedValues = new HashMap<>();
expectedValues.put("start", Comparable.class.getName());
expectedValues.put("end", Comparable.class.getName());
expectedValues.put("start", "java.lang.Comparable<T>");
expectedValues.put("end", "java.lang.Comparable<T>");
expectedValues.put("startInclusive", Boolean.class.getName());
expectedValues.put("endInclusive", Boolean.class.getName());

Expand All @@ -136,6 +136,7 @@ public void testInDateRangeAndInTimeRange() {
expectedValues.put("end", String.class.getName());
expectedValues.put("endOffset", Long.class.getName());
expectedValues.put("endInclusive", Boolean.class.getName());
expectedValues.put("timeZone", String.class.getName());

// When
final Map<String, String> resultIDR = JsonSerialisationUtil.getSerialisedFieldClasses(classNameIDR);
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@
<failsafe.version>2.18.1</failsafe.version>
<slf4j.api.version>1.7.5</slf4j.api.version>

<koryphe.version>1.4.0</koryphe.version>
<koryphe.version>1.5.0-RC1</koryphe.version>
<accumulo.version>1.8.1</accumulo.version>
<hbase.version>1.3.0</hbase.version>
<avro.version>1.7.7</avro.version>
Expand Down

0 comments on commit 69324d9

Please sign in to comment.