Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit bef85e9

Browse filesBrowse files
committed
1:1 copy of spring classes used by play (tag v7.0.7)
1 parent d2d403b commit bef85e9
Copy full SHA for bef85e9

305 files changed

+63,208Lines changed: 63208 additions & 0 deletions

File tree

Expand file treeCollapse file tree
Open diff view settings
Filter options

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
Dismiss banner
Expand file treeCollapse file tree
Open diff view settings
Collapse file

‎web/play-java-forms/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java‎

Copy file name to clipboardExpand all lines: web/play-java-forms/src/main/java/org/springframework/beans/AbstractNestablePropertyAccessor.java
+1,088Lines changed: 1088 additions & 0 deletions
Large diffs are not rendered by default.
Collapse file
+170Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
/*
2+
* Copyright 2002-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.beans;
18+
19+
import java.util.ArrayList;
20+
import java.util.Arrays;
21+
import java.util.List;
22+
import java.util.Map;
23+
24+
import org.jspecify.annotations.Nullable;
25+
26+
/**
27+
* Abstract implementation of the {@link PropertyAccessor} interface.
28+
* Provides base implementations of all convenience methods, with the
29+
* implementation of actual property access left to subclasses.
30+
*
31+
* @author Juergen Hoeller
32+
* @author Stephane Nicoll
33+
* @since 2.0
34+
* @see #getPropertyValue
35+
* @see #setPropertyValue
36+
*/
37+
public abstract class AbstractPropertyAccessor extends TypeConverterSupport implements ConfigurablePropertyAccessor {
38+
39+
private boolean extractOldValueForEditor = false;
40+
41+
private boolean autoGrowNestedPaths = false;
42+
43+
boolean suppressNotWritablePropertyException = false;
44+
45+
46+
@Override
47+
public void setExtractOldValueForEditor(boolean extractOldValueForEditor) {
48+
this.extractOldValueForEditor = extractOldValueForEditor;
49+
}
50+
51+
@Override
52+
public boolean isExtractOldValueForEditor() {
53+
return this.extractOldValueForEditor;
54+
}
55+
56+
@Override
57+
public void setAutoGrowNestedPaths(boolean autoGrowNestedPaths) {
58+
this.autoGrowNestedPaths = autoGrowNestedPaths;
59+
}
60+
61+
@Override
62+
public boolean isAutoGrowNestedPaths() {
63+
return this.autoGrowNestedPaths;
64+
}
65+
66+
67+
@Override
68+
public void setPropertyValue(PropertyValue pv) throws BeansException {
69+
setPropertyValue(pv.getName(), pv.getValue());
70+
}
71+
72+
@Override
73+
public void setPropertyValues(Map<?, ?> map) throws BeansException {
74+
setPropertyValues(new MutablePropertyValues(map));
75+
}
76+
77+
@Override
78+
public void setPropertyValues(PropertyValues pvs) throws BeansException {
79+
setPropertyValues(pvs, false, false);
80+
}
81+
82+
@Override
83+
public void setPropertyValues(PropertyValues pvs, boolean ignoreUnknown) throws BeansException {
84+
setPropertyValues(pvs, ignoreUnknown, false);
85+
}
86+
87+
@Override
88+
public void setPropertyValues(PropertyValues pvs, boolean ignoreUnknown, boolean ignoreInvalid)
89+
throws BeansException {
90+
91+
List<PropertyAccessException> propertyAccessExceptions = null;
92+
List<PropertyValue> propertyValues = (pvs instanceof MutablePropertyValues mpvs ?
93+
mpvs.getPropertyValueList() : Arrays.asList(pvs.getPropertyValues()));
94+
95+
if (ignoreUnknown) {
96+
this.suppressNotWritablePropertyException = true;
97+
}
98+
try {
99+
for (PropertyValue pv : propertyValues) {
100+
// setPropertyValue may throw any BeansException, which won't be caught
101+
// here, if there is a critical failure such as no matching field.
102+
// We can attempt to deal only with less serious exceptions.
103+
try {
104+
setPropertyValue(pv);
105+
}
106+
catch (NotWritablePropertyException ex) {
107+
if (!ignoreUnknown) {
108+
throw ex;
109+
}
110+
// Otherwise, just ignore it and continue...
111+
}
112+
catch (NullValueInNestedPathException ex) {
113+
if (!ignoreInvalid) {
114+
throw ex;
115+
}
116+
// Otherwise, just ignore it and continue...
117+
}
118+
catch (PropertyAccessException ex) {
119+
if (propertyAccessExceptions == null) {
120+
propertyAccessExceptions = new ArrayList<>();
121+
}
122+
propertyAccessExceptions.add(ex);
123+
}
124+
}
125+
}
126+
finally {
127+
if (ignoreUnknown) {
128+
this.suppressNotWritablePropertyException = false;
129+
}
130+
}
131+
132+
// If we encountered individual exceptions, throw the composite exception.
133+
if (propertyAccessExceptions != null) {
134+
PropertyAccessException[] paeArray = propertyAccessExceptions.toArray(new PropertyAccessException[0]);
135+
throw new PropertyBatchUpdateException(paeArray);
136+
}
137+
}
138+
139+
140+
// Redefined with public visibility.
141+
@Override
142+
public @Nullable Class<?> getPropertyType(String propertyPath) {
143+
return null;
144+
}
145+
146+
/**
147+
* Actually get the value of a property.
148+
* @param propertyName name of the property to get the value of
149+
* @return the value of the property
150+
* @throws InvalidPropertyException if there is no such property or
151+
* if the property isn't readable
152+
* @throws PropertyAccessException if the property was valid but the
153+
* accessor method failed
154+
*/
155+
@Override
156+
public abstract @Nullable Object getPropertyValue(String propertyName) throws BeansException;
157+
158+
/**
159+
* Actually set a property value.
160+
* @param propertyName name of the property to set value of
161+
* @param value the new value
162+
* @throws InvalidPropertyException if there is no such property or
163+
* if the property isn't writable
164+
* @throws PropertyAccessException if the property was valid but the
165+
* accessor method failed or a type mismatch occurred
166+
*/
167+
@Override
168+
public abstract void setPropertyValue(String propertyName, @Nullable Object value) throws BeansException;
169+
170+
}
Collapse file
+59Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* Copyright 2002-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.beans;
18+
19+
import java.beans.BeanInfo;
20+
import java.beans.IntrospectionException;
21+
22+
import org.jspecify.annotations.Nullable;
23+
24+
/**
25+
* Strategy interface for creating {@link BeanInfo} instances for Spring beans.
26+
* Can be used to plug in custom bean property resolution strategies (for example, for other
27+
* languages on the JVM) or more efficient {@link BeanInfo} retrieval algorithms.
28+
*
29+
* <p>BeanInfoFactories are instantiated by the {@link CachedIntrospectionResults},
30+
* by using the {@link org.springframework.core.io.support.SpringFactoriesLoader}
31+
* utility class.
32+
*
33+
* When a {@link BeanInfo} is to be created, the {@code CachedIntrospectionResults}
34+
* will iterate through the discovered factories, calling {@link #getBeanInfo(Class)}
35+
* on each one. If {@code null} is returned, the next factory will be queried.
36+
* If none of the factories support the class, a standard {@link BeanInfo} will be
37+
* created as a default.
38+
*
39+
* <p>Note that the {@link org.springframework.core.io.support.SpringFactoriesLoader}
40+
* sorts the {@code BeanInfoFactory} instances by
41+
* {@link org.springframework.core.annotation.Order @Order}, so that ones with a
42+
* higher precedence come first.
43+
*
44+
* @author Arjen Poutsma
45+
* @since 3.2
46+
* @see CachedIntrospectionResults
47+
* @see org.springframework.core.io.support.SpringFactoriesLoader
48+
*/
49+
public interface BeanInfoFactory {
50+
51+
/**
52+
* Return the bean info for the given class, if supported.
53+
* @param beanClass the bean class
54+
* @return the BeanInfo, or {@code null} if the given class is not supported
55+
* @throws IntrospectionException in case of exceptions
56+
*/
57+
@Nullable BeanInfo getBeanInfo(Class<?> beanClass) throws IntrospectionException;
58+
59+
}
Collapse file
+121Lines changed: 121 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,121 @@
1+
/*
2+
* Copyright 2002-present the original author or authors.
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
package org.springframework.beans;
18+
19+
import java.lang.reflect.Constructor;
20+
import java.lang.reflect.Method;
21+
22+
import org.jspecify.annotations.Nullable;
23+
24+
/**
25+
* Exception thrown when instantiation of a bean failed.
26+
* Carries the offending bean class.
27+
*
28+
* @author Juergen Hoeller
29+
* @since 1.2.8
30+
*/
31+
@SuppressWarnings("serial")
32+
public class BeanInstantiationException extends FatalBeanException {
33+
34+
private final Class<?> beanClass;
35+
36+
private final @Nullable Constructor<?> constructor;
37+
38+
private final @Nullable Method constructingMethod;
39+
40+
41+
/**
42+
* Create a new BeanInstantiationException.
43+
* @param beanClass the offending bean class
44+
* @param msg the detail message
45+
*/
46+
public BeanInstantiationException(Class<?> beanClass, String msg) {
47+
this(beanClass, msg, null);
48+
}
49+
50+
/**
51+
* Create a new BeanInstantiationException.
52+
* @param beanClass the offending bean class
53+
* @param msg the detail message
54+
* @param cause the root cause
55+
*/
56+
public BeanInstantiationException(Class<?> beanClass, String msg, @Nullable Throwable cause) {
57+
super("Failed to instantiate [" + beanClass.getName() + "]: " + msg, cause);
58+
this.beanClass = beanClass;
59+
this.constructor = null;
60+
this.constructingMethod = null;
61+
}
62+
63+
/**
64+
* Create a new BeanInstantiationException.
65+
* @param constructor the offending constructor
66+
* @param msg the detail message
67+
* @param cause the root cause
68+
* @since 4.3
69+
*/
70+
public BeanInstantiationException(Constructor<?> constructor, @Nullable String msg, @Nullable Throwable cause) {
71+
super("Failed to instantiate [" + constructor.getDeclaringClass().getName() + "]: " + msg, cause);
72+
this.beanClass = constructor.getDeclaringClass();
73+
this.constructor = constructor;
74+
this.constructingMethod = null;
75+
}
76+
77+
/**
78+
* Create a new BeanInstantiationException.
79+
* @param constructingMethod the delegate for bean construction purposes
80+
* (typically, but not necessarily, a static factory method)
81+
* @param msg the detail message
82+
* @param cause the root cause
83+
* @since 4.3
84+
*/
85+
public BeanInstantiationException(Method constructingMethod, @Nullable String msg, @Nullable Throwable cause) {
86+
super("Failed to instantiate [" + constructingMethod.getReturnType().getName() + "]: " + msg, cause);
87+
this.beanClass = constructingMethod.getReturnType();
88+
this.constructor = null;
89+
this.constructingMethod = constructingMethod;
90+
}
91+
92+
93+
/**
94+
* Return the offending bean class (never {@code null}).
95+
* @return the class that was to be instantiated
96+
*/
97+
public Class<?> getBeanClass() {
98+
return this.beanClass;
99+
}
100+
101+
/**
102+
* Return the offending constructor, if known.
103+
* @return the constructor in use, or {@code null} in case of a
104+
* factory method or in case of default instantiation
105+
* @since 4.3
106+
*/
107+
public @Nullable Constructor<?> getConstructor() {
108+
return this.constructor;
109+
}
110+
111+
/**
112+
* Return the delegate for bean construction purposes, if known.
113+
* @return the method in use (typically a static factory method),
114+
* or {@code null} in case of constructor-based instantiation
115+
* @since 4.3
116+
*/
117+
public @Nullable Method getConstructingMethod() {
118+
return this.constructingMethod;
119+
}
120+
121+
}

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.