Package org.springframework.data.util

Examples of org.springframework.data.util.TypeInformation


  @Test
  @SuppressWarnings({ "rawtypes" })
  public void resolvesTypeByLoadingClass() {

    TypeInformationMapper mapper = new SimpleTypeInformationMapper();
    TypeInformation type = mapper.resolveTypeFrom("java.lang.String");

    TypeInformation expected = ClassTypeInformation.from(String.class);

    assertThat(type, is(expected));
  }
View Full Code Here


public class SimpleElasticsearchPersistentEntityTests {

  @Test(expected = IllegalArgumentException.class)
  public void shouldThrowExceptionGivenVersionPropertyIsNotLong() throws NoSuchFieldException, IntrospectionException {
    // given
    TypeInformation typeInformation = ClassTypeInformation.from(EntityWithWrongVersionType.class);
    SimpleElasticsearchPersistentProperty persistentProperty = new SimpleElasticsearchPersistentProperty(
        EntityWithWrongVersionType.class.getDeclaredField("version"), new PropertyDescriptor("version",
        EntityWithWrongVersionType.class), new SimpleElasticsearchPersistentEntity<EntityWithWrongVersionType>(
        typeInformation), new SimpleTypeHolder()
    );
View Full Code Here

  @Test(expected = MappingException.class)
  public void shouldThrowExceptionGivenMultipleVersionPropertiesArePresent() throws NoSuchFieldException,
      IntrospectionException {
    // given
    TypeInformation typeInformation = ClassTypeInformation.from(EntityWithMultipleVersionField.class);
    SimpleElasticsearchPersistentProperty persistentProperty1 = new SimpleElasticsearchPersistentProperty(
        EntityWithMultipleVersionField.class.getDeclaredField("version1"), new PropertyDescriptor("version1",
        EntityWithMultipleVersionField.class),
        new SimpleElasticsearchPersistentEntity<EntityWithMultipleVersionField>(typeInformation),
        new SimpleTypeHolder()
View Full Code Here

        .field(FIELD_STORE, true);
    builder.endObject();
  }

  protected static boolean isEntity(java.lang.reflect.Field field) {
    TypeInformation typeInformation = ClassTypeInformation.from(field.getType());
    Class<?> clazz = getFieldType(field);
    boolean isComplexType = !SIMPLE_TYPE_HOLDER.isSimpleType(clazz);
    return isComplexType && !Map.class.isAssignableFrom(typeInformation.getType());
  }
View Full Code Here

    return isComplexType && !Map.class.isAssignableFrom(typeInformation.getType());
  }

  protected static Class<?> getFieldType(java.lang.reflect.Field field) {
    Class<?> clazz = field.getType();
    TypeInformation typeInformation = ClassTypeInformation.from(clazz);
    if (typeInformation.isCollectionLike()) {
      clazz = GenericCollectionTypeResolver.getCollectionFieldType(field) != null ? GenericCollectionTypeResolver.getCollectionFieldType(field) : typeInformation.getComponentType().getType();
    }
    return clazz;
  }
View Full Code Here

        }
        xContentBuilder.endObject();
    }

    private static boolean isEntity(java.lang.reflect.Field field) {
        TypeInformation typeInformation = ClassTypeInformation.from(field.getType());
        TypeInformation<?> actualType = typeInformation.getActualType();
        boolean isComplexType = actualType == null ? false : !SIMPLE_TYPE_HOLDER.isSimpleType(actualType.getType());
        return isComplexType &&  !actualType.isCollectionLike() && !Map.class.isAssignableFrom(typeInformation.getType());
    }
View Full Code Here

public class SimpleElasticsearchPersistentEntityTest {

    @Test(expected = IllegalArgumentException.class)
    public void shouldThrowExceptionGivenVersionPropertyIsNotLong() throws NoSuchFieldException, IntrospectionException {
        //given
        TypeInformation typeInformation = ClassTypeInformation.from(EntityWithWrongVersionType.class);
        SimpleElasticsearchPersistentProperty persistentProperty =
                new SimpleElasticsearchPersistentProperty(EntityWithWrongVersionType.class.getDeclaredField("version"),
                        new PropertyDescriptor("version", EntityWithWrongVersionType.class),
                        new SimpleElasticsearchPersistentEntity<EntityWithWrongVersionType>(typeInformation),
                        new SimpleTypeHolder());
View Full Code Here


    @Test(expected = MappingException.class)
    public void shouldThrowExceptionGivenMultipleVersionPropertiesArePresent() throws NoSuchFieldException, IntrospectionException {
        //given
        TypeInformation typeInformation = ClassTypeInformation.from(EntityWithMultipleVersionField.class);
        SimpleElasticsearchPersistentProperty persistentProperty1 =
                new SimpleElasticsearchPersistentProperty(EntityWithMultipleVersionField.class.getDeclaredField("version1"),
                        new PropertyDescriptor("version1", EntityWithMultipleVersionField.class),
                        new SimpleElasticsearchPersistentEntity<EntityWithMultipleVersionField>(typeInformation),
                        new SimpleTypeHolder());
View Full Code Here

TOP

Related Classes of org.springframework.data.util.TypeInformation

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.