From deed811cc098f41ae50e705b2ed8a18010c95cfa Mon Sep 17 00:00:00 2001 From: Kirill Likhodedov Date: Sun, 16 Jun 2019 12:29:32 +0100 Subject: [PATCH] git: convert to kotlin GitOrigin-RevId: ce9f5796abc4317882a2b9e996654bee43c7c76c --- .../src/git4idea/rebase/GitRebaseEntry.kt | 78 +++++-------------- 1 file changed, 18 insertions(+), 60 deletions(-) diff --git a/plugins/git4idea/src/git4idea/rebase/GitRebaseEntry.kt b/plugins/git4idea/src/git4idea/rebase/GitRebaseEntry.kt index ca733b3b39de..e48637439f61 100644 --- a/plugins/git4idea/src/git4idea/rebase/GitRebaseEntry.kt +++ b/plugins/git4idea/src/git4idea/rebase/GitRebaseEntry.kt @@ -13,50 +13,18 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -package git4idea.rebase; +package git4idea.rebase -import com.intellij.openapi.diagnostic.Logger; -import com.intellij.openapi.util.text.StringUtil; -import org.jetbrains.annotations.NonNls; -import org.jetbrains.annotations.NotNull; +import com.intellij.openapi.diagnostic.logger +import com.intellij.openapi.util.text.StringUtil -class GitRebaseEntry { - private static final Logger LOG = Logger.getInstance(GitRebaseEntry.class); +private val LOG = logger() - @NotNull private final String myCommit; - @NotNull private final String mySubject; - @NotNull private Action myAction; +internal class GitRebaseEntry(var action: Action, val commit: String, val subject: String) { - GitRebaseEntry(@NotNull String action, @NotNull String commit, @NotNull String subject) { - this(Action.fromString(action), commit, subject); - } + constructor(action: String, commit: String, subject: String) : this(Action.fromString(action), commit, subject) - GitRebaseEntry(@NotNull Action action, @NotNull String commit, @NotNull String subject) { - myCommit = commit; - mySubject = subject; - myAction = action; - } - - @NotNull - public String getCommit() { - return myCommit; - } - - @NotNull - public String getSubject() { - return mySubject; - } - - @NotNull - public Action getAction() { - return myAction; - } - - public void setAction(@NotNull Action action) { - myAction = action; - } - - public enum Action { + enum class Action(private val text: String, val mnemonic: Char) { PICK("pick", 'p'), EDIT("edit", 'e'), SKIP("skip", 's'), @@ -64,31 +32,21 @@ class GitRebaseEntry { REWORD("reword", 'r'), FIXUP("fixup", 'f'); - @NotNull private final String myText; - private final char myMnemonic; - - Action(@NotNull String text, char mnemonic) { - myText = text; - myMnemonic = mnemonic; + override fun toString(): String { + return text } - public char getMnemonic() { - return myMnemonic; - } + companion object { - @Override - public String toString() { - return myText; - } + internal fun fromString(actionName: String): Action { + try { + return valueOf(StringUtil.toUpperCase(actionName)) + } + catch (e: IllegalArgumentException) { + LOG.error(e) + return PICK + } - @NotNull - static Action fromString(@NonNls @NotNull String actionName) { - try { - return valueOf(StringUtil.toUpperCase(actionName)); - } - catch (IllegalArgumentException e) { - LOG.error(e); - return PICK; } } }