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

org.hibernate.validator.internal.engine.messageinterpolation.LocalizedMessage Maven / Gradle / Ivy

Go to download

JSR 380's RI, Hibernate Validator version ${hibernate-validator.version} and its dependencies repackaged as OSGi bundle

There is a newer version: 5.1.0
Show newest version
/*
 * Hibernate Validator, declare and validate application constraints
 *
 * License: Apache License, Version 2.0
 * See the license.txt file in the root directory or .
 */
package org.hibernate.validator.internal.engine.messageinterpolation;

import java.util.Locale;

/**
 * @author Hardy Ferentschik
 * @author Guillaume Smet
 */
public class LocalizedMessage {
	private final String message;
	private final Locale locale;
	private final int hashCode;

	public LocalizedMessage(String message, Locale locale) {
		this.message = message;
		this.locale = locale;
		this.hashCode = buildHashCode();
	}

	@Override
	public boolean equals(Object o) {
		if ( this == o ) {
			return true;
		}
		if ( o == null || getClass() != o.getClass() ) {
			return false;
		}

		LocalizedMessage that = (LocalizedMessage) o;

		if ( !message.equals( that.message ) ) {
			return false;
		}
		if ( !locale.equals( that.locale ) ) {
			return false;
		}

		return true;
	}

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

	private int buildHashCode() {
		int result = message.hashCode();
		result = 31 * result + locale.hashCode();
		return result;
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy