io.github.springwolf.asyncapi.v3.model.ExtendableObject Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of springwolf-asyncapi Show documentation
Show all versions of springwolf-asyncapi Show documentation
Springwolf implementation of the AsyncApi specification
// SPDX-License-Identifier: Apache-2.0
package io.github.springwolf.asyncapi.v3.model;
import com.fasterxml.jackson.annotation.JsonAnyGetter;
import com.fasterxml.jackson.annotation.JsonAnySetter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
import java.util.HashMap;
import java.util.Map;
import java.util.regex.Pattern;
@Data
@NoArgsConstructor
@AllArgsConstructor
public class ExtendableObject {
private static final Pattern extensionPropertyNamePattern = Pattern.compile("^x-[\\w\\d\\-\\_]+$");
/**
* Extension fields in the form x-extension-field-name for the exposed API.
*/
@JsonAnyGetter
@JsonIgnore
protected Map extensionFields;
@JsonAnySetter
protected final void readExtensionProperty(String name, Object value) {
if (extensionPropertyNamePattern.matcher(name).matches()) {
if (extensionFields == null) {
extensionFields = new HashMap<>();
}
extensionFields.put(name, value);
} else {
throw new IllegalArgumentException(String.format("\"%s\" is not valid extension property", name));
}
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy