001/* 002 * Copyright 2018 Paul Schaub. 003 * 004 * Licensed under the Apache License, Version 2.0 (the "License"); 005 * you may not use this file except in compliance with the License. 006 * You may obtain a copy of the License at 007 * 008 * http://www.apache.org/licenses/LICENSE-2.0 009 * 010 * Unless required by applicable law or agreed to in writing, software 011 * distributed under the License is distributed on an "AS IS" BASIS, 012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 013 * See the License for the specific language governing permissions and 014 * limitations under the License. 015 */ 016package org.pgpainless.algorithm; 017 018import java.util.HashMap; 019import java.util.Map; 020 021import org.bouncycastle.bcpg.sig.Features; 022 023public enum Feature { 024 025 /** 026 * Add modification detection package. 027 * 028 * @see <a href="https://tools.ietf.org/html/rfc4880#section-5.14"> 029 * RFC-4880 ยง5.14: Modification Detection Code Packet</a> 030 */ 031 MODIFICATION_DETECTION(Features.FEATURE_MODIFICATION_DETECTION), 032 ; 033 034 private static final Map<Byte, Feature> MAP = new HashMap<>(); 035 036 static { 037 for (Feature f : Feature.values()) { 038 MAP.put(f.featureId, f); 039 } 040 } 041 042 public static Feature fromId(byte id) { 043 return MAP.get(id); 044 } 045 046 private final byte featureId; 047 048 Feature(byte featureId) { 049 this.featureId = featureId; 050 } 051 052 public byte getFeatureId() { 053 return featureId; 054 } 055}