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.CompressionAlgorithmTags; 022 023public enum CompressionAlgorithm { 024 025 UNCOMPRESSED (CompressionAlgorithmTags.UNCOMPRESSED), 026 ZIP (CompressionAlgorithmTags.ZIP), 027 ZLIB (CompressionAlgorithmTags.ZLIB), 028 BZIP2 (CompressionAlgorithmTags.BZIP2), 029 ; 030 031 private static final Map<Integer, CompressionAlgorithm> MAP = new HashMap<>(); 032 033 static { 034 for (CompressionAlgorithm c : CompressionAlgorithm.values()) { 035 MAP.put(c.algorithmId, c); 036 } 037 } 038 039 public static CompressionAlgorithm fromId(int id) { 040 return MAP.get(id); 041 } 042 043 private final int algorithmId; 044 045 CompressionAlgorithm(int id) { 046 this.algorithmId = id; 047 } 048 049 public int getAlgorithmId() { 050 return algorithmId; 051 } 052}