001/*
002 *  Copyright 2019 Anyware Services
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 org.ametys.cms.data;
017
018/**
019 * Class containing a reference
020 */
021public class Reference
022{
023    /** The value identifier */
024    public static final String VALUE_IDENTIFIER = "value";
025    /** The type identifier */
026    public static final String TYPE_IDENTIFIER = "type";
027    
028    /** The default type */
029    public static final String DEFAULT_TYPE = "__external";
030    
031    private String _value;
032    private String _type;
033    
034    /**
035     * Constructs a reference
036     * @param value the value of the reference
037     */
038    public Reference(String value)
039    {
040        this(value, null);
041    }
042    
043    /**
044     * Constructs a reference
045     * @param value the value of the reference
046     * @param type the type of the reference. For example, the type of an URL is '__external'
047     */
048    public Reference(String value, String type)
049    {
050        _type = type != null ? type : DEFAULT_TYPE;
051        _value = value;
052    }
053
054    /**
055     * Retrieves the value
056     * @return the value
057     */
058    public String getValue()
059    {
060        return _value;
061    }
062
063    /**
064     * Retrieves the type
065     * @return the type
066     */
067    public String getType()
068    {
069        return _type;
070    }
071}