Home | History | Annotate | Download | only in bridge
      1 /*
      2  * Copyright (C) 2012 Google Inc.
      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  */
     16 
     17 package com.google.caliper.bridge;
     18 
     19 import com.google.caliper.model.Measurement;
     20 import com.google.common.base.Objects;
     21 import com.google.common.collect.ImmutableList;
     22 
     23 import java.io.Serializable;
     24 
     25 /**
     26  * A message signaling that the timing interval has ended in the worker.
     27  */
     28 public class StopMeasurementLogMessage extends LogMessage implements Serializable {
     29   private static final long serialVersionUID = 1L;
     30 
     31   private final ImmutableList<Measurement> measurements;
     32 
     33   public StopMeasurementLogMessage(Iterable<Measurement> measurements) {
     34     this.measurements = ImmutableList.copyOf(measurements);
     35   }
     36 
     37   public ImmutableList<Measurement> measurements() {
     38     return measurements;
     39   }
     40 
     41   @Override public void accept(LogMessageVisitor visitor) {
     42     visitor.visit(this);
     43   }
     44 
     45   @Override public int hashCode() {
     46     return Objects.hashCode(measurements);
     47   }
     48 
     49   @Override
     50   public boolean equals(Object obj) {
     51     if (obj == this) {
     52       return true;
     53     } else if (obj instanceof StopMeasurementLogMessage) {
     54       StopMeasurementLogMessage that = (StopMeasurementLogMessage) obj;
     55       return this.measurements.equals(that.measurements);
     56     } else {
     57       return false;
     58     }
     59   }
     60 }
     61