1 package org.kuali.common.devops.archive.sweep.model; 2 3 import static com.google.common.base.Optional.absent; 4 5 import java.io.File; 6 7 import org.kuali.common.core.base.TimedInterval; 8 import org.kuali.common.core.build.ValidatingBuilder; 9 10 import com.google.common.base.Optional; 11 import com.google.common.base.Stopwatch; 12 13 public final class PutFileResult { 14 15 private final File file; 16 private final Optional<Exception> exception; 17 private final TimedInterval timing; 18 19 private PutFileResult(Builder builder) { 20 this.file = builder.file; 21 this.exception = builder.exception; 22 this.timing = builder.timing; 23 } 24 25 public static Builder builder() { 26 return new Builder(); 27 } 28 29 public static class Builder extends ValidatingBuilder<PutFileResult> { 30 31 private File file; 32 private Optional<Exception> exception = absent(); 33 private TimedInterval timing; 34 35 public Builder withFile(File file) { 36 this.file = file; 37 return this; 38 } 39 40 public Builder withException(Optional<Exception> exception) { 41 this.exception = exception; 42 return this; 43 } 44 45 public Builder withException(Exception exception) { 46 return withException(Optional.of(exception)); 47 } 48 49 public Builder withTiming(TimedInterval timing) { 50 this.timing = timing; 51 return this; 52 } 53 54 public Builder time(Stopwatch sw) { 55 return withTiming(TimedInterval.build(sw)); 56 } 57 58 @Override 59 public PutFileResult build() { 60 return validate(new PutFileResult(this)); 61 } 62 } 63 64 public File getFile() { 65 return file; 66 } 67 68 public Optional<Exception> getException() { 69 return exception; 70 } 71 72 public TimedInterval getTiming() { 73 return timing; 74 } 75 76 }