001/*
002 *    GeoAPI - Java interfaces for OGC/ISO standards
003 *    Copyright © 2004-2024 Open Geospatial Consortium, Inc.
004 *    http://www.geoapi.org
005 *
006 *    Licensed under the Apache License, Version 2.0 (the "License");
007 *    you may not use this file except in compliance with the License.
008 *    You may obtain a copy of the License at
009 *
010 *        http://www.apache.org/licenses/LICENSE-2.0
011 *
012 *    Unless required by applicable law or agreed to in writing, software
013 *    distributed under the License is distributed on an "AS IS" BASIS,
014 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
015 *    See the License for the specific language governing permissions and
016 *    limitations under the License.
017 */
018package org.opengis.metadata.maintenance;
019
020import org.opengis.util.CodeList;
021import org.opengis.annotation.UML;
022import org.opengis.geoapi.internal.Vocabulary;
023
024import static org.opengis.annotation.Obligation.*;
025import static org.opengis.annotation.Specification.*;
026
027
028/**
029 * Frequency with which modifications and deletions are made to the data after it is first produced.
030 *
031 * @author  Martin Desruisseaux (IRD)
032 * @author  Rémi Maréchal (Geomatys)
033 * @version 3.1
034 * @since   2.0
035 */
036@Vocabulary(capacity=15)
037@UML(identifier="MD_MaintenanceFrequencyCode", specification=ISO_19115)
038public final class MaintenanceFrequency extends CodeList<MaintenanceFrequency> {
039    /**
040     * Serial number for compatibility with different versions.
041     */
042    private static final long serialVersionUID = -6034786030982260550L;
043
044    /**
045     * Data is repeatedly and frequently updated.
046     */
047    @UML(identifier="continual", obligation=CONDITIONAL, specification=ISO_19115)
048    public static final MaintenanceFrequency CONTINUAL = new MaintenanceFrequency("CONTINUAL");
049
050    /**
051     * Data is updated each day.
052     */
053    @UML(identifier="daily", obligation=CONDITIONAL, specification=ISO_19115)
054    public static final MaintenanceFrequency DAILY = new MaintenanceFrequency("DAILY");
055
056    /**
057     * Data is updated on a weekly basis.
058     */
059    @UML(identifier="weekly", obligation=CONDITIONAL, specification=ISO_19115)
060    public static final MaintenanceFrequency WEEKLY = new MaintenanceFrequency("WEEKLY");
061
062    /**
063     * Data is updated every two weeks.
064     */
065    @UML(identifier="fortnightly", obligation=CONDITIONAL, specification=ISO_19115)
066    public static final MaintenanceFrequency FORTNIGHTLY = new MaintenanceFrequency("FORTNIGHTLY");
067
068    /**
069     * Data is updated each month.
070     */
071    @UML(identifier="monthly", obligation=CONDITIONAL, specification=ISO_19115)
072    public static final MaintenanceFrequency MONTHLY = new MaintenanceFrequency("MONTHLY");
073
074    /**
075     * Data is updated every three months.
076     */
077    @UML(identifier="quarterly", obligation=CONDITIONAL, specification=ISO_19115)
078    public static final MaintenanceFrequency QUARTERLY = new MaintenanceFrequency("QUARTERLY");
079
080    /**
081     * Data is updated twice each year.
082     */
083    @UML(identifier="biannually", obligation=CONDITIONAL, specification=ISO_19115)
084    public static final MaintenanceFrequency BIANNUALLY = new MaintenanceFrequency("BIANNUALLY");
085
086    /**
087     * Data is updated every year.
088     */
089    @UML(identifier="annually", obligation=CONDITIONAL, specification=ISO_19115)
090    public static final MaintenanceFrequency ANNUALLY = new MaintenanceFrequency("ANNUALLY");
091
092    /**
093     * Data is updated as deemed necessary.
094     */
095    @UML(identifier="asNeeded", obligation=CONDITIONAL, specification=ISO_19115)
096    public static final MaintenanceFrequency AS_NEEDED = new MaintenanceFrequency("AS_NEEDED");
097
098    /**
099     * Data is updated in intervals that are uneven in duration.
100     */
101    @UML(identifier="irregular", obligation=CONDITIONAL, specification=ISO_19115)
102    public static final MaintenanceFrequency IRREGULAR = new MaintenanceFrequency("IRREGULAR");
103
104    /**
105     * There are no plans to update the data.
106     */
107    @UML(identifier="notPlanned", obligation=CONDITIONAL, specification=ISO_19115)
108    public static final MaintenanceFrequency NOT_PLANNED = new MaintenanceFrequency("NOT_PLANNED");
109
110    /**
111     * Frequency of maintenance for the data is not known.
112     */
113    @UML(identifier="unknown", obligation=CONDITIONAL, specification=ISO_19115)
114    public static final MaintenanceFrequency UNKNOWN = new MaintenanceFrequency("UNKNOWN");
115
116    /**
117     * Resource is updated at regular intervals.
118     *
119     * @since 3.1
120     */
121    @UML(identifier="periodic", obligation=CONDITIONAL, specification=ISO_19115)
122    public static final MaintenanceFrequency PERIODIC = new MaintenanceFrequency("PERIODIC");
123
124    /**
125     * Resource updated twice a monthly.
126     *
127     * @since 3.1
128     */
129    @UML(identifier="semimonthly", obligation=CONDITIONAL, specification=ISO_19115)
130    public static final MaintenanceFrequency SEMIMONTHLY = new MaintenanceFrequency("SEMIMONTHLY");
131
132    /**
133     * Resource is updated every 2 years.
134     *
135     * @since 3.1
136     */
137    @UML(identifier="biennially", obligation=CONDITIONAL, specification=ISO_19115)
138    public static final MaintenanceFrequency BIENNIALLY = new MaintenanceFrequency("BIENNIALLY");
139
140    /**
141     * Constructs an element of the given name.
142     *
143     * @param name  the name of the new element. This name shall not be in use by another element of this type.
144     */
145    private MaintenanceFrequency(final String name) {
146        super(name);
147    }
148
149    /**
150     * Returns the list of {@code MaintenanceFrequency}s.
151     *
152     * @return the list of codes declared in the current JVM.
153     */
154    public static MaintenanceFrequency[] values() {
155        return values(MaintenanceFrequency.class);
156    }
157
158    /**
159     * Returns the list of codes of the same kind as this code list element.
160     * Invoking this method is equivalent to invoking {@link #values()}, except that
161     * this method can be invoked on an instance of the parent {@code CodeList} class.
162     *
163     * @return all code {@linkplain #values() values} for this code list.
164     */
165    @Override
166    public MaintenanceFrequency[] family() {
167        return values();
168    }
169
170    /**
171     * Returns the maintenance frequency that matches the given string, or returns a new one if none match it.
172     * This methods returns the first instance (in declaration order) for which the {@linkplain #name() name}
173     * is {@linkplain String#equalsIgnoreCase(String) equals, ignoring case}, to the given name.
174     * If no existing instance is found, then a new one is created for the given name.
175     *
176     * @param  code  the name of the code to fetch or to create.
177     * @return a code matching the given name.
178     */
179    public static MaintenanceFrequency valueOf(String code) {
180        return valueOf(MaintenanceFrequency.class, code, MaintenanceFrequency::new).get();
181    }
182}