org.springframework.core.SerializableTypeWrapper.TypeProvider Java Examples

The following examples show how to use org.springframework.core.SerializableTypeWrapper.TypeProvider. 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: ResolvableType.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Private constructor used to create a new {@link ResolvableType} for cache key purposes,
 * with no upfront resolution.
 */
private ResolvableType(
		Type type, @Nullable TypeProvider typeProvider, @Nullable VariableResolver variableResolver) {

	this.type = type;
	this.typeProvider = typeProvider;
	this.variableResolver = variableResolver;
	this.componentType = null;
	this.hash = calculateHashCode();
	this.resolved = null;
}
 
Example #2
Source File: ResolvableType.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Private constructor used to create a new {@link ResolvableType} for cache value purposes,
 * with upfront resolution and a pre-calculated hash.
 * @since 4.2
 */
private ResolvableType(Type type, @Nullable TypeProvider typeProvider,
		@Nullable VariableResolver variableResolver, @Nullable Integer hash) {

	this.type = type;
	this.typeProvider = typeProvider;
	this.variableResolver = variableResolver;
	this.componentType = null;
	this.hash = hash;
	this.resolved = resolveClass();
}
 
Example #3
Source File: ResolvableType.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Private constructor used to create a new {@link ResolvableType} for uncached purposes,
 * with upfront resolution but lazily calculated hash.
 */
private ResolvableType(Type type, @Nullable TypeProvider typeProvider,
		@Nullable VariableResolver variableResolver, @Nullable ResolvableType componentType) {

	this.type = type;
	this.typeProvider = typeProvider;
	this.variableResolver = variableResolver;
	this.componentType = componentType;
	this.hash = null;
	this.resolved = resolveClass();
}
 
Example #4
Source File: ResolvableType.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Return a {@link ResolvableType} for the specified {@link Type} backed by a given
 * {@link VariableResolver}.
 * @param type the source type or {@code null}
 * @param typeProvider the type provider or {@code null}
 * @param variableResolver the variable resolver or {@code null}
 * @return a {@link ResolvableType} for the specified {@link Type} and {@link VariableResolver}
 */
static ResolvableType forType(
		@Nullable Type type, @Nullable TypeProvider typeProvider, @Nullable VariableResolver variableResolver) {

	if (type == null && typeProvider != null) {
		type = SerializableTypeWrapper.forTypeProvider(typeProvider);
	}
	if (type == null) {
		return NONE;
	}

	// For simple Class references, build the wrapper right away -
	// no expensive resolution necessary, so not worth caching...
	if (type instanceof Class) {
		return new ResolvableType(type, typeProvider, variableResolver, (ResolvableType) null);
	}

	// Purge empty entries on access since we don't have a clean-up thread or the like.
	cache.purgeUnreferencedEntries();

	// Check the cache - we may have a ResolvableType which has been resolved before...
	ResolvableType resultType = new ResolvableType(type, typeProvider, variableResolver);
	ResolvableType cachedType = cache.get(resultType);
	if (cachedType == null) {
		cachedType = new ResolvableType(type, typeProvider, variableResolver, resultType.hash);
		cache.put(cachedType, cachedType);
	}
	resultType.resolved = cachedType.resolved;
	return resultType;
}
 
Example #5
Source File: ResolvableType.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Private constructor used to create a new {@link ResolvableType} for cache key purposes,
 * with no upfront resolution.
 */
private ResolvableType(
		Type type, @Nullable TypeProvider typeProvider, @Nullable VariableResolver variableResolver) {

	this.type = type;
	this.typeProvider = typeProvider;
	this.variableResolver = variableResolver;
	this.componentType = null;
	this.hash = calculateHashCode();
	this.resolved = null;
}
 
Example #6
Source File: ResolvableType.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Private constructor used to create a new {@link ResolvableType} for cache value purposes,
 * with upfront resolution and a pre-calculated hash.
 * @since 4.2
 */
private ResolvableType(Type type, @Nullable TypeProvider typeProvider,
		@Nullable VariableResolver variableResolver, @Nullable Integer hash) {

	this.type = type;
	this.typeProvider = typeProvider;
	this.variableResolver = variableResolver;
	this.componentType = null;
	this.hash = hash;
	this.resolved = resolveClass();
}
 
Example #7
Source File: ResolvableType.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Private constructor used to create a new {@link ResolvableType} for uncached purposes,
 * with upfront resolution but lazily calculated hash.
 */
private ResolvableType(Type type, @Nullable TypeProvider typeProvider,
		@Nullable VariableResolver variableResolver, @Nullable ResolvableType componentType) {

	this.type = type;
	this.typeProvider = typeProvider;
	this.variableResolver = variableResolver;
	this.componentType = componentType;
	this.hash = null;
	this.resolved = resolveClass();
}
 
Example #8
Source File: ResolvableType.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Return a {@link ResolvableType} for the specified {@link Type} backed by a given
 * {@link VariableResolver}.
 * @param type the source type or {@code null}
 * @param typeProvider the type provider or {@code null}
 * @param variableResolver the variable resolver or {@code null}
 * @return a {@link ResolvableType} for the specified {@link Type} and {@link VariableResolver}
 */
static ResolvableType forType(
		@Nullable Type type, @Nullable TypeProvider typeProvider, @Nullable VariableResolver variableResolver) {

	if (type == null && typeProvider != null) {
		type = SerializableTypeWrapper.forTypeProvider(typeProvider);
	}
	if (type == null) {
		return NONE;
	}

	// For simple Class references, build the wrapper right away -
	// no expensive resolution necessary, so not worth caching...
	if (type instanceof Class) {
		return new ResolvableType(type, typeProvider, variableResolver, (ResolvableType) null);
	}

	// Purge empty entries on access since we don't have a clean-up thread or the like.
	cache.purgeUnreferencedEntries();

	// Check the cache - we may have a ResolvableType which has been resolved before...
	ResolvableType resultType = new ResolvableType(type, typeProvider, variableResolver);
	ResolvableType cachedType = cache.get(resultType);
	if (cachedType == null) {
		cachedType = new ResolvableType(type, typeProvider, variableResolver, resultType.hash);
		cache.put(cachedType, cachedType);
	}
	resultType.resolved = cachedType.resolved;
	return resultType;
}
 
Example #9
Source File: ResolvableType.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Private constructor used to create a new {@link ResolvableType} for cache key purposes,
 * with no upfront resolution.
 */
private ResolvableType(Type type, TypeProvider typeProvider, VariableResolver variableResolver) {
	this.type = type;
	this.typeProvider = typeProvider;
	this.variableResolver = variableResolver;
	this.componentType = null;
	this.resolved = null;
	this.hash = calculateHashCode();
}
 
Example #10
Source File: ResolvableType.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Private constructor used to create a new {@link ResolvableType} for cache value purposes,
 * with upfront resolution and a pre-calculated hash.
 * @since 4.2
 */
private ResolvableType(Type type, TypeProvider typeProvider, VariableResolver variableResolver, Integer hash) {
	this.type = type;
	this.typeProvider = typeProvider;
	this.variableResolver = variableResolver;
	this.componentType = null;
	this.resolved = resolveClass();
	this.hash = hash;
}
 
Example #11
Source File: ResolvableType.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Private constructor used to create a new {@link ResolvableType} for uncached purposes,
 * with upfront resolution but lazily calculated hash.
 */
private ResolvableType(
		Type type, TypeProvider typeProvider, VariableResolver variableResolver, ResolvableType componentType) {

	this.type = type;
	this.typeProvider = typeProvider;
	this.variableResolver = variableResolver;
	this.componentType = componentType;
	this.resolved = resolveClass();
	this.hash = null;
}
 
Example #12
Source File: ResolvableType.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Return a {@link ResolvableType} for the specified {@link Type} backed by a given
 * {@link VariableResolver}.
 * @param type the source type or {@code null}
 * @param typeProvider the type provider or {@code null}
 * @param variableResolver the variable resolver or {@code null}
 * @return a {@link ResolvableType} for the specified {@link Type} and {@link VariableResolver}
 */
static ResolvableType forType(Type type, TypeProvider typeProvider, VariableResolver variableResolver) {
	if (type == null && typeProvider != null) {
		type = SerializableTypeWrapper.forTypeProvider(typeProvider);
	}
	if (type == null) {
		return NONE;
	}

	// For simple Class references, build the wrapper right away -
	// no expensive resolution necessary, so not worth caching...
	if (type instanceof Class) {
		return new ResolvableType(type, typeProvider, variableResolver, (ResolvableType) null);
	}

	// Purge empty entries on access since we don't have a clean-up thread or the like.
	cache.purgeUnreferencedEntries();

	// Check the cache - we may have a ResolvableType which has been resolved before...
	ResolvableType key = new ResolvableType(type, typeProvider, variableResolver);
	ResolvableType resolvableType = cache.get(key);
	if (resolvableType == null) {
		resolvableType = new ResolvableType(type, typeProvider, variableResolver, key.hash);
		cache.put(resolvableType, resolvableType);
	}
	return resolvableType;
}
 
Example #13
Source File: ResolvableType.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Private constructor used to create a new {@link ResolvableType} for cache key purposes,
 * with no upfront resolution.
 */
private ResolvableType(Type type, TypeProvider typeProvider, VariableResolver variableResolver) {
	this.type = type;
	this.typeProvider = typeProvider;
	this.variableResolver = variableResolver;
	this.componentType = null;
	this.resolved = null;
	this.hash = calculateHashCode();
}
 
Example #14
Source File: ResolvableType.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Private constructor used to create a new {@link ResolvableType} for cache value purposes,
 * with upfront resolution and a pre-calculated hash.
 * @since 4.2
 */
private ResolvableType(Type type, TypeProvider typeProvider, VariableResolver variableResolver, Integer hash) {
	this.type = type;
	this.typeProvider = typeProvider;
	this.variableResolver = variableResolver;
	this.componentType = null;
	this.resolved = resolveClass();
	this.hash = hash;
}
 
Example #15
Source File: ResolvableType.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Private constructor used to create a new {@link ResolvableType} for uncached purposes,
 * with upfront resolution but lazily calculated hash.
 */
private ResolvableType(
		Type type, TypeProvider typeProvider, VariableResolver variableResolver, ResolvableType componentType) {

	this.type = type;
	this.typeProvider = typeProvider;
	this.variableResolver = variableResolver;
	this.componentType = componentType;
	this.resolved = resolveClass();
	this.hash = null;
}
 
Example #16
Source File: ResolvableType.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Return a {@link ResolvableType} for the specified {@link Type} backed by a given
 * {@link VariableResolver}.
 * @param type the source type or {@code null}
 * @param typeProvider the type provider or {@code null}
 * @param variableResolver the variable resolver or {@code null}
 * @return a {@link ResolvableType} for the specified {@link Type} and {@link VariableResolver}
 */
static ResolvableType forType(Type type, TypeProvider typeProvider, VariableResolver variableResolver) {
	if (type == null && typeProvider != null) {
		type = SerializableTypeWrapper.forTypeProvider(typeProvider);
	}
	if (type == null) {
		return NONE;
	}

	// For simple Class references, build the wrapper right away -
	// no expensive resolution necessary, so not worth caching...
	if (type instanceof Class) {
		return new ResolvableType(type, typeProvider, variableResolver, (ResolvableType) null);
	}

	// Purge empty entries on access since we don't have a clean-up thread or the like.
	cache.purgeUnreferencedEntries();

	// Check the cache - we may have a ResolvableType which has been resolved before...
	ResolvableType key = new ResolvableType(type, typeProvider, variableResolver);
	ResolvableType resolvableType = cache.get(key);
	if (resolvableType == null) {
		resolvableType = new ResolvableType(type, typeProvider, variableResolver, key.hash);
		cache.put(resolvableType, resolvableType);
	}
	return resolvableType;
}