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

com.belladati.sdk.impl.AttributeValueImpl Maven / Gradle / Ivy

Go to download

The BellaDati SDK allows accessing a BellaDati server from 3rd-party applications using Java. This project contains the implementation for standard Java.

The newest version!
package com.belladati.sdk.impl;

import com.belladati.sdk.dataset.AttributeValue;
import com.fasterxml.jackson.databind.JsonNode;

class AttributeValueImpl implements AttributeValue {

	private final String label;
	private final String value;

	AttributeValueImpl(JsonNode node) throws InvalidAttributeValueException {
		if (node.hasNonNull("label") && node.hasNonNull("value")) {
			this.label = node.get("label").asText();
			this.value = node.get("value").asText();
		} else {
			throw new InvalidAttributeValueException(node);
		}
	}

	@Override
	public String getLabel() {
		return label;
	}

	@Override
	public String getValue() {
		return value;
	}

	@Override
	public String toString() {
		return label;
	}

	@Override
	public boolean equals(Object obj) {
		if (obj instanceof AttributeValue) {
			return value.equals(((AttributeValue) obj).getValue());
		}
		return false;
	}

	@Override
	public int hashCode() {
		return value.hashCode();
	}

	class InvalidAttributeValueException extends Exception {
		/** The serialVersionUID */
		private static final long serialVersionUID = -4920843734203654180L;

		public InvalidAttributeValueException(JsonNode node) {
			super("Invalid attribute value JSON: " + node.toString());
		}
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy