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

com.github.jasminb.jsonapi.SerializationFeature 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 serialization features that can be set to {@link ResourceConverter}.
 *
 * @author jbegic
 */
public enum SerializationFeature {

	/**
	 * This option if enabled instructs resource converter to serialize entire relationship objects (type and id are
	 * serialized by default)
	 */
	INCLUDE_RELATIONSHIP_ATTRIBUTES(false),

	/**
	 * If enabled, meta attribute will be serialized
	 */
	INCLUDE_META(true),

	/**
	 * If enabled, links attribute will be serialized
	 */
	INCLUDE_LINKS(true);

	final boolean enabled;

	SerializationFeature(boolean enabled) {
		this.enabled = enabled;
	}

	/**
	 * 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 (SerializationFeature feature : values()) {
			if (feature.enabled) {
				result.add(feature);
			}
		}

		return result;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy