DATACMNS-1006 - SimpleTypeHolder now considers java.lang types simple ones.
This prevents AbstractMappingContext from adding them as entities. Related tickets: DATAREST-1018.
This commit is contained in:
@@ -123,6 +123,10 @@ public class SimpleTypeHolder {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (type.getName().startsWith("java.lang")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
for (Class<?> clazz : simpleTypes) {
|
||||
if (clazz.isAssignableFrom(type)) {
|
||||
simpleTypes.add(type);
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011 by the original author(s).
|
||||
* Copyright 2011-2017 by the original author(s).
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -18,8 +18,10 @@ package org.springframework.data.mapping;
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
import java.lang.reflect.Type;
|
||||
import java.util.Collections;
|
||||
import java.util.HashSet;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.junit.Test;
|
||||
import org.springframework.data.mapping.model.SimpleTypeHolder;
|
||||
@@ -60,7 +62,7 @@ public class SimpleTypeHolderUnitTests {
|
||||
|
||||
SimpleTypeHolder holder = new SimpleTypeHolder(new HashSet<Class<?>>(), false);
|
||||
|
||||
assertThat(holder.isSimpleType(String.class), is(false));
|
||||
assertThat(holder.isSimpleType(UUID.class), is(false));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -104,6 +106,14 @@ public class SimpleTypeHolderUnitTests {
|
||||
assertThat(holder.isSimpleType(ComplexEnum.FOO.getClass()), is(true));
|
||||
}
|
||||
|
||||
@Test // DATACMNS-1006
|
||||
public void considersJavaLangTypesSimple() {
|
||||
|
||||
SimpleTypeHolder holder = new SimpleTypeHolder();
|
||||
|
||||
assertThat(holder.isSimpleType(Type.class), is(true));
|
||||
}
|
||||
|
||||
enum SimpleEnum {
|
||||
|
||||
FOO;
|
||||
|
||||
Reference in New Issue
Block a user