/** * Return the value for the field with a given name and type. * * @param field * The name of the field to retrieve the value of. * @param extensionFieldType * The type of the field. * @return The value for the field with the given name. * @throws NoSuchElementException * if this schema does not contain a field of the given name. * @throws IllegalArgumentException * if the given field is null or an empty string or if the extensionFieldType is null. */ @JsonAnyGetter public <T> T getField(String field, ExtensionFieldType<T> extensionFieldType) { if (field == null || field.isEmpty()) { throw new IllegalArgumentException("Invalid field name"); } if (extensionFieldType == null) { throw new IllegalArgumentException("Invalid field type"); } if (!isFieldPresent(field)) { throw new NoSuchElementException("Field " + field + " not valid in this extension"); } return extensionFieldType.fromString(fields.get(field).value); }
/** * This private method is only for serialization via jackson and not exposed anywhere else! * It maps the verbatimField terms into properties with their full qualified name. */ @JsonAnyGetter private Map<String, String> jsonVerbatimFields() { Map<String, String> extendedProps = Maps.newHashMap(); for (Map.Entry<Term, String> prop : fields.entrySet()) { extendedProps.put(prop.getKey().qualifiedName(), prop.getValue()); } return extendedProps; }
/** * This private method is only for serialization via jackson and not exposed anywhere else! * It maps the verbatimField terms into properties with their full qualified name. */ @JsonAnyGetter private Map<String, String> jsonVerbatimFields() { // note: for 1.6.0 MUST use non-getter name; otherwise doesn't matter Map<String, String> extendedProps = Maps.newHashMap(); for (Map.Entry<Term, String> prop : verbatimFields.entrySet()) { extendedProps.put(prop.getKey().qualifiedName(), prop.getValue()); } return extendedProps; }
/** * This private method is only for serialization via jackson and not exposed anywhere else! * It maps the verbatimField terms into properties with their simple name or qualified names for UnknownTerms. */ @JsonAnyGetter private Map<String, String> jsonVerbatimFields() { Map<String, String> extendedProps = Maps.newHashMap(); for (Map.Entry<Term, String> prop : getVerbatimFields().entrySet()) { Term t = prop.getKey(); if (t instanceof UnknownTerm || PROPERTIES.contains(t.simpleName())) { extendedProps.put(t.qualifiedName(), prop.getValue()); } else { // render all terms in controlled enumerations as simple names only - unless we have a property of that name already! extendedProps.put(t.simpleName(), prop.getValue()); } } return extendedProps; }
@Override public void anyGetter(JMethod getter) { getter.annotate(JsonAnyGetter.class); }
@JsonAnyGetter public Map<String, Object> getAdditionalProperties() { return this.additionalProperties; }
/** * @return the map for holding unspecified (user) attributes */ @XmlAnyAttribute @JsonAnyGetter public Map<QName,Object> getAny() { return attrs; }