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

org.restexpress.domain.metadata.RouteMetadata Maven / Gradle / Ivy

The newest version!
/*
    Copyright 2011, Strategic Gains, Inc.

	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.restexpress.domain.metadata;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Collections;
import java.util.List;

/**
 * @author toddf
 * @since Jan 31, 2011
 */
public class RouteMetadata
{
	private String name;
	private UriMetadata uri;
	private List aliases;
	private List supportedFormats;
	private String defaultFormat;
	private List methods = new ArrayList();
	private boolean isSerialized;
	private String baseUrl;

	public String getName()
	{
		return name;
	}

	public void setName(String name)
	{
		this.name = name;
	}

	public UriMetadata getUri()
	{
		return uri;
	}

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

	@SuppressWarnings("unchecked")
    public List getSupportedFormats()
	{
		return supportedFormats == null ? Collections.EMPTY_LIST : supportedFormats;
	}
	
	public void addSupportedFormat(String format)
	{
		if (supportedFormats == null)
		{
			supportedFormats = new ArrayList();
		}
		
		if (!getSupportedFormats().contains(format))
		{
			supportedFormats.add(format);
		}
	}

	public void addAllSupportedFormats(Collection formats)
	{
		for (String format : formats)
		{
			addSupportedFormat(format);
		}
	}

	public String getDefaultFormat()
	{
		return defaultFormat;
	}

	public void setDefaultFormat(String defaultFormat)
	{
		this.defaultFormat = defaultFormat;
	}
	
	@SuppressWarnings("unchecked")
    public List getMethods()
	{
		return methods == null ? Collections.EMPTY_LIST : methods;
	}
	
	public void addMethod(String method)
	{
		if (!methods.contains(method))
		{
			methods.add(method);
		}
	}
	
	public void addAllMethods(Collection methods)
	{
		for (String method : methods)
		{
			addMethod(method);
		}
	}

	public boolean isSerialized()
	{
		return isSerialized;
	}

	public void setSerialized(boolean isSerialized)
	{
		this.isSerialized = isSerialized;
	}
	
	@SuppressWarnings("unchecked")
    public List getAliases()
	{
		return aliases == null ? Collections.EMPTY_LIST : Collections.unmodifiableList(aliases);
	}
	
	public void addAlias(String alias)
	{
		if (aliases == null)
		{
			aliases = new ArrayList();
		}

		if (!aliases.contains(alias))
		{
			aliases.add(alias);
		}
	}
	
	public void addAllAliases(List aliases)
	{
		for (String alias : aliases)
		{
			addAlias(alias);
		}
	}
	
	public String getBaseUrl()
	{
		return baseUrl;
	}
	
	public void setBaseUrl(String baseUrl)
	{
		this.baseUrl = baseUrl;
	}
}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy