/*
 * Copyright (c) Facebook, Inc. and its affiliates.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package com.facebook.buck.doctor.config;

import com.facebook.buck.core.model.BuildId;
import com.google.common.base.Preconditions;
import java.nio.file.Path;
import java.util.Date;
import java.util.List;
import java.util.Optional;
import java.util.OptionalInt;
import org.immutables.value.Value;

@Value.Immutable(copy = false, builder = false)
public interface BuildLogEntry {

  @Value.Parameter
  Path getRelativePath();

  @Value.Parameter
  Optional<BuildId> getBuildId();

  @Value.Parameter
  Optional<List<String>> getCommandArgs();

  @Value.Parameter
  Optional<List<String>> getExpandedCommandArgs();

  @Value.Parameter
  OptionalInt getExitCode();

  @Value.Parameter
  OptionalInt getBuildTimeMs();

  @Value.Parameter
  Optional<Path> getRuleKeyLoggerLogFile();

  @Value.Parameter
  Optional<Path> getMachineReadableLogFile();

  @Value.Parameter
  Optional<Path> getRuleKeyDiagKeysFile();

  @Value.Parameter
  Optional<Path> getRuleKeyDiagGraphFile();

  @Value.Parameter
  Optional<Path> getTraceFile();

  @Value.Parameter
  Optional<Path> getConfigJsonFile();

  @Value.Parameter
  Optional<Path> getBuckFixSpecFile();

  @Value.Parameter
  long getSize();

  @Value.Parameter
  Date getLastModifiedTime();

  @Value.Check
  default void pathIsRelative() {
    Preconditions.checkState(!getRelativePath().isAbsolute());
    if (getRuleKeyLoggerLogFile().isPresent()) {
      Preconditions.checkState(!getRuleKeyLoggerLogFile().get().isAbsolute());
    }
    if (getTraceFile().isPresent()) {
      Preconditions.checkState(!getTraceFile().get().isAbsolute());
    }
  }
}

@@ -698,16 +698,78 @@
 uildId;%0A
+import com.facebook.buck.core.util.immutables.BuckStyleValue;%0A
 import c
@@ -976,54 +976,22 @@
 ;%0A%0A@
-Value.Immutable(copy = false, builder = false)
+BuckStyleValue
 %0Apub
@@ -1021,35 +1021,16 @@
 ntry %7B%0A%0A
-  @Value.Parameter%0A
   Path g
@@ -1048,35 +1048,16 @@
 ath();%0A%0A
-  @Value.Parameter%0A
   Option
@@ -1083,35 +1083,16 @@
 dId();%0A%0A
-  @Value.Parameter%0A
   Option
@@ -1127,35 +1127,16 @@
 rgs();%0A%0A
-  @Value.Parameter%0A
   Option
@@ -1179,35 +1179,16 @@
 rgs();%0A%0A
-  @Value.Parameter%0A
   Option
@@ -1209,35 +1209,16 @@
 ode();%0A%0A
-  @Value.Parameter%0A
   Option
@@ -1242,35 +1242,16 @@
 eMs();%0A%0A
-  @Value.Parameter%0A
   Option
@@ -1287,35 +1287,16 @@
 ile();%0A%0A
-  @Value.Parameter%0A
   Option
@@ -1334,35 +1334,16 @@
 ile();%0A%0A
-  @Value.Parameter%0A
   Option
@@ -1378,35 +1378,16 @@
 ile();%0A%0A
-  @Value.Parameter%0A
   Option
@@ -1423,35 +1423,16 @@
 ile();%0A%0A
-  @Value.Parameter%0A
   Option
@@ -1457,35 +1457,16 @@
 ile();%0A%0A
-  @Value.Parameter%0A
   Option
@@ -1496,35 +1496,16 @@
 ile();%0A%0A
-  @Value.Parameter%0A
   Option
@@ -1542,62 +1542,24 @@
 %0A%0A  
-@Value.Parameter%0A  long getSize();%0A%0A  @Value.Parameter
+long getSize();%0A
 %0A  D

Use @BuckStyleValue with @Check in BuildLogEntry