-
Notifications
You must be signed in to change notification settings - Fork 33
/
JTryResource.java
41 lines (35 loc) · 1000 Bytes
/
JTryResource.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package com.helger.jcodemodel;
import javax.annotation.Nonnull;
/**
* This class represents a single resources that is used in try-with-resources
* statement. See {@link JTryBlock}.
*
* @author Philip Helger
* @since 3.2.3
*/
public class JTryResource implements IJGenerable
{
private final JVar m_aVar;
public JTryResource (@Nonnull final AbstractJType aType,
@Nonnull final String sName,
@Nonnull final IJExpression aInitExpr)
{
this (JMod.FINAL, aType, sName, aInitExpr);
}
public JTryResource (final int nMods,
@Nonnull final AbstractJType aType,
@Nonnull final String sName,
@Nonnull final IJExpression aInitExpr)
{
m_aVar = new JVar (JMods.forVar (nMods), aType, sName, aInitExpr);
}
@Nonnull
public JVar var ()
{
return m_aVar;
}
public void generate (@Nonnull final IJFormatter aFormatter)
{
aFormatter.var (m_aVar);
}
}