001/*
002 * Copyright 2012-2018 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      http://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.boot.actuate.endpoint.web;
018
019import java.util.Collections;
020import java.util.List;
021
022import org.springframework.util.Assert;
023
024/**
025 * Media types that are, by default, produced and consumed by an endpoint.
026 *
027 * @author Andy Wilkinson
028 * @since 2.0.0
029 */
030public class EndpointMediaTypes {
031
032        private final List<String> produced;
033
034        private final List<String> consumed;
035
036        /**
037         * Creates a new {@link EndpointMediaTypes} with the given {@code produced} and
038         * {@code consumed} media types.
039         * @param produced the default media types that are produced by an endpoint. Must not
040         * be {@code null}.
041         * @param consumed the default media types that are consumed by an endpoint. Must not
042         */
043        public EndpointMediaTypes(List<String> produced, List<String> consumed) {
044                Assert.notNull(produced, "Produced must not be null");
045                Assert.notNull(consumed, "Consumed must not be null");
046                this.produced = Collections.unmodifiableList(produced);
047                this.consumed = Collections.unmodifiableList(consumed);
048        }
049
050        /**
051         * Returns the media types produced by an endpoint.
052         * @return the produced media types
053         */
054        public List<String> getProduced() {
055                return this.produced;
056        }
057
058        /**
059         * Returns the media types consumed by an endpoint.
060         * @return the consumed media types
061         */
062        public List<String> getConsumed() {
063                return this.consumed;
064        }
065
066}