@JsonAnySetter public void setUnknownAttribute(String attributeName, Object ignored) { if (!alreadySeenAnySetterAttributes.contains(attributeName)) { alreadySeenAnySetterAttributes.add(attributeName); System.err.println("In LoggedJob, we saw the unknown attribute " + attributeName + "."); } }
@SuppressWarnings("unused") // for input parameter ignored. @JsonAnySetter public void setUnknownAttribute(String attributeName, Object ignored) { if (!alreadySeenAnySetterAttributes.contains(attributeName)) { alreadySeenAnySetterAttributes.add(attributeName); System.err.println("In LoggedJob, we saw the unknown attribute " + attributeName + "."); } }
@JsonAnySetter public Builder setFieldAsList(String fieldName, List<?> values) throws Exception { ObjectMapper mapper = new ObjectMapper(); mapper.disable(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES); Date[] dateArray = null; boolean isDateArray = false; try { dateArray = (Date[])values.toArray(); isDateArray = true; } catch (Exception e) { } if (isDateArray) { DateTimeFormatter dateTimeFormatter = ISODateTimeFormat.dateTime().withZoneUTC(); List<String> stringDateList = new ArrayList<String>(); for (Date date : dateArray) { stringDateList.add(dateTimeFormatter.print(date.getTime())); } setField(fieldName, mapper.writeValueAsString(stringDateList), ExtensionFieldType.STRING, true); return this; } else { setField(fieldName, mapper.writeValueAsString(values), ExtensionFieldType.STRING, true); return this; } }
/** * Sets the field specified by the given field name with the given value of the given type. <br> * Can only be set and saved if extension field is registered in the database * * @param fieldName * the field name * @param value * the new value * @param type * the scim2 type of the field * @return the builder itself */ @JsonAnySetter public <T> Builder setField(String fieldName, T value, ExtensionFieldType<T> type, boolean isMultiValued) { if (fieldName == null || fieldName.isEmpty()) { throw new IllegalArgumentException("The field name can't be null or empty."); } if (value == null) { throw new IllegalArgumentException("The value can't be null."); } if (type == null) { throw new IllegalArgumentException("The type can't be null."); } fields.put(fieldName, new Field(type, type.toString(value), isMultiValued)); return this; }
/** * Helper method for JSON un-marshaling. * @param name field name, MUST be "value" * @param value field value * @throws java.lang.IllegalArgumentException if field name is not "value" */ @JsonAnySetter public void setAny(String name, Object value) throws IllegalArgumentException { if (!VALUE_FIELD.equals(name)) { throw new IllegalArgumentException(name); } this.value = value; }