admin 管理员组

文章数量: 887021


2024年2月23日发(作者:jsp注释的语法格式)

private Object bindObject(ConfigurationPropertyName name, Bindable target, BindHandler handler, Context context, boolean allowRecursiveBinding) { //

重点

根据名称获取属性值 ConfigurationProperty property = findProperty(name, context); if (property == null && != 0 && containsNoDescendantOf(rces(), name)) { return null; } AggregateBinder aggregateBinder = getAggregateBinder(target, context); if (aggregateBinder != null) { return bindAggregate(name, target, handler, context, aggregateBinder); } if (property != null) { try { return bindProperty(target, context, property); } catch (ConverterNotFoundException ex) { // We might still be able to bind it using the recursive binders Object instance = bindDataObject(name, target, handler, context, allowRecursiveBinding); if (instance != null) { return instance; } throw ex; } } return bindDataObject(name, target, handler, context, allowRecursiveBinding); }anBinder源码/* * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * /licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package ;import pector;import tion;import ;import ;import er;import ;import ator;import HashMap;import ;import umer;import on;import er;import ils;import t;import urationPropertyName;import urationPropertySource;import urationPropertyState;import Parameter;import ableType;

import ableType;/** * {@link DataObjectBinder} for mutable Java Beans. * * @author Phillip Webb * @author Madhura Bhave */class JavaBeanBinder implements DataObjectBinder { static final JavaBeanBinder INSTANCE = new JavaBeanBinder(); @Override public T bind(ConfigurationPropertyName name, Bindable target, Context context, DataObjectPropertyBinder propertyBinder) { boolean hasKnownBindableProperties = ue() != null && hasKnownBindableProperties(name, context); Bean bean = (target, hasKnownBindableProperties); if (bean == null) { return null; } BeanSupplier beanSupplier = plier(target); boolean bound = bind(propertyBinder, bean, beanSupplier, context); return (bound ? () : null); } @Override @SuppressWarnings("unchecked") public T create(Bindable target, Context context) { Class type = (Class) e().resolve(); return (type != null) ? tiateClass(type) : null; } private boolean hasKnownBindableProperties(ConfigurationPropertyName name, Context context) { for (ConfigurationPropertySource source : rces()) { if (nsDescendantOf(name) == T) { return true; } } return false; } private boolean bind(DataObjectPropertyBinder propertyBinder, Bean bean, BeanSupplier beanSupplier, Context context) { boolean bound = false; for (BeanProperty beanProperty : perties().values()) { bound |= bind(beanSupplier, propertyBinder, beanProperty); onfigurationProperty(); } return bound; } private boolean bind(BeanSupplier beanSupplier, DataObjectPropertyBinder propertyBinder, BeanProperty property) { String propertyName = e(); ResolvableType type = e(); Supplier value = ue(beanSupplier); Annotation[] annotations = otations(); Object bound = operty(propertyName, (type).withSuppliedValue(value).withAnnotations(annotations)); if (bound == null) { return false; } if (able()) { ue(beanSupplier, bound); } else if (value == null || !(())) { throw new IllegalStateException("No setter found for property: " + e());

throw new IllegalStateException("No setter found for property: " + e()); } return true; } /** * The bean being bound. * * @param the bean type */ static class Bean { private static Bean cached; private final ResolvableType type; private final Class resolvedType; private final Map properties = new LinkedHashMap<>(); Bean(ResolvableType type, Class resolvedType) { = type; edType = resolvedType; addProperties(resolvedType); } private void addProperties(Class type) { while (type != null && !(type)) { Method[] declaredMethods = getSorted(type, Class::getDeclaredMethods, Method::getName); Field[] declaredFields = getSorted(type, Class::getDeclaredFields, Field::getName); addProperties(declaredMethods, declaredFields); type = erclass(); } } private E[] getSorted(S source, Function elements, Function name) { E[] result = (source); (result, ing(name)); return result; } protected void addProperties(Method[] declaredMethods, Field[] declaredFields) { for (int i = 0; i < ; i++) { if (!isCandidate(declaredMethods[i])) { declaredMethods[i] = null; } } for (Method method : declaredMethods) { addMethodIfPossible(method, "get", 0, BeanProperty::addGetter); addMethodIfPossible(method, "is", 0, BeanProperty::addGetter); } for (Method method : declaredMethods) { addMethodIfPossible(method, "set", 1, BeanProperty::addSetter); } for (Field field : declaredFields) { addField(field); } } private boolean isCandidate(Method method) { int modifiers = ifiers(); return !ate(modifiers) && !ected(modifiers) && !ract(modifiers) && !ic(modifiers) && !(laringClass()) && !(laringClass()) && e().indexOf('$') == -1; } private void addMethodIfPossible(Method method, String prefix, int parameterCount,

private void addMethodIfPossible(Method method, String prefix, int parameterCount, BiConsumer consumer) { if (method != null && ameterCount() == parameterCount && e().startsWith(prefix) && e().length() > ()) { String propertyName = talize(e().substring(())); (eIfAbsent(propertyName, this::getBeanProperty), method); } } private BeanProperty getBeanProperty(String name) { return new BeanProperty(name, ); } private void addField(Field field) { BeanProperty property = (e()); if (property != null) { ld(field); } } Map getProperties() { return ties; } @SuppressWarnings("unchecked") BeanSupplier getSupplier(Bindable target) { return new BeanSupplier<>(() -> { T instance = null; if (ue() != null) { instance = ue().get(); } if (instance == null) { instance = (T) tiateClass(edType); } return instance; }); } @SuppressWarnings("unchecked") static Bean get(Bindable bindable, boolean canCallGetValue) { ResolvableType type = e(); Class resolvedType = e(); Supplier value = ue(); T instance = null; if (canCallGetValue && value != null) { instance = (); resolvedType = (instance != null) ? ss() : resolvedType; } if (instance == null && !isInstantiable(resolvedType)) { return null; } Bean bean = ; if (bean == null || !pe(type, resolvedType)) { bean = new Bean<>(type, resolvedType); cached = bean; } return (Bean) bean; } private static boolean isInstantiable(Class type) { if (rface()) { return false; } try { laredConstructor(); return true;

= setter; } } private boolean isBetterSetter(Method setter) { return != null && urnType().equals(ameterTypes()[0]); } void addField(Field field) { if ( == null) { = field; } } String getName() { return ; } ResolvableType getType() { if ( != null) { MethodParameter methodParameter = new MethodParameter(, 0); return hodParameter(methodParameter, ingClassType); } MethodParameter methodParameter = new MethodParameter(, -1); return hodParameter(methodParameter, ingClassType); } Annotation[] getAnnotations() { try { return ( != null) ? laredAnnotations() : null; } catch (Exception ex) { return null; } } Supplier getValue(Supplier instance) { if ( == null) { return null; } return () -> { try { essible(true); return (()); } catch (Exception ex) { throw new IllegalStateException("Unable to get value for property " + , ex); } }; } boolean isSettable() { return != null; } void setValue(Supplier instance, Object value) { try { essible(true); ((), value); } catch (Exception ex) { throw new IllegalStateException("Unable to set value for property " + , ex); } } }

/* * Copyright 2012-2020 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * /licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */package ;/** * Internal utility to help when dealing with data object property names. * * @author Phillip Webb * @author Madhura Bhave * @since 2.2.3 * @see DataObjectBinder */public abstract class DataObjectPropertyName { private DataObjectPropertyName() { } /** * Return the specified Java Bean property name in dashed form. * @param name the source name * @return the dashed from */ public static String toDashedForm(String name) { StringBuilder result = new StringBuilder(()); boolean inIndex = false; for (int i = 0; i < (); i++) { char ch = (i); if (inIndex) { (ch); if (ch == ']') { inIndex = false; } } else { if (ch == '[') { inIndex = true; (ch); } else { ch = (ch != '_') ? ch : '-'; if (rCase(ch) && () > 0 && (() - 1) != '-') { ('-'); } (rCase(ch)); } } } return ng(); }}


本文标签: 注释 获取 属性 名称

更多相关文章

三星9100刷机,查询,root,新手教程详解

9月前

三星9100刷机,查询,root,新手教程详解

在Mac OS上安装VirtualBox

9月前

在Mac OS上安装VirtualBox

AD域认证配置集成数字证书(iTrusCA)

8月前

AD域认证配置集成数字证书(iTrusCA)

系统名称:联想ThinkpadOEM Win7SP1简体中文旗舰版原版光盘镜像64位

7月前

[db:摘要]

pygame小游戏弹弹球屏保(代码全注释,新手也能看懂)

4月前

[db:摘要]

MBR&amp;GPT硬盘分区类型&amp;属性详解(Win下更改设置OEM恢复分区方法)

3月前

[db:摘要]

win7计算机管理对话框功能,win7鼠标设置在哪里|win7打开鼠标属性对话框方法

3月前

[db:摘要]

win7计算机名称还原,电脑系统教程:win7还原系统

3月前

[db:摘要]

电脑右键计算机属性在哪里打开,右键属性打不开怎么办

3月前

[db:摘要]

手机wifi有网电脑显示未连接服务器,?解决手机连接电脑WIFI (Wlan)网络提示“服务器名称无效”的有效方法...

3月前

‍如果还不会如何连接请参考以下文章&#xff1a; 无线网络及用手机免费连接笔记本电脑WIFI上网设置 ‍ 如果用手机连接电脑的WLAN以后打开网站提示“服务器名称无效”时&#xff0c;那就需要设置一下手机的 IP地址 和

4.netsh wlan 查看无线网卡的属性?如何查看电脑支持WIFI5还是WIFI6?如何查看曾经电脑连过的WIFI密码呢?

3月前

目录 (1)netsh命令简介和用途 (2)netsh(针对网络接口)命令 1sh wlan set tracing mode=yes(开启无线追踪日志) 2sh wlan show drivers 查看电脑无线网卡属性(重点)支持

关于如何解决mac电脑下载pdf之后出现名称乱码的解决方法

3月前

关于如何解决mac电脑下载pdf之后出现名称乱码的解决方法。&#xff08;或解压文件乱码的问题&#xff09; 首先呢&#xff0c;由于工作变更及工作需要(说白了是为了装逼&#xff09;&#

微软Edge浏览器集锦功能卡顿不能添加、无法注释等问题的解决方法

2月前

微软Edge浏览器集锦功能卡顿不能添加、无法注释等问题的解决方法 问题描述 正常情况下&#xff0c;在浏览器上方的标签栏右键任意一个标签页&#xff0c;都会出现“将所有标签页添加到集锦”按钮&#xff0c;按

win10 *** ipv4属性无法查看

2月前

解决方案 http:answers.microsoftzh-hanswindowsforumwindows_10-networking%E5%85%B3%E4%BA%8Ewindows-10fe1e3746-9d9a-442

项目属性的target platform和target platform version到底是什么(vs2015开发windows驱动小记)...

2月前

根据官方对属性页的介绍&#xff08;General Property Page (Project)&#xff09;可了解&#xff1a; target platform是build后的结果会跑在哪个平台&#

windows修改用户文件夹名称 更改用户名 修改C盘Users目录下文件夹名称

2月前

知乎上的更详细版本 windows修改 C:Users用户文件夹名称 把中文名修改为英文名 - 知乎 (zhihu)https:zhuanlan.zhihup509804656 简短的说&#xff1a; 1 - 新建

在线查看html浏览器兼容性,HTML5标签、属性、事件及浏览器兼容性速查表分享

2月前

5 可以说是近十年来 Web 标准最巨大的飞跃。和以前的版本不同&#xff0c; 5 并非仅仅用来表示 Web 内容&#xff0c;它的使命是将 Web 带入一个成熟的应用平台&#xff0c;在这个平台上&#

Windows获取CPU温度 计算机名称

2月前

作者 QQ群&#xff1a;852283276 微信&#xff1a;arm80x86 微信公众号&#xff1a;青儿创客基地 B站&#xff1a;主页 https:space.bilibili2088

Python基础教程第二版 9:魔法方法,属性,迭代器(未完)...

1月前

在Windows系统中,批量复制文件夹下所有或者部分文件的名称

1月前

当在使用Windows系统中&#xff0c;需要批量复制某一个文件夹下所有或者部分文件的名称时&#xff0c;可以使用如下方法&#xff1a; 第一步&#xff1a;打开需要批量复制文件名称的文件夹&

发表评论

全部评论 0
暂无评论