private ExpressionValueNamedValueInfo(Value annotation) { super("@Value", false, annotation.value()); } }
private ExpressionValueNamedValueInfo(Value annotation) { super("@Value", false, annotation.value()); } }
private ExpressionValueNamedValueInfo(Value annotation) { super("@Value", false, annotation.value()); } }
@Override protected void processField(Object bean, String beanName, Field field) { // register @Value on field Value value = field.getAnnotation(Value.class); if (value == null) { return; } Set<String> keys = placeholderHelper.extractPlaceholderKeys(value.value()); if (keys.isEmpty()) { return; } for (String key : keys) { SpringValue springValue = new SpringValue(key, value.value(), bean, beanName, field, false); springValueRegistry.register(beanFactory, key, springValue); logger.debug("Monitoring {}", springValue); } }
@Override protected void processMethod(Object bean, String beanName, Method method) { //register @Value on method Value value = method.getAnnotation(Value.class); if (value == null) { return; } //skip Configuration bean methods if (method.getAnnotation(Bean.class) != null) { return; } if (method.getParameterTypes().length != 1) { logger.error("Ignore @Value setter {}.{}, expecting 1 parameter, actual {} parameters", bean.getClass().getName(), method.getName(), method.getParameterTypes().length); return; } Set<String> keys = placeholderHelper.extractPlaceholderKeys(value.value()); if (keys.isEmpty()) { return; } for (String key : keys) { SpringValue springValue = new SpringValue(key, value.value(), bean, beanName, method, false); springValueRegistry.register(beanFactory, key, springValue); logger.info("Monitoring {}", springValue); } }
/** * Inspects a potentially available {@link Value} annotation at the property and returns the {@link String} value of * it. * * @see org.springframework.data.mapping.model.AbstractPersistentProperty#getSpelExpression() */ public String getSpelExpression() { return value == null ? null : value.value(); }
private ExpressionValueNamedValueInfo(Value annotation) { super("@Value", false, annotation.value()); } }
private ExpressionValueNamedValueInfo(Value annotation) { super("@Value", false, annotation.value()); } }
private ExpressionValueNamedValueInfo(Value annotation) { super("@Value", false, annotation.value()); } }
private String getValue(Annotation[] annotations) { for (Annotation anno : annotations) { if (anno.annotationType() == Value.class) { return ((Value) anno).value(); } } return null; }
@Override public String getValue(Object annotation) { Value value = Value.class.cast(annotation); return value.value().replaceAll("\\:.*\\}", "}"); } }
private static String getValue(Annotation[] annotations) { return Arrays.stream(annotations)// .filter(it -> it.annotationType() == Value.class)// .findFirst().map(it -> ((Value) it).value())// .filter(StringUtils::hasText).orElse(null); }
@Override public void doWith(Field field) throws IllegalArgumentException, IllegalAccessException { if (field.isAnnotationPresent(Value.class)) { // we must skip final fields if (Modifier.isFinal(field.getModifiers())) { LOG.warn("Field " + field.getName() + " of bean " + beanName + " defines @Value annotation, although it's declared as final. This field can not be updated if its property value is changed."); return; } Value value = field.getAnnotation(Value.class); String placeholder = value.value(); int startChar = placeholder.indexOf('{'); int endChar = placeholder.indexOf('}'); String property; if ((startChar > 0) && (endChar > startChar)) { property = placeholder.substring(startChar + 1, endChar); } else { property = placeholder; } ReflectionUtils.makeAccessible(field); PropertyUpdateFieldInfo fieldInfo = new PropertyUpdateFieldInfo(realBeanFinal, field, property); fieldInfoList.add(fieldInfo); } } });
/** * Eagerly parses {@link Expression} defined on {@link Value} annotations. Returns a map with * {@code method.hashCode()} as key and the parsed {@link Expression} or an {@link Collections#emptyMap()} if no * {@code Expressions} were found. * * @param parser must not be {@literal null}. * @param targetInterface must not be {@literal null}. * @return */ private static Map<Integer, Expression> potentiallyCreateExpressionsForMethodsOnTargetInterface( SpelExpressionParser parser, Class<?> targetInterface) { Map<Integer, Expression> expressions = new HashMap<>(); for (Method method : targetInterface.getMethods()) { if (!method.isAnnotationPresent(Value.class)) { continue; } Value value = method.getAnnotation(Value.class); if (!StringUtils.hasText(value.value())) { throw new IllegalStateException(String.format("@Value annotation on %s contains empty expression!", method)); } expressions.put(method.hashCode(), parser.parseExpression(value.value(), PARSER_CONTEXT)); } return Collections.unmodifiableMap(expressions); }
attrName = anno.value(); if(attrName!=null){ if(attrName.startsWith("$")){
/** * Creates a new {@link AnnotationBasedPersistentProperty}. * * @param property must not be {@literal null}. * @param owner must not be {@literal null}. */ public AnnotationBasedPersistentProperty(Property property, PersistentEntity<?, P> owner, SimpleTypeHolder simpleTypeHolder) { super(property, owner, simpleTypeHolder); populateAnnotationCache(property); Value value = findAnnotation(Value.class); this.value = value == null ? null : value.value(); }
defaultValue = ((Value) paramAnn).value();