/*
 * Copyright 2013 Square Inc.
 *
 * 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.squareup.wire;

import javax.annotation.Nullable;

public final class Wire {
  private Wire() {
  }

  /**
   * Returns {@code value} if it is not null; {@code defaultValue} otherwise.
   * This is used to conveniently return a default value when a value is null.
   * For example,
   *
   * <pre>
   * MyProto myProto = ...
   * MyField field = Wire.get(myProto.f, MyProto.f_default);
   * </pre>
   *
   * will attempt to retrieve the value of the field 'f' defined by MyProto.
   * If the field is null (i.e., unset), <code>get</code> will return its
   * second argument, which in this case is the default value for the field
   * 'f'.
   */
  public static <T> T get(@Nullable T value, T defaultValue) {
    return value != null ? value : defaultValue;
  }
}

@@ -584,16 +584,39 @@
 se.%0A */%0A
+@file:JvmName(%22Wire%22)%0A%0A
 package 
@@ -636,104 +636,14 @@
 wire
-;
 %0A%0A
-import javax.annotation.Nullable;%0A%0Apublic final class Wire %7B%0A  private Wire() %7B%0A  %7D%0A%0A  
 /**%0A
-  
  * R
@@ -653,21 +653,15 @@
 rns 
-%7B@code 
+%60
 value
-%7D
+%60
  if 
@@ -680,15 +680,9 @@
 ll; 
-%7B@code 
+%60
 defa
@@ -689,17 +689,17 @@
 ultValue
-%7D
+%60
  otherwi
@@ -701,21 +701,16 @@
 herwise.
-%0A   *
  This is
@@ -737,16 +737,19 @@
 y return
+%0A *
  a defau
@@ -778,21 +778,16 @@
 is null.
-%0A   *
  For exa
@@ -797,25 +797,17 @@
 e,%0A 
-  *%0A   * %3Cpre%3E%0A  
+*%0A * %60%60%60%0A
  * M
@@ -827,18 +827,16 @@
 o = ...%0A
-  
  * MyFie
@@ -891,26 +891,17 @@
 );%0A 
-  * %3C/pre%3E%0A   *%0A  
+* %60%60%60%0A *%0A
  * w
@@ -970,21 +970,16 @@
 MyProto.
-%0A   *
  If the 
@@ -991,16 +991,19 @@
  is null
+%0A *
  (i.e., 
@@ -1014,24 +1014,13 @@
 t), 
-%3Ccode%3Eget%3C/code%3E
+%60get%60
  wil
@@ -1031,21 +1031,16 @@
 turn its
-%0A   *
  second 
@@ -1088,24 +1088,27 @@
 lt value for
+%0A *
  the field%0A 
@@ -1109,71 +1109,40 @@
 ield
-%0A   *
  'f'.%0A
-  
  */%0A
-  public static
+fun
  %3CT%3E
- T
  get(
-@Nullable T 
 value
-,
+:
  T
+?,
  def
@@ -1154,45 +1154,25 @@
 alue
-) %7B%0A    return value != null ?
+: T): T =
  value 
+?
 : de
@@ -1185,12 +1185,5 @@
 alue
-;%0A  %7D%0A%7D
 %0A

Convert Wire.java to Kotlin