wwndesc
1.0-76
Main Page
Related Pages
Data Structures
Files
File List
DevRole.java
Go to the documentation of this file.
1
/* smallfoot.org is owned by allan.clark */
2
package
org.smallfoot.wwn;
3
4
/** @file */
5
6
/**
7
* This class seeks to provide simple bitfield type-checking of a device in a fabric
8
* so that I can use type-specific actions in a dependent project. By using this
9
* class to lift the assumption that all known devices are Targets, I can create
10
* additional possible matches that can be additionally checked when asked for more
11
* than default target types. This lets me later package the logic of subparts of
12
* a device (WWNN and WWPN) into the device logic itself, packaging up in a single
13
* place and avoiding needless diuplication without significantly stressing this
14
* model
15
*
16
* @see http://www.javaworld.com/article/2076970/core-java/create-enumerated-constants-in-java.html
17
*/
18
public
final
class
DevRole
19
{
20
public
final
int
value
;
/**< what bit-field is this constant? */
21
private
static
int
max
= 1;
/**< global singleton to keep track of the max DevRole.value so far */
22
23
/** create a new constant, but private to stop extensions or descendents */
24
private
DevRole
()
25
{
26
this.value =
max
;
27
max <<= 1;
28
}
29
30
/**
31
* return true if the device is an instance of the other. For example: if (theTapeDevice.isA(TAPE)) {...}
32
*
33
* @param proto device to compare to
34
*
35
* @return whether device is an instance
36
*/
37
public
boolean
isA
(
DevRole
proto)
38
{
39
return
isA
(proto.
value
);
40
}
41
42
/**
43
* return true if the device is an instance of the other. For example: if (theTapeDevice.isA(TAPE)) {...}
44
*
45
* @param proto device to compare to
46
*
47
* @return whether device is an instance
48
*/
49
public
boolean
isA
(
int
proto)
50
{
51
return
(0 < (value & proto));
52
}
53
54
/**
55
* convenience accessor for this.max
56
*
57
* @return DevRole#max
58
*/
59
public
static
int
max
()
60
{
61
return
max
;
/**< report highest left-shift bit value ever created; someDevice.value == (someDevice.value & (max()-1)) */
62
}
63
public
static
final
DevRole
TARGET
=
new
DevRole
();
/**< a device that offers storage via >1 LUNs ; contrast a TAPE offers only one LUN */
64
static
final
int
TARGETbit = TARGET.
value
;
65
public
static
final
DevRole
INITIATOR
=
new
DevRole
();
/**< a device that initiates a storage request: a server, or a Storage Virtualizer port that talks to backing storage */
66
static
final
int
INITIATORbit = INITIATOR.
value
;
67
public
static
final
DevRole
SWITCH
=
new
DevRole
();
/**< a device that routes/passes traffic: Switch, NPV device/back-of-rack, FCR */
68
static
final
int
SWITCHbit = SWITCH.
value
;
69
}
org.smallfoot.wwn.DevRole.DevRole
DevRole()
create a new constant, but private to stop extensions or descendents
Definition:
DevRole.java:24
org.smallfoot.wwn.DevRole.isA
boolean isA(DevRole proto)
return true if the device is an instance of the other.
Definition:
DevRole.java:37
org.smallfoot.wwn.DevRole.value
final int value
what bit-field is this constant?
Definition:
DevRole.java:20
org.smallfoot.wwn.DevRole.max
static int max()
convenience accessor for this.max
Definition:
DevRole.java:59
org.smallfoot.wwn.DevRole.isA
boolean isA(int proto)
return true if the device is an instance of the other.
Definition:
DevRole.java:49
org.smallfoot.wwn.DevRole.INITIATOR
static final DevRole INITIATOR
a device that initiates a storage request: a server, or a Storage Virtualizer port that talks to back...
Definition:
DevRole.java:65
org.smallfoot.wwn.DevRole
This class seeks to provide simple bitfield type-checking of a device in a fabric so that I can use t...
Definition:
DevRole.java:18
org.smallfoot.wwn.DevRole.SWITCH
static final DevRole SWITCH
a device that routes/passes traffic: Switch, NPV device/back-of-rack, FCR
Definition:
DevRole.java:67
org.smallfoot.wwn.DevRole.TARGET
static final DevRole TARGET
a device that offers storage via >1 LUNs ; contrast a TAPE offers only one LUN
Definition:
DevRole.java:63
java
DevRole.java
Generated on Wed Apr 22 2015 08:56:53 for wwndesc by
1.8.9.1