Andreas Wundsam | bea97f5 | 2013-09-17 12:42:19 -0700 | [diff] [blame] | 1 | package org.projectfloodlight.openflow.types; |
| 2 | |
| 3 | /** |
| 4 | * Represents the speed of a port |
| 5 | */ |
| 6 | public enum PortSpeed { |
| 7 | /** no speed set */ |
| 8 | SPEED_NONE(0), |
| 9 | SPEED_10MB(10), |
| 10 | SPEED_100MB(100), |
| 11 | SPEED_1GB(1_000), |
| 12 | SPEED_10GB(10_000), |
| 13 | SPEED_40GB(40_000), |
| 14 | SPEED_100GB(100_000), |
| 15 | SPEED_1TB(1_000_000); |
| 16 | |
| 17 | private long speedInBps; |
| 18 | private PortSpeed(int speedInMbps) { |
| 19 | this.speedInBps = speedInMbps * 1000L*1000L; |
| 20 | } |
| 21 | |
| 22 | public long getSpeedBps() { |
| 23 | return this.speedInBps; |
| 24 | } |
| 25 | |
| 26 | public static PortSpeed max(PortSpeed s1, PortSpeed s2) { |
| 27 | return (s1.getSpeedBps() > s2.getSpeedBps()) ? s1 : s2; |
| 28 | } |
| 29 | |
| 30 | public static PortSpeed min(PortSpeed s1, PortSpeed s2) { |
| 31 | return (s1.getSpeedBps() < s2.getSpeedBps()) ? s1 : s2; |
| 32 | } |
| 33 | } |