/*
* Constellation - An open source and standard compliant SDI
* http://www.constellation-sdi.org
*
* Copyright 2014 Geomatys.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.constellation.configuration;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlValue;
import java.util.Objects;
/**
*
* @author Guilhem Legal (Geomatys)
* @since 0.6
*/
@XmlAccessorType(XmlAccessType.FIELD)
public class Reference {
@XmlAttribute(namespace="http://www.w3.org/1999/xlink")
private String href;
@XmlAttribute
private String authority;
@XmlValue
private String value;
public Reference() {
}
public Reference(final String href) {
this.href = href;
}
public Reference(final String authority, final String value) {
this.authority = authority;
this.value = value;
}
public Reference(final String href, final String authority, final String value) {
this.href = href;
this.authority = authority;
this.value = value;
}
/**
* @return the href
*/
public String getHref() {
return href;
}
/**
* @param href the href to set
*/
public void setHref(String href) {
this.href = href;
}
/**
* @return the authority
*/
public String getAuthority() {
return authority;
}
/**
* @param authority the authority to set
*/
public void setAuthority(String authority) {
this.authority = authority;
}
/**
* @return the value
*/
public String getValue() {
return value;
}
/**
* @param value the value to set
*/
public void setValue(String value) {
this.value = value;
}
@Override
public String toString() {
final StringBuilder sb = new StringBuilder("[Reference]");
if (authority != null) {
sb.append("authority=").append(authority).append('\n');
}
if (href != null) {
sb.append("href=").append(href).append('\n');
}
if (value != null) {
sb.append("value=").append(value).append('\n');
}
return sb.toString();
}
@Override
public boolean equals(final Object obj) {
if (obj instanceof Reference) {
final Reference that = (Reference) obj;
return Objects.equals(this.authority, that.authority) &&
Objects.equals(this.href, that.href) &&
Objects.equals(this.value, that.value);
}
return false;
}
@Override
public int hashCode() {
int hash = 5;
hash = 97 * hash + (this.href != null ? this.href.hashCode() : 0);
hash = 97 * hash + (this.authority != null ? this.authority.hashCode() : 0);
hash = 97 * hash + (this.value != null ? this.value.hashCode() : 0);
return hash;
}
}