Skip to content

Commit 791e929

Browse files
committed
Finish v0.9.0
2 parents 203afbb + 6f2f41b commit 791e929

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+3335
-56
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,3 +15,4 @@ build/
1515
/.idea/material_theme_project_new.xml
1616
/.idea/inspectionProfiles/Project_Default.xml
1717
/.idea/sonarlint.xml
18+
/.idea/kotlinc.xml

README.MD

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,6 @@
99
[![Coverage](https://sonarcloud.io/api/project_badges/measure?project=1c-syntax_bsl-common-library&metric=coverage)](https://sonarcloud.io/dashboard?id=1c-syntax_bsl-common-library)
1010

1111
[![Download](https://img.shields.io/github/release/1c-syntax/bsl-common-library.svg?label=download&style=flat)](https://github.com/1c-syntax/bsl-common-library/releases/latest)
12-
[![JitPack](https://jitpack.io/v/1c-syntax/bsl-common-library.svg)](https://jitpack.io/#1c-syntax/bsl-common-library)
1312
[![GitHub Releases](https://img.shields.io/github/downloads/1c-syntax/bsl-common-library/latest/total?style=flat-square)](https://github.com/1c-syntax/bsl-common-library/releases)
1413

1514
## Спасибо контрибьютерам

build.gradle.kts

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,20 @@
1-
import java.util.*
21
import org.jreleaser.model.Active.*
2+
import java.util.*
33

44
plugins {
55
`java-library`
66
`maven-publish`
77
jacoco
88
id("org.cadixdev.licenser") version "0.6.1"
99
id("me.qoomon.git-versioning") version "6.4.4"
10-
id("io.freefair.lombok") version "8.14.2"
11-
id("io.freefair.javadoc-links") version "8.14.2"
12-
id("io.freefair.javadoc-utf-8") version "8.14.2"
13-
id("io.freefair.maven-central.validate-poms") version "8.14.2"
14-
id("com.github.ben-manes.versions") version "0.52.0"
10+
id("io.freefair.lombok") version "9.0.0"
11+
id("io.freefair.javadoc-links") version "9.0.0"
12+
id("io.freefair.javadoc-utf-8") version "9.0.0"
13+
id("io.freefair.maven-central.validate-poms") version "9.0.0"
14+
id("com.github.ben-manes.versions") version "0.53.0"
1515
id("ru.vyarus.pom") version "3.0.0"
16-
id("org.jreleaser") version "1.19.0"
17-
id("org.sonarqube") version "6.2.0.5505"
16+
id("org.jreleaser") version "1.20.0"
17+
id("org.sonarqube") version "7.0.0.6105"
1818
}
1919

2020
repositories {
@@ -57,14 +57,16 @@ dependencies {
5757
// stat analysis
5858
compileOnly("com.github.spotbugs", "spotbugs-annotations", "4.8.6")
5959

60+
// логирование
61+
testImplementation("org.slf4j", "slf4j-reload4j", "2.0.16")
62+
6063
// тестирование
61-
testRuntimeOnly("org.junit.jupiter", "junit-jupiter-engine", "5.11.4")
62-
testImplementation("org.junit.jupiter", "junit-jupiter-api", "5.11.4")
64+
testImplementation(platform("org.junit:junit-bom:5.11.4"))
65+
testImplementation("org.junit.jupiter", "junit-jupiter-api")
66+
testImplementation("org.junit.jupiter", "junit-jupiter-params")
6367
testImplementation("org.assertj", "assertj-core", "3.27.0")
6468
testImplementation("com.ginsberg", "junit5-system-exit", "2.0.2")
65-
66-
// логирование
67-
testImplementation("org.slf4j", "slf4j-reload4j", "2.0.16")
69+
testRuntimeOnly("org.junit.jupiter", "junit-jupiter-engine")
6870
}
6971

7072
java {

src/main/java/com/github/_1c_syntax/bsl/support/SupportVariant.java

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,17 @@ public static SupportVariant max(Collection<SupportVariant> variants) {
4949
.orElse(SupportVariant.NONE);
5050
}
5151

52+
/**
53+
* Сравнивает два варианта поддержки и возвращает наибольший по приоритету
54+
*
55+
* @param first Первый вариант
56+
* @param second Второй вариант
57+
* @return Наибольший вариант
58+
*/
59+
public static SupportVariant max(SupportVariant first, SupportVariant second) {
60+
return first.priority <= second.priority ? first : second;
61+
}
62+
5263
/**
5364
* Находит элемент по приоритету
5465
*
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
/*
2+
* This file is a part of BSL Common library.
3+
*
4+
* Copyright (c) 2021 - 2025
5+
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* BSL Common library is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* BSL Common library is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with BSL Common library.
21+
*/
22+
/**
23+
* Пакет содержит вспомогательные структуры данных для режима поддержки
24+
*/
25+
@ParametersAreNonnullByDefault
26+
@ReturnValuesAreNonnullByDefault
27+
package com.github._1c_syntax.bsl.support;
28+
29+
import edu.umd.cs.findbugs.annotations.ReturnValuesAreNonnullByDefault;
30+
31+
import javax.annotation.ParametersAreNonnullByDefault;
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/*
2+
* This file is a part of BSL Common library.
3+
*
4+
* Copyright (c) 2021 - 2025
5+
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* BSL Common library is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* BSL Common library is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with BSL Common library.
21+
*/
22+
package com.github._1c_syntax.bsl.types;
23+
24+
import lombok.Getter;
25+
import lombok.ToString;
26+
import lombok.experimental.Accessors;
27+
28+
import java.util.Locale;
29+
import java.util.Map;
30+
31+
/**
32+
* Варианты длины
33+
*/
34+
@ToString(of = "fullName")
35+
public enum AllowedLength implements EnumWithName {
36+
FIXED("Fixed", "Фиксированная"),
37+
VARIABLE("Variable", "Переменная");
38+
39+
private static final Map<String, AllowedLength> KEYS = EnumWithName.computeKeys(values());
40+
41+
@Getter
42+
@Accessors(fluent = true)
43+
private final MultiName fullName;
44+
45+
46+
AllowedLength(String nameEn, String nameRu) {
47+
this.fullName = MultiName.create(nameEn, nameRu);
48+
}
49+
50+
/**
51+
* Ищет элемент перечисления по именам (рус, анг)
52+
*
53+
* @param string Имя искомого элемента
54+
* @return Найденное значение, если не найден - то VARIABLE
55+
*/
56+
public static AllowedLength valueByName(String string) {
57+
return KEYS.getOrDefault(string.toLowerCase(Locale.ROOT), VARIABLE);
58+
}
59+
}
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/*
2+
* This file is a part of BSL Common library.
3+
*
4+
* Copyright (c) 2021 - 2025
5+
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* BSL Common library is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* BSL Common library is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with BSL Common library.
21+
*/
22+
package com.github._1c_syntax.bsl.types;
23+
24+
import lombok.Getter;
25+
import lombok.ToString;
26+
import lombok.experimental.Accessors;
27+
28+
import java.util.Locale;
29+
import java.util.Map;
30+
31+
/**
32+
* Части даты
33+
*/
34+
@ToString(of = "fullName")
35+
public enum DateFractions implements EnumWithName {
36+
DATE("Date", "Дата"),
37+
DATE_TIME("DateTime", "ДатаВремя"),
38+
TIME("Time", "Время");
39+
40+
private static final Map<String, DateFractions> KEYS = EnumWithName.computeKeys(values());
41+
42+
@Getter
43+
@Accessors(fluent = true)
44+
private final MultiName fullName;
45+
46+
47+
DateFractions(String nameEn, String nameRu) {
48+
this.fullName = MultiName.create(nameEn, nameRu);
49+
}
50+
51+
/**
52+
* Ищет элемент перечисления по именам (рус, анг)
53+
*
54+
* @param string Имя искомого элемента
55+
* @return Найденное значение, если не найден - то DATE_TIME
56+
*/
57+
public static DateFractions valueByName(String string) {
58+
return KEYS.getOrDefault(string.toLowerCase(Locale.ROOT), DATE_TIME);
59+
}
60+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
/*
2+
* This file is a part of BSL Common library.
3+
*
4+
* Copyright (c) 2021 - 2025
5+
* Tymko Oleg <[email protected]>, Maximov Valery <[email protected]> and contributors
6+
*
7+
* SPDX-License-Identifier: LGPL-3.0-or-later
8+
*
9+
* BSL Common library is free software; you can redistribute it and/or
10+
* modify it under the terms of the GNU Lesser General Public
11+
* License as published by the Free Software Foundation; either
12+
* version 3.0 of the License, or (at your option) any later version.
13+
*
14+
* BSL Common library is distributed in the hope that it will be useful,
15+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
16+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17+
* Lesser General Public License for more details.
18+
*
19+
* You should have received a copy of the GNU Lesser General Public
20+
* License along with BSL Common library.
21+
*/
22+
package com.github._1c_syntax.bsl.types;
23+
24+
import java.util.Collections;
25+
import java.util.HashMap;
26+
import java.util.Locale;
27+
import java.util.Map;
28+
29+
/**
30+
* Расширение для перечислений, подсказывающее о наличии строкового значения, по которому его можно найти
31+
*/
32+
public interface EnumWithName {
33+
/**
34+
* Возвращает имена значения перечисления
35+
*
36+
* @return Мультиязычное имя значения перечисления
37+
*/
38+
MultiName fullName();
39+
40+
/**
41+
* Возвращает имя значения на русском языке
42+
*
43+
* @return Имя значения на русском языке
44+
*/
45+
default String nameRu() {
46+
return fullName().getRu();
47+
}
48+
49+
/**
50+
* Возвращает имя значения на английском языке
51+
*
52+
* @return Имя значения на английском языке
53+
*/
54+
default String nameEn() {
55+
return fullName().getEn();
56+
}
57+
58+
/**
59+
* Сервисный метод для формирования кеша ключей
60+
*
61+
* @param values Список элементов класса
62+
* @param exclude Исключаемый элемент
63+
* @param <T> Тип класса
64+
* @return Кеш ключей
65+
*/
66+
static <T extends EnumWithName> Map<String, T> computeKeys(T[] values, T exclude) {
67+
Map<String, T> keysMap = new HashMap<>();
68+
for (var element : values) {
69+
if (element == exclude) {
70+
continue;
71+
}
72+
keysMap.put(element.nameEn().toLowerCase(Locale.ROOT), element);
73+
keysMap.put(element.nameRu().toLowerCase(Locale.ROOT), element);
74+
}
75+
return Collections.unmodifiableMap(keysMap);
76+
}
77+
78+
79+
/**
80+
* Сервисный метод для формирования кеша ключей
81+
*
82+
* @param values Список элементов класса
83+
* @param <T> Тип класса
84+
* @return Кеш ключей
85+
*/
86+
static <T extends EnumWithName> Map<String, T> computeKeys(T[] values) {
87+
Map<String, T> keysMap = new HashMap<>();
88+
for (var element : values) {
89+
keysMap.put(element.nameEn().toLowerCase(Locale.ROOT), element);
90+
keysMap.put(element.nameRu().toLowerCase(Locale.ROOT), element);
91+
}
92+
return Collections.unmodifiableMap(keysMap);
93+
}
94+
}

0 commit comments

Comments
 (0)