List of usage examples for org.springframework.data.util ClassTypeInformation from
public static <S> ClassTypeInformation<S> from(Class<S> type)
From source file:com.couchbase.spring.core.mapping.BasicCouchbasePersistentPropertyTest.java
/** * Create an instance of the demo entity. */// w w w . jav a 2 s. com @Before public void setUp() { entity = new BasicCouchbasePersistentEntity<Beer>(ClassTypeInformation.from(Beer.class)); }
From source file:com._4dconcept.springframework.data.marklogic.core.mapping.BasicMarklogicPersistentEntityTest.java
private <T> BasicMarklogicPersistentEntity<T> createPersistentEntity(Class<T> clazz) { return new BasicMarklogicPersistentEntity<>(ClassTypeInformation.from(clazz)); }
From source file:org.lightadmin.core.config.bootstrap.parsing.validation.TransientFieldMetadataValidator.java
@Override public Collection<? extends DomainConfigurationProblem> validateFieldMetadata( TransientFieldMetadata fieldMetadata, Class<?> domainType, DomainConfigurationValidationContext validationContext) { final String propertyPath = fieldMetadata.getProperty(); if (isBlank(propertyPath)) { return newArrayList(validationContext.invalidPropertyValueExpressionProblem(fieldMetadata.getName())); }/* w w w . j a va 2 s . co m*/ final List<String> properties = properties(propertyPath); if (properties.isEmpty()) { return newArrayList(validationContext.invalidPropertyValueExpressionProblem(fieldMetadata.getName())); } final TypeInformation<?> typeInformation = ClassTypeInformation.from(domainType); final Iterator<String> propertiesIterator = properties.iterator(); StringBuilder currentPropertyPath = null; while (propertiesIterator.hasNext()) { if (currentPropertyPath == null) { currentPropertyPath = new StringBuilder(propertiesIterator.next()); } else { currentPropertyPath.append(PROPERTY_SEPARATOR).append(propertiesIterator.next()); } if (typeInformation.getProperty(currentPropertyPath.toString()) == null) { return newArrayList( validationContext.invalidPropertyValueExpressionProblem(fieldMetadata.getName())); } } return emptyList(); }
From source file:org.develspot.data.orientdb.convert.MappingOrientConverter.java
public <R> R read(Class<R> type, OrientElement source) { if (log.isTraceEnabled()) { log.trace("reading type: " + type + " from orientElement: " + source.getId()); }// w ww . ja va 2s.c om return readInternal(ClassTypeInformation.from(type), source, false); }
From source file:org.datamongo.jira.datamongo1064.mapper.EmbeddedObjectTypeInformationMapper.java
/** * Creates a {@link MappingContextTypeInformationMapper} from the given {@link MappingContext}. Inspects all {@link PersistentEntity} instances for alias information and builds a {@link Map} of * aliases to types from it.//from www. j a v a 2 s. c om * * @param mappingContext must not be {@literal null}. * @throws ClassNotFoundException */ public EmbeddedObjectTypeInformationMapper(String... basePackage) throws ClassNotFoundException { Assert.notNull(basePackage); this.basePackage = basePackage; Map<? extends Class<?>, String> initialEntitySet = getInitialEntitySet(); this.typeMap = new HashMap<ClassTypeInformation<?>, Object>(initialEntitySet.size()); for (Entry<? extends Class<?>, String> entry : initialEntitySet.entrySet()) { ClassTypeInformation<?> key = ClassTypeInformation.from(entry.getKey()); String value = entry.getValue(); if (typeMap.containsValue(value)) { throw new IllegalArgumentException(String.format( "Detected mapping ambiguity! String %s cannot be mapped to more than one type!", value)); } this.typeMap.put(key, value); } }
From source file:com._4dconcept.springframework.data.marklogic.core.mapping.BasicMarklogicPersistentPropertyTest.java
private <T> MarklogicPersistentProperty getPropertyFor(Class<T> type, String fieldname) { return getPropertyFor(new BasicMarklogicPersistentEntity<>(ClassTypeInformation.from(type)), fieldname); }
From source file:com.couchbase.spring.core.convert.MappingCouchbaseConverter.java
@Override public void write(Object source, ConvertedCouchbaseDocument target) { if (source == null) { return;/*from ww w .j a va 2s .co m*/ } TypeInformation<? extends Object> type = ClassTypeInformation.from(source.getClass()); try { writeInternal(source, target, type); } catch (IOException ex) { throw new MappingException( "Could not translate to JSON while converting " + source.getClass().getName()); } }
From source file:com.frank.search.solr.core.convert.MappingSolrConverter.java
@Override public <S, R> List<R> read(SolrDocumentList source, Class<R> type) { if (source == null) { return Collections.emptyList(); }/*from ww w. j a v a2 s .c o m*/ List<R> resultList = new ArrayList<R>(source.size()); TypeInformation<R> typeInformation = ClassTypeInformation.from(type); for (Map<String, ?> item : source) { resultList.add(read(typeInformation, item)); } return resultList; }
From source file:com.frank.search.solr.core.convert.MappingSolrConverter.java
@Override public <R> R read(Class<R> type, Map<String, ?> source) { return read(ClassTypeInformation.from(type), source); }
From source file:io.twipple.springframework.data.clusterpoint.convert.DefaultClusterpointEntityConverter.java
@Override @NotNull/*w ww . ja v a 2 s . c o m*/ public <R> R read(@NotNull Class<R> type, @NotNull ClusterpointDocument source) { Assert.notNull(type); Assert.notNull(source); return read(ClassTypeInformation.from(type), source, null); }