Java Code Examples for org.springframework.expression.PropertyAccessor#getSpecificTargetClasses()

The following examples show how to use org.springframework.expression.PropertyAccessor#getSpecificTargetClasses() . 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: AstUtils.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Determines the set of property resolvers that should be used to try and access a
 * property on the specified target type. The resolvers are considered to be in an
 * ordered list, however in the returned list any that are exact matches for the input
 * target type (as opposed to 'general' resolvers that could work for any type) are
 * placed at the start of the list. In addition, there are specific resolvers that
 * exactly name the class in question and resolvers that name a specific class but it
 * is a supertype of the class we have. These are put at the end of the specific resolvers
 * set and will be tried after exactly matching accessors but before generic accessors.
 * @param targetType the type upon which property access is being attempted
 * @return a list of resolvers that should be tried in order to access the property
 */
public static List<PropertyAccessor> getPropertyAccessorsToTry(
		@Nullable Class<?> targetType, List<PropertyAccessor> propertyAccessors) {

	List<PropertyAccessor> specificAccessors = new ArrayList<>();
	List<PropertyAccessor> generalAccessors = new ArrayList<>();
	for (PropertyAccessor resolver : propertyAccessors) {
		Class<?>[] targets = resolver.getSpecificTargetClasses();
		if (targets == null) {  // generic resolver that says it can be used for any type
			generalAccessors.add(resolver);
		}
		else {
			if (targetType != null) {
				int pos = 0;
				for (Class<?> clazz : targets) {
					if (clazz == targetType) {  // put exact matches on the front to be tried first?
						specificAccessors.add(pos++, resolver);
					}
					else if (clazz.isAssignableFrom(targetType)) {  // put supertype matches at the end of the
						// specificAccessor list
						generalAccessors.add(resolver);
					}
				}
			}
		}
	}
	List<PropertyAccessor> resolvers = new ArrayList<>(specificAccessors.size() + generalAccessors.size());
	resolvers.addAll(specificAccessors);
	resolvers.addAll(generalAccessors);
	return resolvers;
}
 
Example 2
Source File: PropertyOrFieldReference.java    From spring-analysis-note with MIT License 5 votes vote down vote up
/**
 * Determines the set of property resolvers that should be used to try and access a property
 * on the specified target type. The resolvers are considered to be in an ordered list,
 * however in the returned list any that are exact matches for the input target type (as
 * opposed to 'general' resolvers that could work for any type) are placed at the start of the
 * list. In addition, there are specific resolvers that exactly name the class in question
 * and resolvers that name a specific class but it is a supertype of the class we have.
 * These are put at the end of the specific resolvers set and will be tried after exactly
 * matching accessors but before generic accessors.
 * @param contextObject the object upon which property access is being attempted
 * @return a list of resolvers that should be tried in order to access the property
 */
private List<PropertyAccessor> getPropertyAccessorsToTry(
		@Nullable Object contextObject, List<PropertyAccessor> propertyAccessors) {

	Class<?> targetType = (contextObject != null ? contextObject.getClass() : null);

	List<PropertyAccessor> specificAccessors = new ArrayList<>();
	List<PropertyAccessor> generalAccessors = new ArrayList<>();
	for (PropertyAccessor resolver : propertyAccessors) {
		Class<?>[] targets = resolver.getSpecificTargetClasses();
		if (targets == null) {
			// generic resolver that says it can be used for any type
			generalAccessors.add(resolver);
		}
		else if (targetType != null) {
			for (Class<?> clazz : targets) {
				if (clazz == targetType) {
					specificAccessors.add(resolver);
					break;
				}
				else if (clazz.isAssignableFrom(targetType)) {
					generalAccessors.add(resolver);
				}
			}
		}
	}
	List<PropertyAccessor> resolvers = new ArrayList<>(specificAccessors);
	generalAccessors.removeAll(specificAccessors);
	resolvers.addAll(generalAccessors);
	return resolvers;
}
 
Example 3
Source File: AstUtils.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Determines the set of property resolvers that should be used to try and access a
 * property on the specified target type. The resolvers are considered to be in an
 * ordered list, however in the returned list any that are exact matches for the input
 * target type (as opposed to 'general' resolvers that could work for any type) are
 * placed at the start of the list. In addition, there are specific resolvers that
 * exactly name the class in question and resolvers that name a specific class but it
 * is a supertype of the class we have. These are put at the end of the specific resolvers
 * set and will be tried after exactly matching accessors but before generic accessors.
 * @param targetType the type upon which property access is being attempted
 * @return a list of resolvers that should be tried in order to access the property
 */
public static List<PropertyAccessor> getPropertyAccessorsToTry(
		@Nullable Class<?> targetType, List<PropertyAccessor> propertyAccessors) {

	List<PropertyAccessor> specificAccessors = new ArrayList<>();
	List<PropertyAccessor> generalAccessors = new ArrayList<>();
	for (PropertyAccessor resolver : propertyAccessors) {
		Class<?>[] targets = resolver.getSpecificTargetClasses();
		if (targets == null) {  // generic resolver that says it can be used for any type
			generalAccessors.add(resolver);
		}
		else {
			if (targetType != null) {
				int pos = 0;
				for (Class<?> clazz : targets) {
					if (clazz == targetType) {  // put exact matches on the front to be tried first?
						specificAccessors.add(pos++, resolver);
					}
					else if (clazz.isAssignableFrom(targetType)) {  // put supertype matches at the end of the
						// specificAccessor list
						generalAccessors.add(resolver);
					}
				}
			}
		}
	}
	List<PropertyAccessor> resolvers = new ArrayList<>(specificAccessors.size() + generalAccessors.size());
	resolvers.addAll(specificAccessors);
	resolvers.addAll(generalAccessors);
	return resolvers;
}
 
Example 4
Source File: PropertyOrFieldReference.java    From java-technology-stack with MIT License 5 votes vote down vote up
/**
 * Determines the set of property resolvers that should be used to try and access a property
 * on the specified target type. The resolvers are considered to be in an ordered list,
 * however in the returned list any that are exact matches for the input target type (as
 * opposed to 'general' resolvers that could work for any type) are placed at the start of the
 * list. In addition, there are specific resolvers that exactly name the class in question
 * and resolvers that name a specific class but it is a supertype of the class we have.
 * These are put at the end of the specific resolvers set and will be tried after exactly
 * matching accessors but before generic accessors.
 * @param contextObject the object upon which property access is being attempted
 * @return a list of resolvers that should be tried in order to access the property
 */
private List<PropertyAccessor> getPropertyAccessorsToTry(
		@Nullable Object contextObject, List<PropertyAccessor> propertyAccessors) {

	Class<?> targetType = (contextObject != null ? contextObject.getClass() : null);

	List<PropertyAccessor> specificAccessors = new ArrayList<>();
	List<PropertyAccessor> generalAccessors = new ArrayList<>();
	for (PropertyAccessor resolver : propertyAccessors) {
		Class<?>[] targets = resolver.getSpecificTargetClasses();
		if (targets == null) {
			// generic resolver that says it can be used for any type
			generalAccessors.add(resolver);
		}
		else if (targetType != null) {
			for (Class<?> clazz : targets) {
				if (clazz == targetType) {
					specificAccessors.add(resolver);
					break;
				}
				else if (clazz.isAssignableFrom(targetType)) {
					generalAccessors.add(resolver);
				}
			}
		}
	}
	List<PropertyAccessor> resolvers = new ArrayList<>(specificAccessors);
	generalAccessors.removeAll(specificAccessors);
	resolvers.addAll(generalAccessors);
	return resolvers;
}
 
Example 5
Source File: AstUtils.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Determines the set of property resolvers that should be used to try and access a
 * property on the specified target type. The resolvers are considered to be in an
 * ordered list, however in the returned list any that are exact matches for the input
 * target type (as opposed to 'general' resolvers that could work for any type) are
 * placed at the start of the list. In addition, there are specific resolvers that
 * exactly name the class in question and resolvers that name a specific class but it
 * is a supertype of the class we have. These are put at the end of the specific resolvers
 * set and will be tried after exactly matching accessors but before generic accessors.
 * @param targetType the type upon which property access is being attempted
 * @return a list of resolvers that should be tried in order to access the property
 */
public static List<PropertyAccessor> getPropertyAccessorsToTry(
		Class<?> targetType, List<PropertyAccessor> propertyAccessors) {

	List<PropertyAccessor> specificAccessors = new ArrayList<PropertyAccessor>();
	List<PropertyAccessor> generalAccessors = new ArrayList<PropertyAccessor>();
	for (PropertyAccessor resolver : propertyAccessors) {
		Class<?>[] targets = resolver.getSpecificTargetClasses();
		if (targets == null) {  // generic resolver that says it can be used for any type
			generalAccessors.add(resolver);
		}
		else {
			if (targetType != null) {
				int pos = 0;
				for (Class<?> clazz : targets) {
					if (clazz == targetType) {  // put exact matches on the front to be tried first?
						specificAccessors.add(pos++, resolver);
					}
					else if (clazz.isAssignableFrom(targetType)) {  // put supertype matches at the end of the
						// specificAccessor list
						generalAccessors.add(resolver);
					}
				}
			}
		}
	}
	List<PropertyAccessor> resolvers = new LinkedList<PropertyAccessor>();
	resolvers.addAll(specificAccessors);
	resolvers.addAll(generalAccessors);
	return resolvers;
}
 
Example 6
Source File: PropertyOrFieldReference.java    From lams with GNU General Public License v2.0 5 votes vote down vote up
/**
 * Determines the set of property resolvers that should be used to try and access a property
 * on the specified target type. The resolvers are considered to be in an ordered list,
 * however in the returned list any that are exact matches for the input target type (as
 * opposed to 'general' resolvers that could work for any type) are placed at the start of the
 * list. In addition, there are specific resolvers that exactly name the class in question
 * and resolvers that name a specific class but it is a supertype of the class we have.
 * These are put at the end of the specific resolvers set and will be tried after exactly
 * matching accessors but before generic accessors.
 * @param contextObject the object upon which property access is being attempted
 * @return a list of resolvers that should be tried in order to access the property
 */
private List<PropertyAccessor> getPropertyAccessorsToTry(Object contextObject, List<PropertyAccessor> propertyAccessors) {
	Class<?> targetType = (contextObject != null ? contextObject.getClass() : null);

	List<PropertyAccessor> specificAccessors = new ArrayList<PropertyAccessor>();
	List<PropertyAccessor> generalAccessors = new ArrayList<PropertyAccessor>();
	for (PropertyAccessor resolver : propertyAccessors) {
		Class<?>[] targets = resolver.getSpecificTargetClasses();
		if (targets == null) {
			// generic resolver that says it can be used for any type
			generalAccessors.add(resolver);
		}
		else if (targetType != null) {
			for (Class<?> clazz : targets) {
				if (clazz == targetType) {
					specificAccessors.add(resolver);
					break;
				}
				else if (clazz.isAssignableFrom(targetType)) {
					generalAccessors.add(resolver);
				}
			}
		}
	}
	List<PropertyAccessor> resolvers = new ArrayList<PropertyAccessor>();
	resolvers.addAll(specificAccessors);
	generalAccessors.removeAll(specificAccessors);
	resolvers.addAll(generalAccessors);
	return resolvers;
}
 
Example 7
Source File: AstUtils.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Determines the set of property resolvers that should be used to try and access a
 * property on the specified target type. The resolvers are considered to be in an
 * ordered list, however in the returned list any that are exact matches for the input
 * target type (as opposed to 'general' resolvers that could work for any type) are
 * placed at the start of the list. In addition, there are specific resolvers that
 * exactly name the class in question and resolvers that name a specific class but it
 * is a supertype of the class we have. These are put at the end of the specific resolvers
 * set and will be tried after exactly matching accessors but before generic accessors.
 * @param targetType the type upon which property access is being attempted
 * @return a list of resolvers that should be tried in order to access the property
 */
public static List<PropertyAccessor> getPropertyAccessorsToTry(
		Class<?> targetType, List<PropertyAccessor> propertyAccessors) {

	List<PropertyAccessor> specificAccessors = new ArrayList<PropertyAccessor>();
	List<PropertyAccessor> generalAccessors = new ArrayList<PropertyAccessor>();
	for (PropertyAccessor resolver : propertyAccessors) {
		Class<?>[] targets = resolver.getSpecificTargetClasses();
		if (targets == null) {  // generic resolver that says it can be used for any type
			generalAccessors.add(resolver);
		}
		else {
			if (targetType != null) {
				int pos = 0;
				for (Class<?> clazz : targets) {
					if (clazz == targetType) {  // put exact matches on the front to be tried first?
						specificAccessors.add(pos++, resolver);
					}
					else if (clazz.isAssignableFrom(targetType)) {  // put supertype matches at the end of the
						// specificAccessor list
						generalAccessors.add(resolver);
					}
				}
			}
		}
	}
	List<PropertyAccessor> resolvers = new LinkedList<PropertyAccessor>();
	resolvers.addAll(specificAccessors);
	resolvers.addAll(generalAccessors);
	return resolvers;
}
 
Example 8
Source File: PropertyOrFieldReference.java    From spring4-understanding with Apache License 2.0 5 votes vote down vote up
/**
 * Determines the set of property resolvers that should be used to try and access a property
 * on the specified target type. The resolvers are considered to be in an ordered list,
 * however in the returned list any that are exact matches for the input target type (as
 * opposed to 'general' resolvers that could work for any type) are placed at the start of the
 * list. In addition, there are specific resolvers that exactly name the class in question
 * and resolvers that name a specific class but it is a supertype of the class we have.
 * These are put at the end of the specific resolvers set and will be tried after exactly
 * matching accessors but before generic accessors.
 * @param contextObject the object upon which property access is being attempted
 * @return a list of resolvers that should be tried in order to access the property
 */
private List<PropertyAccessor> getPropertyAccessorsToTry(Object contextObject, List<PropertyAccessor> propertyAccessors) {
	Class<?> targetType = (contextObject != null ? contextObject.getClass() : null);

	List<PropertyAccessor> specificAccessors = new ArrayList<PropertyAccessor>();
	List<PropertyAccessor> generalAccessors = new ArrayList<PropertyAccessor>();
	for (PropertyAccessor resolver : propertyAccessors) {
		Class<?>[] targets = resolver.getSpecificTargetClasses();
		if (targets == null) {
			// generic resolver that says it can be used for any type
			generalAccessors.add(resolver);
		}
		else if (targetType != null) {
			for (Class<?> clazz : targets) {
				if (clazz == targetType) {
					specificAccessors.add(resolver);
					break;
				}
				else if (clazz.isAssignableFrom(targetType)) {
					generalAccessors.add(resolver);
				}
			}
		}
	}
	List<PropertyAccessor> resolvers = new ArrayList<PropertyAccessor>();
	resolvers.addAll(specificAccessors);
	generalAccessors.removeAll(specificAccessors);
	resolvers.addAll(generalAccessors);
	return resolvers;
}