Java Code Examples for com.fasterxml.jackson.annotation.JsonIgnoreProperties

The following are top voted examples for showing how to use com.fasterxml.jackson.annotation.JsonIgnoreProperties. These examples are extracted from open source projects. You can vote up the examples you like and your votes will be used in our system to generate more good examples.
Example 1
Project: Fenzo   File: TaskAssignmentResult.java   View source code 6 votes vote down vote up
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown=true)
TaskAssignmentResult(@JsonProperty("avm") AssignableVirtualMachine avm,
                     @JsonProperty("request") TaskRequest request,
                     @JsonProperty("successful") boolean successful,
                     @JsonProperty("failures") List<AssignmentFailure> failures,
                     @JsonProperty("constraintFailure") ConstraintFailure constraintFailure,
                     @JsonProperty("fitness") double fitness) {
    this.avm = avm;
    this.request = request;
    this.taskId = request.getId();
    this.hostname = avm==null? "":avm.getHostname();
    this.successful = successful;
    this.failures = failures;
    this.constraintFailure = constraintFailure;
    this.fitness = fitness;
    assignedPorts = new ArrayList<>();
    rSets = new ArrayList<>();
}
 
Example 2
Project: teavm-flavour   File: ClassInformationProvider.java   View source code 6 votes vote down vote up
private void getIgnoredProperties(ClassInformation information, ReflectClass<?> cls) {
    JsonIgnoreProperties annot = cls.getAnnotation(JsonIgnoreProperties.class);
    if (annot == null) {
        return;
    }

    for (String name : annot.value()) {
        PropertyInformation property = information.properties.get(name);
        if (property == null) {
            property = new PropertyInformation();
            property.name = name;
            information.properties.put(name, property);
        }
        property.ignored = true;
    }
}
 
Example 3
Project: GamificationEngine-Kinben   File: MarketPlaceApi.java   View source code 6 votes vote down vote up
/**
 * This method returns a list with all ids of offers that contain a specific task. This is irrespective 
 * of the marketplace. 
 *   
 * @param taskId
 * 			The id of the task, which all returned offers contain.
 * @param apiKey
 * 			The valid query parameter API key affiliated to one specific organisation, 
 *            to which the offer belongs to.
 * @return A list of all offers' ids that contain the task with the passed id as a list. 
 */
@GET
@Path("/offers/{taskId}/*")
@TypeHint(Integer[].class)
@JsonIgnoreProperties({ "player" })
public Response getAllOffersByTask(
		@PathParam("taskId") @NotNull @ValidPositiveDigit(message = "The task id must be a valid number") String taskId,
		@QueryParam("apiKey") @ValidApiKey String apiKey) {
	
	int idTask = ValidateUtils.requireGreaterThanZero(taskId);
	Task task = taskDao.getTask(idTask, apiKey);
	
	List<Offer> offers = marketPlDao.getOffersByTask(task, apiKey); 
	List<Integer> matchingOffers = new ArrayList<>();
	
	for (Offer offer : offers) {
		LOGGER.debug("| Offer:" + offer.getId());
		matchingOffers.add(offer.getId());
	}

	return ResponseSurrogate.of(matchingOffers);
}
 
Example 4
Project: GamificationEngine-Kinben   File: MarketPlaceApi.java   View source code 6 votes vote down vote up
/**
 * This method returns a list with all offers which contain a specific task and the id of the 
 * offer's marketplace. 
 * 
 * @param taskId
 * 			The id of the task, which all returned offers contain.
 * @param apiKey
 * 			The valid query parameter API key affiliated to one specific organisation, 
 *            to which the offer belongs to.
 * @return A list of all offers and their marketplaces which contain the task with the 
 * 			passed id as a list. 
 */
@GET
@Path("/offers/{taskId}/market/*")
@TypeHint(Offer[].class)
@JsonIgnoreProperties({ "player" })
public Response getAllMarketPlaceOffersByTask(
		@PathParam("taskId") @NotNull @ValidPositiveDigit(message = "The task id must be a valid number") String taskId,
		@QueryParam("apiKey") @ValidApiKey String apiKey) {
	
	int idTask = ValidateUtils.requireGreaterThanZero(taskId);
	Task task = taskDao.getTask(idTask, apiKey);
	
	ArrayList<OfferMarketPlace> offList = MarketPlace.getAllOfferMarketPlaces(marketPlDao, task, apiKey);
	
	return ResponseSurrogate.of(offList);
}
 
Example 5
Project: jsonTweetDownload   File: Tweet.java   View source code 5 votes vote down vote up
@JsonIgnoreProperties
public String getAsJson(Tweet tweet) {
	ObjectMapper mapper = new ObjectMapper();
	String result = "";
	try {
		result = mapper.writeValueAsString(tweet);
	} catch (JsonProcessingException e) {
		e.printStackTrace();
	}
	return result;
}
 
Example 6
Project: Fenzo   File: ConstraintFailure.java   View source code 5 votes vote down vote up
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown=true)
public ConstraintFailure(@JsonProperty("name") String name, @JsonProperty("reason") String reason) {
    this.name = name;
    this.reason = reason;
    objectMapper.configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false);
}
 
Example 7
Project: Fenzo   File: AssignmentFailure.java   View source code 5 votes vote down vote up
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown=true)
public AssignmentFailure(@JsonProperty("resource") VMResource resource,
                         @JsonProperty("asking") double asking,
                         @JsonProperty("used") double used,
                         @JsonProperty("available") double available,
                         @JsonProperty("message") String message
) {
    this.resource = resource;
    this.asking = asking;
    this.used = used;
    this.available = available;
    this.message = message;
}
 
Example 8
Project: Fenzo   File: PreferentialNamedConsumableResourceSet.java   View source code 5 votes vote down vote up
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown=true)
public ConsumeResult(@JsonProperty("index") int index,
                     @JsonProperty("attrName") String attrName,
                     @JsonProperty("resName") String resName,
                     @JsonProperty("fitness") double fitness) {
    this.index = index;
    this.attrName = attrName;
    this.resName = resName;
    this.fitness = fitness;
}
 
Example 9
Project: contest-votesapp   File: GroupMessage.java   View source code 5 votes vote down vote up
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonCreator
public static GroupMessage of( //
		@JsonProperty("_id") final String id, //
		@JsonProperty("_from") final String groupId, //
		@JsonProperty("participant") final String senderPhone, //
		@JsonProperty(value = "notify", required = false) final String senderName, //
		@JsonProperty(value = "body", required = false) final String text) {

	return new GroupMessage(escapeDot(id), escapeDot(groupId), escapeDot(senderPhone), senderName, text == null ? "" : text);
}
 
Example 10
Project: json-view   File: JsonViewSerializer.java   View source code 5 votes vote down vote up
/**
 * Returns a boolean indicating whether the provided field is annotated with
 * some form of ignore. This method is memoized to speed up execution time
 */
boolean annotatedWithIgnore(Field f) {
  return memoizer.ignoreAnnotations(f, () -> {
    JsonIgnore jsonIgnore = getAnnotation(f, JsonIgnore.class);
    JsonIgnoreProperties classIgnoreProperties = getAnnotation(f.getDeclaringClass(), JsonIgnoreProperties.class);
    JsonIgnoreProperties fieldIgnoreProperties = null;
    boolean backReferenced = false;

    //make sure the referring field didn't specify properties to ignore
    if(referringField != null) {
      fieldIgnoreProperties = getAnnotation(referringField, JsonIgnoreProperties.class);
    }

    //make sure the referring field didn't specify a backreference annotation
    if(getAnnotation(f, JsonBackReference.class) != null && referringField != null) {
      for(Field lastField : getDeclaredFields(referringField.getDeclaringClass())) {
        JsonManagedReference fieldManagedReference = getAnnotation(lastField, JsonManagedReference.class);
        if(fieldManagedReference != null && lastField.getType().equals(f.getDeclaringClass())) {
          backReferenced = true;
          break;
        }
      }
    }

    return (jsonIgnore != null && jsonIgnore.value()) ||
        (classIgnoreProperties != null && Arrays.asList(classIgnoreProperties.value()).contains(f.getName())) ||
        (fieldIgnoreProperties != null && Arrays.asList(fieldIgnoreProperties.value()).contains(f.getName())) ||
        backReferenced;
  });
}
 
Example 11
Project: QuizUpWinner   File: JacksonAnnotationIntrospector.java   View source code 5 votes vote down vote up
public Boolean findIgnoreUnknownProperties(AnnotatedClass paramAnnotatedClass)
{
  JsonIgnoreProperties localJsonIgnoreProperties = (JsonIgnoreProperties)paramAnnotatedClass.getAnnotation(JsonIgnoreProperties.class);
  if (localJsonIgnoreProperties == null)
    return null;
  return Boolean.valueOf(localJsonIgnoreProperties.ignoreUnknown());
}
 
Example 12
Project: QuizUpWinner   File: JacksonAnnotationIntrospector.java   View source code 5 votes vote down vote up
public String[] findPropertiesToIgnore(Annotated paramAnnotated)
{
  JsonIgnoreProperties localJsonIgnoreProperties = (JsonIgnoreProperties)paramAnnotated.getAnnotation(JsonIgnoreProperties.class);
  if (localJsonIgnoreProperties == null)
    return null;
  return localJsonIgnoreProperties.value();
}
 
Example 13
Project: feedzai-client   File: PaymentResponse.java   View source code 5 votes vote down vote up
@JsonIgnoreProperties(ignoreUnknown = true)
@JsonCreator
public PaymentResponse(@JsonProperty("id") String id,
                       @JsonProperty("score") Integer score,
                       @JsonProperty("type") String type,
                       @JsonProperty("likelyFraud") Boolean likelyFraud,
                       @JsonProperty("baseRisk") Double baseRisk,
                       @JsonProperty("explanation") List<Explanation> explanation) {
    this.id = id;
    this.score = score;
    this.type = type;
    this.likelyFraud = likelyFraud;
    this.baseRisk = baseRisk;
    this.explanation = explanation;
}
 
Example 14
Project: yasme-android   File: Chat.java   View source code 5 votes vote down vote up
@JsonIgnoreProperties({"pw", "email", "name", "devices", "lastModified", "created"})
public ArrayList<User> getParticipants() {
    if (participants == null) {
        participants = new ArrayList<>();
        User mDummy = new User("Dummy", 12);
        participants.add(mDummy);
        // Without cast IntelliJ is not happy
        Log.e(((Object) this).getClass().getSimpleName(), "Participants are null");
    }
    return new ArrayList<User>(participants);
}
 
Example 15
Project: yasme-android   File: Chat.java   View source code 5 votes vote down vote up
@JsonIgnoreProperties({"pw", "email", "name", "devices", "lastModified", "created"})
public User getOwner() {
    if (owner == null) {
        owner = new User("Dummy", 12);
    }
    return owner;
}
 
Example 16
Project: launchkey-java   File: ServerSentEventAuthorizationResponseCore.java   View source code 5 votes vote down vote up
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown = true)
public ServerSentEventAuthorizationResponseCore(
        @JsonProperty(value = "auth", required = true) String auth,
        @JsonProperty(value = "user_push_id", required = true) String userPushId,
        @JsonProperty(value = "service_user_hash", required = true) String serviceUserHash,
        @JsonProperty(value = "public_key_id", required = true) String publicKeyId,
        @JsonProperty(value = "org_user_hash") String orgUserHash
) {
    this.auth = auth;
    this.userPushId = userPushId;
    this.serviceUserHash = serviceUserHash;
    this.publicKeyId = publicKeyId;
    this.orgUserHash = orgUserHash;
}
 
Example 17
Project: launchkey-java   File: ServerSentEventUserServiceSessionEnd.java   View source code 5 votes vote down vote up
@JsonCreator
@JsonIgnoreProperties(ignoreUnknown = true)
public ServerSentEventUserServiceSessionEnd(
        @JsonProperty("service_user_hash") String userHash,
        @JsonProperty("api_time") Date apiTime
) {
    this.userHash = userHash;
    this.apiTime = apiTime;
}
 
Example 18
Project: jacksonatic   File: JacksonaticJsonIgnoreProperties.java   View source code 4 votes vote down vote up
@Override
public Class<? extends Annotation> annotationType() {
    return JsonIgnoreProperties.class;
}
 
Example 19
Project: jacksonatic   File: JacksonaticJsonIgnoreProperties.java   View source code 4 votes vote down vote up
@Override
public JsonIgnoreProperties build() {
    return jsonIgnoreProperties;
}
 
Example 20
Project: iVIS   File: ApplicationFormQuestion.java   View source code 4 votes vote down vote up
@JsonIgnoreProperties(value = "questions")
public ApplicationFormQuestionGroup getQuestionGroup() {
    return questionGroup;
}
 
Example 21
Project: iVIS   File: ApplicationFormQuestionGroup.java   View source code 4 votes vote down vote up
@JsonIgnoreProperties(value = "question_groups")
public ApplicationFormStep getStep() {
    return step;
}
 
Example 22
Project: iVIS   File: Activity.java   View source code 4 votes vote down vote up
@JsonIgnoreProperties({"activities", "incidents"})
public Issue getIssue() {
    return issue;
}
 
Example 23
Project: iVIS   File: Truancy.java   View source code 4 votes vote down vote up
@JsonIgnoreProperties(value = "truancies")
public Pupil getPupil() {
    return pupil;
}
 
Example 24
Project: iVIS   File: AfterSchoolCenterSection.java   View source code 4 votes vote down vote up
@JsonIgnoreProperties(value = {"school_classes", "after_school_center_sections"})
public School getSchool() {
    return school;
}
 
Example 25
Project: iVIS   File: ApplicationFormStep.java   View source code 4 votes vote down vote up
@JsonIgnoreProperties(value = {"steps", "applications"})
public ApplicationForm getApplicationForm() {
    return applicationForm;
}
 
Example 26
Project: EasyEE   File: SysRole.java   View source code 4 votes vote down vote up
@JsonIgnoreProperties
public Set getSysOperationPermissions() {
	return this.sysOperationPermissions;
}
 
Example 27
Project: EasyEE   File: SysRole.java   View source code 4 votes vote down vote up
@JsonIgnoreProperties
@SuppressWarnings("rawtypes")
public Set getSysOperationPermissions() {
	return this.sysOperationPermissions;
}
 
Example 28
Project: EasyEE   File: SysRole.java   View source code 4 votes vote down vote up
@JsonIgnoreProperties
public Set getSysOperationPermissions() {
	return this.sysOperationPermissions;
}
 
Example 29
Project: EasyEE   File: SysRole.java   View source code 4 votes vote down vote up
@JsonIgnoreProperties
@SuppressWarnings("rawtypes")
public Set getSysOperationPermissions() {
	return this.sysOperationPermissions;
}
 
Example 30
Project: common_utils   File: JavassistFilterPropertyHandler.java   View source code 4 votes vote down vote up
/**
 * 创建jackson的代理注解接口类 <br>
 * 2013-10-25 上午11:59:50
 *
 * @param names 要生成的字段
 * @return 代理接口类
 */
private Class<?> createMixInAnnotation(String[] names) {
    Class<?> clazz = null;
    clazz = proxyMixInAnnotationMap.get(StringHelper.hashCodeOfStringArray(names));
    if (clazz != null) {
        return clazz;
    }

    ClassPool pool = ClassPool.getDefault();

    // 创建代理接口
    CtClass cc = pool.makeInterface("ProxyMixInAnnotation" + System.currentTimeMillis()
            + proxyIndex++);

    ClassFile ccFile = cc.getClassFile();
    ConstPool constpool = ccFile.getConstPool();

    // create the annotation
    AnnotationsAttribute attr = new AnnotationsAttribute(constpool,
            AnnotationsAttribute.visibleTag);
    // 创建JsonIgnoreProperties注解
    Annotation jsonIgnorePropertiesAnnotation = new Annotation(
            JsonIgnoreProperties.class.getName(), constpool);

    BooleanMemberValue ignoreUnknownMemberValue = new BooleanMemberValue(false, constpool);

    ArrayMemberValue arrayMemberValue = new ArrayMemberValue(constpool);// value的数组成员

    Collection<MemberValue> memberValues = new HashSet<MemberValue>();
    for (int i = 0; i < names.length; i++) {
        String name = names[i];
        StringMemberValue memberValue = new StringMemberValue(constpool);// 将name值设入注解内
        memberValue.setValue(name);
        memberValues.add(memberValue);
    }
    arrayMemberValue.setValue(memberValues.toArray(new MemberValue[]{}));

    jsonIgnorePropertiesAnnotation.addMemberValue("value", arrayMemberValue);
    jsonIgnorePropertiesAnnotation.addMemberValue("ignoreUnknown", ignoreUnknownMemberValue);

    attr.addAnnotation(jsonIgnorePropertiesAnnotation);
    ccFile.addAttribute(attr);

    // generate the class
    try {
        clazz = cc.toClass();
        proxyMixInAnnotationMap.put(StringHelper.hashCodeOfStringArray(names), clazz);
        // JsonIgnoreProperties ignoreProperties = (JsonIgnoreProperties)
        // clazz
        // .getAnnotation(JsonIgnoreProperties.class);

        // EntityHelper.print(ignoreProperties);
        //
        // EntityHelper.print(clazz);

        // try {
        // Object instance = clazz.newInstance();
        // EntityHelper.print(instance);
        //
        // } catch (InstantiationException e) {
        // e.printStackTrace();
        // } catch (IllegalAccessException e) {
        // e.printStackTrace();
        // }
    } catch (CannotCompileException e) {
        e.printStackTrace();
    }

    // right
    // mthd.getMethodInfo().addAttribute(attr);

    return clazz;

}
 
Example 31
Project: yasme-android   File: Device.java   View source code 4 votes vote down vote up
@JsonIgnoreProperties({ "pw", "email", "name", "devices", "lastModified", "created" })
public User getUser() {
    return user;
}
 
Example 32
Project: yasme-android   File: OwnDevice.java   View source code 4 votes vote down vote up
@JsonIgnoreProperties({ "pw", "email", "name", "devices", "lastModified", "created" })
public User getUser() {
    return this.user;
}
 
Example 33
Project: yasme-android   File: Message.java   View source code 4 votes vote down vote up
/**
 * Getters *
 */
@JsonIgnoreProperties({ "pw", "email", "name", "devices", "lastModified", "created" })
public User getSender() {
    return sender;
}
 
Example 34
Project: yasme-android   File: Message.java   View source code 4 votes vote down vote up
@JsonIgnoreProperties({ "participants", "status", "name", "owner", "lastModified", "created", "profilePicture", "messages" })
public Chat getChat() {
    return chat;
}
 
Example 35
Project: yasme-android   File: MessageKey.java   View source code 4 votes vote down vote up
@JsonIgnoreProperties({ "user", "publicKey", "product", "lastModified" })
public Device getCreatorDevice() {
	return creatorDevice;
}
 
Example 36
Project: yasme-android   File: MessageKey.java   View source code 4 votes vote down vote up
@JsonIgnoreProperties({ "user", "publicKey", "product", "lastModified" })
public Device getRecipientDevice() {
	return recipientDevice;
}
 
Example 37
Project: yasme-android   File: MessageKey.java   View source code 4 votes vote down vote up
@JsonIgnoreProperties({ "participants", "status", "name", "owner", "lastModified", "created", "profilePicture", "messages" })
public Chat getChat() {
	return chat;
}
 
Example 38
Project: yasme-android   File: User.java   View source code 4 votes vote down vote up
@JsonIgnoreProperties({"id", "user", "publicKey", "product", "lastModified"})
public List<Device> getDevices() {
    return devices;
}
 
Example 39
Project: gwt-jackson   File: BeanProcessor.java   View source code 4 votes vote down vote up
/**
 * <p>processBean</p>
 *
 * @param logger a {@link com.google.gwt.core.ext.TreeLogger} object.
 * @param typeOracle a {@link com.github.nmorel.gwtjackson.rebind.JacksonTypeOracle} object.
 * @param configuration a {@link com.github.nmorel.gwtjackson.rebind.RebindConfiguration} object.
 * @param beanType a {@link com.google.gwt.core.ext.typeinfo.JClassType} object.
 * @return a {@link com.github.nmorel.gwtjackson.rebind.bean.BeanInfo} object.
 * @throws com.google.gwt.core.ext.UnableToCompleteException if any.
 */
public static BeanInfo processBean( TreeLogger logger, JacksonTypeOracle typeOracle, RebindConfiguration configuration, JClassType
        beanType ) throws UnableToCompleteException {
    BeanInfoBuilder builder = new BeanInfoBuilder();
    builder.setType( beanType );

    if ( null != beanType.isGenericType() ) {
        builder.setParameterizedTypes( Arrays.<JClassType>asList( beanType.isGenericType().getTypeParameters() ) );
    }

    determineInstanceCreator( configuration, typeOracle, logger, beanType, builder );

    Optional<JsonAutoDetect> jsonAutoDetect = findFirstEncounteredAnnotationsOnAllHierarchy( configuration, beanType, JsonAutoDetect
            .class );
    if ( jsonAutoDetect.isPresent() ) {
        builder.setCreatorVisibility( jsonAutoDetect.get().creatorVisibility() );
        builder.setFieldVisibility( jsonAutoDetect.get().fieldVisibility() );
        builder.setGetterVisibility( jsonAutoDetect.get().getterVisibility() );
        builder.setIsGetterVisibility( jsonAutoDetect.get().isGetterVisibility() );
        builder.setSetterVisibility( jsonAutoDetect.get().setterVisibility() );
    }

    Optional<JsonIgnoreProperties> jsonIgnoreProperties = findFirstEncounteredAnnotationsOnAllHierarchy( configuration, beanType,
            JsonIgnoreProperties.class );
    if ( jsonIgnoreProperties.isPresent() ) {
        builder.setIgnoredFields( new LinkedHashSet<String>( Arrays.asList( jsonIgnoreProperties.get().value() ) ) );
        builder.setIgnoreUnknown( jsonIgnoreProperties.get().ignoreUnknown() );
    }

    Optional<JsonPropertyOrder> jsonPropertyOrder = findFirstEncounteredAnnotationsOnAllHierarchy( configuration, beanType,
            JsonPropertyOrder.class );
    builder.setPropertyOrderAlphabetic( jsonPropertyOrder.isPresent() && jsonPropertyOrder.get().alphabetic() );
    if ( jsonPropertyOrder.isPresent() && jsonPropertyOrder.get().value().length > 0 ) {
        builder.setPropertyOrderList( Arrays.asList( jsonPropertyOrder.get().value() ) );
    } else if ( !builder.getCreatorParameters().isEmpty() ) {
        List<String> propertyOrderList = new ArrayList<String>( builder.getCreatorParameters().keySet() );
        builder.setPropertyOrderList( propertyOrderList );
        if ( builder.isPropertyOrderAlphabetic() ) {
            Collections.sort( propertyOrderList );
        }
    }

    Optional<JsonInclude> jsonInclude = findFirstEncounteredAnnotationsOnAllHierarchy( configuration, beanType,
            JsonInclude.class );
    if ( jsonInclude.isPresent() ) {
        builder.setInclude( Optional.of( jsonInclude.get().value() ) );
    }

    builder.setIdentityInfo( processIdentity( logger, typeOracle, configuration, beanType ) );
    builder.setTypeInfo( processType( logger, typeOracle, configuration, beanType ) );

    return builder.build();
}