/*
 * Copyright 2000-2017 JetBrains s.r.o.
 *
 * 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.maddyhome.idea.copyright;

import com.intellij.openapi.util.text.StringUtil;
import com.intellij.profile.ProfileEx;
import com.intellij.util.xmlb.SmartSerializer;
import com.maddyhome.idea.copyright.pattern.EntityUtil;

public class CopyrightProfile extends ProfileEx {
  @SuppressWarnings("SpellCheckingInspection")
  public static final String DEFAULT_COPYRIGHT_NOTICE =
    EntityUtil.encode("Copyright (c) $today.year. Lorem ipsum dolor sit amet, consectetur adipiscing elit. \n" +
                      "Morbi non lorem porttitor neque feugiat blandit. Ut vitae ipsum eget quam lacinia accumsan. \n" +
                      "Etiam sed turpis ac ipsum condimentum fringilla. Maecenas magna. \n" +
                      "Proin dapibus sapien vel ante. Aliquam erat volutpat. Pellentesque sagittis ligula eget metus. \n" +
                      "Vestibulum commodo. Ut rhoncus gravida arcu. ");

  private String notice = DEFAULT_COPYRIGHT_NOTICE;
  private String keyword = EntityUtil.encode("Copyright");
  private String allowReplaceRegexp = "";

  //read external
  public CopyrightProfile() {
    this("");
  }

  public CopyrightProfile(String profileName) {
    super(profileName, new SmartSerializer());
  }

  public String getNotice() {
    return notice;
  }

  public String getKeyword() {
    return keyword;
  }

  public void setNotice(String text) {
    notice = text;
  }

  public void setKeyword(String keyword) {
    this.keyword = keyword;
  }

  /**
   * @deprecated use {@link #getAllowReplaceRegexp()} instead
   */
  @Deprecated
  public String getAllowReplaceKeyword() {
    return "";
  }

  /**
   * @deprecated use {@link #setAllowReplaceRegexp(String)} instead
   */
  @Deprecated
  public void setAllowReplaceKeyword(String allowReplaceKeyword) {
    allowReplaceRegexp = StringUtil.escapeToRegexp(allowReplaceKeyword);
  }

  public String getAllowReplaceRegexp() {
    return allowReplaceRegexp;
  }

  public void setAllowReplaceRegexp(final String allowReplaceRegexp) {
    this.allowReplaceRegexp = allowReplaceRegexp;
  }
}

@@ -630,17 +630,16 @@
 opyright
-;
 %0A%0Aimport
@@ -680,17 +680,16 @@
 ringUtil
-;
 %0Aimport 
@@ -718,17 +718,16 @@
 rofileEx
-;
 %0Aimport 
@@ -764,17 +764,16 @@
 rializer
-;
 %0Aimport 
@@ -823,18 +823,10 @@
 Util
-;
 %0A%0A
-public 
 clas
@@ -848,103 +848,148 @@
 ile 
-extends ProfileEx %7B%0A  @SuppressWarnings(%22SpellCheckingInspection%22)%0A  public static final String
+@JvmOverloads constructor(profileName: String = %22%22) : ProfileEx(profileName, SmartSerializer()) %7B%0A  companion object %7B%0A    @JvmField%0A    val
  DEF
@@ -1013,14 +1013,18 @@
 TICE
- =%0A   
+: String =
  Ent
@@ -1030,32 +1030,39 @@
 tityUtil.encode(
+%0A      
 %22Copyright (c) $
@@ -1060,16 +1060,17 @@
 ght (c) 
+%5C
 $today.y
@@ -1137,32 +1137,16 @@
 . %5Cn%22 +%0A
-                
       %22M
@@ -1242,32 +1242,16 @@
 . %5Cn%22 +%0A
-                
       %22E
@@ -1320,32 +1320,16 @@
 . %5Cn%22 +%0A
-                
       %22P
@@ -1428,32 +1428,16 @@
 . %5Cn%22 +%0A
-                
       %22V
@@ -1486,27 +1486,19 @@
 . %22)
-;%0A%0A  private String
+%0A  %7D%0A%0A  var
  not
@@ -1527,34 +1527,22 @@
 T_NOTICE
-;
 %0A  
-private String
+var
  keyword
@@ -1578,26 +1578,15 @@
 ht%22)
-;%0A  private String
+%0A%0A  var
  all
@@ -1604,842 +1604,89 @@
 gexp
- = %22%22;%0A%0A  //read external%0A  public CopyrightProfile() %7B%0A    this(%22%22);%0A  %7D%0A%0A  public CopyrightProfile(String profileName) %7B%0A    super(profileName, new SmartSerializer());%0A  %7D%0A%0A  public String getNotice() %7B%0A    return notice;%0A  %7D%0A%0A  public String getKeyword() %7B%0A    return keyword;%0A  %7D%0A%0A  public void setNotice(String text) %7B%0A    notice = text;%0A  %7D%0A%0A  public void setKeyword(String keyword) %7B%0A    this.keyword = keyword;%0A  %7D%0A%0A  /**%0A   * @deprecated use %7B@link #getAllowReplaceRegexp()%7D instead%0A   */%0A  @Deprecated%0A  public String getAllowReplaceKeyword() %7B%0A    return %22%22;%0A  %7D%0A%0A  /**%0A   * @deprecated use %7B@link #setAllowReplaceRegexp(String)%7D instead%0A   */%0A  @Deprecated%0A  public void setAllowReplaceKeyword(String allowReplaceKeyword) %7B%0A    allowReplaceRegexp = StringUtil.escapeToRegexp(allowReplaceKeyword);%0A  %7D%0A%0A  public String getA
+: String? = null%0A    set(allowReplaceRegexp) %7B%0A      field = StringUtil.nullize(a
 llow
@@ -1702,172 +1702,29 @@
 gexp
-() %7B
+)
 %0A    
-return allowReplaceRegexp;%0A  %7D%0A%0A  public void setAllowReplaceRegexp(final String allowReplaceRegexp) %7B%0A    this.allowReplaceRegexp = allowReplaceRegexp;%0A  %7D%0A%7D
+%7D%0A%7D//read external
 %0A

convert CopyrightProfile to kotlin