1 /*
2 * Copyright 2014 - 2020 Rafael Winterhalter
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16 package net.bytebuddy.description.modifier;
17
18 import net.bytebuddy.jar.asm.Opcodes;
19
20 /**
21 * Defines if a type or member is supposed to be marked as synthetic.
22 */
23 public enum SyntheticState implements ModifierContributor.ForType,
24 ModifierContributor.ForMethod,
25 ModifierContributor.ForField,
26 ModifierContributor.ForParameter {
27
28 /**
29 * Modifier for not marking a type member as synthetic. (This is the default modifier.)
30 */
31 PLAIN(EMPTY_MASK),
32
33 /**
34 * Modifier for marking a type member as synthetic.
35 */
36 SYNTHETIC(Opcodes.ACC_SYNTHETIC);
37
38 /**
39 * The mask of the modifier contributor.
40 */
41 private final int mask;
42
43 /**
44 * Creates a new synthetic state representation.
45 *
46 * @param mask The modifier mask of this instance.
47 */
48 SyntheticState(int mask) {
49 this.mask = mask;
50 }
51
52 /**
53 * {@inheritDoc}
54 */
55 public int getMask() {
56 return mask;
57 }
58
59 /**
60 * {@inheritDoc}
61 */
62 public int getRange() {
63 return Opcodes.ACC_SYNTHETIC;
64 }
65
66 /**
67 * {@inheritDoc}
68 */
69 public boolean isDefault() {
70 return this == PLAIN;
71 }
72
73 /**
74 * Checks if the current state describes the synthetic state.
75 *
76 * @return {@code true} if the current state is synthetic.
77 */
78 public boolean isSynthetic() {
79 return this == SYNTHETIC;
80 }
81 }
82