Java 类com.fasterxml.jackson.databind.introspect.AnnotatedMethod 实例源码

项目:crnk-framework    文件:JacksonResourceFieldInformationProvider.java   
protected Optional<String> getName(Method method) {
    ObjectMapper objectMapper = context.getObjectMapper();
    SerializationConfig serializationConfig = objectMapper.getSerializationConfig();
    if (serializationConfig != null && serializationConfig.getPropertyNamingStrategy() != null) {
        String name = ClassUtils.getGetterFieldName(method);
        Annotation[] declaredAnnotations = method.getDeclaredAnnotations();
        AnnotationMap annotationMap = buildAnnotationMap(declaredAnnotations);

        int paramsLength = method.getParameterAnnotations().length;
        AnnotationMap[] paramAnnotations = new AnnotationMap[paramsLength];
        for (int i = 0; i < paramsLength; i++) {
            AnnotationMap parameterAnnotationMap = buildAnnotationMap(method.getParameterAnnotations()[i]);
            paramAnnotations[i] = parameterAnnotationMap;
        }

        AnnotatedClass annotatedClass = AnnotatedClassBuilder.build(method.getDeclaringClass(), serializationConfig);
        AnnotatedMethod annotatedField = AnnotatedMethodBuilder.build(annotatedClass, method, annotationMap, paramAnnotations);
        return Optional.of(serializationConfig.getPropertyNamingStrategy().nameForGetterMethod(serializationConfig, annotatedField, name));
    }
    return Optional.empty();
}
项目:jackson-dataformat-velocypack    文件:VPackSerializeDeserializeTest.java   
@Test
public void fieldNamingStrategySerialize() throws IOException {
    final ObjectMapper mapper = new VPackMapper();
    mapper.setPropertyNamingStrategy(new PropertyNamingStrategy() {
        private static final long serialVersionUID = 1L;

        @Override
        public String nameForGetterMethod(
            final MapperConfig<?> config,
            final AnnotatedMethod method,
            final String defaultName) {
            return "bla";
        }
    });
    final VPackSlice vpack = new VPackSlice(mapper.writeValueAsBytes(new TestEntityA()));
    assertThat(vpack, is(notNullValue()));
    assertThat(vpack.isObject(), is(true));
    final VPackSlice bla = vpack.get("bla");
    assertThat(bla.isString(), is(true));
    assertThat(bla.getAsString(), is("a"));
}
项目:jackson-dataformat-velocypack    文件:VPackSerializeDeserializeTest.java   
@Test
public void fieldNamingStrategyDeserialize() throws IOException {
    final VPackBuilder builder = new VPackBuilder();
    builder.add(ValueType.OBJECT);
    builder.add("bla", "test");
    builder.close();
    final ObjectMapper mapper = new VPackMapper();
    mapper.setPropertyNamingStrategy(new PropertyNamingStrategy() {
        private static final long serialVersionUID = 1L;

        @Override
        public String nameForSetterMethod(
            final MapperConfig<?> config,
            final AnnotatedMethod method,
            final String defaultName) {
            return "bla";
        }
    });
    final TestEntityA entity = mapper.readValue(builder.slice().getBuffer(), TestEntityA.class);
    assertThat(entity, is(notNullValue()));
    assertThat(entity.a, is("test"));
}
项目:katharsis-framework    文件:ResourceFieldNameTransformer.java   
/**
 * Extract name to be used by Katharsis from getter's name. It uses
 * {@link ResourceFieldNameTransformer#getMethodName(Method)}, {@link JsonProperty} annotation and
 * {@link PropertyNamingStrategy}.
 *
 * @param method method to extract name
 * @return method name
 */
public String getName(Method method) {
    String name = getMethodName(method);

    if (method.isAnnotationPresent(JsonProperty.class) &&
        !"".equals(method.getAnnotation(JsonProperty.class).value())) {
        name = method.getAnnotation(JsonProperty.class).value();
    } else if (serializationConfig != null && serializationConfig.getPropertyNamingStrategy() != null) {
        Annotation[] declaredAnnotations = method.getDeclaredAnnotations();
        AnnotationMap annotationMap = buildAnnotationMap(declaredAnnotations);

        int paramsLength = method.getParameterAnnotations().length;
        AnnotationMap[] paramAnnotations = new AnnotationMap[paramsLength];
        for (int i = 0; i < paramsLength; i++) {
            AnnotationMap parameterAnnotationMap = buildAnnotationMap(method.getParameterAnnotations()[i]);
            paramAnnotations[i] = parameterAnnotationMap;
        }

        AnnotatedClass annotatedClass = AnnotatedClassBuilder.build(method.getDeclaringClass(), serializationConfig);
        AnnotatedMethod annotatedField = AnnotatedMethodBuilder.build(annotatedClass, method, annotationMap, paramAnnotations);
        name = serializationConfig.getPropertyNamingStrategy().nameForGetterMethod(serializationConfig, annotatedField, name);
    }
    return name;
}
项目:haven-platform    文件:JtModule.java   
@Override
public Object findDeserializationConverter(Annotated a) {
    JtToMap ann = a.getAnnotation(JtToMap.class);
    if (ann == null) {
        return null;
    }
    JavaType javaType = a.getType();
    if(a instanceof AnnotatedMethod) {
        AnnotatedMethod am = (AnnotatedMethod) a;
        if(am.getParameterCount() == 1) {
            javaType = am.getParameterType(0);
        } else {
            throw new RuntimeException("Invalid property setter: " + am.getAnnotated());
        }
    }
    return new DeserializationConverterImpl(ann, new Ctx(a, javaType));
}
项目:haven-platform    文件:KvSupportModule.java   
@Override
public Object findDeserializationConverter(Annotated a) {
    Class<? extends PropertyInterceptor>[] interceptors = getInterceptors(a);
    if (interceptors == null) {
        return null;
    }
    JavaType javaType = a.getType();
    if(a instanceof AnnotatedMethod) {
        AnnotatedMethod am = (AnnotatedMethod) a;
        if(am.getParameterCount() == 1) {
            javaType = am.getParameterType(0);
        } else {
            throw new RuntimeException("Invalid property setter: " + am.getAnnotated());
        }
    }
    return new KvInterceptorsDeserializationConverter(interceptors, new KvPropertyContextImpl(a, javaType));
}
项目:jackson-modules-java8    文件:JavaTimeModule.java   
protected AnnotatedMethod _findFactory(AnnotatedClass cls, String name, Class<?>... argTypes)
{
    final int argCount = argTypes.length;
    for (AnnotatedMethod method : cls.getFactoryMethods()) {
        if (!name.equals(method.getName())
                || (method.getParameterCount() != argCount)) {
            continue;
        }
        for (int i = 0; i < argCount; ++i) {
            Class<?> argType = method.getParameter(i).getRawType();
            if (!argType.isAssignableFrom(argTypes[i])) {
                continue;
            }
        }
        return method;
    }
    return null;
}
项目:evt-bridge    文件:ElasticSearchAnnotationIntrospector.java   
@Override
public PropertyName findNameForSerialization(Annotated a) {
    if (!(a instanceof AnnotatedField) && !(a instanceof AnnotatedMethod)) {
        return super.findNameForSerialization(a);
    }

    IndexableProperty property = a.getAnnotation(IndexableProperty.class);
    if (property != null && !property.name().isEmpty()) {
        return new PropertyName(property.name());
    }

    IndexableComponent component = a.getAnnotation(IndexableComponent.class);
    if (component != null && !component.name().isEmpty()) {
        return new PropertyName(component.name());
    }

    IndexableProperties properties = a.getAnnotation(IndexableProperties.class);
    if (properties != null && !properties.name().isEmpty()) {
        return new PropertyName(properties.name());
    }

    return PropertyName.USE_DEFAULT;
}
项目:evt-bridge    文件:ElasticSearchAnnotationIntrospector.java   
@Override
public PropertyName findNameForDeserialization(Annotated a) {
    if (!(a instanceof AnnotatedField) && !(a instanceof AnnotatedMethod)) {
        return super.findNameForDeserialization(a);
    }

    IndexableProperty property = a.getAnnotation(IndexableProperty.class);
    if (property != null && !property.name().isEmpty()) {
        return new PropertyName(property.name());
    }

    IndexableComponent component = a.getAnnotation(IndexableComponent.class);
    if (component != null && !component.name().isEmpty()) {
        return new PropertyName(component.name());
    }

    IndexableProperties properties = a.getAnnotation(IndexableProperties.class);
    if (properties != null && !properties.name().isEmpty()) {
        return new PropertyName(properties.name());
    }

    return PropertyName.USE_DEFAULT;
}
项目:bootique    文件:BQTimeModule.java   
protected AnnotatedMethod _findFactory(AnnotatedClass cls, String name, Class<?>... argTypes) {
    final int argCount = argTypes.length;
    for (AnnotatedMethod method : cls.getStaticMethods()) {
        if (!name.equals(method.getName())
                || (method.getParameterCount() != argCount)) {
            continue;
        }
        for (int i = 0; i < argCount; ++i) {
            Class<?> argType = method.getParameter(i).getRawType();
            if (!argType.isAssignableFrom(argTypes[i])) {
                continue;
            }
        }
        return method;
    }
    return null;
}
项目:spring-data-dev-tools    文件:IssueTrackerConfiguration.java   
@Override
public void setupModule(SetupContext context) {

    context.insertAnnotationIntrospector(new NopAnnotationIntrospector() {

        private static final long serialVersionUID = 479313244908256455L;

        @Override
        public boolean hasIgnoreMarker(AnnotatedMember m) {

            if (!(m instanceof AnnotatedMethod)) {
                return super.hasIgnoreMarker(m);
            }

            AnnotatedMethod method = (AnnotatedMethod) m;

            return method.getName().startsWith("lambda$") ? true : super.hasIgnoreMarker(m);
        }
    });
}
项目:NyBatisCore    文件:ColumnAnnotationInspector.java   
@Override
public Object findDeserializer( Annotated annotated ) {

    if( ! annotated.hasAnnotation(Column.class) || ! isStringType(annotated) ) {
        return super.findDeserializer( annotated );
    }

    Class classType;
    try {
        classType = ( (AnnotatedMethod) annotated ).getRawParameterType( 0 );
    } catch( Exception e ) {
        classType = annotated.getRawType();
    }

    if( Types.isNotString(classType) ) {
        if( Types.isBoolean(classType) ) {
            return ColumnBooleanDeserializer.class;
        } else if( ! Types.isPrimitive(classType) ) {
            return ColumnBeanDeserializer.class;
        }
    }

    return super.findDeserializer( annotated );

}
项目:QuizUpWinner    文件:EnumDeserializer.java   
public static JsonDeserializer<?> deserializerForCreator(DeserializationConfig paramDeserializationConfig, Class<?> paramClass, AnnotatedMethod paramAnnotatedMethod)
{
  Class localClass = paramAnnotatedMethod.getRawParameterType(0);
  Object localObject;
  if (localClass == String.class)
    localObject = null;
  else if ((localClass == Integer.TYPE) || (localClass == Integer.class))
    localObject = Integer.class;
  else if ((localClass == Long.TYPE) || (localClass == Long.class))
    localObject = Long.class;
  else
    throw new IllegalArgumentException("Parameter #0 type for factory method (" + paramAnnotatedMethod + ") not suitable, must be java.lang.String or int/Integer/long/Long");
  if (paramDeserializationConfig.canOverrideAccessModifiers())
    ClassUtil.checkAndFixAccess(paramAnnotatedMethod.getMember());
  return new FactoryBasedDeserializer(paramClass, paramAnnotatedMethod, (Class)localObject);
}
项目:QuizUpWinner    文件:BeanDeserializerFactory.java   
protected void addReferenceProperties(DeserializationContext paramDeserializationContext, BeanDescription paramBeanDescription, BeanDeserializerBuilder paramBeanDeserializerBuilder)
{
  Map localMap = paramBeanDescription.findBackReferenceProperties();
  if (localMap != null)
  {
    Iterator localIterator = localMap.entrySet().iterator();
    while (localIterator.hasNext())
    {
      Map.Entry localEntry = (Map.Entry)localIterator.next();
      String str = (String)localEntry.getKey();
      AnnotatedMember localAnnotatedMember = (AnnotatedMember)localEntry.getValue();
      Object localObject;
      if ((localAnnotatedMember instanceof AnnotatedMethod))
        localObject = ((AnnotatedMethod)localAnnotatedMember).getGenericParameterType(0);
      else
        localObject = localAnnotatedMember.getRawType();
      paramBeanDeserializerBuilder.addBackReferenceProperty(str, constructSettableProperty(paramDeserializationContext, paramBeanDescription, SimpleBeanPropertyDefinition.construct(paramDeserializationContext.getConfig(), localAnnotatedMember), (Type)localObject));
    }
  }
}
项目:QuizUpWinner    文件:BeanDeserializerFactory.java   
protected SettableBeanProperty constructSettableProperty(DeserializationContext paramDeserializationContext, BeanDescription paramBeanDescription, BeanPropertyDefinition paramBeanPropertyDefinition, Type paramType)
{
  AnnotatedMember localAnnotatedMember = paramBeanPropertyDefinition.getMutator();
  if (paramDeserializationContext.canOverrideAccessModifiers())
    localAnnotatedMember.fixAccess();
  JavaType localJavaType1 = paramBeanDescription.resolveType(paramType);
  BeanProperty.Std localStd = new BeanProperty.Std(paramBeanPropertyDefinition.getName(), localJavaType1, paramBeanPropertyDefinition.getWrapperName(), paramBeanDescription.getClassAnnotations(), localAnnotatedMember, paramBeanPropertyDefinition.isRequired());
  JavaType localJavaType2 = resolveType(paramDeserializationContext, paramBeanDescription, localJavaType1, localAnnotatedMember);
  if (localJavaType2 != localJavaType1)
    localStd.withType(localJavaType2);
  JsonDeserializer localJsonDeserializer = findDeserializerFromAnnotation(paramDeserializationContext, localAnnotatedMember);
  JavaType localJavaType3 = modifyTypeByAnnotation(paramDeserializationContext, localAnnotatedMember, localJavaType2);
  TypeDeserializer localTypeDeserializer = (TypeDeserializer)localJavaType3.getTypeHandler();
  Object localObject;
  if ((localAnnotatedMember instanceof AnnotatedMethod))
    localObject = new MethodProperty(paramBeanPropertyDefinition, localJavaType3, localTypeDeserializer, paramBeanDescription.getClassAnnotations(), (AnnotatedMethod)localAnnotatedMember);
  else
    localObject = new FieldProperty(paramBeanPropertyDefinition, localJavaType3, localTypeDeserializer, paramBeanDescription.getClassAnnotations(), (AnnotatedField)localAnnotatedMember);
  if (localJsonDeserializer != null)
    localObject = ((SettableBeanProperty)localObject).withValueDeserializer(localJsonDeserializer);
  AnnotationIntrospector.ReferenceProperty localReferenceProperty = paramBeanPropertyDefinition.findReferenceType();
  if ((localReferenceProperty != null) && (localReferenceProperty.isManagedReference()))
    ((SettableBeanProperty)localObject).setManagedReferenceName(localReferenceProperty.getName());
  return localObject;
}
项目:QuizUpWinner    文件:AnnotationIntrospector.java   
public PropertyName findNameForDeserialization(Annotated paramAnnotated)
{
  String str;
  if ((paramAnnotated instanceof AnnotatedField))
    str = findDeserializationName((AnnotatedField)paramAnnotated);
  else if ((paramAnnotated instanceof AnnotatedMethod))
    str = findDeserializationName((AnnotatedMethod)paramAnnotated);
  else if ((paramAnnotated instanceof AnnotatedParameter))
    str = findDeserializationName((AnnotatedParameter)paramAnnotated);
  else
    str = null;
  if (str != null)
  {
    if (str.length() == 0)
      return PropertyName.USE_DEFAULT;
    return new PropertyName(str);
  }
  return null;
}
项目:QuizUpWinner    文件:AnnotationIntrospector.java   
public PropertyName findNameForSerialization(Annotated paramAnnotated)
{
  String str;
  if ((paramAnnotated instanceof AnnotatedField))
    str = findSerializationName((AnnotatedField)paramAnnotated);
  else if ((paramAnnotated instanceof AnnotatedMethod))
    str = findSerializationName((AnnotatedMethod)paramAnnotated);
  else
    str = null;
  if (str != null)
  {
    if (str.length() == 0)
      return PropertyName.USE_DEFAULT;
    return new PropertyName(str);
  }
  return null;
}
项目:joyplus-tv    文件:EnumDeserializer.java   
/**
 * Factory method used when Enum instances are to be deserialized
 * using a creator (static factory method)
 * 
 * @return Deserializer based on given factory method, if type was suitable;
 *  null if type can not be used
 */
public static JsonDeserializer<?> deserializerForCreator(DeserializationConfig config,
        Class<?> enumClass, AnnotatedMethod factory)
{

    // note: caller has verified there's just one arg; but we must verify its type
    Class<?> paramClass = factory.getRawParameterType(0);
    if (paramClass == String.class) {
        paramClass = null;
    } else  if (paramClass == Integer.TYPE || paramClass == Integer.class) {
        paramClass = Integer.class;
    } else  if (paramClass == Long.TYPE || paramClass == Long.class) {
        paramClass = Long.class;
    } else {
        throw new IllegalArgumentException("Parameter #0 type for factory method ("+factory
                +") not suitable, must be java.lang.String or int/Integer/long/Long");
    }
    if (config.canOverrideAccessModifiers()) {
        ClassUtil.checkAndFixAccess(factory.getMember());
    }
    return new FactoryBasedDeserializer(enumClass, factory, paramClass);
}
项目:joyplus-tv    文件:BeanUtil.java   
public static String okNameForRegularGetter(AnnotatedMethod am, String name)
{
    if (name.startsWith("get")) {
        /* 16-Feb-2009, tatu: To handle [JACKSON-53], need to block
         *   CGLib-provided method "getCallbacks". Not sure of exact
         *   safe criteria to get decent coverage without false matches;
         *   but for now let's assume there's no reason to use any 
         *   such getter from CGLib.
         *   But let's try this approach...
         */
        if ("getCallbacks".equals(name)) {
            if (isCglibGetCallbacks(am)) {
                return null;
            }
        } else if ("getMetaClass".equals(name)) {
            /* 30-Apr-2009, tatu: [JACKSON-103], need to suppress
             *    serialization of a cyclic (and useless) reference
             */
            if (isGroovyMetaClassGetter(am)) {
                return null;
            }
        }
        return manglePropertyName(name.substring(3));
    }
    return null;
}
项目:joyplus-tv    文件:BeanUtil.java   
/**
 * This method was added to address [JACKSON-53]: need to weed out
 * CGLib-injected "getCallbacks". 
 * At this point caller has detected a potential getter method
 * with name "getCallbacks" and we need to determine if it is
 * indeed injectect by Cglib. We do this by verifying that the
 * result type is "net.sf.cglib.proxy.Callback[]"
 *<p>
 * Also, see [JACKSON-177]; Hibernate may repackage cglib
 * it uses, so we better catch that too
 */
protected static boolean isCglibGetCallbacks(AnnotatedMethod am)
{
    Class<?> rt = am.getRawType();
    // Ok, first: must return an array type
    if (rt == null || !rt.isArray()) {
        return false;
    }
    /* And that type needs to be "net.sf.cglib.proxy.Callback".
     * Theoretically could just be a type that implements it, but
     * for now let's keep things simple, fix if need be.
     */
    Class<?> compType = rt.getComponentType();
    // Actually, let's just verify it's a "net.sf.cglib.*" class/interface
    Package pkg = compType.getPackage();
    if (pkg != null) {
        String pname = pkg.getName();
        if (pname.startsWith("net.sf.cglib")
            // also, as per [JACKSON-177]
            || pname.startsWith("org.hibernate.repackage.cglib")) {
            return true;
        }
    }
    return false;
}
项目:crnk-framework    文件:AnnotatedMethodBuilder.java   
public static AnnotatedMethod build(final AnnotatedClass annotatedClass, final Method method,
        final AnnotationMap annotationMap,
        final AnnotationMap[] paramAnnotations) {

    final Constructor<?> constructor = AnnotatedMethod.class.getConstructors()[0];

    return ExceptionUtil.wrapCatchedExceptions(new Callable<AnnotatedMethod>() {
        @Override
        public AnnotatedMethod call() throws Exception {
            return buildAnnotatedField(annotatedClass, method, annotationMap, paramAnnotations, constructor);
        }
    }, "Exception while building AnnotatedMethod");
}
项目:crnk-framework    文件:AnnotatedMethodBuilder.java   
private static AnnotatedMethod buildAnnotatedField(AnnotatedClass annotatedClass, Method method,
        AnnotationMap annotationMap, AnnotationMap[] paramAnnotations,
        Constructor<?> constructor)
        throws IllegalAccessException, InstantiationException, InvocationTargetException {
    Class<?> firstParameterType = constructor.getParameterTypes()[0];

    PreconditionUtil.assertTrue(CANNOT_FIND_PROPER_CONSTRUCTOR,
            firstParameterType == AnnotatedClass.class || TypeResolutionContext.class.equals(firstParameterType));
    return (AnnotatedMethod) constructor.newInstance(annotatedClass, method, annotationMap, paramAnnotations);
}
项目:ARCLib    文件:Gatherer.java   
private boolean isReadable(BeanDescription beanDesc, BeanPropertyWriter writer) {
    String parentType = beanDesc.getType().getRawClass().getName();
    String type = writer.getPropertyType().getName();
    AnnotatedMethod setter = findSetter(beanDesc, writer);
    // If there's a setter, we assume it's OK to report on the value,
    // similarly, if there's no setter but the package names match, we assume
    // that its a nested class used solely for binding to config props, so it
    // should be kosher. This filter is not used if there is JSON metadata for
    // the property, so it's mainly for user-defined beans.
    return (setter != null) || ClassUtils.getPackageName(parentType)
            .equals(ClassUtils.getPackageName(type));
}
项目:ARCLib    文件:Gatherer.java   
private AnnotatedMethod findSetter(BeanDescription beanDesc,
                                   BeanPropertyWriter writer) {
    String name = "set" + StringUtils.capitalize(writer.getName());
    Class<?> type = writer.getPropertyType();
    AnnotatedMethod setter = beanDesc.findMethod(name, new Class<?>[] { type });
    // The enabled property of endpoints returns a boolean primitive but is set
    // using a Boolean class
    if (setter == null && type.equals(Boolean.TYPE)) {
        setter = beanDesc.findMethod(name, new Class<?>[] { Boolean.class });
    }
    return setter;
}
项目:soundwave    文件:EsPropertyNamingStrategy.java   
@Override
public String nameForGetterMethod(MapperConfig<?> config, AnnotatedMethod method,
                                  String defaultName) {
  if (method.getDeclaringClass() == this.effectiveType) {
    return fieldToJsonMapping
        .getOrDefault(defaultName, super.nameForGetterMethod(config, method, defaultName));
  } else {
    return super.nameForGetterMethod(config, method, defaultName);
  }
}
项目:soundwave    文件:EsPropertyNamingStrategy.java   
@Override
public String nameForSetterMethod(MapperConfig<?> config, AnnotatedMethod method,
                                  String defaultName) {
  if (method.getDeclaringClass() == this.effectiveType) {
    return fieldToJsonMapping
        .getOrDefault(defaultName, super.nameForSetterMethod(config, method, defaultName));
  } else {
    return super.nameForSetterMethod(config, method, defaultName);
  }
}
项目:friendly-id    文件:FriendlyIdAnnotationIntrospector.java   
protected Class<?> rawDeserializationType(Annotated a) {
    if (a instanceof AnnotatedMethod) {
        AnnotatedMethod am = (AnnotatedMethod) a;
        if (am.getParameterCount() == 1) {
            return am.getRawParameterType(0);
        }
    }
    return a.getRawType();
}
项目:mblog    文件:JsonUtils.java   
@Override
public Object findSerializer(Annotated a) {
    if (a instanceof AnnotatedMethod) {
        AnnotatedElement m = a.getAnnotated();
        DateTimeFormat an = m.getAnnotation(DateTimeFormat.class);
        if (an != null) {
            if (!DEFAULT_DATE_FORMAT.equals(an.pattern())) {
                return new JsonDateSerializer(an.pattern());
            }
        }
    }
    return super.findSerializer(a);
}
项目:katharsis-framework    文件:AnnotatedMethodBuilder.java   
public static AnnotatedMethod build(AnnotatedClass annotatedClass, Method method, AnnotationMap annotationMap,
                                    AnnotationMap[] paramAnnotations) {
    for(Constructor<?> constructor : AnnotatedMethod.class.getConstructors()) {
        try {
            return buildAnnotatedField(annotatedClass, method, annotationMap, paramAnnotations, constructor);
        } catch (IllegalAccessException | InstantiationException | InvocationTargetException e) {
            throw new InternalException("Exception while building " + AnnotatedMethod.class.getCanonicalName(), e);
        }
    }
    throw new InternalException(CANNOT_FIND_PROPER_CONSTRUCTOR);
}
项目:katharsis-framework    文件:AnnotatedMethodBuilder.java   
private static AnnotatedMethod buildAnnotatedField(AnnotatedClass annotatedClass, Method method,
                                                   AnnotationMap annotationMap, AnnotationMap[] paramAnnotations,
                                                   Constructor<?> constructor)
        throws IllegalAccessException, InstantiationException, InvocationTargetException {
    Class<?> firstParameterType = constructor.getParameterTypes()[0];
    if (firstParameterType == AnnotatedClass.class ||
            "TypeResolutionContext".equals(firstParameterType.getSimpleName())) {
        return (AnnotatedMethod) constructor.newInstance(annotatedClass, method, annotationMap, paramAnnotations);
    } else {
        throw new InternalException(CANNOT_FIND_PROPER_CONSTRUCTOR);
    }
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ConfigurationPropertiesReportEndpoint.java   
private boolean isReadable(BeanDescription beanDesc, BeanPropertyWriter writer) {
    Class<?> parentType = beanDesc.getType().getRawClass();
    Class<?> type = writer.getType().getRawClass();
    AnnotatedMethod setter = findSetter(beanDesc, writer);
    // If there's a setter, we assume it's OK to report on the value,
    // similarly, if there's no setter but the package names match, we assume
    // that its a nested class used solely for binding to config props, so it
    // should be kosher. This filter is not used if there is JSON metadata for
    // the property, so it's mainly for user-defined beans.
    return (setter != null) || ClassUtils.getPackageName(parentType)
            .equals(ClassUtils.getPackageName(type));
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:ConfigurationPropertiesReportEndpoint.java   
private AnnotatedMethod findSetter(BeanDescription beanDesc,
        BeanPropertyWriter writer) {
    String name = "set" + StringUtils.capitalize(writer.getName());
    Class<?> type = writer.getType().getRawClass();
    AnnotatedMethod setter = beanDesc.findMethod(name, new Class<?>[] { type });
    // The enabled property of endpoints returns a boolean primitive but is set
    // using a Boolean class
    if (setter == null && type.equals(Boolean.TYPE)) {
        setter = beanDesc.findMethod(name, new Class<?>[] { Boolean.class });
    }
    return setter;
}
项目:https-github.com-g0t4-jenkins2-course-spring-boot    文件:DataSourceJsonSerializationTests.java   
@Override
public List<BeanPropertyWriter> changeProperties(SerializationConfig config,
        BeanDescription beanDesc, List<BeanPropertyWriter> beanProperties) {
    List<BeanPropertyWriter> result = new ArrayList<BeanPropertyWriter>();
    for (BeanPropertyWriter writer : beanProperties) {
        AnnotatedMethod setter = beanDesc.findMethod(
                "set" + StringUtils.capitalize(writer.getName()),
                new Class<?>[] { writer.getType().getRawClass() });
        if (setter != null && this.conversionService.canConvert(String.class,
                writer.getType().getRawClass())) {
            result.add(writer);
        }
    }
    return result;
}
项目:graphql-spqr    文件:ConvertingDeserializer.java   
private JavaType extractType(Annotated annotated) {
    if (annotated instanceof AnnotatedMethod) {
        AnnotatedMethod method = (AnnotatedMethod) annotated;
        if (ClassUtils.isSetter(method.getAnnotated())) {
            return method.getParameterType(0);
        }
        return method.getType();
    }
    return annotated.getType();
}
项目:spring-boot-concourse    文件:ConfigurationPropertiesReportEndpoint.java   
private boolean isReadable(BeanDescription beanDesc, BeanPropertyWriter writer) {
    String parentType = beanDesc.getType().getRawClass().getName();
    String type = writer.getType().getTypeName();
    AnnotatedMethod setter = findSetter(beanDesc, writer);
    // If there's a setter, we assume it's OK to report on the value,
    // similarly, if there's no setter but the package names match, we assume
    // that its a nested class used solely for binding to config props, so it
    // should be kosher. This filter is not used if there is JSON metadata for
    // the property, so it's mainly for user-defined beans.
    return (setter != null) || ClassUtils.getPackageName(parentType)
            .equals(ClassUtils.getPackageName(type));
}
项目:spring-boot-concourse    文件:ConfigurationPropertiesReportEndpoint.java   
private AnnotatedMethod findSetter(BeanDescription beanDesc,
        BeanPropertyWriter writer) {
    String name = "set" + StringUtils.capitalize(writer.getName());
    Class<?> type = writer.getType().getRawClass();
    AnnotatedMethod setter = beanDesc.findMethod(name, new Class<?>[] { type });
    // The enabled property of endpoints returns a boolean primitive but is set
    // using a Boolean class
    if (setter == null && type.equals(Boolean.TYPE)) {
        setter = beanDesc.findMethod(name, new Class<?>[] { Boolean.class });
    }
    return setter;
}
项目:spring-boot-concourse    文件:DataSourceJsonSerializationTests.java   
@Override
public List<BeanPropertyWriter> changeProperties(SerializationConfig config,
        BeanDescription beanDesc, List<BeanPropertyWriter> beanProperties) {
    List<BeanPropertyWriter> result = new ArrayList<BeanPropertyWriter>();
    for (BeanPropertyWriter writer : beanProperties) {
        AnnotatedMethod setter = beanDesc.findMethod(
                "set" + StringUtils.capitalize(writer.getName()),
                new Class<?>[] { writer.getType().getRawClass() });
        if (setter != null && this.conversionService.canConvert(String.class,
                writer.getType().getRawClass())) {
            result.add(writer);
        }
    }
    return result;
}
项目:evt-bridge    文件:DateSerializer.java   
@Override
public JsonSerializer<?> createContextual(SerializerProvider prov, BeanProperty property) throws JsonMappingException {
    if (property != null) {
        Annotated annotated = property.getMember();
        if (annotated instanceof AnnotatedField || annotated instanceof AnnotatedMethod) {
            IndexableProperty indexableProperty = annotated.getAnnotation(IndexableProperty.class);
            if (indexableProperty != null && !indexableProperty.format().isEmpty()) {
                formatString = indexableProperty.format();
            }
        }
    }

    return this;
}
项目:evt-bridge    文件:DateDeserializer.java   
@Override
public JsonDeserializer<?> createContextual(DeserializationContext ctxt, BeanProperty property) throws JsonMappingException {
    if (property != null) {
        Annotated annotated = property.getMember();
        if (annotated instanceof AnnotatedField || annotated instanceof AnnotatedMethod) {
            IndexableProperty indexableProperty = annotated.getAnnotation(IndexableProperty.class);
            if (indexableProperty != null && !indexableProperty.format().isEmpty()) {
                formatString = indexableProperty.format();
            }
        }
    }

    return this;
}
项目:evt-bridge    文件:ElasticSearchAnnotationIntrospector.java   
@Override
public boolean hasIgnoreMarker(AnnotatedMember m) {
    if (!(m instanceof AnnotatedField) && !(m instanceof AnnotatedMethod)) return false;

    return (m.getAnnotation(IndexableProperty.class) == null
        && m.getAnnotation(IndexableComponent.class) == null && m.getAnnotation(IndexableProperties.class) == null);
}