Package com.fasterxml.jackson.annotation

Examples of com.fasterxml.jackson.annotation.JsonProperty


    public SetterInfo getSetterInfo(Member member, String paramName) {
        SetterInfo si = new SetterInfo();
        si.member = member;
        si.paramName = paramName;
        JsonProperty jsp;
        Type type;
        Class cls;
        if (member instanceof Field) {
            jsp = ((Field) member).getAnnotation(JsonProperty.class);
            type = ((Field) member).getGenericType();
View Full Code Here


        List<SetterInfo> list = new ArrayList<SetterInfo>();
        for (int i = 0; i < names.length; i++) {
            SetterInfo si = new SetterInfo();
            list.add(si);
            si.paramName = names[i];
            JsonProperty jsp = null;
            for (Annotation a : as[i]) {
                if (a instanceof JsonProperty) {
                    jsp = (JsonProperty) a;
                    break;
                }
View Full Code Here

  private static Field findField(final Class<?> clazz, final String fieldName) {
    if (clazz != null) {
      Class<?> myClass = clazz;
      do {
        for (Field field : myClass.getDeclaredFields()) {
          final JsonProperty prop = field.getAnnotation(JsonProperty.class);
          if ((prop != null) && prop.value().equals(fieldName)) {
            return field;
          }
        }
        myClass = myClass.getSuperclass();
      } while (myClass != null);
View Full Code Here

       
        // If it does have the annotation.
        if(filter != null) {
          // Get the serialized field name.
          String fieldName;
          JsonProperty jsonProperty =
            field.getAnnotation(JsonProperty.class);
          if(jsonProperty == null) {
            fieldName = field.getName();
          }
          else {
            fieldName = jsonProperty.value();
          }
         
          // Get the given group name.
          String filterGroup = filter.value();
         
View Full Code Here

        RiakKey key = null;
        RiakUsermeta usermeta = null;
        RiakLinks links = null;
        RiakIndex index = null;
        RiakVClock vclock = null;
    JsonProperty jacksonJsonProperty = null;
        RiakTombstone tombstone = null;

        AnnotatedMember member = beanPropertyWriter.getMember();
        if (member instanceof AnnotatedField) {
            AnnotatedElement element = member.getAnnotated();
View Full Code Here

                                // TODO: try to get the field with a setter or
                                // JSNI
                                if (getterName != null || field.isDefaultAccess() || field.isProtected() || field.isPublic()) {

                                    Json jsonAnnotation = getAnnotation(field, Json.class);
                                    JsonProperty jsonPropertyAnnotation = getAnnotation(field, JsonProperty.class);

                                    String name = field.getName();
                                    String jsonName = name;

                                    if (jsonAnnotation != null && jsonAnnotation.name().length() > 0) {
                                        jsonName = jsonAnnotation.name();
                                    }
                                    if (jsonPropertyAnnotation != null && jsonPropertyAnnotation.value() != null && jsonPropertyAnnotation.value().length() > 0) {
                                        jsonName = jsonPropertyAnnotation.value();
                                    }

                                    String fieldExpr = "parseValue." + name;
                                    if (getterName != null) {
                                        fieldExpr = "parseValue." + getterName + "()";
View Full Code Here

                                // or JSNI
                                if (setterName != null || field.isDefaultAccess() || field.isProtected() || field.isPublic()) {

                                    Json jsonAnnotation = getAnnotation(field, Json.class);
                                    Style style = jsonAnnotation != null ? jsonAnnotation.style() : classStyle;
                                    JsonProperty jsonPropertyAnnotation = getAnnotation(field, JsonProperty.class);

                                    String name = field.getName();
                                    String jsonName = name;

                                    if (jsonAnnotation != null && jsonAnnotation.name().length() > 0) {
                                        jsonName = jsonAnnotation.name();
                                    }
                                    if (jsonPropertyAnnotation != null && jsonPropertyAnnotation.value() != null && jsonPropertyAnnotation.value().length() > 0) {
                                        jsonName = jsonPropertyAnnotation.value();
                                    }

                                    String objectGetter = "object.get(" + wrap(jsonName) + ")";
                                    String expression = locator.decodeExpression(field.getType(), objectGetter, style);
View Full Code Here

    }

    private List<JField> getOrderedFields(List<JField> fields, JConstructor creator) throws UnableToCompleteException {
  List<JField> orderedFields = new ArrayList<JField>();
  for (JParameter param : creator.getParameters()) {
      JsonProperty prop = getAnnotation(param, JsonProperty.class);
      if (prop != null) {
    for (JField field : fields) {
        if (field.getName().equals(prop.value())) {
      orderedFields.add(field);
        }
    }
      } else {
    getLogger().log(ERROR, "a constructor annotated with @JsonCreator requires that all paramaters are annotated with @JsonProperty.");
View Full Code Here

                        break;
                    }
                }
                JField f = type.findField( name );
                // is getter annotated, if yes use this annotation for the field
                JsonProperty propName = null;
                if ( entry.getValue().isAnnotationPresent(JsonProperty.class) ) {
                    propName = getAnnotation(entry.getValue(), JsonProperty.class);
                }
                // is setter annotated, if yes use this annotation for the field
                JMethod m = type.findMethod("s" + entry.getValue().getName().substring(1),
                        new JType[]{ entry.getValue().getReturnType() });
                if ( m != null && m.isAnnotationPresent(JsonProperty.class) ) {
                    propName = getAnnotation(m, JsonProperty.class);
                }
                // if have a field and an annotation from the getter/setter then use that annotation
                if ( propName != null && found && !f.getName().equals(propName.value())) {
                    allFields.remove(f);
                    DummyJField dummy = new DummyJField( name, entry.getValue().getReturnType() );
                    dummy.setAnnotation( propName );
                    allFields.add(dummy);
                }
View Full Code Here

    private boolean has_IdName(Field f) {
        return "_id".equals(f.getName());
    }

    private boolean hasJsonProperty(Field f) {
        JsonProperty annotation = f.getAnnotation(JsonProperty.class);
        return annotation != null && "_id".equals(annotation.value());
    }
View Full Code Here

TOP

Related Classes of com.fasterxml.jackson.annotation.JsonProperty

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.