Skip to content

Commit 8bbebf0

Browse files
committed
style(core): format code and adjust whitespace
- Removed unnecessary blank lines - Adjusted spacing around operators and braces - Ensured consistent indentation and alignment - Added missing annotations and improved code readability
1 parent 6ed75df commit 8bbebf0

File tree

2 files changed

+27
-26
lines changed

2 files changed

+27
-26
lines changed

cosid-core/src/main/java/me/ahoo/cosid/converter/RadixIdConverter.java

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public abstract class RadixIdConverter implements IdConverter {
4949
* 122.
5050
*/
5151
static final char LOWERCASE_Z = 'z';
52-
52+
5353
static final char[] digits = {
5454
/*
5555
* offset: 0.
@@ -69,13 +69,13 @@ public abstract class RadixIdConverter implements IdConverter {
6969
LOWERCASE_A, 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm',
7070
'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', LOWERCASE_Z,
7171
};
72-
72+
7373
public static final char PAD_CHAR = ZERO;
74-
74+
7575
private final boolean padStart;
7676
private final int charSize;
7777
private final long maxId;
78-
78+
7979
protected RadixIdConverter(boolean padStart, int charSize) {
8080
Preconditions.checkArgument(charSize > 0 && charSize <= getMaxCharSize(), "charSize cannot be greater than MAX_CHAR_SIZE[%s]!", getMaxCharSize());
8181
this.padStart = padStart;
@@ -86,7 +86,7 @@ protected RadixIdConverter(boolean padStart, int charSize) {
8686
this.maxId = Double.valueOf(Math.pow(getRadix(), charSize)).longValue();
8787
}
8888
}
89-
89+
9090
public static int offset(char digitChar) {
9191
if (digitChar >= ZERO && digitChar <= NINE) {
9292
return digitChar - ZERO;
@@ -99,7 +99,7 @@ public static int offset(char digitChar) {
9999
}
100100
return -1;
101101
}
102-
102+
103103
public static int maxCharSize(int radix, int bits) {
104104
long maxId = ~(-1L << bits);
105105
int divideTimes = 0;
@@ -109,34 +109,34 @@ public static int maxCharSize(int radix, int bits) {
109109
}
110110
return divideTimes;
111111
}
112-
112+
113113
boolean isPadStart() {
114114
return padStart;
115115
}
116-
116+
117117
public int getCharSize() {
118118
return charSize;
119119
}
120-
120+
121121
public long getMaxId() {
122122
return maxId;
123123
}
124-
124+
125125
abstract int getRadix();
126-
126+
127127
abstract int getMaxCharSize();
128-
128+
129129
@Override
130130
public @NonNull String asString(long id) {
131-
131+
132132
Preconditions.checkArgument(id > -1, "id[%s] must be greater than -1!", id);
133-
133+
134134
final int maxCharSize = getMaxCharSize();
135-
135+
136136
if (charSize < maxCharSize) {
137137
Preconditions.checkArgument(id < maxId, "id[%s] cannot be greater than maxId:[%s]!", id, maxId);
138138
}
139-
139+
140140
char[] buf = new char[charSize];
141141
int charIdx = charSize;
142142
final int radix = getRadix();
@@ -145,16 +145,17 @@ public long getMaxId() {
145145
buf[--charIdx] = digits[mod];
146146
id = id / radix;
147147
}
148-
148+
149149
if (padStart && charIdx > 0) {
150150
while (charIdx > 0) {
151151
buf[--charIdx] = PAD_CHAR;
152152
}
153153
}
154-
154+
155155
return new String(buf, charIdx, (charSize - charIdx));
156156
}
157-
157+
158+
@Override
158159
public long asLong(@NonNull String idString) {
159160
char firstChar = idString.charAt(0);
160161
if (firstChar < ZERO) {
@@ -178,7 +179,7 @@ public long asLong(@NonNull String idString) {
178179
}
179180
return result;
180181
}
181-
182+
182183
@Override
183184
public Stat stat() {
184185
return new RadixConverterStat(getClass().getSimpleName(), getRadix(), getCharSize(), isPadStart(), getMaxId());

cosid-core/src/main/java/me/ahoo/cosid/segment/grouped/GroupedAccessor.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,27 +21,27 @@
2121
@ThreadSafe
2222
public final class GroupedAccessor {
2323
private static final ThreadLocal<GroupedKey> CURRENT = new ThreadLocal<>();
24-
24+
2525
public static void set(GroupedKey groupedKey) {
2626
CURRENT.set(groupedKey);
2727
}
28-
28+
2929
public static void setIfNotNever(GroupedKey groupedKey) {
3030
if (GroupedKey.NEVER.equals(groupedKey)) {
3131
return;
3232
}
3333
set(groupedKey);
3434
}
35-
36-
@NonNull
35+
3736
public static GroupedKey get() {
3837
return CURRENT.get();
3938
}
40-
39+
40+
@NonNull
4141
public static GroupedKey requiredGet() {
4242
return Objects.requireNonNull(get(), "The current thread has not set the GroupedKey.");
4343
}
44-
44+
4545
public static void clear() {
4646
CURRENT.remove();
4747
}

0 commit comments

Comments
 (0)