a255c4696f0790be44f1911dc4b00f0c314a1b68
[ccsdk/apps.git] / sdnr / wireless-transport / code-Carbon-SR1 / apps / route / impl / src / main / java / com / highstreet / technologies / odl / app / impl / tools / Unit.java
1 /*
2  * Copyright © 2015 ZTE and others.  All rights reserved.
3  *
4  * This program and the accompanying materials are made available under the
5  * terms of the Eclipse Public License v1.0 which accompanies this distribution,
6  * and is available at http://www.eclipse.org/legal/epl-v10.html
7  */
8 package com.highstreet.technologies.odl.app.impl.tools;
9
10 /**
11  * Created by odl on 17-6-8.
12  */
13 public enum Unit
14 {
15     k_bits_s, m_bits_s(1024, k_bits_s), m_byte_s(8 * 1024, k_bits_s);
16
17     Unit(int ratio, Unit last)
18     {
19         this.ratio = ratio;
20         this.last = last;
21     }
22
23     Unit()
24     {
25         this.ratio = 1;
26         this.last = this;
27     }
28
29     private final int ratio;
30     private final Unit last;
31
32     public Double convert(double result, Unit from)
33     {
34         return result * ((double) from.ratio / (double) this.ratio);
35     }
36 }