Skip to content

Commit

Permalink
v3.0.9
Browse files Browse the repository at this point in the history
  • Loading branch information
justlive1 committed Nov 20, 2024
1 parent 9eca9af commit cdb0b0f
Show file tree
Hide file tree
Showing 37 changed files with 1,210 additions and 289 deletions.
2 changes: 1 addition & 1 deletion oxygen-core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
<parent>
<artifactId>oxygen</artifactId>
<groupId>vip.justlive</groupId>
<version>3.0.8</version>
<version>3.0.9</version>
</parent>
<modelVersion>4.0.0</modelVersion>

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -56,4 +56,8 @@ public class CoreConfigKeys {
"100");

public final ConfigKey AIO_USE_FUTURE = new ConfigKey("oxygen.aio.future", "false");

public final ConfigKey HTTP_REQUEST_HOLDER_ENABLED = new ConfigKey(
"oxygen.httpRequest.holder.enabled", "true");

}
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,6 @@
@UtilityClass
public class DecimalSystemConvert {

private final char[] DIGITS =
{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h',
'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z'};


/**
* 进制转换,默认使用数字+字母数组做为数据源
*
Expand All @@ -36,14 +31,14 @@ public class DecimalSystemConvert {
* @return 结果
*/
public String convert(long value, int shift) {
return convert(value, shift, DIGITS);
return convert(value, shift, Strings.ALPHA_NUMERIC);
}

/**
* 进制转换
*
* @param value 原始数据
* @param shift 进制数
* @param value 原始数据
* @param shift 进制数
* @param source 进制数组源
* @return 结果
*/
Expand All @@ -69,20 +64,20 @@ public String convert(long value, int shift, char[] source) {
* @return 十进制
*/
public long recover(String value, int shift) {
return recover(value, shift, DIGITS);
return recover(value, shift, Strings.ALPHA_NUMERIC);
}

/**
* 恢复成十进制
*
* @param value 进制转换后的值
* @param shift 进制
* @param value 进制转换后的值
* @param shift 进制
* @param source 进制数组源
* @return 十进制
*/
public long recover(String value, int shift, char[] source) {
char[] buf = value.toCharArray();
int result = 0;
long result = 0;
for (int i = buf.length - 1; i >= 0; i--) {
int index = indexOf(buf[i], shift, source);
if (index == -1) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Random;
import java.util.Set;
import java.util.concurrent.Executor;
import java.util.function.Consumer;
Expand All @@ -37,7 +38,9 @@
@Slf4j
@UtilityClass
public class MoreObjects {


static final Random RANDOM = new Random();

/**
* 非空检查
*
Expand All @@ -48,7 +51,7 @@ public class MoreObjects {
public <T> T notNull(T obj) {
return notNull(obj, "can not be null");
}

/**
* 非空检查
*
Expand All @@ -63,7 +66,7 @@ public <T> T notNull(T obj, String msg) {
}
return obj;
}

/**
* 获取第一个不为null的值,没有则返回null
*
Expand All @@ -90,7 +93,7 @@ public <T> T firstOrNull(T first, T second, T... others) {
}
return null;
}

/**
* 获取第一个不为null的值
*
Expand All @@ -108,7 +111,7 @@ public <T> T firstNonNull(T first, T second, T... others) {
}
throw new IllegalArgumentException();
}

/**
* 对象转map
*
Expand All @@ -118,7 +121,7 @@ public <T> T firstNonNull(T first, T second, T... others) {
public Map<String, Object> beanToMap(Object bean) {
return beanToMap(bean, false);
}

/**
* 对象转map 对象属性也同样转换
*
Expand Down Expand Up @@ -150,7 +153,7 @@ public Map<String, Object> beanToMap(Object bean, boolean deep) {
}
return map;
}

/**
* 解析queryString转成Map
*
Expand All @@ -171,7 +174,7 @@ public Map<String, String> parseQueryString(String queryString) {
}
return queryMap;
}

/**
* @param queryString
* @return
Expand All @@ -190,7 +193,7 @@ public Map<String, List<String>> parseMultiQueryString(String queryString) {
}
return queryMap;
}

/**
* bean转换成queryString
*
Expand All @@ -200,7 +203,7 @@ public Map<String, List<String>> parseMultiQueryString(String queryString) {
public String beanToQueryString(Object bean) {
return beanToQueryString(bean, false);
}

/**
* bean转换成queryString
*
Expand All @@ -218,7 +221,7 @@ public String beanToQueryString(Object bean, boolean urlEncoded) {
}
return sb.toString();
}

/**
* map转换成properties
*
Expand All @@ -237,8 +240,8 @@ public Properties beanToProps(Object bean) {
}
return props;
}


/**
* always true
*
Expand All @@ -248,7 +251,7 @@ public Properties beanToProps(Object bean) {
public <T> Predicate<T> alwaysTrue() {
return t -> true;
}

/**
* always false
*
Expand All @@ -258,7 +261,7 @@ public <T> Predicate<T> alwaysTrue() {
public <T> Predicate<T> alwaysFalse() {
return t -> false;
}

/**
* toString
*
Expand All @@ -271,7 +274,7 @@ public String safeToString(Object obj) {
}
return obj.toString();
}

/**
* 捕获异常的foreach
*
Expand All @@ -286,7 +289,7 @@ public <T> void caughtForeach(Iterable<T> iterable, Consumer<? super T> consumer
iterable.forEach(new CaughtConsumer<>(consumer));
}
}

/**
* 创建map
*
Expand All @@ -297,7 +300,7 @@ public <T> void caughtForeach(Iterable<T> iterable, Consumer<? super T> consumer
public <K, V> Map<K, V> mapOf() {
return new HashMap<>(2);
}

/**
* 创建map
*
Expand All @@ -312,7 +315,7 @@ public <K, V> Map<K, V> mapOf(K k, V v) {
map.put(notNull(k), v);
return map;
}

/**
* 创建map
*
Expand All @@ -330,7 +333,7 @@ public <K, V> Map<K, V> mapOf(K k1, V v1, K k2, V v2) {
map.put(notNull(k2), v2);
return map;
}

/**
* 创建map
*
Expand All @@ -351,7 +354,7 @@ public <K, V> Map<K, V> mapOf(K k1, V v1, K k2, V v2, K k3, V v3) {
map.put(notNull(k3), v3);
return map;
}

/**
* 取交集
*
Expand All @@ -377,7 +380,7 @@ public <T> Set<T> intersection(Set<T> first, Set<T> second, Set<T>... others) {
}
return intersection;
}

/**
* 去并集
*
Expand All @@ -399,7 +402,7 @@ public <T> Set<T> union(Set<T> first, Set<T> second, Set<T>... others) {
}
return union;
}

/**
* 当前线程直接运行
*
Expand All @@ -408,7 +411,7 @@ public <T> Set<T> union(Set<T> first, Set<T> second, Set<T>... others) {
public Executor directExecutor() {
return Runnable::run;
}

private void convert(Map<?, ?> map, Properties result, String prefix) {
for (Map.Entry<?, ?> entry : map.entrySet()) {
if (entry.getValue() instanceof Map) {
Expand All @@ -420,13 +423,13 @@ private void convert(Map<?, ?> map, Properties result, String prefix) {
}
}
}

private void convert(Map<String, Object> result, String key, Object value, boolean deep) {
if (!deep) {
result.put(key, value);
return;
}

if (ClassUtils.isJavaInternalType(value.getClass()) && !(value instanceof Map)) {
result.put(key, value);
return;
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* Copyright (C) 2022 the original author or authors.
*
* 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 vip.justlive.oxygen.core.util.base;

import java.util.concurrent.atomic.AtomicLong;

/**
* 简单序列
*
* @author wubo
*/
public class SimpleSequence implements Sequence<Long> {

private final AtomicLong sequence;

public SimpleSequence() {
this(0);
}

public SimpleSequence(long initialValue) {
this.sequence = new AtomicLong(initialValue);
}

@Override
public Long nextId() {
return sequence.getAndIncrement();
}
}
Loading

0 comments on commit cdb0b0f

Please sign in to comment.