001/*
002 *   Copyright 2024 Vonage
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 */
016package com.vonage.client.common;
017
018import com.fasterxml.jackson.annotation.JsonIgnore;
019import com.fasterxml.jackson.annotation.JsonProperty;
020import com.vonage.client.JsonableBaseObject;
021import java.net.URI;
022
023/**
024 * Represents the {@code _links} section of a HAL response.
025 */
026public class HalLinks extends JsonableBaseObject {
027        @JsonProperty("first") UrlContainer first;
028        @JsonProperty("self") UrlContainer self;
029        @JsonProperty("prev") UrlContainer prev;
030        @JsonProperty("next") UrlContainer next;
031        @JsonProperty("last") UrlContainer last;
032
033        protected HalLinks() {
034        }
035
036        /**
037         * The {@code href} property of {@code first}.
038         *
039         * @return URL of the first page, or {@code null} if absent.
040         */
041        @JsonIgnore
042        public URI getFirstUrl() {
043                return first != null ? first.getHref() : null;
044        }
045
046        /**
047         * The {@code href} property of {@code self}.
048         *
049         * @return URL of the current page, or {@code null} if absent.
050         */
051        @JsonIgnore
052        public URI getSelfUrl() {
053                return self != null ? self.getHref() : null;
054        }
055
056        /**
057         * The {@code href} property of {@code prev}.
058         *
059         * @return URL of the previous page, or {@code null} if absent.
060         */
061        @JsonIgnore
062        public URI getPrevUrl() {
063                return prev != null ? prev.getHref() : null;
064        }
065
066        /**
067         * The {@code href} property of {@code next}.
068         *
069         * @return URL of the next page, or {@code null} if absent.
070         */
071        @JsonIgnore
072        public URI getNextUrl() {
073                return next != null ? next.getHref() : null;
074        }
075
076        /**
077         * The {@code href} property of {@code last}.
078         *
079         * @return URL of the last page, or {@code null} if absent.
080         */
081        @JsonIgnore
082        public URI getLastUrl() {
083                return last != null ? last.getHref() : null;
084        }
085}