/*
 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved.
 * ORACLE PROPRIETARY/CONFIDENTIAL. Use is subject to license terms.
 * 
 * $Id: JaxbLinkEx.java 73484 2014-02-13 13:09:45Z supol $ 
 */

package com.sun.ts.tests.jaxrs.api.rs.core.linkjaxbadapter;

import java.net.URI;
import java.util.HashMap;
import java.util.Map;

import javax.xml.bind.annotation.XmlAnyAttribute;
import javax.xml.bind.annotation.XmlAttribute;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.namespace.QName;

/**
 * JaxbLink with setters and xml annotations
 */
@XmlRootElement
public class JaxbLinkEx {

	protected URI uri;
	protected Map<QName, Object> params;

	/**
	 * Default constructor needed during unmarshalling.
	 */
	public JaxbLinkEx() {
	}

	/**
	 * Construct an instance from a URI and no parameters.
	 * 
	 * @param uri
	 *            underlying URI.
	 */
	public JaxbLinkEx(URI uri) {
		this.uri = uri;
	}

	/**
	 * Construct an instance from a URI and some parameters.
	 * 
	 * @param uri
	 *            underlying URI.
	 * @param params
	 *            parameters of this link.
	 */
	public JaxbLinkEx(URI uri, Map<QName, Object> params) {
		this.uri = uri;
		this.params = params;
	}

	/**
	 * Get the underlying URI for this link.
	 * 
	 * @return underlying URI.
	 */
	@XmlAttribute(name = "href")
	public URI getUri() {
		return uri;
	}

	/**
	 * Get the parameter map for this link.
	 * 
	 * @return parameter map.
	 */
	@XmlAnyAttribute
	public Map<QName, Object> getParams() {
		if (params == null) {
			params = new HashMap<QName, Object>();
		}
		return params;
	}

	public void setUri(final URI uri) {
		this.uri = uri;
	}

	public void setParams(final Map<QName, Object> params) {
		this.params = params;
	}
}
