Java Code Examples for java.beans.Introspector#decapitalize()
The following examples show how to use
java.beans.Introspector#decapitalize() .
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: CallbackDescriptor.java From deltaspike with Apache License 2.0 | 6 votes |
private CallbackEntry(Class<?> beanClass, Class<? extends Annotation> callbackMarker) { this.targetBeanClass = beanClass; Named named = this.targetBeanClass.getAnnotation(Named.class); if (named != null && !"".equals(named.value())) { this.beanName = named.value(); } else { //fallback to the default (which might exist) -> TODO check meta-data of Bean<T> this.beanName = Introspector.decapitalize(targetBeanClass.getSimpleName()); } List<String> processedMethodNames = new ArrayList<String>(); findMethodWithCallbackMarker(callbackMarker, beanClass, processedMethodNames); }
Example 2
Source File: PipelineOptionsReflector.java From beam with Apache License 2.0 | 6 votes |
/** * Extract pipeline options and their respective getter methods from a series of {@link Method * methods}. A single pipeline option may appear in many methods. * * @return A mapping of option name to the input methods which declare it. */ static Multimap<String, Method> getPropertyNamesToGetters(Iterable<Method> methods) { Multimap<String, Method> propertyNamesToGetters = HashMultimap.create(); for (Method method : methods) { String methodName = method.getName(); if ((!methodName.startsWith("get") && !methodName.startsWith("is")) || method.getParameterTypes().length != 0 || method.getReturnType() == void.class) { continue; } String propertyName = Introspector.decapitalize( methodName.startsWith("is") ? methodName.substring(2) : methodName.substring(3)); propertyNamesToGetters.put(propertyName, method); } return propertyNamesToGetters; }
Example 3
Source File: CommonAnnotationBeanPostProcessor.java From spring-analysis-note with MIT License | 5 votes |
public ResourceElement(Member member, AnnotatedElement ae, @Nullable PropertyDescriptor pd) { super(member, pd); Resource resource = ae.getAnnotation(Resource.class); String resourceName = resource.name(); Class<?> resourceType = resource.type(); this.isDefaultName = !StringUtils.hasLength(resourceName); if (this.isDefaultName) { resourceName = this.member.getName(); if (this.member instanceof Method && resourceName.startsWith("set") && resourceName.length() > 3) { resourceName = Introspector.decapitalize(resourceName.substring(3)); } } else if (embeddedValueResolver != null) { resourceName = embeddedValueResolver.resolveStringValue(resourceName); } if (Object.class != resourceType) { checkResourceType(resourceType); } else { // No resource type specified... check field/method. resourceType = getResourceType(); } this.name = (resourceName != null ? resourceName : ""); this.lookupType = resourceType; String lookupValue = resource.lookup(); this.mappedName = (StringUtils.hasLength(lookupValue) ? lookupValue : resource.mappedName()); Lazy lazy = ae.getAnnotation(Lazy.class); this.lazyLookup = (lazy != null && lazy.value()); }
Example 4
Source File: SimpleBeanNameGenerator.java From primecloud-controller with GNU General Public License v2.0 | 5 votes |
/** * {@inheritDoc} */ @Override public String generateBeanName(BeanDefinition definition, BeanDefinitionRegistry registry) { String name = definition.getBeanClassName(); int index = name.lastIndexOf("."); if (index != -1) { name = name.substring(index + 1); } if (name.endsWith("Impl")) { name = name.substring(0, name.length() - 4); } name = Introspector.decapitalize(name); return name; }
Example 5
Source File: KebabCasePropertyBeanIntrospector.java From spring-cloud-app-broker with Apache License 2.0 | 5 votes |
/** * Derives the camel-case name of a property from the given set method. * * @param m the method * @return the corresponding property name */ private String camelCasePropertyName(final Method m) { final String methodName = m.getName().substring(WRITE_METHOD_PREFIX.length()); return methodName.length() > 1 ? Introspector.decapitalize(methodName) : methodName.toLowerCase(Locale.ENGLISH); }
Example 6
Source File: AmazonWebserviceClientConfigurationUtils.java From spring-cloud-aws with Apache License 2.0 | 4 votes |
public static String getBeanName(String serviceClassName) { String clientClassName = ClassUtils.getShortName(serviceClassName); String shortenedClassName = StringUtils.delete(clientClassName, SERVICE_IMPLEMENTATION_SUFFIX); return Introspector.decapitalize(shortenedClassName); }
Example 7
Source File: JAXB.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
private static String inferName(Class clazz) { return Introspector.decapitalize(clazz.getSimpleName()); }
Example 8
Source File: ExpressionUtil.java From summerframework with Apache License 2.0 | 4 votes |
public static String expressionToFieldName(Expression expression) { return Introspector.decapitalize(expressionToMethodName(expression).replace("get", "")); }
Example 9
Source File: ExtendedBeanInfo.java From java-technology-stack with MIT License | 4 votes |
private String propertyNameFor(Method method) { return Introspector.decapitalize(method.getName().substring(3, method.getName().length())); }
Example 10
Source File: JAXB.java From openjdk-jdk8u with GNU General Public License v2.0 | 4 votes |
private static String inferName(Class clazz) { return Introspector.decapitalize(clazz.getSimpleName()); }
Example 11
Source File: BeanBuilder.java From deltaspike with Apache License 2.0 | 4 votes |
private String createDefaultBeanName(AnnotatedType<T> type) { Class<T> javaClass = type.getJavaClass(); return Introspector.decapitalize(javaClass.getSimpleName()); }
Example 12
Source File: JaxbBuilder.java From xmlunit with Apache License 2.0 | 4 votes |
private static String inferName(final Class clazz) { return Introspector.decapitalize(clazz.getSimpleName()); }
Example 13
Source File: SingletonServiceFactory.java From light-4j with Apache License 2.0 | 4 votes |
/** * @param interfaceClasses A list of the interfaces implemented by the map. (usually just one though) * @param map Mapping of name of concrete class to its fields (could be field name : value, or list of types to value). * @throws Exception */ private static List<Object> constructAndAddToServiceMap(List<String> interfaceClasses, Map map) throws Exception { Iterator it = map.entrySet().iterator(); List<Object> items = new ArrayList<>(); if (it.hasNext()) { Map.Entry<String, Map<String, Object>> pair = (Map.Entry) it.next(); String key = pair.getKey(); Class implClass = Class.forName(key); Object mapOrList = pair.getValue(); // at this moment, pair.getValue() has two scenarios, // 1. map that can be used to set properties after construct the object with reflection. // 2. list that can be used by matched constructor to create the instance. Object obj; if(mapOrList instanceof Map) { obj = construct(implClass); Method[] allMethods = implClass.getMethods(); for(Method method : allMethods) { if(method.getName().startsWith("set")) { //logger.debug("method name " + method.getName()); Object [] o = new Object [1]; String propertyName = Introspector.decapitalize(method.getName().substring(3)); Object v = ((Map)mapOrList).get(propertyName); if(v == null) { // it is not primitive type, so find the object in service map. Class<?>[] pType = method.getParameterTypes(); v = serviceMap.get(pType[0].getName()); } if(v != null) { o[0] = v; method.invoke(obj, o); } } } } else if(mapOrList instanceof List){ obj = ServiceUtil.constructByParameterizedConstructor(implClass, (List)mapOrList); } else { throw new RuntimeException("Only Map or List is allowed for implementation parameters, null provided."); } items.add(obj); for(String c: interfaceClasses) { serviceMap.put(c, obj); // all interfaces share the same impl } } return items; }
Example 14
Source File: DefaultInstanceManager.java From tomcatsrc with Apache License 2.0 | 4 votes |
@Deprecated public static String getName(Method setter) { // Note: method signature has already been checked for correctness. // The method name always starts with "set". return Introspector.decapitalize(setter.getName().substring(3)); }
Example 15
Source File: DatatablesMetadataProvider.java From gvnix with GNU General Public License v3.0 | 4 votes |
/** * Locates All {@link FinderMetadataDetails} and its related * {@link QueryHolder} for every declared dynamic finder <br> * <br> * <em>Note:</em> This method is similar to * {@link WebMetadataServiceImpl#getDynamicFinderMethodsAndFields(JavaType, MemberDetails, String)} * but without register dependency (this dependency produces NPE in * {@link #getMetadata(String, JavaType, PhysicalTypeMetadata, String)} when * it tries to get JPA information) * * @param entity * @param path * @param entityMemberDetails * @param plural * @param entityName * @return * @see WebMetadataServiceImpl#getDynamicFinderMethodsAndFields(JavaType, * MemberDetails, String) */ private Map<FinderMetadataDetails, QueryHolderTokens> getFindersRegisterd( JavaType entity, LogicalPath path, MemberDetails entityMemberDetails, String plural, String entityName) { // Get finder metadata final String finderMetadataKey = FinderMetadata.createIdentifier( entity, path); final FinderMetadata finderMetadata = (FinderMetadata) getMetadataService() .get(finderMetadataKey); if (finderMetadata == null) { return null; } QueryHolderTokens queryHolder; FinderMetadataDetails details; Map<FinderMetadataDetails, QueryHolderTokens> findersRegistered = new HashMap<FinderMetadataDetails, QueryHolderTokens>(); // Iterate over for (final MethodMetadata method : finderMetadata .getAllDynamicFinders()) { final List<JavaSymbolName> parameterNames = method .getParameterNames(); final List<JavaType> parameterTypes = AnnotatedJavaType .convertFromAnnotatedJavaTypes(method.getParameterTypes()); final List<FieldMetadata> fields = new ArrayList<FieldMetadata>(); for (int i = 0; i < parameterTypes.size(); i++) { JavaSymbolName fieldName = null; if (parameterNames.get(i).getSymbolName().startsWith("max") || parameterNames.get(i).getSymbolName() .startsWith("min")) { fieldName = new JavaSymbolName( Introspector.decapitalize(StringUtils .capitalize(parameterNames.get(i) .getSymbolName().substring(3)))); } else { fieldName = parameterNames.get(i); } final FieldMetadata field = BeanInfoUtils .getFieldForPropertyName(entityMemberDetails, fieldName); if (field != null) { final FieldMetadataBuilder fieldMd = new FieldMetadataBuilder( field); fieldMd.setFieldName(parameterNames.get(i)); fields.add(fieldMd.build()); } } details = new FinderMetadataDetails(method.getMethodName() .getSymbolName(), method, fields); // locate QueryHolder instances. This objects contain // information about a roo finder (parameters names and types // and a "token" list with of find definition queryHolder = getQueryHolder(entityMemberDetails, method.getMethodName(), plural, entityName); findersRegistered.put(details, queryHolder); } return findersRegistered; }
Example 16
Source File: JAXB.java From Java8CN with Apache License 2.0 | 4 votes |
private static String inferName(Class clazz) { return Introspector.decapitalize(clazz.getSimpleName()); }
Example 17
Source File: ClassUtils.java From nd4j with Apache License 2.0 | 4 votes |
public static String getShortNameAsProperty(Class<?> clazz) { String shortName = getShortName((Class) clazz); int dotIndex = shortName.lastIndexOf(46); shortName = dotIndex != -1 ? shortName.substring(dotIndex + 1) : shortName; return Introspector.decapitalize(shortName); }
Example 18
Source File: RpcDefinitionPostProcessor.java From joyrpc with Apache License 2.0 | 4 votes |
/** * 处理服务提供者注解 * * @param definition bean定义 * @param registry 注册中心 */ protected void processProviderAnnotation(final BeanDefinition definition, BeanDefinitionRegistry registry) { String className = definition.getBeanClassName(); if (isEmpty(className)) { return; } Class<?> providerClass = resolveClassName(className, classLoader); //查找服务提供者注解 Class<?> targetClass = providerClass; Pair<AnnotationProvider<Annotation, Annotation>, Annotation> pair = null; while (targetClass != null && targetClass != Object.class) { pair = getProviderAnnotation(targetClass); if (pair != null) { break; } targetClass = targetClass.getSuperclass(); } if (pair != null) { ProviderBean<?> provider = pair.getKey().toProviderBean(pair.getValue(), environment); //获取接口类名 Class<?> interfaceClazz = provider.getInterfaceClass(() -> getInterfaceClass(providerClass)); if (interfaceClazz == null) { //没有找到接口 throw new BeanInitializationException("there is not any interface in class " + providerClass); } //获取服务实现类的Bean名称 String refName = getComponentName(providerClass); if (refName == null) { refName = Introspector.decapitalize(getShortName(providerClass.getName())); //注册服务实现对象 if (!registry.containsBeanDefinition(refName)) { registry.registerBeanDefinition(refName, definition); } } if (isEmpty(provider.getId())) { provider.setId(PROVIDER_PREFIX + refName); } //添加provider addProvider(provider, interfaceClazz, refName); } }
Example 19
Source File: ClassUtils.java From spring4-understanding with Apache License 2.0 | 3 votes |
/** * Return the short string name of a Java class in uncapitalized JavaBeans * property format. Strips the outer class name in case of an inner class. * @param clazz the class * @return the short name rendered in a standard JavaBeans property format * @see java.beans.Introspector#decapitalize(String) */ public static String getShortNameAsProperty(Class<?> clazz) { String shortName = ClassUtils.getShortName(clazz); int dotIndex = shortName.lastIndexOf(PACKAGE_SEPARATOR); shortName = (dotIndex != -1 ? shortName.substring(dotIndex + 1) : shortName); return Introspector.decapitalize(shortName); }
Example 20
Source File: ClassUtils.java From java-technology-stack with MIT License | 3 votes |
/** * Return the short string name of a Java class in uncapitalized JavaBeans * property format. Strips the outer class name in case of an inner class. * @param clazz the class * @return the short name rendered in a standard JavaBeans property format * @see java.beans.Introspector#decapitalize(String) */ public static String getShortNameAsProperty(Class<?> clazz) { String shortName = getShortName(clazz); int dotIndex = shortName.lastIndexOf(PACKAGE_SEPARATOR); shortName = (dotIndex != -1 ? shortName.substring(dotIndex + 1) : shortName); return Introspector.decapitalize(shortName); }