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

org.raml.model.Action Maven / Gradle / Ivy

There is a newer version: 0.8.40
Show newest version
/*
 * Copyright 2016 (c) MuleSoft, 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.raml.model;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;

import org.raml.model.parameter.Header;
import org.raml.model.parameter.QueryParameter;
import org.raml.model.parameter.UriParameter;
import org.raml.parser.annotation.Key;
import org.raml.parser.annotation.Mapping;
import org.raml.parser.annotation.Parent;
import org.raml.parser.annotation.Scalar;
import org.raml.parser.annotation.Sequence;
import org.raml.parser.resolver.MimeTypeHandler;
import org.raml.parser.resolver.ResponseHandler;
import org.raml.parser.rule.SecurityReferenceSequenceRule;

public class Action implements Serializable
{

    private static final long serialVersionUID = 8444315314405971949L;

    @Key
    private ActionType type;

    @Scalar
    private String description;

    @Mapping
    private Map headers = new LinkedHashMap();

    @Mapping
    private Map queryParameters = new LinkedHashMap();

    @Mapping(innerHandler = MimeTypeHandler.class)
    private Map body;

    @Mapping(innerHandler = ResponseHandler.class)
    private Map responses = new LinkedHashMap();

    @Parent
    private Resource resource;

    @Sequence
    private List is = new ArrayList();

    @Sequence
    private List protocols = new ArrayList();

    @Sequence(rule = SecurityReferenceSequenceRule.class)
    private List securedBy = new ArrayList();

    @Mapping(rule = org.raml.parser.rule.UriParametersRule.class)
    private Map> baseUriParameters = new LinkedHashMap>();

    public Action()
    {
    }

    public ActionType getType()
    {
        return type;
    }

    public void setType(ActionType type)
    {
        this.type = type;
    }

    public String getDescription()
    {
        return description;
    }

    public void setDescription(String description)
    {
        this.description = description;
    }

    public Map getHeaders()
    {
        return headers;
    }

    public void setHeaders(Map headers)
    {
        this.headers = headers;
    }

    public Map getQueryParameters()
    {
        return queryParameters;
    }

    public void setQueryParameters(Map queryParameters)
    {
        this.queryParameters = queryParameters;
    }

    public Map getBody()
    {
        return body;
    }

    public void setBody(Map body)
    {
        this.body = body;
    }

    public boolean hasBody()
    {
        return body != null && !body.isEmpty();
    }

    public Map getResponses()
    {
        return responses;
    }

    public void setResponses(Map responses)
    {
        this.responses = responses;
    }

    public Resource getResource()
    {
        return resource;
    }

    public void setResource(Resource resource)
    {
        this.resource = resource;
    }

    public List getIs()
    {
        return is;
    }

    public void setIs(List is)
    {
        this.is = is;
    }

    public List getProtocols()
    {
        return protocols;
    }

    public void setProtocols(List protocols)
    {
        this.protocols = protocols;
    }

    public List getSecuredBy()
    {
        return securedBy;
    }

    public void setSecuredBy(List securedBy)
    {
        this.securedBy = securedBy;
    }

    public Map> getBaseUriParameters()
    {
        return baseUriParameters;
    }

    public void setBaseUriParameters(Map> baseUriParameters)
    {
        this.baseUriParameters = baseUriParameters;
    }

    @Override
    public String toString()
    {
        return "Action{" +
               "type='" + type + '\'' +
               ", resource=" + (resource != null ? resource.getUri() : "-") + '}';
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy