blob: e605dcfdba1933be371a5c69a5ac7e53dd1387a4 [file] [log] [blame]
Marc De Leenheerb0fb41d2015-12-03 22:16:53 -08001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16package org.onosproject.net;
17
18import java.util.Comparator;
19
20import static com.google.common.base.Preconditions.checkArgument;
21import static com.google.common.base.Preconditions.checkNotNull;
22
23/**
24 * Comparator implementation for OchSignal. Assumes identical grid type and channel spacing.
25 */
26public class DefaultOchSignalComparator implements Comparator<OchSignal> {
27 @Override
28 public int compare(OchSignal o1, OchSignal o2) {
29 checkNotNull(o1.gridType());
30 checkNotNull(o1.channelSpacing());
31
32 checkArgument(o1.gridType().equals(o2.gridType()));
33 checkArgument(o1.channelSpacing().equals(o2.channelSpacing()));
34
35 return o1.spacingMultiplier() * o1.slotGranularity() - o2.spacingMultiplier() * o2.slotGranularity();
36 }
37}