Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
F
floodlight
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
croft1
floodlight
Commits
d38ef320
Commit
d38ef320
authored
13 years ago
by
Gregor Maier
Browse files
Options
Downloads
Patches
Plain Diff
Restructure code. Put all the constructors together! No other changes.
parent
dbe6f9ec
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/main/java/net/floodlightcontroller/devicemanager/internal/Device.java
+56
-54
56 additions, 54 deletions
...t/floodlightcontroller/devicemanager/internal/Device.java
with
56 additions
and
54 deletions
src/main/java/net/floodlightcontroller/devicemanager/internal/Device.java
+
56
−
54
View file @
d38ef320
...
@@ -95,6 +95,61 @@ public class Device implements IDevice {
...
@@ -95,6 +95,61 @@ public class Device implements IDevice {
}
}
}
}
/**
* Create a device from a set of entities
* @param deviceManager the device manager for this device
* @param deviceKey the unique identifier for this device object
* @param entities the initial entities for the device
* @param entityClass the entity class associated with the entities
*/
public
Device
(
DeviceManagerImpl
deviceManager
,
Long
deviceKey
,
Collection
<
AttachmentPoint
>
attachmentPoints
,
Collection
<
Entity
>
entities
,
IEntityClass
entityClass
)
{
this
.
deviceManager
=
deviceManager
;
this
.
deviceKey
=
deviceKey
;
this
.
entities
=
entities
.
toArray
(
new
Entity
[
entities
.
size
()]);
if
(
attachmentPoints
==
null
)
{
this
.
attachmentPoints
=
null
;
}
else
{
this
.
attachmentPoints
=
new
ArrayList
<
AttachmentPoint
>(
attachmentPoints
);
}
this
.
macAddressString
=
HexString
.
toHexString
(
this
.
entities
[
0
].
getMacAddress
(),
6
);
this
.
entityClass
=
entityClass
;
Arrays
.
sort
(
this
.
entities
);
}
/**
* Construct a new device consisting of the entities from the old device
* plus an additional entity
* @param device the old device object
* @param newEntity the entity to add. newEntity must be have the same
* entity class as device
*/
public
Device
(
Device
device
,
Entity
newEntity
)
{
this
.
deviceManager
=
device
.
deviceManager
;
this
.
deviceKey
=
device
.
deviceKey
;
this
.
entities
=
Arrays
.<
Entity
>
copyOf
(
device
.
entities
,
device
.
entities
.
length
+
1
);
this
.
entities
[
this
.
entities
.
length
-
1
]
=
newEntity
;
Arrays
.
sort
(
this
.
entities
);
if
(
device
.
attachmentPoints
!=
null
)
{
this
.
attachmentPoints
=
new
ArrayList
<
AttachmentPoint
>(
device
.
attachmentPoints
);
}
else
this
.
attachmentPoints
=
null
;
this
.
macAddressString
=
HexString
.
toHexString
(
this
.
entities
[
0
].
getMacAddress
(),
6
);
this
.
entityClass
=
device
.
entityClass
;
}
private
Map
<
Long
,
AttachmentPoint
>
getAPMap
()
{
private
Map
<
Long
,
AttachmentPoint
>
getAPMap
()
{
if
(
attachmentPoints
==
null
)
return
null
;
if
(
attachmentPoints
==
null
)
return
null
;
...
@@ -274,60 +329,7 @@ public class Device implements IDevice {
...
@@ -274,60 +329,7 @@ public class Device implements IDevice {
return
sp
.
toArray
(
new
SwitchPort
[
sp
.
size
()]);
return
sp
.
toArray
(
new
SwitchPort
[
sp
.
size
()]);
}
}
/**
* Create a device from a set of entities
* @param deviceManager the device manager for this device
* @param deviceKey the unique identifier for this device object
* @param entities the initial entities for the device
* @param entityClass the entity class associated with the entities
*/
public
Device
(
DeviceManagerImpl
deviceManager
,
Long
deviceKey
,
Collection
<
AttachmentPoint
>
attachmentPoints
,
Collection
<
Entity
>
entities
,
IEntityClass
entityClass
)
{
this
.
deviceManager
=
deviceManager
;
this
.
deviceKey
=
deviceKey
;
this
.
entities
=
entities
.
toArray
(
new
Entity
[
entities
.
size
()]);
if
(
attachmentPoints
==
null
)
{
this
.
attachmentPoints
=
null
;
}
else
{
this
.
attachmentPoints
=
new
ArrayList
<
AttachmentPoint
>(
attachmentPoints
);
}
this
.
macAddressString
=
HexString
.
toHexString
(
this
.
entities
[
0
].
getMacAddress
(),
6
);
this
.
entityClass
=
entityClass
;
Arrays
.
sort
(
this
.
entities
);
}
/**
* Construct a new device consisting of the entities from the old device
* plus an additional entity
* @param device the old device object
* @param newEntity the entity to add. newEntity must be have the same
* entity class as device
*/
public
Device
(
Device
device
,
Entity
newEntity
)
{
this
.
deviceManager
=
device
.
deviceManager
;
this
.
deviceKey
=
device
.
deviceKey
;
this
.
entities
=
Arrays
.<
Entity
>
copyOf
(
device
.
entities
,
device
.
entities
.
length
+
1
);
this
.
entities
[
this
.
entities
.
length
-
1
]
=
newEntity
;
Arrays
.
sort
(
this
.
entities
);
if
(
device
.
attachmentPoints
!=
null
)
{
this
.
attachmentPoints
=
new
ArrayList
<
AttachmentPoint
>(
device
.
attachmentPoints
);
}
else
this
.
attachmentPoints
=
null
;
this
.
macAddressString
=
HexString
.
toHexString
(
this
.
entities
[
0
].
getMacAddress
(),
6
);
this
.
entityClass
=
device
.
entityClass
;
}
// *******
// *******
// IDevice
// IDevice
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment