2 Commits

Author SHA1 Message Date
yhl452493373
54e2f9dffb 增加 String format(Sequences sequences, Integer minLength, String pattern)方法 2022-02-10 18:05:49 +08:00
yhl452493373
1a9a158126 update README 2022-02-10 11:28:52 +08:00
3 changed files with 19 additions and 4 deletions

View File

@@ -8,7 +8,7 @@
使用方法:
+ 在项目中放置jar包的地方把seq-1.0.0.jar、seq-1.0.0-sources.jar、seq-1.0.0-pom.xml复制过去
+ 在项目中放置jar包的地方把seq-1.1.0.jar、seq-1.1.0-sources.jar、seq-1.1.0-pom.xml复制过去
+ 在pom.xml中增加以下内容然后执行maven命令mvn clean
```xml
@@ -50,9 +50,9 @@
</goals>
<configuration>
<!-- ${project.basedir}表示当前项目的根目录 -->
<file>${project.basedir}/lib/seq-1.0.0.jar</file>
<pomFile>${pom.basedir}/lib/seq-1.0.0-pom.xml</pomFile>
<sources>${project.basedir}/lib/seq-1.0.0-sources.jar</sources>
<file>${project.basedir}/lib/seq-1.1.0.jar</file>
<pomFile>${pom.basedir}/lib/seq-1.1.0-pom.xml</pomFile>
<sources>${project.basedir}/lib/seq-1.1.0-sources.jar</sources>
<repositoryLayout>default</repositoryLayout>
<groupId>com.yanghuanglin</groupId>
<artifactId>seq</artifactId>

View File

@@ -50,6 +50,16 @@ public interface Generator {
*/
String generate(String key, String type, Integer minLength);
/**
* 将{@link #generate(String, String)}得到的序号对象格式化为补零后的序号字符串。实际上只会用到{@link Sequences#getSeq()}属性
*
* @param sequences 生成的序号对象
* @param minLength 序号数字最小长度
* @param pattern 格式
* @return 格式化后的字符串
*/
String format(Sequences sequences, Integer minLength, String pattern);
/**
* 将生成的序号对象格式化为指定格式
* <p/>

View File

@@ -132,6 +132,11 @@ public class SequencesGenerator implements Generator {
return sequences.format(minLength);
}
@Override
public String format(Sequences sequences, Integer minLength, String pattern) {
return format(sequences.getSeq(), minLength, pattern);
}
@Override
public String format(Long seq, Integer minLength, String pattern) {
return format(seq, null, minLength, pattern);