CitationType.java

/*
 * Copyright 2024 Global Crop Diversity Trust
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *   http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package org.genesys.server.model.bib;

public enum CitationType {
	JOURNAL_ARTICLE("JOUR"),
	BOOK("BOOK"),
	BOOK_SECTION("CHAP"),
	CONFERENCE_PROCEEDINGS("CONF"),
	AGGREGATED_DATABASE("AGGR"),
	ONLINE_DATABASE("DBASE"),
	DATASET("DATA"),
	COMPUTER_PROGRAM("COMP"),
	BLOG("BLOG"),
	MANUSCRIPT("MANSCPT"),
	PAMPHLET("PAMP"),
	REPORT("RPRT"),
	THESIS("THES"),
	UNPUBLISHED_WORK("UNPB"),
	VIDEO_RECORDING("VIDEO"),
	WEB_PAGE("WEB"),
	OTHER("GEN");

	private final String code;

	private CitationType(String code) {
		this.code = code;
	}

	public String getCode() {
		return code;
	}

	/**
	 * Get {@code CitationType} from RIS code
	 */
	public static CitationType forValue(String code) {
		switch (code) {
			case "JOUR": return JOURNAL_ARTICLE;
			case "BOOK": return BOOK;
			case "CHAP": return BOOK_SECTION;
			case "CONF": return CONFERENCE_PROCEEDINGS;
			case "AGGR": return AGGREGATED_DATABASE;
			case "DBASE": return ONLINE_DATABASE;
			case "DATA": return DATASET;
			case "COMP": return COMPUTER_PROGRAM;
			case "BLOG": return BLOG;
			case "MANSCPT": return MANUSCRIPT;
			case "PAMP": return PAMPHLET;
			case "RPRT": return REPORT;
			case "THES": return THESIS;
			case "UNPB": return UNPUBLISHED_WORK;
			case "VIDEO": return VIDEO_RECORDING;
			case "WEB": return WEB_PAGE;

			default: return OTHER;
		}
	}
}