org.springframework.data.mapping.Alias Java Examples

The following examples show how to use org.springframework.data.mapping.Alias. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: DefaultArangoTypeMapper.java    From spring-data with Apache License 2.0 5 votes vote down vote up
public void writeType(final TypeInformation<?> info, final VPackBuilder sink) {
	Assert.notNull(info, "TypeInformation must not be null!");

	final Alias alias = getAliasFor(info);
	if (alias.isPresent()) {
		accessor.writeTypeTo(sink, alias.getValue());
	}
}
 
Example #2
Source File: DefaultArangoTypeMapper.java    From spring-data with Apache License 2.0 5 votes vote down vote up
protected final Alias getAliasFor(final TypeInformation<?> info) {
	Assert.notNull(info, "TypeInformation must not be null!");
	
	for (final TypeInformationMapper mapper : mappers) {
		final Alias alias = mapper.createAliasFor(info);
		if (alias.isPresent()) {
			return alias;
		}
	}

	return Alias.NONE;
}
 
Example #3
Source File: DefaultArangoTypeMapper.java    From spring-data with Apache License 2.0 5 votes vote down vote up
private TypeInformation<?> getFromCacheOrCreate(final Alias alias) {
	return typeCache.computeIfAbsent(alias, key -> {
		for (final TypeInformationMapper mapper : mappers) {
			final TypeInformation<?> typeInformation = mapper.resolveTypeFrom(key);

			if (typeInformation != null) {
				return Optional.of(typeInformation);
			}
		}
		return Optional.empty();
	}).orElse(null);
}
 
Example #4
Source File: DefaultArangoTypeMapper.java    From spring-data with Apache License 2.0 5 votes vote down vote up
public Alias readAliasFrom(final VPackSlice source) {
	if (source.isArray()) {
		return Alias.NONE;
	}

	if (source.isObject()) {
		final VPackSlice typeKey = source.get(this.typeKey);
		return Alias.ofNullable(typeKey.isString() ? typeKey.getAsString() : null);
	}

	throw new IllegalArgumentException("Cannot read alias from VPack type " + source.getType());
}
 
Example #5
Source File: DefaultVaultTypeMapper.java    From spring-vault with Apache License 2.0 4 votes vote down vote up
public Alias readAliasFrom(Map<String, Object> source) {
	return this.typeKey == null ? Alias.NONE : Alias.ofNullable(source.get(this.typeKey));
}
 
Example #6
Source File: DefaultTypeMapperBenchmark.java    From spring-data-dev-tools with Apache License 2.0 4 votes vote down vote up
@Override
public Alias readAliasFrom(Map<String, Object> source) {
	return Alias.ofNullable(source.get("_class"));
}
 
Example #7
Source File: ArangoTypeAliasAccessor.java    From spring-data with Apache License 2.0 votes vote down vote up
Alias readAliasFrom(VPackSlice source);