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