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

org.hibernate.boot.jaxb.Origin Maven / Gradle / Ivy

There is a newer version: 7.0.0.Alpha1
Show newest version
/*
 * Hibernate, Relational Persistence for Idiomatic Java
 *
 * License: GNU Lesser General Public License (LGPL), version 2.1 or later.
 * See the lgpl.txt file in the root directory or .
 */
package org.hibernate.boot.jaxb;

import java.io.Serializable;
import java.util.Locale;

import org.hibernate.internal.util.compare.EqualsHelper;

/**
 * Describes the origin of an xml document
 *
 * @author Steve Ebersole
 */
public class Origin implements Serializable {
	public static final String UNKNOWN_FILE_PATH = "";

	private final SourceType type;
	private final String name;

	public Origin(SourceType type, String name) {
		this.type = type;
		this.name = name;
	}

	/**
	 * Retrieve the type of origin.
	 *
	 * @return The origin type.
	 */
	public SourceType getType() {
		return type;
	}

	/**
	 * The name of the document origin.  Interpretation is relative to the type, but might be the
	 * resource name or file URL.
	 *
	 * @return The name.
	 */
	public String getName() {
		return name;
	}

	@Override
	public boolean equals(Object o) {
		if ( this == o ) {
			return true;
		}
		if ( !( o instanceof Origin ) ) {
			return false;
		}

		final Origin other = (Origin) o;
		return type == other.type
				&& EqualsHelper.equals( name, other.name );

	}

	@Override
	public int hashCode() {
		int result = type != null ? type.hashCode() : 0;
		result = 31 * result + ( name != null ? name.hashCode() : 0 );
		return result;
	}

	@Override
	public String toString() {
		return String.format( Locale.ENGLISH, "Origin(name=%s,type=%s)", name, type );
	}
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy