001/* 002 * CDDL HEADER START 003 * 004 * The contents of this file are subject to the terms of the 005 * Common Development and Distribution License, Version 1.0 only 006 * (the "License"). You may not use this file except in compliance 007 * with the License. 008 * 009 * You can obtain a copy of the license at legal-notices/CDDLv1_0.txt 010 * or http://forgerock.org/license/CDDLv1.0.html. 011 * See the License for the specific language governing permissions 012 * and limitations under the License. 013 * 014 * When distributing Covered Code, include this CDDL HEADER in each 015 * file and include the License file at legal-notices/CDDLv1_0.txt. 016 * If applicable, add the following below this CDDL HEADER, with the 017 * fields enclosed by brackets "[]" replaced with your own identifying 018 * information: 019 * Portions Copyright [yyyy] [name of copyright owner] 020 * 021 * CDDL HEADER END 022 * 023 * 024 * Copyright 2008 Sun Microsystems, Inc. 025 * Portions Copyright 2015 ForgeRock AS. 026 */ 027package org.opends.server.replication.common; 028 029/** 030 * The various modes supported for assured replication. 031 */ 032public enum AssuredMode 033{ 034 /** Safe read assured mode. */ 035 SAFE_READ_MODE((byte) 1), 036 /** Safe data assured mode. */ 037 SAFE_DATA_MODE((byte) 2); 038 039 /** The mode value. */ 040 private byte value = -1; 041 042 private AssuredMode(byte value) 043 { 044 this.value = value; 045 } 046 047 /** 048 * Returns the AssuredMode matching the passed mode numeric representation. 049 * @param value The numeric value for the mode to return 050 * @return The matching AssuredMode 051 * @throws java.lang.IllegalArgumentException If provided mode value is 052 * wrong 053 */ 054 public static AssuredMode valueOf(byte value) throws IllegalArgumentException 055 { 056 switch (value) 057 { 058 case 1: 059 return SAFE_READ_MODE; 060 case 2: 061 return SAFE_DATA_MODE; 062 default: 063 throw new IllegalArgumentException("Wrong assured mode numeric value: " 064 + value); 065 } 066 } 067 068 /** 069 * Get a numeric representation of the mode. 070 * @return The numeric representation of the mode 071 */ 072 public byte getValue() 073 { 074 return value; 075 } 076 077}