/*
 * Copyright 2000-2017 JetBrains s.r.o. Use of this source code is governed by the Apache 2.0 license that can be found in the LICENSE file.
 */
package com.intellij.usages;

import com.intellij.openapi.components.PersistentStateComponent;
import com.intellij.openapi.components.ServiceManager;
import com.intellij.openapi.components.State;
import com.intellij.openapi.components.Storage;
import com.intellij.util.xmlb.XmlSerializerUtil;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;

@State(name = "ShowUsagesSettings", storages = @Storage("usageView.xml"))
public class ShowUsagesSettings implements PersistentStateComponent<UsageViewSettings> {
  private final UsageViewSettings myState = new UsageViewSettings();
  
  @Nullable
  @Override
  public UsageViewSettings getState() {
    return myState;
  }

  @Override
  public void loadState(@NotNull UsageViewSettings state) {
    XmlSerializerUtil.copyBean(state, myState);
  }

  public static ShowUsagesSettings getInstance() {
    return ServiceManager.getService(ShowUsagesSettings.class);
  }

  public ShowUsagesSettings() {
    myState.setGroupByFileStructure(false);
    myState.setGroupByModule(false);
    myState.setGroupByPackage(false);
    myState.setGroupByUsageType(false);
    myState.setGroupByScope(false);
  }
}

@@ -168,17 +168,16 @@
 j.usages
-;
 %0A%0Aimport
@@ -233,17 +233,16 @@
 omponent
-;
 %0Aimport 
@@ -287,17 +287,16 @@
 eManager
-;
 %0Aimport 
@@ -332,17 +332,16 @@
 ts.State
-;
 %0Aimport 
@@ -379,17 +379,16 @@
 .Storage
-;
 %0Aimport 
@@ -431,94 +431,8 @@
 Util
-;%0Aimport org.jetbrains.annotations.NotNull;%0Aimport org.jetbrains.annotations.Nullable;
 %0A%0A@S
@@ -476,17 +476,24 @@
 rages = 
-@
+arrayOf(
 Storage(
@@ -513,16 +513,10 @@
 l%22))
+)
 %0A
-public 
 clas
@@ -540,18 +540,9 @@
 ngs 
-implements
+:
  Per
@@ -598,31 +598,11 @@
 ate 
-final UsageViewSettings
+val
  myS
@@ -611,12 +611,8 @@
 te =
- new
  Usa
@@ -630,46 +630,70 @@
 ngs(
-);%0A  %0A  @Nullable%0A  @O
+false, false, false, false, false)%0A%0A  o
 verride
-%0A  public
+ fun getState():
  Usa
@@ -706,27 +706,17 @@
 Settings
- getState()
+?
  %7B%0A    r
@@ -728,25 +728,24 @@
  myState
-;
 %0A  %7D%0A%0A  
 @Overrid
@@ -740,31 +740,20 @@
 %0A%0A  
-@O
+o
 verride
-%0A  public void
+ fun
  loa
@@ -763,16 +763,14 @@
 ate(
-@NotNull
+state:
  Usa
@@ -787,14 +787,8 @@
 ings
- state
 ) %7B%0A
@@ -833,25 +833,24 @@
 myState)
-;
 %0A  %7D%0A%0A  
 public s
@@ -845,21 +845,45 @@
 %0A%0A  
-public static
+companion object %7B%0A%0A    val instance:
  Sho
@@ -901,35 +901,22 @@
 ings
- getInstance() %7B%0A
+%0A  
     
-return
+get() =
  Ser
@@ -960,248 +960,21 @@
 ings
-.
+::
 class
-);%0A  %7D%0A%0A  public ShowUsagesSettings() %7B%0A    myState.setGroupByFileStructure(false);%0A    myState.setGroupByModule(false);%0A    myState.setGroupByPackage(false);%0A    myState.setGroupByUsageType(false);%0A    myState.setGroupByScope(false);
+.java)
 %0A  %7D

convert ShowUsagesSettings to kotlin