@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<>(); }
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; } }
/** * 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); }
/** * 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); }
@JsonIgnoreProperties public String getAsJson(Tweet tweet) { ObjectMapper mapper = new ObjectMapper(); String result = ""; try { result = mapper.writeValueAsString(tweet); } catch (JsonProcessingException e) { e.printStackTrace(); } return result; }
@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); }
@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; }
@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; }
@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); }
/** * 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; }); }
public Boolean findIgnoreUnknownProperties(AnnotatedClass paramAnnotatedClass) { JsonIgnoreProperties localJsonIgnoreProperties = (JsonIgnoreProperties)paramAnnotatedClass.getAnnotation(JsonIgnoreProperties.class); if (localJsonIgnoreProperties == null) return null; return Boolean.valueOf(localJsonIgnoreProperties.ignoreUnknown()); }
public String[] findPropertiesToIgnore(Annotated paramAnnotated) { JsonIgnoreProperties localJsonIgnoreProperties = (JsonIgnoreProperties)paramAnnotated.getAnnotation(JsonIgnoreProperties.class); if (localJsonIgnoreProperties == null) return null; return localJsonIgnoreProperties.value(); }
@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; }
@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); }
@JsonIgnoreProperties({"pw", "email", "name", "devices", "lastModified", "created"}) public User getOwner() { if (owner == null) { owner = new User("Dummy", 12); } return owner; }
@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; }
@JsonCreator @JsonIgnoreProperties(ignoreUnknown = true) public ServerSentEventUserServiceSessionEnd( @JsonProperty("service_user_hash") String userHash, @JsonProperty("api_time") Date apiTime ) { this.userHash = userHash; this.apiTime = apiTime; }
@Override public Class<? extends Annotation> annotationType() { return JsonIgnoreProperties.class; }
@Override public JsonIgnoreProperties build() { return jsonIgnoreProperties; }
@JsonIgnoreProperties(value = "questions") public ApplicationFormQuestionGroup getQuestionGroup() { return questionGroup; }
@JsonIgnoreProperties(value = "question_groups") public ApplicationFormStep getStep() { return step; }
@JsonIgnoreProperties({"activities", "incidents"}) public Issue getIssue() { return issue; }
@JsonIgnoreProperties(value = "truancies") public Pupil getPupil() { return pupil; }
@JsonIgnoreProperties(value = {"school_classes", "after_school_center_sections"}) public School getSchool() { return school; }
@JsonIgnoreProperties(value = {"steps", "applications"}) public ApplicationForm getApplicationForm() { return applicationForm; }
@JsonIgnoreProperties public Set getSysOperationPermissions() { return this.sysOperationPermissions; }
@JsonIgnoreProperties @SuppressWarnings("rawtypes") public Set getSysOperationPermissions() { return this.sysOperationPermissions; }
/** * 创建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; }
@JsonIgnoreProperties({ "pw", "email", "name", "devices", "lastModified", "created" }) public User getUser() { return user; }
@JsonIgnoreProperties({ "pw", "email", "name", "devices", "lastModified", "created" }) public User getUser() { return this.user; }
/** * Getters * */ @JsonIgnoreProperties({ "pw", "email", "name", "devices", "lastModified", "created" }) public User getSender() { return sender; }
@JsonIgnoreProperties({ "participants", "status", "name", "owner", "lastModified", "created", "profilePicture", "messages" }) public Chat getChat() { return chat; }
@JsonIgnoreProperties({ "user", "publicKey", "product", "lastModified" }) public Device getCreatorDevice() { return creatorDevice; }
@JsonIgnoreProperties({ "user", "publicKey", "product", "lastModified" }) public Device getRecipientDevice() { return recipientDevice; }
@JsonIgnoreProperties({"id", "user", "publicKey", "product", "lastModified"}) public List<Device> getDevices() { return devices; }
/** * <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(); }