001    /*
002     *    GeoAPI - Java interfaces for OGC/ISO standards
003     *    http://www.geoapi.org
004     *
005     *    Copyright (C) 2004-2012 Open Geospatial Consortium, Inc.
006     *    All Rights Reserved. http://www.opengeospatial.org/ogc/legal
007     *
008     *    Permission to use, copy, and modify this software and its documentation, with
009     *    or without modification, for any purpose and without fee or royalty is hereby
010     *    granted, provided that you include the following on ALL copies of the software
011     *    and documentation or portions thereof, including modifications, that you make:
012     *
013     *    1. The full text of this NOTICE in a location viewable to users of the
014     *       redistributed or derivative work.
015     *    2. Notice of any changes or modifications to the OGC files, including the
016     *       date changes were made.
017     *
018     *    THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE
019     *    NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
020     *    TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT
021     *    THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY
022     *    PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS.
023     *
024     *    COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR
025     *    CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION.
026     *
027     *    The name and trademarks of copyright holders may NOT be used in advertising or
028     *    publicity pertaining to the software without specific, written prior permission.
029     *    Title to copyright in this software and any associated documentation will at all
030     *    times remain with copyright holders.
031     */
032    package org.opengis.metadata.citation;
033    
034    import java.util.List;
035    import java.util.ArrayList;
036    
037    import org.opengis.util.CodeList;
038    import org.opengis.annotation.UML;
039    
040    import static org.opengis.annotation.Obligation.*;
041    import static org.opengis.annotation.Specification.*;
042    
043    
044    /**
045     * Function performed by the responsible party.
046     *
047     * @author  Martin Desruisseaux (IRD)
048     * @author  Cory Horner (Refractions Research)
049     * @version 3.0
050     * @since   2.0
051     */
052    @UML(identifier="CI_RoleCode", specification=ISO_19115)
053    public final class Role extends CodeList<Role> {
054        /**
055         * Serial number for compatibility with different versions.
056         */
057        private static final long serialVersionUID = -7763516018565534103L;
058    
059        /**
060         * List of all enumerations of this type.
061         * Must be declared before any enum declaration.
062         */
063        private static final List<Role> VALUES = new ArrayList<Role>(11);
064    
065        /**
066         * Party that supplies the resource.
067         */
068        @UML(identifier="resourceProvider", obligation=CONDITIONAL, specification=ISO_19115)
069        public static final Role RESOURCE_PROVIDER = new Role("RESOURCE_PROVIDER");
070    
071        /**
072         * Party that accepts accountability and responsibility for the data and ensures
073         * appropriate care and maintenance of the resource.
074         */
075        @UML(identifier="custodian", obligation=CONDITIONAL, specification=ISO_19115)
076        public static final Role CUSTODIAN = new Role("CUSTODIAN");
077    
078        /**
079         * Party that owns the resource.
080         */
081        @UML(identifier="owner", obligation=CONDITIONAL, specification=ISO_19115)
082        public static final Role OWNER = new Role("OWNER");
083    
084        /**
085         * Party who uses the resource.
086         */
087        @UML(identifier="user", obligation=CONDITIONAL, specification=ISO_19115)
088        public static final Role USER = new Role("USER");
089    
090        /**
091         * Party who distributes the resource.
092         */
093        @UML(identifier="distributor", obligation=CONDITIONAL, specification=ISO_19115)
094        public static final Role DISTRIBUTOR = new Role("DISTRIBUTOR");
095    
096        /**
097         * Party who created the resource.
098         */
099        @UML(identifier="originator", obligation=CONDITIONAL, specification=ISO_19115)
100        public static final Role ORIGINATOR = new Role("ORIGINATOR");
101    
102        /**
103         * Party who can be contacted for acquiring knowledge about or acquisition of the resource.
104         */
105        @UML(identifier="pointOfContact", obligation=CONDITIONAL, specification=ISO_19115)
106        public static final Role POINT_OF_CONTACT = new Role("POINT_OF_CONTACT");
107    
108        /**
109         * Key party responsible for gathering information and conducting research.
110         */
111        @UML(identifier="principalInvestigator", obligation=CONDITIONAL, specification=ISO_19115)
112        public static final Role PRINCIPAL_INVESTIGATOR = new Role("PRINCIPAL_INVESTIGATOR");
113    
114        /**
115         * Party who has processed the data in a manner such that the resource has been modified.
116         */
117        @UML(identifier="processor", obligation=CONDITIONAL, specification=ISO_19115)
118        public static final Role PROCESSOR = new Role("PROCESSOR");
119    
120        /**
121         * Party who published the resource.
122         */
123        @UML(identifier="publisher", obligation=CONDITIONAL, specification=ISO_19115)
124        public static final Role PUBLISHER = new Role("PUBLISHER");
125    
126        /**
127         * Party who authored the resource.
128         *
129         * @since 2.1
130         */
131        @UML(identifier="author", obligation=CONDITIONAL, specification=ISO_19115)
132        public static final Role AUTHOR = new Role("AUTHOR");
133    
134        /**
135         * Constructs an enum with the given name. The new enum is
136         * automatically added to the list returned by {@link #values}.
137         *
138         * @param name The enum name. This name must not be in use by an other enum of this type.
139         */
140        private Role(final String name) {
141            super(name, VALUES);
142        }
143    
144        /**
145         * Returns the list of {@code Role}s.
146         *
147         * @return The list of codes declared in the current JVM.
148         */
149        public static Role[] values() {
150            synchronized (VALUES) {
151                return VALUES.toArray(new Role[VALUES.size()]);
152            }
153        }
154    
155        /**
156         * Returns the list of enumerations of the same kind than this enum.
157         */
158        @Override
159        public Role[] family() {
160            return values();
161        }
162    
163        /**
164         * Returns the role that matches the given string, or returns a
165         * new one if none match it. More specifically, this methods returns the first instance for
166         * which <code>{@linkplain #name() name()}.{@linkplain String#equals equals}(code)</code>
167         * returns {@code true}. If no existing instance is found, then a new one is created for
168         * the given name.
169         *
170         * @param code The name of the code to fetch or to create.
171         * @return A code matching the given name.
172         */
173        public static Role valueOf(String code) {
174            return valueOf(Role.class, code);
175        }
176    }