View Javadoc
1   /*-
2    * #%L
3    * io.earcam.instrumental.module.jpms
4    * %%
5    * Copyright (C) 2018 earcam
6    * %%
7    * SPDX-License-Identifier: (BSD-3-Clause OR EPL-1.0 OR Apache-2.0 OR MIT)
8    * 
9    * You <b>must</b> choose to accept, in full - any individual or combination of 
10   * the following licenses:
11   * <ul>
12   * 	<li><a href="https://opensource.org/licenses/BSD-3-Clause">BSD-3-Clause</a></li>
13   * 	<li><a href="https://www.eclipse.org/legal/epl-v10.html">EPL-1.0</a></li>
14   * 	<li><a href="https://www.apache.org/licenses/LICENSE-2.0">Apache-2.0</a></li>
15   * 	<li><a href="https://opensource.org/licenses/MIT">MIT</a></li>
16   * </ul>
17   * #L%
18   */
19  package io.earcam.instrumental.module.jpms;
20  
21  import java.io.Serializable;
22  import java.util.Objects;
23  import java.util.Set;
24  
25  import javax.annotation.concurrent.Immutable;
26  
27  /**
28   * <p>
29   * Require class.
30   * </p>
31   *
32   */
33  @Immutable
34  public class Require implements Serializable {
35  
36  	private static final long serialVersionUID = 935948472668991696L;
37  	private final String module;
38  	private final int access;
39  	private final String version;
40  
41  
42  	/**
43  	 * <p>
44  	 * Constructor for Require.
45  	 * </p>
46  	 *
47  	 * @param module a {@link java.lang.String} object.
48  	 * @param access a int.
49  	 * @param version a {@link java.lang.String} object.
50  	 */
51  	public Require(String module, int access, String version)
52  	{
53  		this.module = module;
54  		this.access = access;
55  		this.version = version;
56  	}
57  
58  
59  	@Override
60  	public boolean equals(Object other)
61  	{
62  		return other instanceof Require && equals((Require) other);
63  	}
64  
65  
66  	/**
67  	 * <p>
68  	 * equals.
69  	 * </p>
70  	 *
71  	 * @param that a {@link io.earcam.instrumental.module.jpms.Require} object.
72  	 * @return a boolean.
73  	 */
74  	public boolean equals(Require that)
75  	{
76  		return that != null
77  				&& Objects.equals(that.module(), module)
78  				&& that.access() == access
79  				&& Objects.equals(that.version(), version);
80  	}
81  
82  
83  	@Override
84  	public int hashCode()
85  	{
86  		return Objects.hash(module, access, version);
87  	}
88  
89  
90  	/**
91  	 * <p>
92  	 * module.
93  	 * </p>
94  	 *
95  	 * @return a {@link java.lang.String} object.
96  	 */
97  	public String module()
98  	{
99  		return module;
100 	}
101 
102 
103 	/**
104 	 * <p>
105 	 * access.
106 	 * </p>
107 	 *
108 	 * @return a int.
109 	 */
110 	public int access()
111 	{
112 		return access;
113 	}
114 
115 
116 	/**
117 	 * <p>
118 	 * modifiers.
119 	 * </p>
120 	 *
121 	 * @return a {@link java.util.Set} object.
122 	 */
123 	public Set<RequireModifier> modifiers()
124 	{
125 		return Access.modifiers(RequireModifier.class, access());
126 	}
127 
128 
129 	/**
130 	 * <p>
131 	 * version.
132 	 * </p>
133 	 *
134 	 * @return a {@link java.lang.String} object.
135 	 */
136 	public String version()
137 	{
138 		return version;
139 	}
140 }