All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.github.jasminb.jsonapi.DeserializationFeature Maven / Gradle / Ivy

Go to download

JSONAPI-Converter is a library that provides means for integrating with services using JSON API specification.

There is a newer version: 0.14
Show newest version
package com.github.jasminb.jsonapi;

import java.util.HashSet;
import java.util.Set;

/**
 * Enumeration that defines list of deserialization features that can be set to {@link ResourceConverter}.
 *
 * @author jbegic
 */
public enum DeserializationFeature {

	/**
	 * This option enforces presence of the 'id' attribute in resources being parsed.
	 */
	REQUIRE_RESOURCE_ID(true),

	/**
	 * This option determines whether encountering unknown types results in {@link IllegalArgumentException} being
	 * thrown, or if parsing continues and the unknown field is ignored.
	 */
	ALLOW_UNKNOWN_INCLUSIONS(false);

	private final boolean enabledByDefault;

	DeserializationFeature(boolean enabledByDefault) {
		this.enabledByDefault = enabledByDefault;
	}

	/**
	 * Returns set of features that are enabled by default.
	 * @return returns features that are enabled by default
	 */
	public static Set getDefaultFeatures() {
		Set result = new HashSet<>();

		for (DeserializationFeature deserializationFeature : values()) {
			if (deserializationFeature.enabledByDefault) {
				result.add(deserializationFeature);
			}
		}

		return result;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy