1 /* 2 * Copyright (c) 2023 Huawei Device Co., Ltd. 3 * Licensed under the Apache License, Version 2.0 (the "License"); 4 * you may not use this file except in compliance with the License. 5 * You may obtain a copy of the License at 6 * 7 * http://www.apache.org/licenses/LICENSE-2.0 8 * 9 * Unless required by applicable law or agreed to in writing, software 10 * distributed under the License is distributed on an "AS IS" BASIS, 11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 * See the License for the specific language governing permissions and 13 * limitations under the License. 14 */ 15 16 package com.update.check.action.view; 17 18 import com.intellij.AbstractBundle; 19 import com.intellij.reference.SoftReference; 20 import org.jetbrains.annotations.NotNull; 21 import org.jetbrains.annotations.PropertyKey; 22 import java.lang.ref.Reference; 23 import java.util.ResourceBundle; 24 25 /** 26 * ConstString 27 * 28 * @since 23-04-07 29 */ 30 public class ConstString { 31 32 private static final String BUNDLE = "const"; 33 34 private static Reference<ResourceBundle> outBundle; 35 36 /** 37 * get Fields 38 * 39 * @param key key 40 * @param params object 41 * @return field 42 */ get(@otNull @ropertyKeyresourceBundle = BUNDLE) String key, @NotNull Object... params)43 public static String get(@NotNull @PropertyKey(resourceBundle = BUNDLE) String key, @NotNull Object... params) { 44 return AbstractBundle.message(ConstString.getBundle(), key, params); 45 } 46 47 /** 48 * getBundle 49 * 50 * @return bundle 51 */ getBundle()52 public static ResourceBundle getBundle() { 53 ResourceBundle bundle = SoftReference.dereference(ConstString.outBundle); 54 if (bundle == null) { 55 bundle = ResourceBundle.getBundle(ConstString.BUNDLE); 56 ConstString.outBundle = new SoftReference<>(bundle); 57 } 58 59 return bundle; 60 } 61 } 62