Debian Codegraph @

src/main/java/ezvcard/parameter/SoundType.java

raw symbols SCIP
1 package ezvcard.parameter;
2
3 import java.util.Collection;
4
5 import ezvcard.property.Sound;
6
7 /*
8 * Copyright 2011 George El-Haddad. All rights reserved.
9 *
10 * Redistribution and use in source and binary forms, with or without modification, are
11 * permitted provided that the following conditions are met:
12 *
13 * 1. Redistributions of source code must retain the above copyright notice, this list of
14 * conditions and the following disclaimer.
15 *
16 * 2. Redistributions in binary form must reproduce the above copyright notice, this list
17 * of conditions and the following disclaimer in the documentation and/or other materials
18 * provided with the distribution.
19 *
20 * THIS SOFTWARE IS PROVIDED BY GEORGE EL-HADDAD ''AS IS'' AND ANY EXPRESS OR IMPLIED
21 * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
22 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL GEORGE EL-HADDAD OR
23 * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
24 * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
25 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
26 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
28 * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29 *
30 * The views and conclusions contained in the software and documentation are those of the
31 * authors and should not be interpreted as representing official policies, either expressed
32 * or implied, of George El-Haddad.
33 */
34
35 /*
36 Copyright (c) 2012-2023, Michael Angstadt
37 All rights reserved.
38
39 Redistribution and use in source and binary forms, with or without
40 modification, are permitted provided that the following conditions are met:
41
42 1. Redistributions of source code must retain the above copyright notice, this
43 list of conditions and the following disclaimer.
44 2. Redistributions in binary form must reproduce the above copyright notice,
45 this list of conditions and the following disclaimer in the documentation
46 and/or other materials provided with the distribution.
47
48 THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
49 ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
50 WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
51 DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
52 ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
53 (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
54 LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
55 ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
56 (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
57 SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
58
59 The views and conclusions contained in the software and documentation are those
60 of the authors and should not be interpreted as representing official policies,
61 either expressed or implied, of the FreeBSD Project.
62 */
63
64 /**
65 * Represents the TYPE parameter of the {@link Sound} property.
66 * <p>
67 * <b>Supported versions:</b> {@code 2.1, 3.0, 4.0}
68 * </p>
69 * @author George El-Haddad Mar 10, 2010
70 * @author Michael Angstadt
71 */
72 public class SoundType extends MediaTypeParameter {
73 private static final MediaTypeCaseClasses<SoundType> enums = new MediaTypeCaseClasses<>(SoundType.class);
74
75 public static final SoundType AAC = new SoundType("AAC", "audio/aac", "aac");
76 public static final SoundType MIDI = new SoundType("MIDI", "audio/midi", "mid");
77 public static final SoundType MP3 = new SoundType("MP3", "audio/mp3", "mp3");
78 public static final SoundType MPEG = new SoundType("MPEG", "audio/mpeg", "mpeg");
79 public static final SoundType OGG = new SoundType("OGG", "audio/ogg", "ogg");
80 public static final SoundType WAV = new SoundType("WAV", "audio/wav", "wav");
81
82 private SoundType(String value, String mediaType, String extension) {
83 super(value, mediaType, extension);
84 }
85
86 /**
87 * Searches for a parameter value that is defined as a static constant in
88 * this class.
89 * @param type the TYPE parameter value to search for (e.g. "MP3") or null
90 * to not search by this value
91 * @param mediaType the media type to search for (e.g. "audio/mp3") or null
92 * to not search by this value
93 * @param extension the file extension to search for (excluding the ".",
94 * e.g. "mp3") or null to not search by this value
95 * @return the object or null if not found
96 */
97 public static SoundType find(String type, String mediaType, String extension) {
98 return enums.find(new String[] { type, mediaType, extension });
99 }
100
101 /**
102 * Searches for a parameter value and creates one if it cannot be found. All
103 * objects are guaranteed to be unique, so they can be compared with
104 * {@code ==} equality.
105 * @param type the TYPE parameter value to search for (e.g. "MP3") or null
106 * to not search by this value
107 * @param mediaType the media type to search for (e.g. "audio/mp3") or null
108 * to not search by this value
109 * @param extension the file extension to search for (excluding the ".",
110 * e.g. "mp3") or null to not search by this value
111 * @return the object
112 */
113 public static SoundType get(String type, String mediaType, String extension) {
114 return enums.get(new String[] { type, mediaType, extension });
115 }
116
117 /**
118 * Gets all of the parameter values that are defined as static constants in
119 * this class.
120 * @return the parameter values
121 */
122 public static Collection<SoundType> all() {
123 return enums.all();
124 }
125 }