From b2b3cf8af601af5e3145f9fc1273fd9980b3107f Mon Sep 17 00:00:00 2001 From: patrick Date: Thu, 23 May 2024 16:39:13 +0800 Subject: [PATCH] add Aesome Repo Feature to collect Github Awesome --- README.md | 24 + ci/checkstyle.xml | 582 +- ci/checkstyle_bnk.xml | 196 + .../io/fluent/builtin/CollectionsUtils.java | 208 +- .../java/io/fluent/builtin/FileUtils.java | 7 +- .../fluent/builtin/JavaProjectFileUtils.java | 61 +- .../java/io/fluent/builtin/MatcherUtils.java | 26 +- .../java/io/fluent/builtin/NamingUtils.java | 21 +- .../java/io/fluent/builtin/PingYinUtils.java | 25 +- .../io/fluent/builtin/PredictionsUtil.java | 20 +- .../java/io/fluent/builtin/StringUtils.java | 3 +- .../main/java/io/fluent/builtin/XmlUtils.java | 13 +- .../builtin/annotation/NotThreadSafe.java | 3 +- .../io/fluent/builtin/annotation/WithBug.java | 2 +- .../io/fluent/builtin/config/AppConfig.java | 12 +- .../builtin/config/AppConfigException.java | 12 +- .../builtin/config/ConfigGroupName.java | 3 +- .../fluent/builtin/config/DotEnvConfig.java | 11 +- .../io/fluent/builtin/config/PropUtils.java | 22 +- .../fluent/builtin/constant/CharsetConst.java | 25 +- .../builtin/constant/PunctuationConst.java | 242 +- .../builtin/constant/RegexpConstant.java | 9 +- .../fluent/builtin/constant/SystemConst.java | 251 +- .../builtin/constant/enums/LangEnum.java | 355 +- .../builtin/constant/enums/ProxyTypeEnum.java | 23 +- .../constant/file/FileOptionConst.java | 41 +- .../constant/file/FileProtocolConst.java | 41 +- .../builtin/constant/file/FileTypeConst.java | 64 +- .../constant/file/ImageTypeConstant.java | 18 +- .../io/fluent/builtin/meta/GenericsUtils.java | 358 +- .../fluent/builtin/meta/ReflectionUtils.java | 196 +- .../java/io/fluent/builtin/package-info.java | 6 +- .../io/fluent/builtin/reflection/Assert.java | 34 +- .../fluent/builtin/reflection/ClassUtils.java | 482 +- .../builtin/reflection/ClassValues.java | 20 +- .../builtin/reflection/MethodCaptor.java | 81 +- .../builtin/reflection/MethodSignature.java | 104 +- .../reflection/PropertyDescriptorCache.java | 391 +- .../builtin/reflection/PropertyGetter.java | 3 +- .../builtin/reflection/PropertyUtils.java | 990 +-- .../builtin/reflection/RecordSupport.java | 597 +- .../builtin/reflection/RecordUtils.java | 55 +- .../ReflectionRuntimeException.java | 15 +- .../reflection/TypedPropertyGetter.java | 2 +- .../fluent/builtin/reflection/VoidMethod.java | 2 +- .../GenericImmutableProxyForwarder.java | 154 +- .../reflection/immutable/Immutable.java | 3 +- .../reflection/immutable/ImmutableProxy.java | 591 +- .../ImmutableProxyForwarderBoolean.java | 17 +- .../ImmutableProxyForwarderInteger.java | 17 +- .../ImmutableProxyForwarderLong.java | 17 +- .../ImmutableProxyForwarderString.java | 17 +- .../immutable/ImmutableProxyOption.java | 30 +- .../reflection/immutable/ReadOnly.java | 5 +- .../collection/DeepImmutableCollection.java | 192 +- .../collection/DeepImmutableEntrySet.java | 69 +- .../collection/DeepImmutableList.java | 164 +- .../collection/DeepImmutableMap.java | 68 +- .../collection/DeepImmutableSet.java | 27 +- .../collection/ImmutableIterator.java | 52 +- .../collection/ImmutableListIterator.java | 108 +- .../fluent/builtin/config/AppConfigTest.java | 27 +- .../builtin/config/DotEnvConfigTest.java | 16 +- .../builtin/strings/MatcherUtilsTest.java | 8 +- .../builtin/strings/NamingUtilsTest.java | 8 +- .../datafactory/api/annotation/DataDesc.java | 15 +- .../api/annotation/DataFactory.java | 110 +- .../api/annotation/package-info.java | 3 +- .../datafactory/api/core/IAnnotationData.java | 20 +- .../io/fluent/datafactory/api/core/IData.java | 16 +- .../api/core/IDataFactoryContext.java | 49 +- .../datafactory/api/core/IRegexGen.java | 20 +- .../fluent/datafactory/api/package-info.java | 5 +- .../datafactory/core/DataFactoryData.java | 19 +- .../core/api/context/DefaultDataContext.java | 94 +- .../core/api/data/aggregate/ArrayData.java | 27 +- .../core/api/data/aggregate/BeanData.java | 190 +- .../core/api/data/aggregate/EnumData.java | 20 +- .../core/api/data/aggregate/IterableData.java | 86 +- .../core/api/data/aggregate/MapData.java | 65 +- .../core/api/data/aggregate/NullData.java | 46 +- .../core/api/data/aggregate/package-info.java | 3 +- .../annotation/AbstractAnnotationData.java | 87 +- .../data/annotation/AbstractNumberData.java | 221 +- .../DefaultDataFactoryAnnotationData.java | 123 +- .../core/api/data/lang/StringData.java | 96 +- .../core/api/data/lang/package-info.java | 3 +- .../core/api/data/math/BigDecimalData.java | 14 +- .../core/api/data/math/BigIntegerData.java | 13 +- .../core/api/data/math/package-info.java | 3 +- .../core/api/data/package-info.java | 3 +- .../api/data/primitive/BoolArrayData.java | 19 +- .../core/api/data/primitive/BoolData.java | 14 +- .../api/data/primitive/ByteArrayData.java | 17 +- .../core/api/data/primitive/ByteData.java | 26 +- .../api/data/primitive/CharArrayData.java | 18 +- .../core/api/data/primitive/CharData.java | 21 +- .../api/data/primitive/DoubleArrayData.java | 21 +- .../core/api/data/primitive/DoubleData.java | 13 +- .../api/data/primitive/FloatArrayData.java | 18 +- .../core/api/data/primitive/FloatData.java | 12 +- .../api/data/primitive/IntegerArrayData.java | 22 +- .../core/api/data/primitive/IntegerData.java | 14 +- .../api/data/primitive/LongArrayData.java | 18 +- .../core/api/data/primitive/LongData.java | 14 +- .../api/data/primitive/ShortArrayData.java | 18 +- .../core/api/data/primitive/ShortData.java | 27 +- .../core/api/data/primitive/VoidData.java | 10 +- .../core/api/data/primitive/package-info.java | 6 +- .../core/api/data/time/LocalDateData.java | 11 +- .../core/api/data/time/LocalDateTimeData.java | 12 +- .../core/api/data/time/LocalTimeData.java | 13 +- .../core/api/data/time/YearData.java | 13 +- .../core/api/data/time/package-info.java | 3 +- .../core/api/data/util/CurrencyData.java | 10 +- .../core/api/data/util/DateData.java | 14 +- .../core/api/data/util/package-info.java | 2 +- .../datafactory/core/api/package-info.java | 3 +- .../core/api/regex/DefaultRegexGen.java | 13 +- .../DataFactoryRuntimeException.java | 32 +- .../fluent/datafactory/core/package-info.java | 5 +- .../support/factory/DataFactoryMapping.java | 224 +- .../core/support/factory/package-info.java | 2 +- .../core/support/package-info.java | 2 +- .../datafactory/core/util/DataClassUtil.java | 89 +- .../core/util/DataFactoryDataUtil.java | 48 +- .../core/util/DataPrimitiveUtil.java | 50 +- .../datafactory/core/util/InnerDataUtil.java | 110 +- .../io/fluent/datafactory/package-info.java | 2 +- .../datafactory/core/DataFactoryDataTest.java | 23 +- .../datafactory/core/DataSourceBuilder.java | 20 +- .../datafactory/core/PostgreSqlTest.java | 915 +-- .../fluent/datafactory/core/SqlExecutor.java | 33 +- .../io/fluent/datafactory/core/TestTable.java | 172 +- .../java/io/fluent/datafactory/core/User.java | 21 +- .../core/UserAnnotationNumber.java | 41 +- .../io/fluentqa/excel/ExcelReadWriter.java | 25 +- .../java/io/fluentqa/excel/package-info.java | 2 +- .../io/fluentqa/excel/DemoExcelModel.java | 10 +- .../io/fluentqa/excel/ExcelUtilsTest.java | 37 +- .../fluent/clients/base/HttpClientOption.java | 34 +- .../io/fluent/clients/base/HttpException.java | 21 +- .../fluent/clients/base/HttpRequestModel.java | 20 +- .../clients/base/HttpResponseModel.java | 5 +- .../io/fluent/clients/base/MediaTypeEnum.java | 90 +- .../io/fluent/clients/base/MethodEnum.java | 11 +- .../clients/factory/HttpClientFactory.java | 63 +- .../clients/factory/HttpClientProcessor.java | 3 +- .../clients/interceptors/CustomCallback.java | 4 +- .../HttpRequestHeaderInterceptor.java | 7 +- .../interceptors/retry/RetryCallback.java | 15 +- .../interceptors/retry/RetryHelper.java | 69 +- .../clients/rest/RestAssuredClient.java | 31 +- .../clients/base/HttpRequestModelTest.java | 8 +- .../factory/HttpClientFactoryTest.java | 46 +- .../fluentqa/mindmap/api/MindMapAccessor.java | 52 +- .../mindmap/api/MindMapConvertConfig.java | 27 +- .../io/fluentqa/mindmap/api/MindMapPath.java | 39 +- .../mindmap/api/MindMapPathRecord.java | 99 +- .../mindmap/api/MindMapTransformer.java | 8 +- .../fluentqa/mindmap/api/MindmapTypeEnum.java | 46 +- .../io/fluentqa/mindmap/api/NodeLevel.java | 4 +- .../mindmap/exception/MindMapException.java | 30 +- .../mindmap/freemind/FreeMindNode.java | 30 +- .../mindmap/freemind/FreeMindTransformer.java | 115 +- .../mindmap/freemind/model/Arrowlink.java | 335 +- .../mindmap/freemind/model/Attribute.java | 90 +- .../freemind/model/AttributeLayout.java | 91 +- .../mindmap/freemind/model/Cloud.java | 53 +- .../fluentqa/mindmap/freemind/model/Edge.java | 133 +- .../fluentqa/mindmap/freemind/model/Font.java | 195 +- .../fluentqa/mindmap/freemind/model/Hook.java | 138 +- .../fluentqa/mindmap/freemind/model/Html.java | 68 +- .../fluentqa/mindmap/freemind/model/Icon.java | 53 +- .../mindmap/freemind/model/Linktarget.java | 382 +- .../fluentqa/mindmap/freemind/model/Map.java | 98 +- .../fluentqa/mindmap/freemind/model/Node.java | 767 +- .../mindmap/freemind/model/ObjectFactory.java | 225 +- .../mindmap/freemind/model/Parameters.java | 571 +- .../mindmap/freemind/model/Richcontent.java | 96 +- .../fluentqa/mindmap/freemind/model/Text.java | 12 +- .../io/fluentqa/mindmap/package-info.java | 2 +- .../io/fluentqa/mindmap/xmind/XMindNode.java | 8 +- .../io/fluentqa/mindmap/xmind/XMindUtil.java | 78 +- .../mindmap/xmind/XmindTransformer.java | 123 +- .../mindmap/xmind/model/Attached.java | 18 +- .../mindmap/xmind/model/Children.java | 8 +- .../mindmap/xmind/model/Comments.java | 11 +- .../mindmap/xmind/model/JsonRootBean.java | 12 +- .../fluentqa/mindmap/xmind/model/Notes.java | 8 +- .../mindmap/xmind/model/RootTopic.java | 19 +- .../mindmap/xmind/model/XmindRawData.java | 44 +- .../io/fluentqa/mindmap/api/DemoBean.java | 20 +- .../fluentqa/mindmap/api/DemoBeanConfig.java | 19 +- .../fluentqa/mindmap/api/DemoBeanWOLevel.java | 10 +- .../mindmap/api/MindMapAccessorTest.java | 31 +- .../freemind/FreeMindConverterTest.java | 24 +- .../fluentqa/mindmap/xmind/XMindUtilTest.java | 33 +- .../mindmap/xmind/XmindTransformerTest.java | 22 +- components/fluent-openapi/pom.xml | 5 + .../java/io/fluent/differ/OpenApiDiffer.java | 1 - .../java/io/fluent/postman/PostmanParser.java | 21 +- .../java/io/fluent/postman/ValueUtils.java | 48 +- .../io/fluent/postman/model/PostmanBody.java | 88 +- .../postman/model/PostmanCollection.java | 11 +- .../postman/model/PostmanCollectionInfo.java | 6 +- .../io/fluent/postman/model/PostmanEvent.java | 9 +- .../fluent/postman/model/PostmanFileBody.java | 2 +- .../postman/model/PostmanFormDataBody.java | 79 +- .../io/fluent/postman/model/PostmanItem.java | 25 +- .../fluent/postman/model/PostmanKeyValue.java | 21 +- .../io/fluent/postman/model/PostmanQuery.java | 61 +- .../fluent/postman/model/PostmanRawBody.java | 24 +- .../fluent/postman/model/PostmanRequest.java | 20 +- .../fluent/postman/model/PostmanResponse.java | 23 +- .../fluent/postman/model/PostmanScript.java | 7 +- .../io/fluent/postman/model/PostmanUrl.java | 42 +- .../postman/model/PostmanUrlEncodedBody.java | 79 +- .../postman/model/ResponseBodyMode.java | 40 +- .../java/io/fluent/postman/package-info.java | 2 +- .../java/io/fluent/swagger/SwaggerParser.java | 13 + .../io/fluent/swagger/model/SwaggerApi.java | 19 +- .../io/fluent/swagger/model/SwaggerInfo.java | 8 +- .../swagger/model/SwaggerParameter.java | 12 +- .../fluent/swagger/model/SwaggerRequest.java | 17 +- .../io/fluent/swagger/model/SwaggerTag.java | 4 +- .../java/io/fluent/swagger/package-info.java | 2 +- .../main/java/io/fluent/utils/TypeUtils.java | 128 +- .../main/java/io/fluent/utils/UrlUtils.java | 120 +- .../io/fluent/postman/PostmanParserTest.java | 12 +- .../java/io/fluent/quickdao/QuickDao.java | 128 +- .../quickdao/annotations/QuickDaoColumn.java | 4 +- .../quickdao/constants/DefaultConstants.java | 4 +- .../datasource/DataSourceCreator.java | 5 +- .../datasource/DialectAndDrivers.java | 36 +- .../datasource/model/DataSourceSetting.java | 11 +- .../datasource/model/TableColumn.java | 14 +- .../datasource/model/TableInfoQuery.java | 63 +- .../model/TableInfoQueryFinder.java | 29 +- .../io/fluent/quickdao/entity/EntityUtil.java | 33 +- .../exceptions/DbExecutionFoundException.java | 8 +- .../exceptions/NoDbDriverFoundException.java | 8 +- .../quickdao/service/SqlExecuteResponse.java | 2 +- .../quickdao/service/SqlQueryResponse.java | 6 +- .../fluent/quickdao/service/SqlRequest.java | 41 +- .../fluent/quickdao/service/SqlService.java | 21 +- .../fluent/quickdao/service/package-info.java | 2 +- .../java/io/fluent/quickdao/QuickDaoTest.java | 230 +- .../quickdao/entity/EntityUtilTest.java | 10 +- .../quickdao/entity/GithubStarredRepo.java | 20 +- components/fluent-testlibs/pom.xml | 12 + .../supplier/converters/BooleanConverter.java | 20 +- .../supplier/converters/DefaultConverter.java | 18 +- .../supplier/converters/DoubleConverter.java | 28 +- .../supplier/converters/IConverter.java | 10 +- .../supplier/converters/IntegerConverter.java | 20 +- .../converters/LocalDateConverter.java | 23 +- .../converters/LocalDateTimeConverter.java | 23 +- .../supplier/converters/StringConverter.java | 8 +- .../core/DataProviderTransformer.java | 122 +- .../supplier/core/DataSupplier.java | 16 +- .../supplier/core/DataSupplierAspect.java | 169 +- .../core/DataSupplierInterceptor.java | 32 +- .../IAnnotationTransformerInterceptor.java | 63 +- .../datafactory/supplier/data/Column.java | 9 +- .../datafactory/supplier/data/CsvReader.java | 64 +- .../datafactory/supplier/data/DataReader.java | 18 +- .../datafactory/supplier/data/FieldName.java | 5 +- .../datafactory/supplier/data/JsonReader.java | 55 +- .../datafactory/supplier/data/Sheet.java | 6 +- .../datafactory/supplier/data/Source.java | 6 +- .../supplier/data/TestDataReader.java | 63 +- .../supplier/data/XlsxCellMapper.java | 123 +- .../datafactory/supplier/data/XlsxReader.java | 142 +- .../datafactory/supplier/data/YamlReader.java | 42 +- .../supplier/model/DataSupplierMetaData.java | 110 +- .../supplier/model/TestNGMethod.java | 74 +- .../supplier/model/TypeMappings.java | 46 +- .../supplier/utils/ReflectionUtils.java | 271 +- .../supplier/utils/ServiceLoaderUtils.java | 21 +- .../java/io/fluent/testlibs/package-info.java | 2 +- .../testlibs/random/IdCardGenerator.java | 7215 ++++++++--------- .../testlibs/random/RandomGenerator.java | 491 +- .../testlibs/datafactory/DataFactory.java | 4 +- .../testlibs/datatransform/DemoClass.java | 89 +- .../testlibs/datatransform/PetEntity.java | 21 +- .../fluent/testlibs/instanceio/Address.java | 2 +- .../testlibs/instanceio/DemoInstance.java | 47 +- .../io/fluent/testlibs/instanceio/Gender.java | 3 +- .../io/fluent/testlibs/instanceio/Person.java | 10 +- .../fluent/testlibs/ngork/NgorkChannels.java | 16 +- .../java/io/fluent/testlibs/package-info.java | 2 +- .../java/io/fluentqa/md/MarkdownAccessor.java | 3 +- .../java/io/fluentqa/md/package-info.java | 2 +- .../fluentqa/md/parser/FieldParseConfig.java | 8 +- .../io/fluentqa/md/parser/ParseConfig.java | 17 +- .../awesome/AwesomeListParserConfig.java | 11 +- .../md/parser/awesome/AwesomeModel.java | 9 +- .../awesome/MarkdownAwesomeListParser.java | 65 +- .../MarkdownAwesomeListParserTest.java | 122 +- docs/1-FEATURES/1-API-Sepc-Mgr.md | 14 + docs/1-FEATURES/README.md | 31 + .../1-\345\244\226\345\214\205.md" | 0 ...76\345\207\206\346\265\213\350\257\225.md" | 0 ...15\345\210\260\344\270\234\350\245\277.md" | 0 docs/README.md | 2 + docs/features/authing-integrations.md | 2 - docs/framework/README.md | 3 - docs/lessons/database/database-schema.png | Bin 44238 -> 0 bytes docs/lessons/database/database.md | 5 - docs/lessons/docker/docker-in-5-minutes.md | 9 - ...77\347\224\250\345\205\245\351\227\250.md" | 4 - fluent-apps/qaserver/pom.xml | 2 +- .../fluentqa/github/FluentGithubModule.java | 9 +- .../github/model/AwesomeResource.java | 29 + .../github/model/GithubStarredRepo.java | 6 +- .../jobs/github/GithubJobFetchParameters.java | 1 + .../src/main/resources/application-dev.yaml | 2 +- .../base/handlers/SqlTagFetchHandler.java | 33 +- .../base/model/ModelWithValidFlag.java | 30 +- .../base/model/ModelWithValidFlagVo.java | 37 +- .../io/fluentqa/base/model/NamedModelVO.java | 74 +- .../base/model/NamedTimeStatusModel.java | 124 +- .../java/io/fluentqa/base/package-info.java | 2 +- .../base/proxies/AuditDataEnhancerProxy.java | 5 +- .../FluentEruptApiAutoConfiguration.java | 101 +- .../generator/api/action/MagicApiTpl.java | 34 +- .../fluentqa/generator/api/package-info.java | 2 +- .../EruptMagicAPIRequestInterceptor.java | 199 +- .../io/fluentqa/generator/package-info.java | 2 +- .../service/JsonToPojoGenerateService.java | 76 +- .../generator/pojo/PojoGeneratorTest.java | 17 +- .../main/java/io/fluent/ai/package-info.java | 1 - .../fluent/wrappers/feishu/BitTableApis.java | 182 +- .../io/fluent/wrappers/feishu/RawApiCall.java | 185 +- .../dto/req/TenantAccessTokenGetReqDTO.java | 18 +- .../dto/resp/TenantAccessTokenGetRespDTO.java | 31 +- .../feishu/auth/service/AuthApiService.java | 33 +- .../feishu/bitable/dto/FieldProperty.java | 122 +- .../wrappers/feishu/bitable/dto/Person.java | 24 +- .../bitable/dto/req/BiFieldQueryReqDTO.java | 12 +- .../dto/req/BiFieldSaveBodyReqDTO.java | 58 +- .../bitable/dto/req/BiFieldSaveReqDTO.java | 19 +- .../dto/req/BiRecordSaveItemReqDTO.java | 22 +- .../dto/req/BiTableRecordQueryReqDTO.java | 48 +- .../dto/req/TableRecordSaveReqDTO.java | 11 +- .../bitable/dto/resp/BiFieldItemRespDTO.java | 45 +- .../bitable/dto/resp/BiRecordItemRespDTO.java | 42 +- .../bitable/dto/resp/BiTableItemRespDTO.java | 19 +- .../dto/resp/TableRecordSyncRespDTO.java | 29 +- .../bitable/service/BiTableApiService.java | 194 +- .../common/constant/FeishuErrorCodeEnum.java | 52 +- .../wrappers/feishu/common/dto/Page.java | 28 +- .../feishu/common/dto/PageReqDTO.java | 21 +- .../wrappers/feishu/common/dto/Resp.java | 82 +- .../common/exception/FeishuException.java | 6 +- .../fluent/wrappers/feishu/package-info.java | 7 +- .../fluent/git/github/GithubUserService.java | 72 +- .../git/github/config/ConfigHolder.java | 43 +- .../git/github/entity/GithubStarredRepo.java | 34 +- .../git/github/models/GithubRepoModel.java | 2162 ++--- .../io/fluent/git/github/models/License.java | 131 +- .../io/fluent/git/github/models/Owner.java | 484 +- .../fluent/git/github/models/Permissions.java | 131 +- .../io/fluent/git/github/repo/GithubDao.java | 28 +- .../fluent/git/gitlab/GitlabInterceptor.java | 34 +- .../fluent/git/gitlab/api/GitlabMember.java | 10 +- .../git/gitlab/api/GitlabMembership.java | 13 +- .../fluent/git/gitlab/api/GitlabService.java | 12 +- .../io/fluent/git/gitlab/package-info.java | 2 +- .../main/java/io/fluent/git/package-info.java | 2 +- .../git/github/GithubUserServiceTest.java | 80 +- .../jira/config/BasicAuthentication.java | 28 +- .../io/fluentqa/jira/config/CacheConfig.java | 30 +- .../jira/config/CommentMappingConfig.java | 72 +- .../java/io/fluentqa/jira/config/Context.java | 5 +- .../jira/config/DescriptionMappingConfig.java | 28 +- .../jira/config/JiraConnectionProperties.java | 114 +- .../fluentqa/jira/config/JiraProjectSync.java | 270 +- .../fluentqa/jira/config/JiraSyncConfig.java | 238 +- .../jira/config/TransitionConfig.java | 227 +- .../fluentqa/jira/domain/JiraChangeLog.java | 70 +- .../io/fluentqa/jira/domain/JiraComment.java | 74 +- .../io/fluentqa/jira/domain/JiraComments.java | 64 +- .../fluentqa/jira/domain/JiraComponent.java | 12 +- .../jira/domain/JiraComponentsList.java | 3 +- .../io/fluentqa/jira/domain/JiraField.java | 44 +- .../fluentqa/jira/domain/JiraFieldList.java | 3 +- .../fluentqa/jira/domain/JiraFieldSchema.java | 57 +- .../fluentqa/jira/domain/JiraFieldsBean.java | 25 +- .../jira/domain/JiraFieldsUpdate.java | 260 +- .../jira/domain/JiraFilterResult.java | 16 +- .../fluentqa/jira/domain/JiraIdResource.java | 27 +- .../io/fluentqa/jira/domain/JiraIssue.java | 144 +- .../fluentqa/jira/domain/JiraIssueFields.java | 340 +- .../jira/domain/JiraIssueHistoryEntry.java | 82 +- .../jira/domain/JiraIssueHistoryItem.java | 164 +- .../fluentqa/jira/domain/JiraIssueStatus.java | 12 +- .../fluentqa/jira/domain/JiraIssueType.java | 12 +- .../fluentqa/jira/domain/JiraIssueUpdate.java | 78 +- .../io/fluentqa/jira/domain/JiraLinkIcon.java | 25 +- .../jira/domain/JiraLoginRequest.java | 43 +- .../jira/domain/JiraLoginResponse.java | 19 +- .../fluentqa/jira/domain/JiraNamedBean.java | 9 +- .../jira/domain/JiraNamedResource.java | 38 +- .../io/fluentqa/jira/domain/JiraPriority.java | 12 +- .../jira/domain/JiraPriorityList.java | 3 +- .../io/fluentqa/jira/domain/JiraProject.java | 73 +- .../jira/domain/JiraProjectsList.java | 3 +- .../fluentqa/jira/domain/JiraRemoteLink.java | 48 +- .../jira/domain/JiraRemoteLinkObject.java | 55 +- .../fluentqa/jira/domain/JiraRemoteLinks.java | 3 +- .../fluentqa/jira/domain/JiraResolution.java | 12 +- .../jira/domain/JiraResolutionList.java | 3 +- .../io/fluentqa/jira/domain/JiraResource.java | 22 +- .../jira/domain/JiraSearchResult.java | 58 +- .../fluentqa/jira/domain/JiraServerInfo.java | 55 +- .../io/fluentqa/jira/domain/JiraSession.java | 32 +- .../fluentqa/jira/domain/JiraTransition.java | 29 +- .../fluentqa/jira/domain/JiraTransitions.java | 25 +- .../io/fluentqa/jira/domain/JiraUser.java | 41 +- .../io/fluentqa/jira/domain/JiraVersion.java | 11 +- .../jira/domain/JiraVersionsList.java | 3 +- .../jira/domain/WellKnownCustomFieldType.java | 42 +- .../jira/domain/WellKnownJiraField.java | 46 +- .../java/io/fluentqa/jira/package-info.java | 2 +- .../{fluent-ai => fluent-supabase}/pom.xml | 14 +- .../src/main/java/io/fluent/tw/TwClient.java | 29 +- .../main/java/io/fluent/tw/package-info.java | 2 +- .../fluent/tw/service/FollowingService.java | 42 +- .../test/java/io/fluent/tw/TwClientTest.java | 32 +- fluent-wrappers/pom.xml | 1 + .../modules/base/AbstractFluentModule.java | 47 +- .../modules/base/FluentModuleException.java | 33 +- .../modules/base/FluentTestingPlugin.java | 8 +- .../fluent/modules/base/InjectableModule.java | 4 +- .../fluent/modules/base/PluginSettings.java | 46 +- .../java/io/fluent/modules/package-info.java | 2 - pom.xml | 3 +- references.yaml | 1 + 440 files changed, 17684 insertions(+), 18093 deletions(-) create mode 100644 ci/checkstyle_bnk.xml create mode 100644 components/fluent-openapi/src/main/java/io/fluent/swagger/SwaggerParser.java create mode 100644 docs/1-FEATURES/1-API-Sepc-Mgr.md create mode 100644 docs/1-FEATURES/README.md rename "docs/buzzwords/1-\345\244\226\345\214\205.md" => "docs/10-THOUGHTS/1-\345\244\226\345\214\205.md" (100%) rename "docs/buzzwords/2-\347\262\276\345\207\206\346\265\213\350\257\225.md" => "docs/10-THOUGHTS/2-\347\262\276\345\207\206\346\265\213\350\257\225.md" (100%) rename "docs/buzzwords/3-\344\270\272\344\273\200\344\271\210\350\247\211\345\276\227\345\255\246\344\270\215\345\210\260\344\270\234\350\245\277.md" => "docs/10-THOUGHTS/3-\344\270\272\344\273\200\344\271\210\350\247\211\345\276\227\345\255\246\344\270\215\345\210\260\344\270\234\350\245\277.md" (100%) delete mode 100644 docs/features/authing-integrations.md delete mode 100644 docs/framework/README.md delete mode 100644 docs/lessons/database/database-schema.png delete mode 100644 docs/lessons/database/database.md delete mode 100644 docs/lessons/docker/docker-in-5-minutes.md delete mode 100644 "docs/simplify-qa/low-code/baas/supabase/Supabase\344\275\277\347\224\250\345\205\245\351\227\250.md" create mode 100644 fluent-apps/qaserver/src/main/java/io/fluentqa/github/model/AwesomeResource.java delete mode 100644 fluent-wrappers/fluent-ai/src/main/java/io/fluent/ai/package-info.java rename fluent-wrappers/{fluent-ai => fluent-supabase}/pom.xml (60%) diff --git a/README.md b/README.md index 54fe8a9..5ec69f6 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,29 @@ # README +This Project is the answer to : + +``` +接口自动化测试平台需求: +1、可对接 swagger 文档,自动/手动导入接口信息 +2、具备接口信息管理、测试用例管理、测试步骤管理、测试报告管理的功能 +3、具备接口调试的功能 +4、以测试集为单位执行多个测试用例,并生成测试报告 + +API Automation Testing Platform Requirements: + +1. Capable of integrating with Swagger documentation, with the ability to automatically/ manually import interface information. +2. with functions for managing interface information, test case management, test step management, and test report management. +3. Possesses the capability for interface debugging. +4. Executes multiple test cases as a test suite and generates test reports. +``` + +Build A [restack](https://www.restack.io/) like toolkits but for Software QA. + + +## Features + + + FluentQA Workspace project is JAVA Project includes: 1. Toolkits to handler QA Daily Work diff --git a/ci/checkstyle.xml b/ci/checkstyle.xml index 5a429ad..cb197f9 100644 --- a/ci/checkstyle.xml +++ b/ci/checkstyle.xml @@ -1,196 +1,432 @@ + "-//Checkstyle//DTD Checkstyle Configuration 1.3//EN" + "https://checkstyle.org/dtds/configuration_1_3.dtd"> + + - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + - - - + + + + - - - - - - + + + + + + + + + + + + + + + + + + + - - - - - - + + + + + + + + + + - - + + + - - - + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + value="LITERAL_TRY, LITERAL_CATCH, LITERAL_FINALLY, LITERAL_IF, LITERAL_ELSE, + LITERAL_DO"/> - - - - - - - - - - - - + + + + + - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + - - - + + + + + + + + + + + + + + + + + - - + + + + - - - + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + - - - - - - - - - - - - diff --git a/ci/checkstyle_bnk.xml b/ci/checkstyle_bnk.xml new file mode 100644 index 0000000..aa2b7d8 --- /dev/null +++ b/ci/checkstyle_bnk.xml @@ -0,0 +1,196 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/CollectionsUtils.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/CollectionsUtils.java index ab11278..cc98a09 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/CollectionsUtils.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/CollectionsUtils.java @@ -1,8 +1,8 @@ package io.fluent.builtin; +import static io.fluent.builtin.PredictionsUtil.distinctByKey; import cn.hutool.core.collection.CollectionUtil; - import java.util.Collection; import java.util.List; import java.util.function.Function; @@ -10,116 +10,106 @@ import java.util.stream.Collectors; import java.util.stream.Stream; -import static io.fluent.builtin.PredictionsUtil.distinctByKey; - -/** - * 集合操作工具类 - */ +/** 集合操作工具类 */ public class CollectionsUtils extends CollectionUtil { - private CollectionsUtils() { - } - - /** - * 根据条件过滤数组元素 - * - * @param source - * @param condition - * @param - * @return 如果全部过滤完则返回null - */ - public static T filterToOne(T[] source, Predicate condition) { - - List result = filter(source, condition); - if (result != null && result.size() >= 1) return result.get(0); - return null; + private CollectionsUtils() {} + + /** + * 根据条件过滤数组元素 + * + * @param source + * @param condition + * @param + * @return 如果全部过滤完则返回null + */ + public static T filterToOne(T[] source, Predicate condition) { + + List result = filter(source, condition); + if (result != null && result.size() >= 1) return result.get(0); + return null; + } + + /** + * filter source by condition + * + * @param source + * @param condition + * @param + * @return {@List} all the matched result + */ + public static List filter(T[] source, Predicate condition) { + + return Stream.of(source).filter(condition).collect(Collectors.toList()); + } + + /** + * 根据条件过滤集合元素 + * + * @param source + * @param conditions + * @param + * @return 如果全部过滤完则返回null + */ + public static T filterByOrConditions(Collection source, Predicate... conditions) { + + for (T s : source) { + for (Predicate condition : conditions) { + if (condition.test(s)) return s; + } } - - /** - * filter source by condition - * - * @param source - * @param condition - * @param - * @return {@List} all the matched result - */ - public static List filter(T[] source, Predicate condition) { - - return Stream.of(source).filter(condition).collect(Collectors.toList()); + return null; + } + + /** + * 根据条件过滤集合元素 + * + * @param source + * @param condition + * @param + * @return 如果全部过滤完则返回空ArrayList + */ + public static List filter(Collection source, Predicate condition) { + return source.stream().filter(condition).collect(Collectors.toList()); + } + + /** + * 根据条件过滤集合元素 + * + * @param source + * @param condition + * @param + * @return 如果全部过滤完则返回null + */ + public static T filterToOne(Collection source, Predicate condition) { + List result = source.stream().filter(condition).collect(Collectors.toList()); + if (result == null && result.size() == 0) return null; + return source.stream().filter(condition).collect(Collectors.toList()).get(0); + } + + /** + * return if one array contains another array + * + * @param source + * @param target + * @param + * @return + */ + public static boolean arrayContains(T[] source, T target) { + for (T t : source) { + if (t.equals(target)) return true; } - - - /** - * 根据条件过滤集合元素 - * - * @param source - * @param conditions - * @param - * @return 如果全部过滤完则返回null - */ - public static T filterByOrConditions(Collection source, Predicate... conditions) { - - for (T s : source) { - for (Predicate condition : conditions) { - if (condition.test(s)) return s; - } - } - return null; - } - - - /** - * 根据条件过滤集合元素 - * - * @param source - * @param condition - * @param - * @return 如果全部过滤完则返回空ArrayList - */ - public static List filter(Collection source, Predicate condition) { - return source.stream().filter(condition).collect(Collectors.toList()); - } - - - /** - * 根据条件过滤集合元素 - * - * @param source - * @param condition - * @param - * @return 如果全部过滤完则返回null - */ - public static T filterToOne(Collection source, Predicate condition) { - List result = source.stream().filter(condition).collect(Collectors.toList()); - if (result == null && result.size() == 0) return null; - return source.stream().filter(condition).collect(Collectors.toList()).get(0); - } - - /** - * return if one array contains another array - * - * @param source - * @param target - * @param - * @return - */ - public static boolean arrayContains(T[] source, T target) { - for (T t : source) { - if (t.equals(target)) return true; - } - return false; - } - - - public static T lastElementOf(T[] objects) { - if (objects == null || objects.length == 0) return null; - int length = objects.length; - return objects[length - 1]; - } - - public static List filterToReduceRedundant(List redundantList, - Function keyExtractor) { - return redundantList.stream().filter(distinctByKey(keyExtractor)).toList(); - } - + return false; + } + + public static T lastElementOf(T[] objects) { + if (objects == null || objects.length == 0) return null; + int length = objects.length; + return objects[length - 1]; + } + + public static List filterToReduceRedundant( + List redundantList, Function keyExtractor) { + return redundantList.stream().filter(distinctByKey(keyExtractor)).toList(); + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/FileUtils.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/FileUtils.java index 7e23570..4aa7a89 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/FileUtils.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/FileUtils.java @@ -2,8 +2,5 @@ import cn.hutool.core.io.FileUtil; -/** - * Simple Extends FileUtils to separate - */ -public class FileUtils extends FileUtil { -} +/** Simple Extends FileUtils to separate */ +public class FileUtils extends FileUtil {} diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/JavaProjectFileUtils.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/JavaProjectFileUtils.java index 2569637..d7ea9fa 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/JavaProjectFileUtils.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/JavaProjectFileUtils.java @@ -1,11 +1,8 @@ package io.fluent.builtin; - import cn.hutool.core.io.FileUtil; import com.google.common.collect.Lists; import com.google.common.collect.Maps; -import lombok.extern.slf4j.Slf4j; - import java.io.File; import java.io.IOException; import java.io.UnsupportedEncodingException; @@ -15,24 +12,23 @@ import java.util.List; import java.util.Map; import java.util.regex.Pattern; +import lombok.extern.slf4j.Slf4j; -/** - * 文件操作工具类 - */ +/** 文件操作工具类 */ @Slf4j public class JavaProjectFileUtils extends FileUtil { private static final String classPath = getClassPath(); public static final String separatorChar = File.separatorChar == '\\' ? "\\\\" : File.separator; - private static final String SOURCEBASEPATH = classPath.replaceAll("target/classes/", "") - .replaceAll("target/test-classes/", ""); + private static final String SOURCEBASEPATH = + classPath.replaceAll("target/classes/", "").replaceAll("target/test-classes/", ""); - private JavaProjectFileUtils() { - } + private JavaProjectFileUtils() {} private static String getClassPath() { try { - return java.net.URLDecoder.decode(JavaProjectFileUtils.class.getClassLoader().getResource("").getPath(), "utf-8"); + return java.net.URLDecoder.decode( + JavaProjectFileUtils.class.getClassLoader().getResource("").getPath(), "utf-8"); } catch (UnsupportedEncodingException e) { log.error("error+{}", e); } @@ -64,9 +60,7 @@ public static String getDirPathInTestResource(String resourcePath) { return SOURCEBASEPATH + "src/test/resources/" + resourcePath; } - /** - * package转换为路径格式 - */ + /** package转换为路径格式 */ public static String packageToDir(String packageName) { String[] array = packageName.split("\\."); StringBuilder sb = new StringBuilder(); @@ -77,19 +71,18 @@ public static String packageToDir(String packageName) { } public static Map> getResourceDirFileMap(String dirPath) { - Map> maps = Maps.newHashMap();// {dir_name, list} + Map> maps = Maps.newHashMap(); // {dir_name, list} File dir = new File(dirPath); if (dir.isDirectory()) { File[] files = dir.listFiles(); - if (files == null) - throw new RuntimeException("输入路径错误,请检查输入路径"); + if (files == null) throw new RuntimeException("输入路径错误,请检查输入路径"); for (File f : files) { if (f.isDirectory()) { if (maps.get(dir.getName()) == null) { maps.putAll(getResourceDirFileMap(dirPath + "/" + f.getName())); } else { - maps.get(dir.getName()).addAll( - getResourceDirFileMap(dirPath + "/" + f.getName()).get(dirPath)); + maps.get(dir.getName()) + .addAll(getResourceDirFileMap(dirPath + "/" + f.getName()).get(dirPath)); } } else { if (maps.get(dir.getName()) == null) { @@ -113,11 +106,12 @@ public static Map> getResourceDirFileMap(String dirPath) { public static File writeToFile(String path, String text) { File file = new File(path); - if (!file.exists()) try { - file.createNewFile(); - } catch (IOException e) { - throw new RuntimeException("create file failed for " + file.getName()); - } + if (!file.exists()) + try { + file.createNewFile(); + } catch (IOException e) { + throw new RuntimeException("create file failed for " + file.getName()); + } ArrayList texts = Lists.newArrayList(text); FileUtil.writeLines(texts, file, "utf-8", true); @@ -127,18 +121,18 @@ public static File writeToFile(String path, String text) { public static File writeToFile(String path, String text, boolean isAppend) { File file = new File(path); - if (!file.exists()) try { - file.createNewFile(); - } catch (IOException e) { - throw new RuntimeException("create file failed for " + file.getName()); - } + if (!file.exists()) + try { + file.createNewFile(); + } catch (IOException e) { + throw new RuntimeException("create file failed for " + file.getName()); + } ArrayList texts = Lists.newArrayList(text); FileUtil.writeLines(texts, file, "utf-8", isAppend); return file; } - /** * 删除文件 * @@ -147,10 +141,8 @@ public static File writeToFile(String path, String text, boolean isAppend) { public static boolean deleteFile(String path) { File file = new File(path); return file.delete(); - } - /** * Read file from class Path * @@ -166,7 +158,6 @@ public static String readClasspathFile(String pathInClassPath) { log.error("result={}", (Object) e.getStackTrace()); throw new RuntimeException(pathInClassPath + " is not existing"); } - } public static File createFileInClassPath(String dir, String fileName) { @@ -203,17 +194,14 @@ public static File createFile(String fileName) { * @param path * @param fileSuffix */ - public static void checkIfSuitableFile(String path, String... fileSuffix) { for (String s : fileSuffix) { if (path.endsWith(s)) return; } throw new RuntimeException(path + " ,File suffix is not correct,please check the file"); - } - /** * 创建目录 * @@ -298,5 +286,4 @@ public static String getPathForSystemFile(final String fileName) { File file = new File(fileName); return file.getAbsolutePath(); } - } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/MatcherUtils.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/MatcherUtils.java index c2f3c12..7604d53 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/MatcherUtils.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/MatcherUtils.java @@ -1,25 +1,23 @@ package io.fluent.builtin; import cn.hutool.core.util.StrUtil; - import java.util.regex.Matcher; import java.util.regex.Pattern; public class MatcherUtils { - private static final Pattern CHINESE_PATTERN = Pattern.compile("[\u4e00-\u9fa5]"); + private static final Pattern CHINESE_PATTERN = Pattern.compile("[\u4e00-\u9fa5]"); - public static boolean match(String regex, String value) { - Pattern pattern = Pattern.compile(regex); - Matcher matcher = pattern.matcher(value); - return matcher.matches(); - } + public static boolean match(String regex, String value) { + Pattern pattern = Pattern.compile(regex); + Matcher matcher = pattern.matcher(value); + return matcher.matches(); + } - public static boolean containChinese(String value) { - if (StrUtil.isBlank(value)) { - return false; - } - Matcher matcher = CHINESE_PATTERN.matcher(value); - return matcher.find(); + public static boolean containChinese(String value) { + if (StrUtil.isBlank(value)) { + return false; } - + Matcher matcher = CHINESE_PATTERN.matcher(value); + return matcher.find(); + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/NamingUtils.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/NamingUtils.java index ccab487..12f446e 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/NamingUtils.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/NamingUtils.java @@ -4,15 +4,16 @@ public class NamingUtils { - public static String underscoreToCamel(String value) { - StringBuilder result = new StringBuilder(); - String[] arr = value.split(StringUtils.UNDERLINE); - for (String s : arr) { - result.append((String.valueOf(s.charAt(0))).toUpperCase()).append(s.substring(1)); - } - return result.toString(); - } - public static String camelToUnderscore(String value) { - return StrUtil.toUnderlineCase(value); + public static String underscoreToCamel(String value) { + StringBuilder result = new StringBuilder(); + String[] arr = value.split(StringUtils.UNDERLINE); + for (String s : arr) { + result.append((String.valueOf(s.charAt(0))).toUpperCase()).append(s.substring(1)); } + return result.toString(); + } + + public static String camelToUnderscore(String value) { + return StrUtil.toUnderlineCase(value); + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/PingYinUtils.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/PingYinUtils.java index 0f104a6..9e6e94f 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/PingYinUtils.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/PingYinUtils.java @@ -4,19 +4,20 @@ public class PingYinUtils { - public static String convertToPinyinAbbreviation(String chineseName) { - StringBuilder abbreviation = new StringBuilder(); + private PingYinUtils() {} - // 将中文名转换为拼音数组 - char[] chineseNameArray = chineseName.toCharArray(); - for (char c : chineseNameArray) { - String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(c); - for (String pinyin : pinyinArray) { - // 提取每个拼音的首字母 - abbreviation.append(pinyin.charAt(0)); - } + public static String convertToPinyinAbbreviation(final String chineseName) { + StringBuilder abbreviation = new StringBuilder(); - } - return abbreviation.toString().toUpperCase(); + // 将中文名转换为拼音数组 + char[] chineseNameArray = chineseName.toCharArray(); + for (char c : chineseNameArray) { + String[] pinyinArray = PinyinHelper.toHanyuPinyinStringArray(c); + for (String pinyin : pinyinArray) { + // 提取每个拼音的首字母 + abbreviation.append(pinyin.charAt(0)); + } } + return abbreviation.toString().toUpperCase(); + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/PredictionsUtil.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/PredictionsUtil.java index ec50ac6..75f3bb4 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/PredictionsUtil.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/PredictionsUtil.java @@ -1,19 +1,19 @@ package io.fluent.builtin; - import java.util.Set; import java.util.concurrent.ConcurrentHashMap; import java.util.function.Function; import java.util.function.Predicate; + public class PredictionsUtil { - public static Predicate distinctByKey(Function keyExtractor) { - Set seen = ConcurrentHashMap.newKeySet(); - return new Predicate() { - @Override - public boolean test(T t) { - return seen.add(keyExtractor.apply(t)); - } - }; - } + public static Predicate distinctByKey(Function keyExtractor) { + Set seen = ConcurrentHashMap.newKeySet(); + return new Predicate() { + @Override + public boolean test(T t) { + return seen.add(keyExtractor.apply(t)); + } + }; + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/StringUtils.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/StringUtils.java index b527b2a..739e98c 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/StringUtils.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/StringUtils.java @@ -2,5 +2,4 @@ import cn.hutool.core.util.StrUtil; -public class StringUtils extends StrUtil { -} +public class StringUtils extends StrUtil {} diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/XmlUtils.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/XmlUtils.java index 6de0523..4a6d76b 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/XmlUtils.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/XmlUtils.java @@ -3,12 +3,11 @@ import cn.hutool.core.util.XmlUtil; import jakarta.xml.bind.JAXBContext; import jakarta.xml.bind.Unmarshaller; -import lombok.extern.slf4j.Slf4j; -import org.w3c.dom.Document; - -import javax.xml.xpath.XPathConstants; import java.io.BufferedInputStream; import java.io.FileInputStream; +import javax.xml.xpath.XPathConstants; +import lombok.extern.slf4j.Slf4j; +import org.w3c.dom.Document; @Slf4j public class XmlUtils extends XmlUtil { @@ -17,14 +16,12 @@ public static Document getDocument(String xmlFilePath) { return XmlUtil.readXML(xmlFilePath); } - public static Object getValueByXpath(String xmlFilePath, - String xpathExpr) { + public static Object getValueByXpath(String xmlFilePath, String xpathExpr) { Document doc = getDocument(xmlFilePath); return XmlUtil.getByXPath(xpathExpr, doc, XPathConstants.STRING); } - public static Object getValueByXpath(Document doc, - String xpathExpr) { + public static Object getValueByXpath(Document doc, String xpathExpr) { return XmlUtil.getByXPath(xpathExpr, doc, XPathConstants.STRING); } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/annotation/NotThreadSafe.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/annotation/NotThreadSafe.java index 510ceca..db4d231 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/annotation/NotThreadSafe.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/annotation/NotThreadSafe.java @@ -6,5 +6,4 @@ @Inherited @Target({ElementType.TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) -public @interface NotThreadSafe { -} \ No newline at end of file +public @interface NotThreadSafe {} diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/annotation/WithBug.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/annotation/WithBug.java index 07e85cc..e17ea4d 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/annotation/WithBug.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/annotation/WithBug.java @@ -5,7 +5,7 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -@Target({ElementType.TYPE,ElementType.METHOD}) +@Target({ElementType.TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) public @interface WithBug { String desc() default ""; diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/config/AppConfig.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/config/AppConfig.java index 8a48e38..877fe9e 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/config/AppConfig.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/config/AppConfig.java @@ -1,20 +1,17 @@ package io.fluent.builtin.config; - import cn.hutool.core.bean.BeanUtil; import cn.hutool.setting.Setting; -import io.fluent.builtin.meta.ReflectionUtils; import io.fluent.builtin.StringUtils; - +import io.fluent.builtin.meta.ReflectionUtils; import java.util.HashMap; public class AppConfig { Setting setting; - private AppConfig() { - } + private AppConfig() {} - private final static String DEFAULT_SETTING_PATH = "config/app.setting"; + private static final String DEFAULT_SETTING_PATH = "config/app.setting"; public static AppConfig create() { return create(DEFAULT_SETTING_PATH); @@ -51,7 +48,8 @@ public T getConfigSetBean(String groupName, Class beanType) { } public T getConfigSetBean(Class beanType) { - ConfigGroupName groupName = ReflectionUtils.getClassLevelAnnotation(beanType, ConfigGroupName.class); + ConfigGroupName groupName = + ReflectionUtils.getClassLevelAnnotation(beanType, ConfigGroupName.class); if (groupName != null && StringUtils.isBlank(groupName.name())) { throw new AppConfigException(beanType.getName() + "is not annotated by ConfigGroupName"); } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/config/AppConfigException.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/config/AppConfigException.java index 3a6f27d..36f1795 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/config/AppConfigException.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/config/AppConfigException.java @@ -1,15 +1,15 @@ package io.fluent.builtin.config; -public class AppConfigException extends RuntimeException{ +public class AppConfigException extends RuntimeException { public AppConfigException() { super(); } - public AppConfigException(String message) { + public AppConfigException(final String message) { super(message); } - public AppConfigException(String message, Throwable cause) { + public AppConfigException(final String message, Throwable cause) { super(message, cause); } @@ -17,7 +17,11 @@ public AppConfigException(Throwable cause) { super(cause); } - protected AppConfigException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + protected AppConfigException( + final String message, + Throwable cause, + boolean enableSuppression, + boolean writableStackTrace) { super(message, cause, enableSuppression, writableStackTrace); } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/config/ConfigGroupName.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/config/ConfigGroupName.java index 0bea874..ac11829 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/config/ConfigGroupName.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/config/ConfigGroupName.java @@ -6,7 +6,6 @@ @Inherited @Target({ElementType.TYPE, ElementType.METHOD}) @Retention(RetentionPolicy.RUNTIME) - public @interface ConfigGroupName { - String name() default ""; + String name() default ""; } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/config/DotEnvConfig.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/config/DotEnvConfig.java index 8650d7b..878725b 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/config/DotEnvConfig.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/config/DotEnvConfig.java @@ -4,12 +4,9 @@ public class DotEnvConfig { - static Dotenv dotenv = Dotenv.load(); - - - public static String getValue(String key) { - return dotenv.get(key); - } - + static Dotenv dotenv = Dotenv.load(); + public static String getValue(String key) { + return dotenv.get(key); + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/config/PropUtils.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/config/PropUtils.java index c1c9b23..9bd489e 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/config/PropUtils.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/config/PropUtils.java @@ -1,25 +1,23 @@ package io.fluent.builtin.config; import cn.hutool.setting.dialect.PropsUtil; -import lombok.extern.slf4j.Slf4j; - import java.io.ByteArrayInputStream; import java.io.IOException; import java.util.Objects; import java.util.Properties; +import lombok.extern.slf4j.Slf4j; @Slf4j public class PropUtils extends PropsUtil { - public static Properties toProperties(String propString) { - Properties p = new Properties(); - try { - Objects.requireNonNull(propString, "should not be null"); - p.load(new ByteArrayInputStream(propString.getBytes())); - } catch (IOException | NullPointerException e) { - log.error("{} to properties failed,error ={}", propString, e.getStackTrace()); - } - return p; + public static Properties toProperties(String propString) { + Properties p = new Properties(); + try { + Objects.requireNonNull(propString, "should not be null"); + p.load(new ByteArrayInputStream(propString.getBytes())); + } catch (IOException | NullPointerException e) { + log.error("{} to properties failed,error ={}", propString, e.getStackTrace()); } - + return p; + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/CharsetConst.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/CharsetConst.java index acdbbad..5dcddc0 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/CharsetConst.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/CharsetConst.java @@ -1,25 +1,16 @@ package io.fluent.builtin.constant; -/** - * 编码常量 - */ +/** 编码常量 */ public final class CharsetConst { - private CharsetConst(){} + private CharsetConst() {} - /** - * utf-8 - */ - public static final String UTF8 = "UTF-8"; + /** utf-8 */ + public static final String UTF8 = "UTF-8"; - /** - * utf-16 - */ - public static final String UTF16 = "UTF-16"; - - /** - * gbk - */ - public static final String GBK = "GBK"; + /** utf-16 */ + public static final String UTF16 = "UTF-16"; + /** gbk */ + public static final String GBK = "GBK"; } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/PunctuationConst.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/PunctuationConst.java index ae7ba85..cf4e2dc 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/PunctuationConst.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/PunctuationConst.java @@ -1,130 +1,122 @@ package io.fluent.builtin.constant; -/** - * 标点符号常量 - */ +/** 标点符号常量 */ public final class PunctuationConst { - private PunctuationConst(){} - - - - /** - * 逗号 - */ - public static final String COMMA = ","; - - /** - * 冒号 - */ - public static final String COLON = ":"; - - /** - * 圆点 - */ - public static final String DOT = "."; - - /** - * 空格 - */ - public static final String BLANK = " "; - - /** - * 单引号 - */ - public static final String SINGLE_QUOTES = "'"; - - /** - * 下划线 - */ - public static final String UNDERLINE = "_"; - - /** - * at 符号 - */ - public static final String AT = "@"; - - /** - * 斜杠 - */ - public static final String SLASH = "/"; - - /** - * 星 - * @since 0.0.8 - */ - public static final String STAR = "*"; - - /** - * 双引号 - * @since 0.0.8 - */ - public static final String DOUBLE_QUOTES = "\""; - - /** - * 空 - * @since 0.0.8 - */ - public static final String EMPTY = ""; - - /** - * 非 - * @since 0.0.8 - */ - public static final String NOT = "!"; - - /** - * 与 - * @since 0.0.8 - */ - public static final String AND = "&"; - - /** - * 或 - * @since 0.0.8 - */ - public static final String OR = "|"; - - /** - * # - * @since 0.0.8 - */ - public static final String SHAPE = "#"; - - /** - * 美元 - * @since 0.0.8 - */ - public static final String DOLLAR = "$"; - - /** - * 百分比 - * @since 0.0.8 - */ - public static final String PERCENT = "%"; - - /** - * 幂 - * @since 0.0.8 - */ - public static final String CARET = "^"; - - /** - * 中划线 - * @since 0.0.8 - */ - public static final String MIDDLE_LINE = "-"; - - /** - * 等于号 - * @since 0.1.17 - */ - public static final String EQUAL = "="; - - /** - * 问号 - * @since 0.1.9 - */ - public static final String QUESTION_MARK = "?"; - + private PunctuationConst() {} + + /** 逗号 */ + public static final String COMMA = ","; + + /** 冒号 */ + public static final String COLON = ":"; + + /** 圆点 */ + public static final String DOT = "."; + + /** 空格 */ + public static final String BLANK = " "; + + /** 单引号 */ + public static final String SINGLE_QUOTES = "'"; + + /** 下划线 */ + public static final String UNDERLINE = "_"; + + /** at 符号 */ + public static final String AT = "@"; + + /** 斜杠 */ + public static final String SLASH = "/"; + + /** + * 星 + * + * @since 0.0.8 + */ + public static final String STAR = "*"; + + /** + * 双引号 + * + * @since 0.0.8 + */ + public static final String DOUBLE_QUOTES = "\""; + + /** + * 空 + * + * @since 0.0.8 + */ + public static final String EMPTY = ""; + + /** + * 非 + * + * @since 0.0.8 + */ + public static final String NOT = "!"; + + /** + * 与 + * + * @since 0.0.8 + */ + public static final String AND = "&"; + + /** + * 或 + * + * @since 0.0.8 + */ + public static final String OR = "|"; + + /** + * # + * + * @since 0.0.8 + */ + public static final String SHAPE = "#"; + + /** + * 美元 + * + * @since 0.0.8 + */ + public static final String DOLLAR = "$"; + + /** + * 百分比 + * + * @since 0.0.8 + */ + public static final String PERCENT = "%"; + + /** + * 幂 + * + * @since 0.0.8 + */ + public static final String CARET = "^"; + + /** + * 中划线 + * + * @since 0.0.8 + */ + public static final String MIDDLE_LINE = "-"; + + /** + * 等于号 + * + * @since 0.1.17 + */ + public static final String EQUAL = "="; + + /** + * 问号 + * + * @since 0.1.9 + */ + public static final String QUESTION_MARK = "?"; } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/RegexpConstant.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/RegexpConstant.java index 54a6c44..63e989a 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/RegexpConstant.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/RegexpConstant.java @@ -2,9 +2,6 @@ public interface RegexpConstant { - /** - * 简单手机号正则(这里只是简单校验是否为 11位,实际规则更复杂) - */ - String MOBILE_REG = "[1]\\d{10}"; - -} \ No newline at end of file + /** 简单手机号正则(这里只是简单校验是否为 11位,实际规则更复杂) */ + String MOBILE_REG = "[1]\\d{10}"; +} diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/SystemConst.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/SystemConst.java index f7f764d..d45edb4 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/SystemConst.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/SystemConst.java @@ -3,163 +3,104 @@ /** * 系统常量 * - * String currentUser = System.getProperty("user.name"); + *

String currentUser = System.getProperty("user.name"); */ public final class SystemConst { - private SystemConst(){} - - /** - * Java 运行时环境版本 - */ - public static final String VERSION = "java.version"; - - /** - * Java 运行时环境供应商 - */ - public static final String VENDOR = "java.vendor"; - - /** - * Java 供应商的 URL - */ - public static final String VENDOR_URL = "java.vendor.url"; - - /** - * Java 安装目录 - */ - public static final String HOME = "java.home"; - - /** - * Java 虚拟机规范版本 - */ - public static final String VM_SPECIFICATION_VERSION = "java.vm.specification.version"; - - /** - * Java 虚拟机规范供应商 - */ - public static final String VM_SPECIFICATION_VENDOR = "java.vm.specification.vendor"; - - /** - * Java 虚拟机规范名称 - */ - public static final String VM_SPECIFICATION_NAME = "java.vm.specification.name"; - - /** - * Java 虚拟机实现版本 - */ - public static final String VM_VERSION = "java.vm.version"; - - /** - * Java 虚拟机实现供应商 - */ - public static final String VM_VENDOR = "java.vm.vendor"; - - /** - * Java 虚拟机实现名称 - */ - public static final String VM_NAME = "java.vm.name"; - - /** - * Java 运行时环境规范版本 - */ - public static final String SPECIFICATION_VERSION = "java.specification.version"; - - /** - * Java 运行时环境规范供应商 - */ - public static final String SPECIFICATION_VENDOR = "java.specification.vendor"; - - /** - * Java 运行时环境规范名称 - */ - public static final String SPECIFICATION_NAME = "java.specification.name"; - - /** - * Java 类格式版本号 - */ - public static final String CLASS_VERSION = "java.class.version"; - - /** - * 类路径 - */ - public static final String CLASS_PATH = "java.class.path"; - - /** - * 加载库时搜索的路径列表 - */ - public static final String LIBRARY_PATH = "java.library.path"; - - /** - * 默认的临时文件路径 - */ - public static final String IO_TMPDIR = "java.io.tmpdir"; - - /** - * 要使用的 JIT 编译器的名称 - */ - public static final String COMPILER = "java.compiler"; - - /** - * 一个或多个扩展目录的路径 - */ - public static final String EXT_DIRS = "java.ext.dirs"; - - /** - * 操作系统的名称 - */ - public static final String OS_NAME = "os.name"; - - /** - * 操作系统的架构 - */ - public static final String OS_ARCH = "os.arch"; - - /** - * 操作系统的版本 - */ - public static final String OS_VERSION = "os.version"; - - /** - * 文件分隔符 - * UNIX / - */ - public static final String FILE_SEPARATOR = "file.separator"; - - /** - * 路径分隔符 - * Unix : - */ - public static final String PATH_SEPARATOR = "path.separator"; - - /** - * 行分隔符 - * Unix /n - */ - public static final String LINE_SEPARATOR = "line.separator"; - - /** - * 用户的账户名称 - */ - public static final String USER_NAME = "user.name"; - - /** - * 用户的主目录 - */ - public static final String USER_HOME = "user.home"; - - /** - * 户的当前工作目录 - */ - public static final String USER_DIR = "user.dir"; - - /** - * 获取指定配置信息 - * @param key key - * @return 结果 - */ - @Deprecated - public static String getProperty(final String key) { - return System.getProperty(key); - } + private SystemConst() {} + /** Java 运行时环境版本 */ + public static final String VERSION = "java.version"; + + /** Java 运行时环境供应商 */ + public static final String VENDOR = "java.vendor"; + + /** Java 供应商的 URL */ + public static final String VENDOR_URL = "java.vendor.url"; + + /** Java 安装目录 */ + public static final String HOME = "java.home"; + + /** Java 虚拟机规范版本 */ + public static final String VM_SPECIFICATION_VERSION = "java.vm.specification.version"; + + /** Java 虚拟机规范供应商 */ + public static final String VM_SPECIFICATION_VENDOR = "java.vm.specification.vendor"; + + /** Java 虚拟机规范名称 */ + public static final String VM_SPECIFICATION_NAME = "java.vm.specification.name"; + + /** Java 虚拟机实现版本 */ + public static final String VM_VERSION = "java.vm.version"; + + /** Java 虚拟机实现供应商 */ + public static final String VM_VENDOR = "java.vm.vendor"; + + /** Java 虚拟机实现名称 */ + public static final String VM_NAME = "java.vm.name"; + + /** Java 运行时环境规范版本 */ + public static final String SPECIFICATION_VERSION = "java.specification.version"; + + /** Java 运行时环境规范供应商 */ + public static final String SPECIFICATION_VENDOR = "java.specification.vendor"; + + /** Java 运行时环境规范名称 */ + public static final String SPECIFICATION_NAME = "java.specification.name"; + + /** Java 类格式版本号 */ + public static final String CLASS_VERSION = "java.class.version"; + + /** 类路径 */ + public static final String CLASS_PATH = "java.class.path"; + + /** 加载库时搜索的路径列表 */ + public static final String LIBRARY_PATH = "java.library.path"; + + /** 默认的临时文件路径 */ + public static final String IO_TMPDIR = "java.io.tmpdir"; + + /** 要使用的 JIT 编译器的名称 */ + public static final String COMPILER = "java.compiler"; + + /** 一个或多个扩展目录的路径 */ + public static final String EXT_DIRS = "java.ext.dirs"; + + /** 操作系统的名称 */ + public static final String OS_NAME = "os.name"; + + /** 操作系统的架构 */ + public static final String OS_ARCH = "os.arch"; + + /** 操作系统的版本 */ + public static final String OS_VERSION = "os.version"; + + /** 文件分隔符 UNIX / */ + public static final String FILE_SEPARATOR = "file.separator"; + + /** 路径分隔符 Unix : */ + public static final String PATH_SEPARATOR = "path.separator"; + + /** 行分隔符 Unix /n */ + public static final String LINE_SEPARATOR = "line.separator"; + + /** 用户的账户名称 */ + public static final String USER_NAME = "user.name"; + + /** 用户的主目录 */ + public static final String USER_HOME = "user.home"; + + /** 户的当前工作目录 */ + public static final String USER_DIR = "user.dir"; + + /** + * 获取指定配置信息 + * + * @param key key + * @return 结果 + */ + @Deprecated + public static String getProperty(final String key) { + return System.getProperty(key); + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/enums/LangEnum.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/enums/LangEnum.java index e79a97e..5ba909b 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/enums/LangEnum.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/enums/LangEnum.java @@ -5,193 +5,182 @@ package io.fluent.builtin.constant.enums; -/** - * 翻译语言枚举 - * - - */ +/** 翻译语言枚举 */ public enum LangEnum { - /** - * 自动匹配 - */ - AUTO_DETECT("auto", "自动匹配"), - EN("en", " 英文"), - EN_US("en_US", " 英文 (美国)"), - AR("ar", " 阿拉伯文"), - AR_AE("ar_AE", " 阿拉伯文 (阿拉伯联合酋长国)"), - AR_BH("ar_BH", " 阿拉伯文 (巴林)"), - AR_DZ("ar_DZ", " 阿拉伯文 (阿尔及利亚)"), - AR_EG("ar_EG", " 阿拉伯文 (埃及)"), - AR_IQ("ar_IQ", " 阿拉伯文 (伊拉克)"), - AR_JO("ar_JO", " 阿拉伯文 (约旦)"), - AR_KW("ar_KW", " 阿拉伯文 (科威特)"), - AR_LB("ar_LB", " 阿拉伯文 (黎巴嫩)"), - AR_LY("ar_LY", " 阿拉伯文 (利比亚)"), - AR_MA("ar_MA", " 阿拉伯文 (摩洛哥)"), - AR_OM("ar_OM", " 阿拉伯文 (阿曼)"), - AR_QA("ar_QA", " 阿拉伯文 (卡塔尔)"), - AR_SA("ar_SA", " 阿拉伯文 (沙特阿拉伯)"), - AR_SD("ar_SD", " 阿拉伯文 (苏丹)"), - AR_SY("ar_SY", " 阿拉伯文 (叙利亚)"), - AR_TN("ar_TN", " 阿拉伯文 (突尼斯)"), - AR_YE("ar_YE", " 阿拉伯文 (也门)"), - BE("be", " 白俄罗斯文"), - BE_BY("be_BY", " 白俄罗斯文 (白俄罗斯)"), - BG("bg", " 保加利亚文"), - BG_BG("bg_BG", " 保加利亚文 (保加利亚)"), - CA("ca", " 加泰罗尼亚文"), - CA_ES("ca_ES", " 加泰罗尼亚文 (西班牙)"), - CA_ES_EURO("ca_ES_EURO", " 加泰罗尼亚文 (西班牙,Euro)"), - CS("cs", " 捷克文"), - CS_CZ("cs_CZ", " 捷克文 (捷克共和国)"), - DA("da", " 丹麦文"), - DA_DK("da_DK", " 丹麦文 (丹麦)"), - DE("de", " 德文"), - DE_AT("de_AT", " 德文 (奥地利)"), - DE_AT_EURO("de_AT_EURO", " 德文 (奥地利,Euro)"), - DE_CH("de_CH", " 德文 (瑞士)"), - DE_DE("de_DE", " 德文 (德国)"), - DE_DE_EURO("de_DE_EURO", " 德文 (德国,Euro)"), - DE_LU("de_LU", " 德文 (卢森堡)"), - DE_LU_EURO("de_LU_EURO", " 德文 (卢森堡,Euro)"), - EL("el", " 希腊文"), - EL_GR("el_GR", " 希腊文 (希腊)"), - EN_AU("en_AU", " 英文 (澳大利亚)"), - EN_CA("en_CA", " 英文 (加拿大)"), - EN_GB("en_GB", " 英文 (英国)"), - EN_IE("en_IE", " 英文 (爱尔兰)"), - EN_IE_EURO("en_IE_EURO", " 英文 (爱尔兰,Euro)"), - EN_NZ("en_NZ", " 英文 (新西兰)"), - EN_ZA("en_ZA", " 英文 (南非)"), - ES("es", " 西班牙文"), - ES_BO("es_BO", " 西班牙文 (玻利维亚)"), - ES_AR("es_AR", " 西班牙文 (阿根廷)"), - ES_CL("es_CL", " 西班牙文 (智利)"), - ES_CO("es_CO", " 西班牙文 (哥伦比亚)"), - ES_CR("es_CR", " 西班牙文 (哥斯达黎加)"), - ES_DO("es_DO", " 西班牙文 (多米尼加共和国)"), - ES_EC("es_EC", " 西班牙文 (厄瓜多尔)"), - ES_ES("es_ES", " 西班牙文 (西班牙)"), - ES_ES_EURO("es_ES_EURO", " 西班牙文 (西班牙,Euro)"), - ES_GT("es_GT", " 西班牙文 (危地马拉)"), - ES_HN("es_HN", " 西班牙文 (洪都拉斯)"), - ES_MX("es_MX", " 西班牙文 (墨西哥)"), - ES_NI("es_NI", " 西班牙文 (尼加拉瓜)"), - ET("et", " 爱沙尼亚文"), - ES_PA("es_PA", " 西班牙文 (巴拿马)"), - ES_PE("es_PE", " 西班牙文 (秘鲁)"), - ES_PR("es_PR", " 西班牙文 (波多黎哥)"), - ES_PY("es_PY", " 西班牙文 (巴拉圭)"), - ES_SV("es_SV", " 西班牙文 (萨尔瓦多)"), - ES_UY("es_UY", " 西班牙文 (乌拉圭)"), - ES_VE("es_VE", " 西班牙文 (委内瑞拉)"), - ET_EE("et_EE", " 爱沙尼亚文 (爱沙尼亚)"), - FI("fi", " 芬兰文"), - FI_FI("fi_FI", " 芬兰文 (芬兰)"), - FI_FI_EURO("fi_FI_EURO", " 芬兰文 (芬兰,Euro)"), - FR("fr", " 法文"), - FR_BE("fr_BE", " 法文 (比利时)"), - FR_BE_EURO("fr_BE_EURO", " 法文 (比利时,Euro)"), - FR_CA("fr_CA", " 法文 (加拿大)"), - FR_CH("fr_CH", " 法文 (瑞士)"), - FR_FR("fr_FR", " 法文 (法国)"), - FR_FR_EURO("fr_FR_EURO", " 法文 (法国,Euro)"), - FR_LU("fr_LU", " 法文 (卢森堡)"), - FR_LU_EURO("fr_LU_EURO", " 法文 (卢森堡,Euro)"), - HR("hr", " 克罗地亚文"), - HR_HR("hr_HR", " 克罗地亚文 (克罗地亚)"), - HU("hu", " 匈牙利文"), - HU_HU("hu_HU", " 匈牙利文 (匈牙利)"), - IS("is", " 冰岛文"), - IS_IS("is_IS", " 冰岛文 (冰岛)"), - IT("it", " 意大利文"), - IT_CH("it_CH", " 意大利文 (瑞士)"), - IT_IT("it_IT", " 意大利文 (意大利)"), - IT_IT_EURO("it_IT_EURO", " 意大利文 (意大利,Euro)"), - IW("iw", " 希伯来文"), - IW_IL("iw_IL", " 希伯来文 (以色列)"), - JA("ja", " 日文"), - JA_JP("ja_JP", " 日文 (日本)"), - KO("ko", " 朝鲜文"), - KO_KR("ko_KR", " 朝鲜文 (南朝鲜)"), - LT("lt", " 立陶宛文"), - LT_LT("lt_LT", " 立陶宛文 (立陶宛)"), - LV("lv", " 拉托维亚文(列托)"), - LV_LV("lv_LV", " 拉托维亚文(列托) (拉脱维亚)"), - MK("mk", " 马其顿文"), - MK_MK("mk_MK", " 马其顿文 (马其顿王国)"), - NL("nl", " 荷兰文"), - NL_BE("nl_BE", " 荷兰文 (比利时)"), - NL_BE_EURO("nl_BE_EURO", " 荷兰文 (比利时,Euro)"), - NL_NL("nl_NL", " 荷兰文 (荷兰)"), - NL_NL_EURO("nl_NL_EURO", " 荷兰文 (荷兰,Euro)"), - NO("no", " 挪威文"), - NO_NO("no_NO", " 挪威文 (挪威)"), - NO_NO_NY("no_NO_NY", " 挪威文 (挪威,Nynorsk)"), - PL("pl", " 波兰文"), - PL_PL("pl_PL", " 波兰文 (波兰)"), - PT("pt", " 葡萄牙文"), - PT_BR("pt_BR", " 葡萄牙文 (巴西)"), - PT_PT("pt_PT", " 葡萄牙文 (葡萄牙)"), - PT_PT_EURO("pt_PT_EURO", " 葡萄牙文 (葡萄牙,Euro)"), - RO("ro", " 罗马尼亚文"), - RO_RO("ro_RO", " 罗马尼亚文 (罗马尼亚)"), - RU("ru", " 俄文"), - RU_RU("ru_RU", " 俄文 (俄罗斯)"), - SH("sh", " 塞波尼斯-克罗地亚文"), - SH_YU("sh_YU", " 塞波尼斯-克罗地亚文 (南斯拉夫)"), - SK("sk", " 斯洛伐克文"), - SK_SK("sk_SK", " 斯洛伐克文 (斯洛伐克)"), - SL("sl", " 斯洛文尼亚文"), - SL_SI("sl_SI", " 斯洛文尼亚文 (斯洛文尼亚)"), - SQ("sq", " 阿尔巴尼亚文"), - SQ_AL("sq_AL", " 阿尔巴尼亚文 (阿尔巴尼亚)"), - SR("sr", " 塞尔维亚文"), - SR_YU("sr_YU", " 塞尔维亚文 (南斯拉夫)"), - SV("sv", " 瑞典文"), - SV_SE("sv_SE", " 瑞典文 (瑞典)"), - TH("th", " 泰文"), - TH_TH("th_TH", " 泰文 (泰国)"), - TR("tr", " 土耳其文"), - TR_TR("tr_TR", " 土耳其文 (土耳其)"), - UK("uk", " 乌克兰文"), - UK_UA("uk_UA", " 乌克兰文 (乌克兰)"), - ZH("zh", " 中文"), - ZH_CN("zh_CN", " 中文 (中国)"), - ZH_HK("zh_HK", " 中文 (香港)"), - ZH_TW("zh_TW", " 中文 (台湾)"); - - /** - * 语言类型 - */ - private final String lang; + /** 自动匹配 */ + AUTO_DETECT("auto", "自动匹配"), + EN("en", " 英文"), + EN_US("en_US", " 英文 (美国)"), + AR("ar", " 阿拉伯文"), + AR_AE("ar_AE", " 阿拉伯文 (阿拉伯联合酋长国)"), + AR_BH("ar_BH", " 阿拉伯文 (巴林)"), + AR_DZ("ar_DZ", " 阿拉伯文 (阿尔及利亚)"), + AR_EG("ar_EG", " 阿拉伯文 (埃及)"), + AR_IQ("ar_IQ", " 阿拉伯文 (伊拉克)"), + AR_JO("ar_JO", " 阿拉伯文 (约旦)"), + AR_KW("ar_KW", " 阿拉伯文 (科威特)"), + AR_LB("ar_LB", " 阿拉伯文 (黎巴嫩)"), + AR_LY("ar_LY", " 阿拉伯文 (利比亚)"), + AR_MA("ar_MA", " 阿拉伯文 (摩洛哥)"), + AR_OM("ar_OM", " 阿拉伯文 (阿曼)"), + AR_QA("ar_QA", " 阿拉伯文 (卡塔尔)"), + AR_SA("ar_SA", " 阿拉伯文 (沙特阿拉伯)"), + AR_SD("ar_SD", " 阿拉伯文 (苏丹)"), + AR_SY("ar_SY", " 阿拉伯文 (叙利亚)"), + AR_TN("ar_TN", " 阿拉伯文 (突尼斯)"), + AR_YE("ar_YE", " 阿拉伯文 (也门)"), + BE("be", " 白俄罗斯文"), + BE_BY("be_BY", " 白俄罗斯文 (白俄罗斯)"), + BG("bg", " 保加利亚文"), + BG_BG("bg_BG", " 保加利亚文 (保加利亚)"), + CA("ca", " 加泰罗尼亚文"), + CA_ES("ca_ES", " 加泰罗尼亚文 (西班牙)"), + CA_ES_EURO("ca_ES_EURO", " 加泰罗尼亚文 (西班牙,Euro)"), + CS("cs", " 捷克文"), + CS_CZ("cs_CZ", " 捷克文 (捷克共和国)"), + DA("da", " 丹麦文"), + DA_DK("da_DK", " 丹麦文 (丹麦)"), + DE("de", " 德文"), + DE_AT("de_AT", " 德文 (奥地利)"), + DE_AT_EURO("de_AT_EURO", " 德文 (奥地利,Euro)"), + DE_CH("de_CH", " 德文 (瑞士)"), + DE_DE("de_DE", " 德文 (德国)"), + DE_DE_EURO("de_DE_EURO", " 德文 (德国,Euro)"), + DE_LU("de_LU", " 德文 (卢森堡)"), + DE_LU_EURO("de_LU_EURO", " 德文 (卢森堡,Euro)"), + EL("el", " 希腊文"), + EL_GR("el_GR", " 希腊文 (希腊)"), + EN_AU("en_AU", " 英文 (澳大利亚)"), + EN_CA("en_CA", " 英文 (加拿大)"), + EN_GB("en_GB", " 英文 (英国)"), + EN_IE("en_IE", " 英文 (爱尔兰)"), + EN_IE_EURO("en_IE_EURO", " 英文 (爱尔兰,Euro)"), + EN_NZ("en_NZ", " 英文 (新西兰)"), + EN_ZA("en_ZA", " 英文 (南非)"), + ES("es", " 西班牙文"), + ES_BO("es_BO", " 西班牙文 (玻利维亚)"), + ES_AR("es_AR", " 西班牙文 (阿根廷)"), + ES_CL("es_CL", " 西班牙文 (智利)"), + ES_CO("es_CO", " 西班牙文 (哥伦比亚)"), + ES_CR("es_CR", " 西班牙文 (哥斯达黎加)"), + ES_DO("es_DO", " 西班牙文 (多米尼加共和国)"), + ES_EC("es_EC", " 西班牙文 (厄瓜多尔)"), + ES_ES("es_ES", " 西班牙文 (西班牙)"), + ES_ES_EURO("es_ES_EURO", " 西班牙文 (西班牙,Euro)"), + ES_GT("es_GT", " 西班牙文 (危地马拉)"), + ES_HN("es_HN", " 西班牙文 (洪都拉斯)"), + ES_MX("es_MX", " 西班牙文 (墨西哥)"), + ES_NI("es_NI", " 西班牙文 (尼加拉瓜)"), + ET("et", " 爱沙尼亚文"), + ES_PA("es_PA", " 西班牙文 (巴拿马)"), + ES_PE("es_PE", " 西班牙文 (秘鲁)"), + ES_PR("es_PR", " 西班牙文 (波多黎哥)"), + ES_PY("es_PY", " 西班牙文 (巴拉圭)"), + ES_SV("es_SV", " 西班牙文 (萨尔瓦多)"), + ES_UY("es_UY", " 西班牙文 (乌拉圭)"), + ES_VE("es_VE", " 西班牙文 (委内瑞拉)"), + ET_EE("et_EE", " 爱沙尼亚文 (爱沙尼亚)"), + FI("fi", " 芬兰文"), + FI_FI("fi_FI", " 芬兰文 (芬兰)"), + FI_FI_EURO("fi_FI_EURO", " 芬兰文 (芬兰,Euro)"), + FR("fr", " 法文"), + FR_BE("fr_BE", " 法文 (比利时)"), + FR_BE_EURO("fr_BE_EURO", " 法文 (比利时,Euro)"), + FR_CA("fr_CA", " 法文 (加拿大)"), + FR_CH("fr_CH", " 法文 (瑞士)"), + FR_FR("fr_FR", " 法文 (法国)"), + FR_FR_EURO("fr_FR_EURO", " 法文 (法国,Euro)"), + FR_LU("fr_LU", " 法文 (卢森堡)"), + FR_LU_EURO("fr_LU_EURO", " 法文 (卢森堡,Euro)"), + HR("hr", " 克罗地亚文"), + HR_HR("hr_HR", " 克罗地亚文 (克罗地亚)"), + HU("hu", " 匈牙利文"), + HU_HU("hu_HU", " 匈牙利文 (匈牙利)"), + IS("is", " 冰岛文"), + IS_IS("is_IS", " 冰岛文 (冰岛)"), + IT("it", " 意大利文"), + IT_CH("it_CH", " 意大利文 (瑞士)"), + IT_IT("it_IT", " 意大利文 (意大利)"), + IT_IT_EURO("it_IT_EURO", " 意大利文 (意大利,Euro)"), + IW("iw", " 希伯来文"), + IW_IL("iw_IL", " 希伯来文 (以色列)"), + JA("ja", " 日文"), + JA_JP("ja_JP", " 日文 (日本)"), + KO("ko", " 朝鲜文"), + KO_KR("ko_KR", " 朝鲜文 (南朝鲜)"), + LT("lt", " 立陶宛文"), + LT_LT("lt_LT", " 立陶宛文 (立陶宛)"), + LV("lv", " 拉托维亚文(列托)"), + LV_LV("lv_LV", " 拉托维亚文(列托) (拉脱维亚)"), + MK("mk", " 马其顿文"), + MK_MK("mk_MK", " 马其顿文 (马其顿王国)"), + NL("nl", " 荷兰文"), + NL_BE("nl_BE", " 荷兰文 (比利时)"), + NL_BE_EURO("nl_BE_EURO", " 荷兰文 (比利时,Euro)"), + NL_NL("nl_NL", " 荷兰文 (荷兰)"), + NL_NL_EURO("nl_NL_EURO", " 荷兰文 (荷兰,Euro)"), + NO("no", " 挪威文"), + NO_NO("no_NO", " 挪威文 (挪威)"), + NO_NO_NY("no_NO_NY", " 挪威文 (挪威,Nynorsk)"), + PL("pl", " 波兰文"), + PL_PL("pl_PL", " 波兰文 (波兰)"), + PT("pt", " 葡萄牙文"), + PT_BR("pt_BR", " 葡萄牙文 (巴西)"), + PT_PT("pt_PT", " 葡萄牙文 (葡萄牙)"), + PT_PT_EURO("pt_PT_EURO", " 葡萄牙文 (葡萄牙,Euro)"), + RO("ro", " 罗马尼亚文"), + RO_RO("ro_RO", " 罗马尼亚文 (罗马尼亚)"), + RU("ru", " 俄文"), + RU_RU("ru_RU", " 俄文 (俄罗斯)"), + SH("sh", " 塞波尼斯-克罗地亚文"), + SH_YU("sh_YU", " 塞波尼斯-克罗地亚文 (南斯拉夫)"), + SK("sk", " 斯洛伐克文"), + SK_SK("sk_SK", " 斯洛伐克文 (斯洛伐克)"), + SL("sl", " 斯洛文尼亚文"), + SL_SI("sl_SI", " 斯洛文尼亚文 (斯洛文尼亚)"), + SQ("sq", " 阿尔巴尼亚文"), + SQ_AL("sq_AL", " 阿尔巴尼亚文 (阿尔巴尼亚)"), + SR("sr", " 塞尔维亚文"), + SR_YU("sr_YU", " 塞尔维亚文 (南斯拉夫)"), + SV("sv", " 瑞典文"), + SV_SE("sv_SE", " 瑞典文 (瑞典)"), + TH("th", " 泰文"), + TH_TH("th_TH", " 泰文 (泰国)"), + TR("tr", " 土耳其文"), + TR_TR("tr_TR", " 土耳其文 (土耳其)"), + UK("uk", " 乌克兰文"), + UK_UA("uk_UA", " 乌克兰文 (乌克兰)"), + ZH("zh", " 中文"), + ZH_CN("zh_CN", " 中文 (中国)"), + ZH_HK("zh_HK", " 中文 (香港)"), + ZH_TW("zh_TW", " 中文 (台湾)"); - /** - * 描述 - */ - private final String desc; + /** 语言类型 */ + private final String lang; - LangEnum(String lang, String desc) { - this.lang = lang; - this.desc = desc; - } + /** 描述 */ + private final String desc; - /** - * 显示语言信息 - * - * @return 字符串结果 - */ - public String lang() { - return this.lang; - } + LangEnum(String lang, String desc) { + this.lang = lang; + this.desc = desc; + } - /** - * 显示语言信息 - * - * @return 字符串结果 - */ - public String desc() { - return this.desc; - } + /** + * 显示语言信息 + * + * @return 字符串结果 + */ + public String lang() { + return this.lang; + } + /** + * 显示语言信息 + * + * @return 字符串结果 + */ + public String desc() { + return this.desc; + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/enums/ProxyTypeEnum.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/enums/ProxyTypeEnum.java index 7189e62..c8ec9e5 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/enums/ProxyTypeEnum.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/enums/ProxyTypeEnum.java @@ -1,23 +1,14 @@ package io.fluent.builtin.constant.enums; -/** - *

代理类型枚举

- */ +/** 代理类型枚举 */ public enum ProxyTypeEnum { - /** - * 不执行任何代理 - */ - NONE, + /** 不执行任何代理 */ + NONE, - /** - * jdk 动态代理 - */ - DYNAMIC, - - /** - * cglib 动态代理 - */ - CGLIB; + /** jdk 动态代理 */ + DYNAMIC, + /** cglib 动态代理 */ + CGLIB; } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/file/FileOptionConst.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/file/FileOptionConst.java index b4f8398..de668a4 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/file/FileOptionConst.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/file/FileOptionConst.java @@ -1,37 +1,22 @@ package io.fluent.builtin.constant.file; -/** - * 文件操作常量 - * 可以结合 {@link java.io.RandomAccessFile} 随机访问文件使用 - */ +/** 文件操作常量 可以结合 {@link java.io.RandomAccessFile} 随机访问文件使用 */ public final class FileOptionConst { - private FileOptionConst(){} + private FileOptionConst() {} - /** - * 读取权限 - */ - public static final String READ = "r"; + /** 读取权限 */ + public static final String READ = "r"; - /** - * 读取写入权限 - * 备注:这时会默认使用 buffer,不会立刻刷新到文件。 - * 系统直接挂了,或者 debug 会比较麻烦。 - * 可以参考 - */ - public static final String READ_WRITE = "rw"; + /** 读取写入权限 备注:这时会默认使用 buffer,不会立刻刷新到文件。 系统直接挂了,或者 debug 会比较麻烦。 可以参考 */ + public static final String READ_WRITE = "rw"; - /** - * 打开以便读取和写入。相对于 "rw","rws" 还要求对“文件的内容”或“元数据”的每个更新都同步写入到基础存储设备。 - * 适用场景:安全性要求较高,文件内容不大,debug 模式。 - * 元数据:又称中介数据、中继数据,为描述数据的数据(data about data),主要是描述数据属性(property)的信息,用来支持如指示存储位置、历史数据、资源查找、文件记录等功能。 - */ - public static final String READ_WRITE_SYNCHRONOUSLY = "rws"; - - /** - * 打开以便读取和写入,相对于 "rw","rwd" 还要求对“文件的内容”的每个更新都同步写入到基础存储设备 - * 备注:介于 rw-rws 中间。个人暂时比较倾向于这种方式。 - */ - public static final String READ_WRITE_DATA = "rwd"; + /** + * 打开以便读取和写入。相对于 "rw","rws" 还要求对“文件的内容”或“元数据”的每个更新都同步写入到基础存储设备。 适用场景:安全性要求较高,文件内容不大,debug 模式。 + * 元数据:又称中介数据、中继数据,为描述数据的数据(data about data),主要是描述数据属性(property)的信息,用来支持如指示存储位置、历史数据、资源查找、文件记录等功能。 + */ + public static final String READ_WRITE_SYNCHRONOUSLY = "rws"; + /** 打开以便读取和写入,相对于 "rw","rwd" 还要求对“文件的内容”的每个更新都同步写入到基础存储设备 备注:介于 rw-rws 中间。个人暂时比较倾向于这种方式。 */ + public static final String READ_WRITE_DATA = "rwd"; } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/file/FileProtocolConst.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/file/FileProtocolConst.java index 1d72b23..b886d2d 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/file/FileProtocolConst.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/file/FileProtocolConst.java @@ -1,29 +1,26 @@ - package io.fluent.builtin.constant.file; -/** - * 文件协议常量 - - */ +/** 文件协议常量 */ public final class FileProtocolConst { - /** - * 私有化构造器 - * - * @since 0.1.54 - */ - private FileProtocolConst(){} - - /** - * 文件信息 - * @since 0.1.54 - */ - public static final String FILE = "file"; + /** + * 私有化构造器 + * + * @since 0.1.54 + */ + private FileProtocolConst() {} - /** - * jar 文件信息 - * @since 0.1.55 - */ - public static final String JAR = "jar"; + /** + * 文件信息 + * + * @since 0.1.54 + */ + public static final String FILE = "file"; + /** + * jar 文件信息 + * + * @since 0.1.55 + */ + public static final String JAR = "jar"; } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/file/FileTypeConst.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/file/FileTypeConst.java index febc4fe..1cb7a60 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/file/FileTypeConst.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/file/FileTypeConst.java @@ -1,50 +1,34 @@ - package io.fluent.builtin.constant.file; -/** - * 文件类型常量 - */ +/** 文件类型常量 */ public final class FileTypeConst { - /** - * file type const - */ - private FileTypeConst(){} - - /** - * 文件类型过滤 - */ - public static class Glob { - private Glob(){} - - /** - * 所有文件类型 - */ - public static final String ALL = "*.*"; - } - - /** - * 压缩文件 - */ - public static class Compress { - private Compress(){} + /** file type const */ + private FileTypeConst() {} - public static final String ZIP = ".zip"; - public static final String RAR = ".rar"; - public static final String JAR = ".jar"; - } + /** 文件类型过滤 */ + public static class Glob { + private Glob() {} - /** - * 图片 - */ - public static class Image { - private Image(){} + /** 所有文件类型 */ + public static final String ALL = "*.*"; + } - public static final String PNG = ".png"; - public static final String JPG = ".jpg"; - public static final String JPEG = ".jpeg"; - public static final String GIF = ".gif"; - } + /** 压缩文件 */ + public static class Compress { + private Compress() {} + public static final String ZIP = ".zip"; + public static final String RAR = ".rar"; + public static final String JAR = ".jar"; + } + /** 图片 */ + public static class Image { + private Image() {} + public static final String PNG = ".png"; + public static final String JPG = ".jpg"; + public static final String JPEG = ".jpeg"; + public static final String GIF = ".gif"; + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/file/ImageTypeConstant.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/file/ImageTypeConstant.java index fd1baa4..fcbc9af 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/file/ImageTypeConstant.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/constant/file/ImageTypeConstant.java @@ -2,17 +2,11 @@ public interface ImageTypeConstant { - /** - * gif类型 - */ - String GIF = "gif"; - /** - * png类型 - */ - String PNG = "png"; + /** gif类型 */ + String GIF = "gif"; + /** png类型 */ + String PNG = "png"; - /** - * jpg - */ - String JPG = "jpg"; + /** jpg */ + String JPG = "jpg"; } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/meta/GenericsUtils.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/meta/GenericsUtils.java index e5bd799..cbb2b2c 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/meta/GenericsUtils.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/meta/GenericsUtils.java @@ -1,8 +1,6 @@ package io.fluent.builtin.meta; - import cn.hutool.core.lang.ParameterizedTypeImpl; - import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.ParameterizedType; @@ -10,209 +8,193 @@ import java.util.ArrayList; import java.util.List; -/** - * 泛型工具类 - */ +/** 泛型工具类 */ public class GenericsUtils { - /** - * 根据传入class查询它实现第一个**接口**的泛型里的第一个入参的类型 - * - * @param clazz - * @return - */ - public static Class getGenericType(Class clazz) { - - Type[] types = clazz.getGenericInterfaces(); - if (types.length == 0) { - return getSuperClassGenricType(clazz); - } - if (types[0] instanceof ParameterizedType) { - Type[] types2 = ((ParameterizedTypeImpl) types[0]).getActualTypeArguments(); - if (types2.length == 0) { - return getSuperClassGenricType(clazz); - } - - Class entityClz = (Class) types2[0]; - return entityClz; - } + /** + * 根据传入class查询它实现第一个**接口**的泛型里的第一个入参的类型 + * + * @param clazz + * @return + */ + public static Class getGenericType(Class clazz) { + + Type[] types = clazz.getGenericInterfaces(); + if (types.length == 0) { + return getSuperClassGenricType(clazz); + } + if (types[0] instanceof ParameterizedType) { + Type[] types2 = ((ParameterizedTypeImpl) types[0]).getActualTypeArguments(); + if (types2.length == 0) { return getSuperClassGenricType(clazz); + } + Class entityClz = (Class) types2[0]; + return entityClz; } + return getSuperClassGenricType(clazz); + } - /** - * 通过反射,获得指定类的父类的泛型参数的实际类型. 如DaoSupport - * - * @param clazz clazz 需要反射的类,该类必须继承范型父类 - * @param index 泛型参数所在索引,从0开始. - * @return 范型参数的实际类型, 如果没有实现ParameterizedType接口,即不支持泛型,所以直接返回 - * Object.class - */ - @SuppressWarnings("unchecked") - public static Class getSuperClassGenricType(Class clazz, int index) { - - Type genType = clazz.getGenericSuperclass(); - - - if (!(genType instanceof ParameterizedType)) { - - return Object.class; - } - - - Type[] params = ((ParameterizedType) genType).getActualTypeArguments(); - if (index >= params.length || index < 0) { + /** + * 通过反射,获得指定类的父类的泛型参数的实际类型. 如DaoSupport + * + * @param clazz clazz 需要反射的类,该类必须继承范型父类 + * @param index 泛型参数所在索引,从0开始. + * @return 范型参数的实际类型, 如果没有实现ParameterizedType接口,即不支持泛型,所以直接返回 Object.class + */ + @SuppressWarnings("unchecked") + public static Class getSuperClassGenricType(Class clazz, int index) { - throw new RuntimeException("你输入的索引" - + (index < 0 ? "不能小于0" : "超出了参数的总数")); - } - if (!(params[index] instanceof Class)) { + Type genType = clazz.getGenericSuperclass(); - return Object.class; - } - return (Class) params[index]; - } + if (!(genType instanceof ParameterizedType)) { - /** - * 通过反射,获得指定类的父类的第一个泛型参数的实际类型. 如DaoSupport - * - * @param clazz clazz 需要反射的类,该类必须继承泛型父类 - * @return 泛型参数的实际类型, 如果没有实现ParameterizedType接口,即不支持泛型,所以直接返回 - * Object.class - */ - @SuppressWarnings("unchecked") - public static Class getSuperClassGenricType(Class clazz) { - - return getSuperClassGenricType(clazz, 0); + return Object.class; } - /** - * 通过反射,获得方法返回值泛型参数的实际类型. 如: public Map getNames(){} - * - * @param Method method 方法 - * @param int index 泛型参数所在索引,从0开始. - * @return 泛型参数的实际类型, 如果没有实现ParameterizedType接口,即不支持泛型,所以直接返回 - * Object.class - */ - @SuppressWarnings("unchecked") - public static Class getMethodGenericReturnType(Method method, int index) { - - Type returnType = method.getGenericReturnType(); - - if (returnType instanceof ParameterizedType) { - - ParameterizedType type = (ParameterizedType) returnType; - Type[] typeArguments = type.getActualTypeArguments(); - - if (index >= typeArguments.length || index < 0) { + Type[] params = ((ParameterizedType) genType).getActualTypeArguments(); + if (index >= params.length || index < 0) { - throw new RuntimeException("你输入的索引" - + (index < 0 ? "不能小于0" : "超出了参数的总数")); - } - return (Class) typeArguments[index]; - } - return Object.class; + throw new RuntimeException("你输入的索引" + (index < 0 ? "不能小于0" : "超出了参数的总数")); } + if (!(params[index] instanceof Class)) { - /** - * 通过反射,获得方法返回值第一个泛型参数的实际类型. 如: public Map getNames(){} - * - * @param Method method 方法 - * @return 泛型参数的实际类型, 如果没有实现ParameterizedType接口,即不支持泛型,所以直接返回 - * Object.class - */ - @SuppressWarnings("unchecked") - public static Class getMethodGenericReturnType(Method method) { - - return getMethodGenericReturnType(method, 0); + return Object.class; } - - /** - * 通过反射,获得方法输入参数第index个输入参数的所有泛型参数的实际类型. 如: public void add(Map maps, List names){} - * - * @param Method method 方法 - * @param int index 第几个输入参数 - * @return 输入参数的泛型参数的实际类型集合, 如果没有实现ParameterizedType接口,即不支持泛型,所以直接返回空集合 - */ - @SuppressWarnings("unchecked") - public static List getMethodGenericParameterTypes(Method method, - int index) { - - List results = new ArrayList(); - Type[] genericParameterTypes = method.getGenericParameterTypes(); - - if (index >= genericParameterTypes.length || index < 0) { - - throw new RuntimeException("你输入的索引" - + (index < 0 ? "不能小于0" : "超出了参数的总数")); - } - Type genericParameterType = genericParameterTypes[index]; - - if (genericParameterType instanceof ParameterizedType) { - - ParameterizedType aType = (ParameterizedType) genericParameterType; - Type[] parameterArgTypes = aType.getActualTypeArguments(); - for (Type parameterArgType : parameterArgTypes) { - Class parameterArgClass = (Class) parameterArgType; - results.add(parameterArgClass); - } - return results; - } - return results; + return (Class) params[index]; + } + + /** + * 通过反射,获得指定类的父类的第一个泛型参数的实际类型. 如DaoSupport + * + * @param clazz clazz 需要反射的类,该类必须继承泛型父类 + * @return 泛型参数的实际类型, 如果没有实现ParameterizedType接口,即不支持泛型,所以直接返回 Object.class + */ + @SuppressWarnings("unchecked") + public static Class getSuperClassGenricType(Class clazz) { + + return getSuperClassGenricType(clazz, 0); + } + + /** + * 通过反射,获得方法返回值泛型参数的实际类型. 如: public Map getNames(){} + * + * @param Method method 方法 + * @param int index 泛型参数所在索引,从0开始. + * @return 泛型参数的实际类型, 如果没有实现ParameterizedType接口,即不支持泛型,所以直接返回 Object.class + */ + @SuppressWarnings("unchecked") + public static Class getMethodGenericReturnType(Method method, int index) { + + Type returnType = method.getGenericReturnType(); + + if (returnType instanceof ParameterizedType) { + + ParameterizedType type = (ParameterizedType) returnType; + Type[] typeArguments = type.getActualTypeArguments(); + + if (index >= typeArguments.length || index < 0) { + + throw new RuntimeException("你输入的索引" + (index < 0 ? "不能小于0" : "超出了参数的总数")); + } + return (Class) typeArguments[index]; } - - /** - * 通过反射,获得方法输入参数第一个输入参数的所有泛型参数的实际类型. 如: public void add(Map - * maps, List names){} - * - * @param Method method 方法 - * @return 输入参数的泛型参数的实际类型集合, 如果没有实现ParameterizedType接口,即不支持泛型,所以直接返回空集合 - */ - @SuppressWarnings("unchecked") - public static List getMethodGenericParameterTypes(Method method) { - - return getMethodGenericParameterTypes(method, 0); + return Object.class; + } + + /** + * 通过反射,获得方法返回值第一个泛型参数的实际类型. 如: public Map getNames(){} + * + * @param Method method 方法 + * @return 泛型参数的实际类型, 如果没有实现ParameterizedType接口,即不支持泛型,所以直接返回 Object.class + */ + @SuppressWarnings("unchecked") + public static Class getMethodGenericReturnType(Method method) { + + return getMethodGenericReturnType(method, 0); + } + + /** + * 通过反射,获得方法输入参数第index个输入参数的所有泛型参数的实际类型. 如: public void add(Map maps, List + * names){} + * + * @param Method method 方法 + * @param int index 第几个输入参数 + * @return 输入参数的泛型参数的实际类型集合, 如果没有实现ParameterizedType接口,即不支持泛型,所以直接返回空集合 + */ + @SuppressWarnings("unchecked") + public static List getMethodGenericParameterTypes(Method method, int index) { + + List results = new ArrayList(); + Type[] genericParameterTypes = method.getGenericParameterTypes(); + + if (index >= genericParameterTypes.length || index < 0) { + + throw new RuntimeException("你输入的索引" + (index < 0 ? "不能小于0" : "超出了参数的总数")); } + Type genericParameterType = genericParameterTypes[index]; - /** - * 通过反射,获得Field泛型参数的实际类型. 如: public Map names; - * - * @param Field field 字段 - * @param int index 泛型参数所在索引,从0开始. - * @return 泛型参数的实际类型, 如果没有实现ParameterizedType接口,即不支持泛型,所以直接返回 - * Object.class - */ - @SuppressWarnings("unchecked") - public static Class getFieldGenericType(Field field, int index) { - - Type genericFieldType = field.getGenericType(); - - if (genericFieldType instanceof ParameterizedType) { - - ParameterizedType aType = (ParameterizedType) genericFieldType; - Type[] fieldArgTypes = aType.getActualTypeArguments(); - if (index >= fieldArgTypes.length || index < 0) { - - throw new RuntimeException("你输入的索引" - + (index < 0 ? "不能小于0" : "超出了参数的总数")); - } - return (Class) fieldArgTypes[index]; - } - return Object.class; - } + if (genericParameterType instanceof ParameterizedType) { - /** - * 通过反射,获得Field泛型参数的实际类型. 如: public Map names; - * - * @param Field field 字段 - * @param int index 泛型参数所在索引,从0开始. - * @return 泛型参数的实际类型, 如果没有实现ParameterizedType接口,即不支持泛型,所以直接返回 - * Object.class - */ - @SuppressWarnings("unchecked") - public static Class getFieldGenericType(Field field) { - - return getFieldGenericType(field, 0); + ParameterizedType aType = (ParameterizedType) genericParameterType; + Type[] parameterArgTypes = aType.getActualTypeArguments(); + for (Type parameterArgType : parameterArgTypes) { + Class parameterArgClass = (Class) parameterArgType; + results.add(parameterArgClass); + } + return results; + } + return results; + } + + /** + * 通过反射,获得方法输入参数第一个输入参数的所有泛型参数的实际类型. 如: public void add(Map maps, List + * names){} + * + * @param Method method 方法 + * @return 输入参数的泛型参数的实际类型集合, 如果没有实现ParameterizedType接口,即不支持泛型,所以直接返回空集合 + */ + @SuppressWarnings("unchecked") + public static List getMethodGenericParameterTypes(Method method) { + + return getMethodGenericParameterTypes(method, 0); + } + + /** + * 通过反射,获得Field泛型参数的实际类型. 如: public Map names; + * + * @param Field field 字段 + * @param int index 泛型参数所在索引,从0开始. + * @return 泛型参数的实际类型, 如果没有实现ParameterizedType接口,即不支持泛型,所以直接返回 Object.class + */ + @SuppressWarnings("unchecked") + public static Class getFieldGenericType(Field field, int index) { + + Type genericFieldType = field.getGenericType(); + + if (genericFieldType instanceof ParameterizedType) { + + ParameterizedType aType = (ParameterizedType) genericFieldType; + Type[] fieldArgTypes = aType.getActualTypeArguments(); + if (index >= fieldArgTypes.length || index < 0) { + + throw new RuntimeException("你输入的索引" + (index < 0 ? "不能小于0" : "超出了参数的总数")); + } + return (Class) fieldArgTypes[index]; } -} \ No newline at end of file + return Object.class; + } + + /** + * 通过反射,获得Field泛型参数的实际类型. 如: public Map names; + * + * @param Field field 字段 + * @param int index 泛型参数所在索引,从0开始. + * @return 泛型参数的实际类型, 如果没有实现ParameterizedType接口,即不支持泛型,所以直接返回 Object.class + */ + @SuppressWarnings("unchecked") + public static Class getFieldGenericType(Field field) { + + return getFieldGenericType(field, 0); + } +} diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/meta/ReflectionUtils.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/meta/ReflectionUtils.java index d4ad71f..0aa2bcd 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/meta/ReflectionUtils.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/meta/ReflectionUtils.java @@ -4,19 +4,17 @@ import cn.hutool.core.util.ReflectUtil; import cn.hutool.core.util.StrUtil; import com.google.common.collect.Lists; -import lombok.extern.slf4j.Slf4j; - import java.lang.annotation.Annotation; import java.lang.reflect.*; import java.util.Arrays; import java.util.Collections; import java.util.List; - +import lombok.extern.slf4j.Slf4j; /** * 反射工具类. - *

- * 提供调用getter/setter方法, 访问私有变量, 调用私有方法, 获取泛型类型Class, 被AOP过的真实类等工具函数. + * + *

提供调用getter/setter方法, 访问私有变量, 调用私有方法, 获取泛型类型Class, 被AOP过的真实类等工具函数. */ @SuppressWarnings("unchecked") @Slf4j @@ -25,14 +23,13 @@ public class ReflectionUtils extends ReflectUtil { private static final String GETTER_PREFIX = "get"; private static final String CGLIB_CLASS_SEPARATOR = "$$"; - private ReflectionUtils() { - } + private ReflectionUtils() {} /** * 反射调用方法 * - * @param obj 实例 - * @param m 方法 + * @param obj 实例 + * @param m 方法 * @param args 参数 * @return */ @@ -45,34 +42,28 @@ public static Object invokeMethod(Object obj, Method m, Object... args) { return null; } - /** - * 调用Getter方法. - */ + /** 调用Getter方法. */ public static Object invokeGetter(Object obj, String propertyName) { String getterMethodName = GETTER_PREFIX + StrUtil.upperFirst(propertyName); if (getAccessibleMethod(obj, getterMethodName) == null) { getterMethodName = GETTER_PREFIX + propertyName; } - return invokeMethod(obj, getterMethodName, new Class[]{}, new Object[]{}); + return invokeMethod(obj, getterMethodName, new Class[] {}, new Object[] {}); } - - /** - * 调用Setter方法, 仅匹配方法名。 - */ + /** 调用Setter方法, 仅匹配方法名。 */ public static void invokeSetter(Object obj, String propertyName, Object value) { String setterMethodName = SETTER_PREFIX + StrUtil.upperFirst(propertyName); - invokeMethodByName(obj, setterMethodName, new Object[]{value}); + invokeMethodByName(obj, setterMethodName, new Object[] {value}); } - /** - * 直接读取对象属性值, 无视private/protected修饰符, 不经过getter函数. - */ + /** 直接读取对象属性值, 无视private/protected修饰符, 不经过getter函数. */ public static Object getFieldValue(final Object obj, final String fieldName) { Field field = getAccessibleField(obj, fieldName); if (field == null) { - throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + obj + "]"); + throw new IllegalArgumentException( + "Could not find field [" + fieldName + "] on target [" + obj + "]"); } Object result = null; @@ -88,7 +79,7 @@ public static Object getFieldValue(final Object obj, final String fieldName) { * 获取字段 * * @param object 实例 - * @param field 字段实例 + * @param field 字段实例 * @return */ public static Object getFieldValue(final Object object, Field field) { @@ -101,14 +92,13 @@ public static Object getFieldValue(final Object object, Field field) { } } - /** - * 直接设置对象属性值, 无视private/protected修饰符, 不经过setter函数. - */ + /** 直接设置对象属性值, 无视private/protected修饰符, 不经过setter函数. */ public static void setFieldValue(final Object obj, final String fieldName, final Object value) { Field field = getAccessibleField(obj, fieldName); if (field == null) { - throw new IllegalArgumentException("Could not find field [" + fieldName + "] on target [" + obj + "]"); + throw new IllegalArgumentException( + "Could not find field [" + fieldName + "] on target [" + obj + "]"); } try { @@ -118,17 +108,19 @@ public static void setFieldValue(final Object obj, final String fieldName, final } } - /** - * 直接调用对象方法, 无视private/protected修饰符. - * 用于一次性调用的情况,否则应使用getAccessibleMethod()函数获得Method后反复调用. + * 直接调用对象方法, 无视private/protected修饰符. 用于一次性调用的情况,否则应使用getAccessibleMethod()函数获得Method后反复调用. * 同时匹配方法名+参数类型, */ - public static Object invokeMethod(final Object obj, final String methodName, final Class[] parameterTypes, - final Object[] args) { + public static Object invokeMethod( + final Object obj, + final String methodName, + final Class[] parameterTypes, + final Object[] args) { Method method = getAccessibleMethod(obj, methodName, parameterTypes); if (method == null) { - throw new IllegalArgumentException("Could not find method [" + methodName + "] on target [" + obj + "]"); + throw new IllegalArgumentException( + "Could not find method [" + methodName + "] on target [" + obj + "]"); } try { @@ -139,14 +131,15 @@ public static Object invokeMethod(final Object obj, final String methodName, fin } /** - * 直接调用对象方法, 无视private/protected修饰符, - * 用于一次性调用的情况,否则应使用getAccessibleMethodByName()函数获得Method后反复调用. + * 直接调用对象方法, 无视private/protected修饰符, 用于一次性调用的情况,否则应使用getAccessibleMethodByName()函数获得Method后反复调用. * 只匹配函数名,如果有多个同名函数调用第一个。 */ - public static Object invokeMethodByName(final Object obj, final String methodName, final Object[] args) { + public static Object invokeMethodByName( + final Object obj, final String methodName, final Object[] args) { Method method = getAccessibleMethodByName(obj, methodName); if (method == null) { - throw new IllegalArgumentException("Could not find method [" + methodName + "] on target [" + obj + "]"); + throw new IllegalArgumentException( + "Could not find method [" + methodName + "] on target [" + obj + "]"); } try { @@ -160,11 +153,13 @@ public static Object invokeMethodByName(final Object obj, final String methodNam /** * 循环向上转型, 获取对象的DeclaredField, 并强制设置为可访问. - *

- * 如向上转型到Object仍无法找到, 返回null. + * + *

如向上转型到Object仍无法找到, 返回null. */ public static Field getAccessibleField(final Object obj, final String fieldName) { - for (Class superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) { + for (Class superClass = obj.getClass(); + superClass != Object.class; + superClass = superClass.getSuperclass()) { try { Field field = superClass.getDeclaredField(fieldName); makeAccessible(field); @@ -178,7 +173,9 @@ public static Field getAccessibleField(final Object obj, final String fieldName) public static List getAccessibleFields(Class clazz) { List fields = Lists.newArrayList(); - for (Class superClass = clazz; superClass != Object.class; superClass = superClass.getSuperclass()) { + for (Class superClass = clazz; + superClass != Object.class; + superClass = superClass.getSuperclass()) { Collections.addAll(fields, superClass.getDeclaredFields()); } @@ -193,12 +190,14 @@ public static List getAccessibleFields(Class clazz) { * @return */ public static String getAccessibleFieldTypeName(final Object obj, final String fieldName) { - for (Class superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) { + for (Class superClass = obj.getClass(); + superClass != Object.class; + superClass = superClass.getSuperclass()) { try { Field field = superClass.getDeclaredField(fieldName); makeAccessible(field); return field.getType().getSimpleName(); - } catch (NoSuchFieldException e) {// NOSONAR + } catch (NoSuchFieldException e) { // NOSONAR log.debug("{} is not found", fieldName); } } @@ -206,12 +205,14 @@ public static String getAccessibleFieldTypeName(final Object obj, final String f } public static Pair getFieldTypeAndValue(final Object obj, final String fieldName) { - for (Class superClass = obj.getClass(); superClass != Object.class; superClass = superClass.getSuperclass()) { + for (Class superClass = obj.getClass(); + superClass != Object.class; + superClass = superClass.getSuperclass()) { try { Field field = superClass.getDeclaredField(fieldName); makeAccessible(field); return Pair.of(field.getType().getSimpleName(), field.get(obj)); - } catch (NoSuchFieldException e) {// NOSONAR + } catch (NoSuchFieldException e) { // NOSONAR log.debug("{} is not found", fieldName); } catch (IllegalAccessException e) { log.debug("{} is not accessible", fieldName); @@ -221,16 +222,16 @@ public static Pair getFieldTypeAndValue(final Object obj, final String fieldName } /** - * 循环向上转型, 获取对象的DeclaredMethod,并强制设置为可访问. - * 如向上转型到Object仍无法找到, 返回null. - * 匹配函数名+参数类型。 - *

- * 用于方法需要被多次调用的情况. 先使用本函数先取得Method,然后调用Method.invoke(Object obj, Object... args) + * 循环向上转型, 获取对象的DeclaredMethod,并强制设置为可访问. 如向上转型到Object仍无法找到, 返回null. 匹配函数名+参数类型。 + * + *

用于方法需要被多次调用的情况. 先使用本函数先取得Method,然后调用Method.invoke(Object obj, Object... args) */ - public static Method getAccessibleMethod(final Object obj, final String methodName, - final Class... parameterTypes) { + public static Method getAccessibleMethod( + final Object obj, final String methodName, final Class... parameterTypes) { - for (Class searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) { + for (Class searchType = obj.getClass(); + searchType != Object.class; + searchType = searchType.getSuperclass()) { try { Method method = searchType.getDeclaredMethod(methodName, parameterTypes); makeAccessible(method); @@ -243,15 +244,15 @@ public static Method getAccessibleMethod(final Object obj, final String methodNa } /** - * 循环向上转型, 获取对象的DeclaredMethod,并强制设置为可访问. - * 如向上转型到Object仍无法找到, 返回null. - * 只匹配函数名。 - *

- * 用于方法需要被多次调用的情况. 先使用本函数先取得Method,然后调用Method.invoke(Object obj, Object... args) + * 循环向上转型, 获取对象的DeclaredMethod,并强制设置为可访问. 如向上转型到Object仍无法找到, 返回null. 只匹配函数名。 + * + *

用于方法需要被多次调用的情况. 先使用本函数先取得Method,然后调用Method.invoke(Object obj, Object... args) */ public static Method getAccessibleMethodByName(final Object obj, final String methodName) { - for (Class searchType = obj.getClass(); searchType != Object.class; searchType = searchType.getSuperclass()) { + for (Class searchType = obj.getClass(); + searchType != Object.class; + searchType = searchType.getSuperclass()) { Method[] methods = searchType.getDeclaredMethods(); for (Method method : methods) { if (method.getName().equals(methodName)) { @@ -263,31 +264,28 @@ public static Method getAccessibleMethodByName(final Object obj, final String me return null; } - /** - * 改变private/protected的方法为public,尽量不调用实际改动的语句,避免JDK的SecurityManager抱怨。 - */ + /** 改变private/protected的方法为public,尽量不调用实际改动的语句,避免JDK的SecurityManager抱怨。 */ public static void makeAccessible(Method method) { - if ((!Modifier.isPublic(method.getModifiers()) || !Modifier.isPublic(method.getDeclaringClass().getModifiers())) - && !method.isAccessible()) { + if ((!Modifier.isPublic(method.getModifiers()) + || !Modifier.isPublic(method.getDeclaringClass().getModifiers())) + && !method.isAccessible()) { method.setAccessible(true); } } - /** - * 改变private/protected的成员变量为public,尽量不调用实际改动的语句,避免JDK的SecurityManager抱怨。 - */ + /** 改变private/protected的成员变量为public,尽量不调用实际改动的语句,避免JDK的SecurityManager抱怨。 */ public static void makeAccessible(Field field) { - if ((!Modifier.isPublic(field.getModifiers()) || !Modifier.isPublic(field.getDeclaringClass().getModifiers()) || Modifier - .isFinal(field.getModifiers())) && !field.isAccessible()) { + if ((!Modifier.isPublic(field.getModifiers()) + || !Modifier.isPublic(field.getDeclaringClass().getModifiers()) + || Modifier.isFinal(field.getModifiers())) + && !field.isAccessible()) { field.setAccessible(true); } } /** - * 通过反射, 获得Class定义中声明的泛型参数的类型, 注意泛型必须定义在父类处 - * 如无法找到, 返回Object.class. - * eg. - * public UserDao extends HibernateDao + * 通过反射, 获得Class定义中声明的泛型参数的类型, 注意泛型必须定义在父类处 如无法找到, 返回Object.class. eg. public UserDao extends + * HibernateDao * * @param clazz The class to introspect * @return the first generic declaration, or Object.class if cannot be determined @@ -296,10 +294,8 @@ public static Class getClassGenericType(final Class clazz) { return getClassGenericType(clazz, 0); } - public static boolean isParameterizedList(Field field) { - return ReflectionUtils.evalAssignableClass(field, List.class) - && hasGenericParameter(field); + return ReflectionUtils.evalAssignableClass(field, List.class) && hasGenericParameter(field); } /** @@ -351,7 +347,6 @@ public static Class getGenericParameterClass(final Object obj, String fieldName) return (Class) ((ParameterizedType) genericType).getActualTypeArguments()[0]; } - /** * 获取字段的泛型集合 * @@ -359,18 +354,16 @@ public static Class getGenericParameterClass(final Object obj, String fieldName) * @return */ public static List getGenericParameterClassList(Field field) { - if (!ReflectionUtils.hasGenericParameter(field)) - return Collections.EMPTY_LIST; + if (!ReflectionUtils.hasGenericParameter(field)) return Collections.EMPTY_LIST; Type genericType = field.getGenericType(); List clazzList = Lists.newArrayList(); - clazzList.addAll(Arrays.asList((Class[]) ((ParameterizedType) genericType).getActualTypeArguments())); + clazzList.addAll( + Arrays.asList((Class[]) ((ParameterizedType) genericType).getActualTypeArguments())); return clazzList; } - /** - * 通过反射, 获得Class定义中声明的父类的泛型参数的类型. - * 如无法找到, 返回Object.class. + * 通过反射, 获得Class定义中声明的父类的泛型参数的类型. 如无法找到, 返回Object.class. * * @param clazz clazz The class to introspect * @param index the Index of the generic declaration,start from 0. @@ -388,8 +381,13 @@ public static Class getClassGenericType(final Class clazz, final int index) { Type[] params = ((ParameterizedType) genType).getActualTypeArguments(); if (index >= params.length || index < 0) { - log.warn("Index: " + index + ", Size of " + clazz.getSimpleName() + "'s Parameterized Type: " - + params.length); + log.warn( + "Index: " + + index + + ", Size of " + + clazz.getSimpleName() + + "'s Parameterized Type: " + + params.length); return Object.class; } if (!(params[index] instanceof Class)) { @@ -408,24 +406,20 @@ public static Class getClassGenericType(final Class clazz, final int index) { */ public static Class getUserClass(Object instance) { Class clazz = instance.getClass(); - if (clazz != null - && clazz.getName().contains(CGLIB_CLASS_SEPARATOR)) { + if (clazz != null && clazz.getName().contains(CGLIB_CLASS_SEPARATOR)) { Class superClass = clazz.getSuperclass(); - if (superClass != null - && !Object.class.equals(superClass)) { + if (superClass != null && !Object.class.equals(superClass)) { return superClass; } } return clazz; - } - /** - * 将反射时的checked exception转换为unchecked com.auto.exception. - */ + /** 将反射时的checked exception转换为unchecked com.auto.exception. */ public static RuntimeException convertReflectionExceptionToUnchecked(Exception e) { - if ((e instanceof IllegalAccessException) || (e instanceof IllegalArgumentException) - || (e instanceof NoSuchMethodException)) { + if ((e instanceof IllegalAccessException) + || (e instanceof IllegalArgumentException) + || (e instanceof NoSuchMethodException)) { return new IllegalArgumentException(e); } else if (e instanceof InvocationTargetException) { return new RuntimeException(((InvocationTargetException) e).getTargetException()); @@ -488,9 +482,11 @@ public static boolean isGivenClassList(Class givenClass, Field field) { } public static T getClassLevelAnnotation(Class clazz, Class annotation) { - if (clazz.getAnnotation(annotation) == null) throw new RuntimeException( - String.format("[%s] class doesn't have [%s] annotation", - clazz.getSimpleName(), annotation.getSimpleName())); + if (clazz.getAnnotation(annotation) == null) + throw new RuntimeException( + String.format( + "[%s] class doesn't have [%s] annotation", + clazz.getSimpleName(), annotation.getSimpleName())); return (T) clazz.getAnnotation(annotation); } @@ -502,7 +498,7 @@ public static T getClassLevelAnnotation(Class clazz, String annotationName) } } throw new RuntimeException( - String.format("[%s] class doesn't have [%s] annotation", - clazz.getSimpleName(), annotationName)); + String.format( + "[%s] class doesn't have [%s] annotation", clazz.getSimpleName(), annotationName)); } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/package-info.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/package-info.java index e16e473..56752ca 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/package-info.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/package-info.java @@ -1,4 +1,2 @@ -/** - * @author Patrick - **/ -package io.fluent.builtin; \ No newline at end of file +/** @author Patrick */ +package io.fluent.builtin; diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/Assert.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/Assert.java index d6acd21..b079023 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/Assert.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/Assert.java @@ -4,25 +4,23 @@ final class Assert { - private Assert() { - } + private Assert() {} - static void isNull(Object value, Supplier message) { - if (value != null) { - throw new IllegalArgumentException(message.get()); - } - } + static void isNull(Object value, Supplier message) { + if (value != null) { + throw new IllegalArgumentException(message.get()); + } + } - static void notNull(Object value, Supplier message) { - if (value == null) { - throw new IllegalArgumentException(message.get()); - } - } - - static void isTrue(boolean condition, Supplier message) { - if (!condition) { - throw new IllegalArgumentException(message.get()); - } - } + static void notNull(Object value, Supplier message) { + if (value == null) { + throw new IllegalArgumentException(message.get()); + } + } + static void isTrue(boolean condition, Supplier message) { + if (!condition) { + throw new IllegalArgumentException(message.get()); + } + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/ClassUtils.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/ClassUtils.java index 5782a62..820655e 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/ClassUtils.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/ClassUtils.java @@ -12,246 +12,252 @@ import java.util.TreeSet; import java.util.stream.Collectors; import java.util.stream.Stream; - import org.jetbrains.annotations.NotNull; public final class ClassUtils { - private static final String JAVASSIST_CLASS_SEPARATOR = "$$"; - private static final String BYTE_BUDDY_CLASS_SEPARATOR = "$ByteBuddy$"; - private static final String HIBERNATE_PROXY_CLASS_SEPARATOR = "$HibernateProxy$"; - - private static final ClassValue> methodsSignaturesCache = ClassValues.create(ClassUtils::getAllDeclaredMethodSignatures); - - private ClassUtils() { - } - - public static Class getRealClass(T object) { - if (object instanceof Class) { - throw new IllegalArgumentException("The provided object is already a class: " + object + ". " + - "You probably want to call ClassUtils.getRealClass(Class) instead."); - } - @SuppressWarnings("unchecked") - Class entityClass = (Class) object.getClass(); - return getRealClass(entityClass); - } - - public static Class getRealClass(Class clazz) { - if (isProxyClass(clazz)) { - if (Proxy.isProxyClass(clazz)) { - Class[] interfaces = clazz.getInterfaces(); - Assert.isTrue(interfaces.length == 1, - () -> "Unexpected number of interfaces: " + interfaces.length); - @SuppressWarnings("unchecked") - Class proxiedInterface = (Class) interfaces[0]; - return proxiedInterface; - } - @SuppressWarnings("unchecked") - Class superclass = (Class) clazz.getSuperclass(); - return getRealClass(superclass); - } - return clazz; - } - - public static T createNewInstanceLike(T source) { - if (source == null) { - return null; - } - - Class sourceClass = getRealClass(source); - return createNewInstance(sourceClass); - } - - public static boolean isFromPackage(Class clazz, String packageName) { - Package aPackage = clazz.getPackage(); - return aPackage != null && aPackage.getName().equals(packageName); - } - - public static boolean isRecord(Object bean) { - return RecordSupport.isRecord(bean); - } - - public static boolean isRecord(Class beanType) { - return RecordSupport.isRecord(beanType); - } - - @SuppressWarnings(/* this unchecked cast is OK, since this is the contract of newInstance() */"unchecked") - public static T createNewInstance(Class sourceClass) { - try { - Constructor constructor = sourceClass.getDeclaredConstructor(); - return createInstance(constructor); - } catch (ReflectiveOperationException e) { - throw new ReflectionRuntimeException("Failed to construct an instance of " + sourceClass, e); - } - } - - static T createInstance(Constructor constructor, Object... initArgs) throws ReflectiveOperationException { - boolean accessible = constructor.isAccessible(); - try { - if (!accessible) { - constructor.setAccessible(true); - } - return constructor.newInstance(initArgs); - } finally { - if (!accessible) { - constructor.setAccessible(false); - } - } - } - - @NotNull - public static String getVoidMethodName(T bean, VoidMethod voidMethod) { - Class beanClass = getRealClass(bean); - return getVoidMethodName(beanClass, voidMethod); - } - - @NotNull - public static String getVoidMethodName(Class beanClass, VoidMethod voidMethod) { - Method method = getVoidMethod(beanClass, voidMethod); - return method.getName(); - } - - @NotNull - public static Method getVoidMethod(Class beanClass, VoidMethod voidMethod) { - PropertyDescriptorCache cache = PropertyUtils.getCache(beanClass); - return cache.getMethod(voidMethod); - } - - @NotNull - public static Method getMethod(Class beanClass, PropertyGetter getterMethod) { - PropertyDescriptorCache cache = PropertyUtils.getCache(beanClass); - return cache.getMethod(getterMethod); - } - - @NotNull - public static Method getMethod(T bean, PropertyGetter getterMethod) { - Class beanClass = getRealClass(bean); - return getMethod(beanClass, getterMethod); - } - - @NotNull - public static String getMethodName(T bean, PropertyGetter getterMethod) { - Class beanClass = getRealClass(bean); - return getMethodName(beanClass, getterMethod); - } - - @NotNull - public static String getMethodName(Class beanClass, PropertyGetter getterMethod) { - Method method = getMethod(beanClass, getterMethod); - return method.getName(); - } - - @NotNull - public static Method getMethod(Class beanClass, VoidMethod voidMethod) { - return getVoidMethod(beanClass, voidMethod); - } - - @NotNull - public static String getMethodName(T bean, VoidMethod voidMethod) { - return getVoidMethodName(bean, voidMethod); - } - - @NotNull - public static String getMethodName(Class beanClass, VoidMethod voidMethod) { - return getVoidMethodName(beanClass, voidMethod); - } - - public static boolean isProxy(Object object) { - return object != null && isProxyClass(object.getClass()); - } - - public static boolean isProxyClass(Class clazz) { - if (clazz == null) { - return false; - } - - if (Proxy.isProxyClass(clazz)) { - return true; - } - - return matchesWellKnownProxyClassNamePattern(clazz.getName()); - } - - static boolean matchesWellKnownProxyClassNamePattern(String className) { - return className.contains(BYTE_BUDDY_CLASS_SEPARATOR) - || className.contains(JAVASSIST_CLASS_SEPARATOR) - || className.contains(HIBERNATE_PROXY_CLASS_SEPARATOR); - } - - public static boolean haveSameSignature(Method oneMethod, Method otherMethod) { - return new MethodSignature(oneMethod).equals(new MethodSignature(otherMethod)); - } - - public static List findMethodsByArgumentTypes(Class classToSearchIn, Class... argumentTypes) { - return Stream.of(classToSearchIn.getMethods()) - .filter(method -> Arrays.equals(method.getParameterTypes(), argumentTypes)) - .collect(Collectors.toList()); - } - - public static boolean hasMethodWithSameSignature(Class clazz, Method method) { - Set methods = methodsSignaturesCache.get(clazz); - return methods.contains(new MethodSignature(method)); - } - - public static Set getAllDeclaredMethods(Class clazz) { - Set methods = new LinkedHashSet<>(Arrays.asList(clazz.getDeclaredMethods())); - if (clazz.getSuperclass() != null && !clazz.getSuperclass().equals(Object.class)) { - methods.addAll(getAllDeclaredMethods(clazz.getSuperclass())); - } - for (Class interfaceClass : clazz.getInterfaces()) { - methods.addAll(getAllDeclaredMethods(interfaceClass)); - } - return Collections.unmodifiableSet(methods); - } - - public static Set getAllDeclaredMethodSignatures(Class clazz) { - return getAllDeclaredMethods(clazz).stream() - .map(MethodSignature::new) - .collect(Collectors.toCollection(TreeSet::new)); - } - - public static A findAnnotation(Method method, Class annotationType) { - A annotation = method.getAnnotation(annotationType); - if (annotation != null) { - return annotation; - } - return findAnnotation(method.getDeclaringClass(), method, annotationType); - } - - private static A findAnnotation(Class declaringClass, Method method, Class annotationType) { - if (declaringClass == null || declaringClass.equals(Object.class)) { - return null; - } - if (declaringClass.getSuperclass() != null) { - for (Method methodCandidate : declaringClass.getSuperclass().getMethods()) { - if (isOverride(method, methodCandidate)) { - A annotation = findAnnotation(methodCandidate, annotationType); - if (annotation != null) { - return annotation; - } - } - } - } - for (Class interfaceClass : declaringClass.getInterfaces()) { - for (Method methodCandidate : interfaceClass.getDeclaredMethods()) { - if (isOverride(method, methodCandidate)) { - A annotation = findAnnotation(methodCandidate, annotationType); - if (annotation != null) { - return annotation; - } - } - } - A annotation = findAnnotation(interfaceClass, method, annotationType); - if (annotation != null) { - return annotation; - } - } - return findAnnotation(declaringClass.getSuperclass(), method, annotationType); - } - - private static boolean isOverride(Method method, Method candidate) { - return method.getName().equals(candidate.getName()) - && candidate.getParameterCount() == method.getParameterCount() - && Arrays.equals(candidate.getParameterTypes(), method.getParameterTypes()); - } + private static final String JAVASSIST_CLASS_SEPARATOR = "$$"; + private static final String BYTE_BUDDY_CLASS_SEPARATOR = "$ByteBuddy$"; + private static final String HIBERNATE_PROXY_CLASS_SEPARATOR = "$HibernateProxy$"; + + private static final ClassValue> methodsSignaturesCache = + ClassValues.create(ClassUtils::getAllDeclaredMethodSignatures); + + private ClassUtils() {} + + public static Class getRealClass(T object) { + if (object instanceof Class) { + throw new IllegalArgumentException( + "The provided object is already a class: " + + object + + ". " + + "You probably want to call ClassUtils.getRealClass(Class) instead."); + } + @SuppressWarnings("unchecked") + Class entityClass = (Class) object.getClass(); + return getRealClass(entityClass); + } + + public static Class getRealClass(Class clazz) { + if (isProxyClass(clazz)) { + if (Proxy.isProxyClass(clazz)) { + Class[] interfaces = clazz.getInterfaces(); + Assert.isTrue( + interfaces.length == 1, () -> "Unexpected number of interfaces: " + interfaces.length); + @SuppressWarnings("unchecked") + Class proxiedInterface = (Class) interfaces[0]; + return proxiedInterface; + } + @SuppressWarnings("unchecked") + Class superclass = (Class) clazz.getSuperclass(); + return getRealClass(superclass); + } + return clazz; + } + + public static T createNewInstanceLike(T source) { + if (source == null) { + return null; + } + + Class sourceClass = getRealClass(source); + return createNewInstance(sourceClass); + } + + public static boolean isFromPackage(Class clazz, String packageName) { + Package aPackage = clazz.getPackage(); + return aPackage != null && aPackage.getName().equals(packageName); + } + + public static boolean isRecord(Object bean) { + return RecordSupport.isRecord(bean); + } + + public static boolean isRecord(Class beanType) { + return RecordSupport.isRecord(beanType); + } + + @SuppressWarnings( + /* this unchecked cast is OK, since this is the contract of newInstance() */ "unchecked") + public static T createNewInstance(Class sourceClass) { + try { + Constructor constructor = sourceClass.getDeclaredConstructor(); + return createInstance(constructor); + } catch (ReflectiveOperationException e) { + throw new ReflectionRuntimeException("Failed to construct an instance of " + sourceClass, e); + } + } + + static T createInstance(Constructor constructor, Object... initArgs) + throws ReflectiveOperationException { + boolean accessible = constructor.isAccessible(); + try { + if (!accessible) { + constructor.setAccessible(true); + } + return constructor.newInstance(initArgs); + } finally { + if (!accessible) { + constructor.setAccessible(false); + } + } + } + + @NotNull + public static String getVoidMethodName(T bean, VoidMethod voidMethod) { + Class beanClass = getRealClass(bean); + return getVoidMethodName(beanClass, voidMethod); + } + + @NotNull + public static String getVoidMethodName(Class beanClass, VoidMethod voidMethod) { + Method method = getVoidMethod(beanClass, voidMethod); + return method.getName(); + } + + @NotNull + public static Method getVoidMethod(Class beanClass, VoidMethod voidMethod) { + PropertyDescriptorCache cache = PropertyUtils.getCache(beanClass); + return cache.getMethod(voidMethod); + } + + @NotNull + public static Method getMethod(Class beanClass, PropertyGetter getterMethod) { + PropertyDescriptorCache cache = PropertyUtils.getCache(beanClass); + return cache.getMethod(getterMethod); + } + + @NotNull + public static Method getMethod(T bean, PropertyGetter getterMethod) { + Class beanClass = getRealClass(bean); + return getMethod(beanClass, getterMethod); + } + + @NotNull + public static String getMethodName(T bean, PropertyGetter getterMethod) { + Class beanClass = getRealClass(bean); + return getMethodName(beanClass, getterMethod); + } + + @NotNull + public static String getMethodName(Class beanClass, PropertyGetter getterMethod) { + Method method = getMethod(beanClass, getterMethod); + return method.getName(); + } + + @NotNull + public static Method getMethod(Class beanClass, VoidMethod voidMethod) { + return getVoidMethod(beanClass, voidMethod); + } + + @NotNull + public static String getMethodName(T bean, VoidMethod voidMethod) { + return getVoidMethodName(bean, voidMethod); + } + + @NotNull + public static String getMethodName(Class beanClass, VoidMethod voidMethod) { + return getVoidMethodName(beanClass, voidMethod); + } + + public static boolean isProxy(Object object) { + return object != null && isProxyClass(object.getClass()); + } + + public static boolean isProxyClass(Class clazz) { + if (clazz == null) { + return false; + } + + if (Proxy.isProxyClass(clazz)) { + return true; + } + + return matchesWellKnownProxyClassNamePattern(clazz.getName()); + } + + static boolean matchesWellKnownProxyClassNamePattern(String className) { + return className.contains(BYTE_BUDDY_CLASS_SEPARATOR) + || className.contains(JAVASSIST_CLASS_SEPARATOR) + || className.contains(HIBERNATE_PROXY_CLASS_SEPARATOR); + } + + public static boolean haveSameSignature(Method oneMethod, Method otherMethod) { + return new MethodSignature(oneMethod).equals(new MethodSignature(otherMethod)); + } + + public static List findMethodsByArgumentTypes( + Class classToSearchIn, Class... argumentTypes) { + return Stream.of(classToSearchIn.getMethods()) + .filter(method -> Arrays.equals(method.getParameterTypes(), argumentTypes)) + .collect(Collectors.toList()); + } + + public static boolean hasMethodWithSameSignature(Class clazz, Method method) { + Set methods = methodsSignaturesCache.get(clazz); + return methods.contains(new MethodSignature(method)); + } + + public static Set getAllDeclaredMethods(Class clazz) { + Set methods = new LinkedHashSet<>(Arrays.asList(clazz.getDeclaredMethods())); + if (clazz.getSuperclass() != null && !clazz.getSuperclass().equals(Object.class)) { + methods.addAll(getAllDeclaredMethods(clazz.getSuperclass())); + } + for (Class interfaceClass : clazz.getInterfaces()) { + methods.addAll(getAllDeclaredMethods(interfaceClass)); + } + return Collections.unmodifiableSet(methods); + } + + public static Set getAllDeclaredMethodSignatures(Class clazz) { + return getAllDeclaredMethods(clazz).stream() + .map(MethodSignature::new) + .collect(Collectors.toCollection(TreeSet::new)); + } + + public static A findAnnotation(Method method, Class annotationType) { + A annotation = method.getAnnotation(annotationType); + if (annotation != null) { + return annotation; + } + return findAnnotation(method.getDeclaringClass(), method, annotationType); + } + + private static A findAnnotation( + Class declaringClass, Method method, Class annotationType) { + if (declaringClass == null || declaringClass.equals(Object.class)) { + return null; + } + if (declaringClass.getSuperclass() != null) { + for (Method methodCandidate : declaringClass.getSuperclass().getMethods()) { + if (isOverride(method, methodCandidate)) { + A annotation = findAnnotation(methodCandidate, annotationType); + if (annotation != null) { + return annotation; + } + } + } + } + for (Class interfaceClass : declaringClass.getInterfaces()) { + for (Method methodCandidate : interfaceClass.getDeclaredMethods()) { + if (isOverride(method, methodCandidate)) { + A annotation = findAnnotation(methodCandidate, annotationType); + if (annotation != null) { + return annotation; + } + } + } + A annotation = findAnnotation(interfaceClass, method, annotationType); + if (annotation != null) { + return annotation; + } + } + return findAnnotation(declaringClass.getSuperclass(), method, annotationType); + } + + private static boolean isOverride(Method method, Method candidate) { + return method.getName().equals(candidate.getName()) + && candidate.getParameterCount() == method.getParameterCount() + && Arrays.equals(candidate.getParameterTypes(), method.getParameterTypes()); + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/ClassValues.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/ClassValues.java index bd1adad..a4950f2 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/ClassValues.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/ClassValues.java @@ -4,16 +4,14 @@ public final class ClassValues { - private ClassValues() { - } - - public static ClassValue create(Function, T> mapper) { - return new ClassValue() { - @Override - protected T computeValue(Class type) { - return mapper.apply(type); - } - }; - } + private ClassValues() {} + public static ClassValue create(Function, T> mapper) { + return new ClassValue() { + @Override + protected T computeValue(Class type) { + return mapper.apply(type); + } + }; + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/MethodCaptor.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/MethodCaptor.java index f9a9bcf..2e223a7 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/MethodCaptor.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/MethodCaptor.java @@ -4,7 +4,6 @@ import java.lang.reflect.Method; import java.util.concurrent.atomic.AtomicReference; - import net.bytebuddy.ByteBuddy; import net.bytebuddy.description.modifier.Visibility; import net.bytebuddy.dynamic.scaffold.subclass.ConstructorStrategy; @@ -15,43 +14,45 @@ public class MethodCaptor { - static final String FIELD_NAME = "$methodCaptor"; - - private final AtomicReference capturedMethod = new AtomicReference<>(); - - void capture(Method method) { - Method existing = capturedMethod.getAndSet(method); - Assert.isNull(existing, () -> String.format("Method already captured: %s called twice?", existing)); - } - - Method getCapturedMethod() { - Method method = capturedMethod.get(); - Assert.notNull(method, () -> "Method could not be captured." + - " This can happen when no method was invoked or the method is final or non-public."); - return method; - } - - @RuntimeType - public static Object intercept(@Origin Method method, @FieldValue(FIELD_NAME) MethodCaptor methodCaptor) { - methodCaptor.capture(method); - return PropertyUtils.getDefaultValueObject(method.getReturnType()); - } - - static Class createProxyClass(Class beanClass) { - try { - return new ByteBuddy() - .subclass(beanClass, ConstructorStrategy.Default.NO_CONSTRUCTORS) - .defineField(MethodCaptor.FIELD_NAME, MethodCaptor.class, Visibility.PRIVATE) - .method(isMethod() - .and(takesArguments(0)) - .and(not(isDeclaredBy(Object.class)))) - .intercept(MethodDelegation.to(MethodCaptor.class)) - .make() - .load(PropertyUtils.class.getClassLoader()) - .getLoaded(); - } catch (IllegalAccessError e) { - throw new ReflectionRuntimeException("Failed to create proxy on " + beanClass, e); - } - } - + static final String FIELD_NAME = "$methodCaptor"; + + private final AtomicReference capturedMethod = new AtomicReference<>(); + + void capture(Method method) { + Method existing = capturedMethod.getAndSet(method); + Assert.isNull( + existing, () -> String.format("Method already captured: %s called twice?", existing)); + } + + Method getCapturedMethod() { + Method method = capturedMethod.get(); + Assert.notNull( + method, + () -> + "Method could not be captured." + + " This can happen when no method was invoked or the method is final or non-public."); + return method; + } + + @RuntimeType + public static Object intercept( + @Origin Method method, @FieldValue(FIELD_NAME) MethodCaptor methodCaptor) { + methodCaptor.capture(method); + return PropertyUtils.getDefaultValueObject(method.getReturnType()); + } + + static Class createProxyClass(Class beanClass) { + try { + return new ByteBuddy() + .subclass(beanClass, ConstructorStrategy.Default.NO_CONSTRUCTORS) + .defineField(MethodCaptor.FIELD_NAME, MethodCaptor.class, Visibility.PRIVATE) + .method(isMethod().and(takesArguments(0)).and(not(isDeclaredBy(Object.class)))) + .intercept(MethodDelegation.to(MethodCaptor.class)) + .make() + .load(PropertyUtils.class.getClassLoader()) + .getLoaded(); + } catch (IllegalAccessError e) { + throw new ReflectionRuntimeException("Failed to create proxy on " + beanClass, e); + } + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/MethodSignature.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/MethodSignature.java index a129e74..a64b218 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/MethodSignature.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/MethodSignature.java @@ -8,61 +8,69 @@ final class MethodSignature implements Comparable { - private final String name; - private final Class returnType; - private final Class[] parameterTypes; + private final String name; + private final Class returnType; + private final Class[] parameterTypes; - MethodSignature(Method method) { - this.name = method.getName(); - this.returnType = method.getReturnType(); - this.parameterTypes = method.getParameterTypes(); - } + MethodSignature(Method method) { + this.name = method.getName(); + this.returnType = method.getReturnType(); + this.parameterTypes = method.getParameterTypes(); + } - @Override - public boolean equals(Object o) { - if (this == o) { - return true; - } - if (o == null || getClass() != o.getClass()) { - return false; - } - MethodSignature that = (MethodSignature) o; - return Objects.equals(name, that.name) - && Objects.equals(returnType, that.returnType) - && Arrays.equals(parameterTypes, that.parameterTypes); - } + @Override + public boolean equals(Object o) { + if (this == o) { + return true; + } + if (o == null || getClass() != o.getClass()) { + return false; + } + MethodSignature that = (MethodSignature) o; + return Objects.equals(name, that.name) + && Objects.equals(returnType, that.returnType) + && Arrays.equals(parameterTypes, that.parameterTypes); + } - @Override - public int hashCode() { - return Objects.hash(name, returnType, Arrays.hashCode(parameterTypes)); - } + @Override + public int hashCode() { + return Objects.hash(name, returnType, Arrays.hashCode(parameterTypes)); + } - String getName() { - return name; - } + String getName() { + return name; + } - Class getReturnType() { - return returnType; - } + Class getReturnType() { + return returnType; + } - private Class[] getParameterTypes() { - return parameterTypes; - } + private Class[] getParameterTypes() { + return parameterTypes; + } - @Override - public int compareTo(MethodSignature other) { - Comparator comparator = Comparator.comparing(MethodSignature::getName) - .thenComparing(MethodSignature::getReturnType, Comparator.comparing(Class::getName)) - .thenComparing(MethodSignature::getParameterTypes, Comparator.comparing(MethodSignature::mapToString)); - return comparator.compare(this, other); - } + @Override + public int compareTo(MethodSignature other) { + Comparator comparator = + Comparator.comparing(MethodSignature::getName) + .thenComparing(MethodSignature::getReturnType, Comparator.comparing(Class::getName)) + .thenComparing( + MethodSignature::getParameterTypes, + Comparator.comparing(MethodSignature::mapToString)); + return comparator.compare(this, other); + } - private static String mapToString(Class[] list) { - return Arrays.stream(list).map(Class::getName).collect(Collectors.joining(", ")); - } + private static String mapToString(Class[] list) { + return Arrays.stream(list).map(Class::getName).collect(Collectors.joining(", ")); + } - @Override - public String toString() { - return getReturnType().getName() + " " + getName() + "(" + mapToString(getParameterTypes()) + ")"; - } + @Override + public String toString() { + return getReturnType().getName() + + " " + + getName() + + "(" + + mapToString(getParameterTypes()) + + ")"; + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/PropertyDescriptorCache.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/PropertyDescriptorCache.java index e2914bf..7497fc1 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/PropertyDescriptorCache.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/PropertyDescriptorCache.java @@ -23,189 +23,210 @@ class PropertyDescriptorCache { - private final Class originalClass; - private final AtomicReference> methodCapturingProxy = new AtomicReference<>(); - private final Map propertyDescriptorsByName = new LinkedHashMap<>(); - private final Map propertyDescriptorsByField = new LinkedHashMap<>(); - private final Map propertyDescriptorsByMethod = new LinkedHashMap<>(); - private final Map, Map> propertyDescriptorsByAnnotation = new LinkedHashMap<>(); - private final Map, Method> methodByPropertyGetterCache = new ConcurrentHashMap<>(); - private final Map, Method> methodByVoidMethodCache = new ConcurrentHashMap<>(); - private final Map defaultValues = new ConcurrentHashMap<>(); - - PropertyDescriptorCache(Class originalClass) { - this.originalClass = originalClass; - - for (PropertyDescriptor propertyDescriptor : getAllPropertyDescriptors()) { - PropertyDescriptor existing = propertyDescriptorsByName.putIfAbsent(propertyDescriptor.getName(), propertyDescriptor); - Assert.isNull(existing, () -> "PropertyDescriptor for name " + propertyDescriptor.getName() + " already exists: " + existing); - - Method readMethod = propertyDescriptor.getReadMethod(); - if (readMethod != null) { - propertyDescriptorsByMethod.put(readMethod, propertyDescriptor); - putAnnotations(propertyDescriptor, readMethod.getAnnotations()); - } - - Method writeMethod = propertyDescriptor.getWriteMethod(); - if (writeMethod != null) { - propertyDescriptorsByMethod.put(writeMethod, propertyDescriptor); - putAnnotations(propertyDescriptor, writeMethod.getAnnotations()); - } - } - - for (Field field : getFields()) { - PropertyDescriptor propertyDescriptor = propertyDescriptorsByName.get(field.getName()); - if (propertyDescriptor != null) { - PropertyDescriptor existing = propertyDescriptorsByField.putIfAbsent(field, propertyDescriptor); - Assert.isNull(existing, () -> "Property descriptor for " + field + " already exists: " + existing); - putAnnotations(propertyDescriptor, field.getAnnotations()); - } - } - } - - Class getMethodCapturingProxy() { - return methodCapturingProxy.updateAndGet(proxyClass -> { - if (proxyClass == null) { - return MethodCaptor.createProxyClass(originalClass); - } else { - return proxyClass; - } - }); - } - - private Set getFields() { - List allFields = new ArrayList<>(); - collectFields(originalClass, allFields); - allFields.sort(Comparator.comparing(Field::getName)); - return new LinkedHashSet<>(allFields); - } - - private static void collectFields(Class type, Collection collectedFields) { - collectedFields.addAll(Arrays.asList(type.getFields())); - collectedFields.addAll(Arrays.asList(type.getDeclaredFields())); - if (!type.equals(Object.class)) { - Class superclass = type.getSuperclass(); - if (superclass != null) { - collectFields(superclass, collectedFields); - } - } - } - - private void putAnnotations(PropertyDescriptor propertyDescriptor, Annotation[] annotations) { - for (Annotation annotation : annotations) { - propertyDescriptorsByAnnotation.computeIfAbsent(annotation.annotationType(), k -> new LinkedHashMap<>()) // - .putIfAbsent(propertyDescriptor, annotation); - } - } - - private static Collection collectAllPropertyDescriptors(Class type) { - try { - Map propertyDescriptors = new TreeMap<>(); - - for (PropertyDescriptor propertyDescriptor : collectPropertyDescriptorsOfClass(type)) { - propertyDescriptors.put(propertyDescriptor.getName(), propertyDescriptor); - } - - collectPropertyDescriptorsOfInterfaces(type, propertyDescriptors); - return propertyDescriptors.values(); - } catch (IntrospectionException e) { - throw new ReflectionRuntimeException(e); - } - } - - private static Collection collectPropertyDescriptorsOfClass(Class type) throws IntrospectionException { - if (RecordSupport.isRecord(type)) { - return RecordSupport.collectPropertyDescriptorsOfRecord(type); - } - BeanInfo beanInfo = Introspector.getBeanInfo(type); - return Arrays.asList(beanInfo.getPropertyDescriptors()); - } - - // workaround for https://bugs.openjdk.java.net/browse/JDK-8071693 - private static void collectPropertyDescriptorsOfInterfaces(Class type, Map propertyDescriptors) - throws IntrospectionException { - if (type == null || type.equals(Object.class)) { - return; - } - for (Class typeInterface : type.getInterfaces()) { - BeanInfo beanInfo = Introspector.getBeanInfo(typeInterface); - for (PropertyDescriptor propertyDescriptor : beanInfo.getPropertyDescriptors()) { - propertyDescriptors.putIfAbsent(propertyDescriptor.getName(), propertyDescriptor); - } - collectPropertyDescriptorsOfInterfaces(typeInterface, propertyDescriptors); - } - collectPropertyDescriptorsOfInterfaces(type.getSuperclass(), propertyDescriptors); - } - - private Collection getAllPropertyDescriptors() { - return collectAllPropertyDescriptors(originalClass); - } - - Collection getDescriptors() { - return Collections.unmodifiableCollection(propertyDescriptorsByName.values()); - } - - PropertyDescriptor getDescriptorByMethod(Method method) { - return propertyDescriptorsByMethod.get(method); - } - - PropertyDescriptor getDescriptorByField(Field field) { - return propertyDescriptorsByField.get(field); - } - - Map getDescriptorsForAnnotation(Class annotationClass) { - @SuppressWarnings("unchecked") - Map descriptors = (Map) propertyDescriptorsByAnnotation.getOrDefault( - annotationClass, Collections.emptyMap()); - return Collections.unmodifiableMap(descriptors); - } - - PropertyDescriptor getDescriptorByName(String propertyName) { - return propertyDescriptorsByName.get(propertyName); - } - - Object getDefaultValue(PropertyDescriptor propertyDescriptor) { - return defaultValues.computeIfAbsent(propertyDescriptor, this::determineDefaultValue); - } - - private Object determineDefaultValue(PropertyDescriptor propertyDescriptor) { - try { - Object defaultObject = ClassUtils.createNewInstance(originalClass); - return PropertyUtils.read(defaultObject, propertyDescriptor); - } catch (RuntimeException e) { - throw new ReflectionRuntimeException("Failed to determine default value for " + PropertyUtils.getQualifiedPropertyName(originalClass, propertyDescriptor), e); - } - } - - Method getMethod(TypedPropertyGetter propertyGetter) { - assertHasNoDeclaredFields(propertyGetter); - return methodByPropertyGetterCache.computeIfAbsent(propertyGetter, getter -> PropertyUtils.findMethodByGetter(originalClass, getter)); - } - - Method getMethod(VoidMethod voidMethod) { - assertHasNoDeclaredFields(voidMethod); - return methodByVoidMethodCache.computeIfAbsent(voidMethod, m -> PropertyUtils.findMethodByGetter(originalClass, toPropertyGetter(m))); - } - - private static void assertHasNoDeclaredFields(Object lambda) { - if (hasDeclaredFields(lambda)) { - throw new IllegalArgumentException(lambda + " is call site specific"); - } - } - - private static boolean hasDeclaredFields(Object lambda) { - return lambda.getClass().getDeclaredFields().length > 0; - } - - private static PropertyGetter toPropertyGetter(VoidMethod voidMethod) { - return bean -> { - try { - voidMethod.invoke(bean); - } catch (Exception e) { - throw new ReflectionRuntimeException(e); - } - return null; - }; - } - + private final Class originalClass; + private final AtomicReference> methodCapturingProxy = new AtomicReference<>(); + private final Map propertyDescriptorsByName = new LinkedHashMap<>(); + private final Map propertyDescriptorsByField = new LinkedHashMap<>(); + private final Map propertyDescriptorsByMethod = new LinkedHashMap<>(); + private final Map, Map> + propertyDescriptorsByAnnotation = new LinkedHashMap<>(); + private final Map, Method> methodByPropertyGetterCache = + new ConcurrentHashMap<>(); + private final Map, Method> methodByVoidMethodCache = new ConcurrentHashMap<>(); + private final Map defaultValues = new ConcurrentHashMap<>(); + + PropertyDescriptorCache(Class originalClass) { + this.originalClass = originalClass; + + for (PropertyDescriptor propertyDescriptor : getAllPropertyDescriptors()) { + PropertyDescriptor existing = + propertyDescriptorsByName.putIfAbsent(propertyDescriptor.getName(), propertyDescriptor); + Assert.isNull( + existing, + () -> + "PropertyDescriptor for name " + + propertyDescriptor.getName() + + " already exists: " + + existing); + + Method readMethod = propertyDescriptor.getReadMethod(); + if (readMethod != null) { + propertyDescriptorsByMethod.put(readMethod, propertyDescriptor); + putAnnotations(propertyDescriptor, readMethod.getAnnotations()); + } + + Method writeMethod = propertyDescriptor.getWriteMethod(); + if (writeMethod != null) { + propertyDescriptorsByMethod.put(writeMethod, propertyDescriptor); + putAnnotations(propertyDescriptor, writeMethod.getAnnotations()); + } + } + + for (Field field : getFields()) { + PropertyDescriptor propertyDescriptor = propertyDescriptorsByName.get(field.getName()); + if (propertyDescriptor != null) { + PropertyDescriptor existing = + propertyDescriptorsByField.putIfAbsent(field, propertyDescriptor); + Assert.isNull( + existing, () -> "Property descriptor for " + field + " already exists: " + existing); + putAnnotations(propertyDescriptor, field.getAnnotations()); + } + } + } + + Class getMethodCapturingProxy() { + return methodCapturingProxy.updateAndGet( + proxyClass -> { + if (proxyClass == null) { + return MethodCaptor.createProxyClass(originalClass); + } else { + return proxyClass; + } + }); + } + + private Set getFields() { + List allFields = new ArrayList<>(); + collectFields(originalClass, allFields); + allFields.sort(Comparator.comparing(Field::getName)); + return new LinkedHashSet<>(allFields); + } + + private static void collectFields(Class type, Collection collectedFields) { + collectedFields.addAll(Arrays.asList(type.getFields())); + collectedFields.addAll(Arrays.asList(type.getDeclaredFields())); + if (!type.equals(Object.class)) { + Class superclass = type.getSuperclass(); + if (superclass != null) { + collectFields(superclass, collectedFields); + } + } + } + + private void putAnnotations(PropertyDescriptor propertyDescriptor, Annotation[] annotations) { + for (Annotation annotation : annotations) { + propertyDescriptorsByAnnotation + .computeIfAbsent(annotation.annotationType(), k -> new LinkedHashMap<>()) // + .putIfAbsent(propertyDescriptor, annotation); + } + } + + private static Collection collectAllPropertyDescriptors(Class type) { + try { + Map propertyDescriptors = new TreeMap<>(); + + for (PropertyDescriptor propertyDescriptor : collectPropertyDescriptorsOfClass(type)) { + propertyDescriptors.put(propertyDescriptor.getName(), propertyDescriptor); + } + + collectPropertyDescriptorsOfInterfaces(type, propertyDescriptors); + return propertyDescriptors.values(); + } catch (IntrospectionException e) { + throw new ReflectionRuntimeException(e); + } + } + + private static Collection collectPropertyDescriptorsOfClass(Class type) + throws IntrospectionException { + if (RecordSupport.isRecord(type)) { + return RecordSupport.collectPropertyDescriptorsOfRecord(type); + } + BeanInfo beanInfo = Introspector.getBeanInfo(type); + return Arrays.asList(beanInfo.getPropertyDescriptors()); + } + + // workaround for https://bugs.openjdk.java.net/browse/JDK-8071693 + private static void collectPropertyDescriptorsOfInterfaces( + Class type, Map propertyDescriptors) + throws IntrospectionException { + if (type == null || type.equals(Object.class)) { + return; + } + for (Class typeInterface : type.getInterfaces()) { + BeanInfo beanInfo = Introspector.getBeanInfo(typeInterface); + for (PropertyDescriptor propertyDescriptor : beanInfo.getPropertyDescriptors()) { + propertyDescriptors.putIfAbsent(propertyDescriptor.getName(), propertyDescriptor); + } + collectPropertyDescriptorsOfInterfaces(typeInterface, propertyDescriptors); + } + collectPropertyDescriptorsOfInterfaces(type.getSuperclass(), propertyDescriptors); + } + + private Collection getAllPropertyDescriptors() { + return collectAllPropertyDescriptors(originalClass); + } + + Collection getDescriptors() { + return Collections.unmodifiableCollection(propertyDescriptorsByName.values()); + } + + PropertyDescriptor getDescriptorByMethod(Method method) { + return propertyDescriptorsByMethod.get(method); + } + + PropertyDescriptor getDescriptorByField(Field field) { + return propertyDescriptorsByField.get(field); + } + + Map getDescriptorsForAnnotation( + Class annotationClass) { + @SuppressWarnings("unchecked") + Map descriptors = + (Map) + propertyDescriptorsByAnnotation.getOrDefault(annotationClass, Collections.emptyMap()); + return Collections.unmodifiableMap(descriptors); + } + + PropertyDescriptor getDescriptorByName(String propertyName) { + return propertyDescriptorsByName.get(propertyName); + } + + Object getDefaultValue(PropertyDescriptor propertyDescriptor) { + return defaultValues.computeIfAbsent(propertyDescriptor, this::determineDefaultValue); + } + + private Object determineDefaultValue(PropertyDescriptor propertyDescriptor) { + try { + Object defaultObject = ClassUtils.createNewInstance(originalClass); + return PropertyUtils.read(defaultObject, propertyDescriptor); + } catch (RuntimeException e) { + throw new ReflectionRuntimeException( + "Failed to determine default value for " + + PropertyUtils.getQualifiedPropertyName(originalClass, propertyDescriptor), + e); + } + } + + Method getMethod(TypedPropertyGetter propertyGetter) { + assertHasNoDeclaredFields(propertyGetter); + return methodByPropertyGetterCache.computeIfAbsent( + propertyGetter, getter -> PropertyUtils.findMethodByGetter(originalClass, getter)); + } + + Method getMethod(VoidMethod voidMethod) { + assertHasNoDeclaredFields(voidMethod); + return methodByVoidMethodCache.computeIfAbsent( + voidMethod, m -> PropertyUtils.findMethodByGetter(originalClass, toPropertyGetter(m))); + } + + private static void assertHasNoDeclaredFields(Object lambda) { + if (hasDeclaredFields(lambda)) { + throw new IllegalArgumentException(lambda + " is call site specific"); + } + } + + private static boolean hasDeclaredFields(Object lambda) { + return lambda.getClass().getDeclaredFields().length > 0; + } + + private static PropertyGetter toPropertyGetter(VoidMethod voidMethod) { + return bean -> { + try { + voidMethod.invoke(bean); + } catch (Exception e) { + throw new ReflectionRuntimeException(e); + } + return null; + }; + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/PropertyGetter.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/PropertyGetter.java index 3f9b3e7..903f7a5 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/PropertyGetter.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/PropertyGetter.java @@ -1,5 +1,4 @@ package io.fluent.builtin.reflection; @FunctionalInterface -public interface PropertyGetter extends TypedPropertyGetter { -} +public interface PropertyGetter extends TypedPropertyGetter {} diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/PropertyUtils.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/PropertyUtils.java index 46f7049..d06855a 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/PropertyUtils.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/PropertyUtils.java @@ -12,7 +12,6 @@ import java.util.function.Supplier; import java.util.stream.Collectors; import java.util.stream.Stream; - import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.VisibleForTesting; @@ -20,467 +19,530 @@ public final class PropertyUtils { - private static final ClassValue> cache = ClassValues.create(PropertyDescriptorCache::new); - - private PropertyUtils() { - } - - @Nullable - public static PropertyDescriptor getPropertyDescriptorByName(Object bean, String propertyName) { - return getPropertyDescriptorByName(ClassUtils.getRealClass(bean), propertyName); - } - - @Nullable - public static PropertyDescriptor getPropertyDescriptorByName(Class beanClass, String propertyName) { - PropertyDescriptorCache propertyDescriptorCache = getCache(beanClass); - return propertyDescriptorCache.getDescriptorByName(propertyName); - } - - @NotNull - public static PropertyDescriptor getPropertyDescriptorByNameOrThrow(Object bean, String propertyName) { - Class beanClass = ClassUtils.getRealClass(bean); - return getPropertyDescriptorByNameOrThrow(beanClass, propertyName); - } - - @NotNull - public static PropertyDescriptor getPropertyDescriptorByNameOrThrow(Class beanClass, String propertyName) { - PropertyDescriptor propertyDescriptor = getPropertyDescriptorByName(beanClass, propertyName); - Assert.notNull(propertyDescriptor, () -> String.format("Property '%s' not found for '%s'", propertyName, beanClass.getSimpleName())); - return propertyDescriptor; - } - - public static Collection getPropertyDescriptors(Class type) { - PropertyDescriptorCache propertyDescriptorCache = getCache(type); - return propertyDescriptorCache.getDescriptors(); - } - - public static Collection getPropertyDescriptors(Object object) { - return getPropertyDescriptors(ClassUtils.getRealClass(object)); - } - - public static Map getPropertyDescriptorsWithAnnotation(Object object, Class annotationClass) { - Class objectClass = ClassUtils.getRealClass(object); - return getPropertyDescriptorsWithAnnotation(objectClass, annotationClass); - } - - public static Map getPropertyDescriptorsWithAnnotation(Class type, - Class annotationClass) { - PropertyDescriptorCache propertyDescriptorCache = getCache(type); - return propertyDescriptorCache.getDescriptorsForAnnotation(annotationClass); - } - - @SuppressWarnings("unchecked") - static PropertyDescriptorCache getCache(Class type) { - return (PropertyDescriptorCache) cache.get(type); - } - - public static T copyNonDefaultValues(T source, T destination) { - return copyNonDefaultValues(source, destination, Collections.emptySet()); - } - - public static T copyNonDefaultValues(T source, T destination, PropertyDescriptor... excludedProperties) { - return copyNonDefaultValues(source, destination, Stream.of(excludedProperties).collect(Collectors.toSet())); - } - - public static T copyNonDefaultValues(T source, T destination, Collection excludedProperties) { - getPropertyDescriptors(source).stream() - .filter(property -> !excludedProperties.contains(property)) - .filter(PropertyUtils::isFullyAccessible) - .filter(propertyDescriptor -> !hasDefaultValue(source, propertyDescriptor)) - .forEach(propertyDescriptor -> copyValue(source, destination, propertyDescriptor)); - return destination; - } - - public static Object copyValue(T source, T destination, PropertyDescriptor propertyDescriptor) { - Object value = read(source, propertyDescriptor); - write(destination, propertyDescriptor, value); - return value; - } - - public static boolean hasDefaultValue(T bean, PropertyDescriptor propertyDescriptor) { - Object value = read(bean, propertyDescriptor); - Class beanClass = ClassUtils.getRealClass(bean); - return isDefaultValue(beanClass, propertyDescriptor, value); - } - - public static boolean hasSameValue(T a, T b, PropertyDescriptor propertyDescriptor) { - Object valueFromA = read(a, propertyDescriptor); - Object valueFromB = read(b, propertyDescriptor); - return Objects.equals(valueFromA, valueFromB); - } - - public static boolean hasDifferentValue(T a, T b, PropertyDescriptor propertyDescriptor) { - return !hasSameValue(a, b, propertyDescriptor); - } - - public static boolean isDefaultValue(Class objectClass, TypedPropertyGetter propertyGetter, Object value) { - return isDefaultValue(objectClass, getPropertyDescriptor(objectClass, propertyGetter), value); - } - - public static boolean isDefaultValue(Class objectClass, PropertyDescriptor propertyDescriptor, Object value) { - Object defaultValue = getDefaultValue(objectClass, propertyDescriptor); - if (defaultValue instanceof Float && value instanceof Float) { - return (float) defaultValue == (float) value; - } else if (defaultValue instanceof Double && value instanceof Double) { - return (double) defaultValue == (double) value; - } else { - return Objects.equals(value, defaultValue); - } - } - - public static Object getDefaultValue(Class objectClass, PropertyDescriptor propertyDescriptor) { - return getCache(objectClass).getDefaultValue(propertyDescriptor); - } - - public static void write(Object destination, String propertyName, Object value) { - PropertyDescriptor propertyDescriptor = getPropertyDescriptorByNameOrThrow(destination, propertyName); - write(destination, propertyDescriptor, value); - } - - public static void writeIfPropertyExists(Object destination, String propertyName, Supplier valueSupplier) { - PropertyDescriptor property = getPropertyDescriptorByName(destination, propertyName); - if (property != null) { - T value = valueSupplier.get(); - write(destination, property, value); - } - } - - public static void write(Object destination, PropertyDescriptor propertyDescriptor, Object value) { - write(destination, propertyDescriptor, value, false); - } - - public static void write(Object destination, PropertyDescriptor propertyDescriptor, Object value, boolean force) { - try { - if (!isWritable(propertyDescriptor)) { - if (force) { - writeDirectly(destination, propertyDescriptor, value); - } else { - throw new IllegalArgumentException(propertyDescriptor.getName() + " is not writable"); - } - } else { - Object[] args = new Object[] { value }; - Method writeMethod = propertyDescriptor.getWriteMethod(); - withAccessibleObject(writeMethod, method -> method.invoke(destination, args), force); - } - } catch (ReflectiveOperationException | RuntimeException e) { - throw new ReflectionRuntimeException("Failed to write " + getQualifiedPropertyName(destination, propertyDescriptor), e); - } - } - - public static void writeDirectly(Object destination, PropertyDescriptor propertyDescriptor, Object value) { - writeDirectly(destination, propertyDescriptor.getName(), value); - } - - public static void writeDirectly(Object destination, String propertyName, Object value) { - try { - Field field = findField(destination.getClass(), propertyName); - writeDirectly(destination, field, value); - } catch (NoSuchFieldException e) { - throw new ReflectionRuntimeException("Failed to write " + getQualifiedPropertyName(destination, propertyName), e); - } - } - - public static void writeDirectly(Object destination, Field field, Object value) { - Assert.notNull(destination, () -> "Destination must not be null"); - try { - withAccessibleObject(field, f -> f.set(destination, value)); - } catch (ReflectiveOperationException e) { - throw new ReflectionRuntimeException("Failed to write " + getQualifiedPropertyName(destination, field), e); - } - } - - private static Field findField(Class objectClass, String propertyName) throws NoSuchFieldException { - try { - return objectClass.getDeclaredField(propertyName); - } catch (NoSuchFieldException e) { - Class superclass = objectClass.getSuperclass(); - if (!superclass.equals(Object.class)) { - return findField(superclass, propertyName); - } - throw e; - } - } - - public static T readDirectly(Object object, PropertyDescriptor propertyDescriptor) { - return readDirectly(object, propertyDescriptor.getName()); - } - - public static T readDirectly(Object object, String propertyName) { - try { - Field field = findField(object.getClass(), propertyName); - return readDirectly(object, field); - } catch (NoSuchFieldException e) { - throw new ReflectionRuntimeException("Failed to read " + getQualifiedPropertyName(object, propertyName), e); - } - } - - public static T readDirectly(Object object, Field field) { - try { - return withAccessibleObject(field, f -> { - @SuppressWarnings("unchecked") - T value = (T) field.get(object); - return value; - }, true); - } catch (ReflectiveOperationException e) { - throw new ReflectionRuntimeException("Failed to read " + getQualifiedPropertyName(object, field), e); - } - } - - public static T read(Object source, PropertyDescriptor propertyDescriptor) { - return read(source, propertyDescriptor, false); - } - - public static T read(Object source, PropertyDescriptor propertyDescriptor, boolean force) { - final Object result; - try { - if (!isReadable(propertyDescriptor)) { - if (force) { - return readDirectly(source, propertyDescriptor); - } else { - throw new IllegalArgumentException(String.format("%s must be readable", propertyDescriptor.getName())); - } - } else { - Method readMethod = propertyDescriptor.getReadMethod(); - result = withAccessibleObject(readMethod, method -> readMethod.invoke(source), force); - } - } catch (ReflectiveOperationException | RuntimeException e) { - throw new ReflectionRuntimeException("Failed to read " + getQualifiedPropertyName(source, propertyDescriptor), e); - } - @SuppressWarnings("unchecked") - T castedResult = (T) result; - return castedResult; - } - - public static T readIfPropertyExists(Object source, String propertyName) { - PropertyDescriptor property = getPropertyDescriptorByName(source, propertyName); - if (property != null) { - return read(source, property); - } else { - return null; - } - } - - public static T readProperty(Object entity, PropertyDescriptor propertyDescriptor, Class expectedType) { - Class clazz = ClassUtils.getRealClass(entity); - String propertyName = propertyDescriptor.getName(); - Class propertyType = propertyDescriptor.getPropertyType(); - if (!expectedType.isAssignableFrom(propertyType)) { - throw new IllegalArgumentException(String.format("%s.%s is of type %s but %s is expected", clazz, propertyName, propertyType, expectedType)); - } - return PropertyUtils.read(entity, propertyDescriptor); - } - - @NotNull - public static PropertyDescriptor getPropertyDescriptor(T bean, TypedPropertyGetter propertyGetter) { - Class beanClass = ClassUtils.getRealClass(bean); - return getPropertyDescriptor(beanClass, propertyGetter); - } - - @NotNull - public static PropertyDescriptor getPropertyDescriptor(Class beanClass, TypedPropertyGetter propertyGetter) { - Method method = getMethod(beanClass, propertyGetter); - PropertyDescriptor propertyDescriptor = getPropertyDescriptorByMethod(beanClass, method); - Assert.notNull(propertyDescriptor, () -> String.format("Found no property for %s on %s", method, beanClass)); - return propertyDescriptor; - } - - @NotNull - public static String getPropertyName(Class beanClass, TypedPropertyGetter propertyGetter) { - PropertyDescriptor propertyDescriptor = getPropertyDescriptor(beanClass, propertyGetter); - return propertyDescriptor.getName(); - } - - @NotNull - public static String getPropertyName(T bean, TypedPropertyGetter propertyGetter) { - Class beanClass = ClassUtils.getRealClass(bean); - return getPropertyName(beanClass, propertyGetter); - } - - @Nullable - public static PropertyDescriptor getPropertyDescriptorByMethod(Class beanClass, Method method) { - PropertyDescriptorCache propertyDescriptorCache = getCache(beanClass); - return propertyDescriptorCache.getDescriptorByMethod(method); - } - - @Nullable - public static PropertyDescriptor getPropertyDescriptorByField(Class beanClass, Field field) { - PropertyDescriptorCache propertyDescriptorCache = getCache(beanClass); - return propertyDescriptorCache.getDescriptorByField(field); - } - - @NotNull - public static Method getMethod(Class beanClass, TypedPropertyGetter propertyGetter) { - PropertyDescriptorCache cache = getCache(beanClass); - return cache.getMethod(propertyGetter); - } - - public static Method findMethodByGetter(Class beanClass, TypedPropertyGetter propertyGetter) { - if (RecordSupport.isRecord(beanClass)) { - return RecordSupport.findMethod(beanClass, propertyGetter); - } else { - MethodCaptor methodCaptor = new MethodCaptor(); - T proxy = createProxy(beanClass, methodCaptor); - - propertyGetter.get(proxy); - - return methodCaptor.getCapturedMethod(); - } - } - - private static T createProxy(Class beanClass, MethodCaptor methodCaptor) { - Class proxyClass = getCache(beanClass).getMethodCapturingProxy(); - try { - T proxyInstance = ObjenesisHelper.newInstance(proxyClass); - writeDirectly(proxyInstance, MethodCaptor.FIELD_NAME, methodCaptor); - return proxyInstance; - } catch (IllegalAccessError e) { - throw new ReflectionRuntimeException("Failed to create proxy on " + beanClass, e); - } - } - - public static boolean hasAnnotationOfProperty(Class entityType, PropertyDescriptor descriptor, Class annotationClass) { - return getAnnotationOfProperty(entityType, descriptor, annotationClass) != null; - } - - public static A getAnnotationOfProperty(Class entityType, TypedPropertyGetter propertyGetter, Class annotationClass) { - PropertyDescriptor propertyDescriptor = getPropertyDescriptor(entityType, propertyGetter); - return getAnnotationOfProperty(entityType, propertyDescriptor, annotationClass); - } - - public static A getAnnotationOfProperty(Object object, PropertyDescriptor descriptor, Class annotationClass) { - Class objectClass = ClassUtils.getRealClass(object); - return getAnnotationOfProperty(objectClass, descriptor, annotationClass); - } - - public static A getAnnotationOfProperty(Class entityType, PropertyDescriptor descriptor, Class annotationClass) { - PropertyDescriptorCache cache = getCache(entityType); - Map descriptorsForAnnotation = cache.getDescriptorsForAnnotation(annotationClass); - return descriptorsForAnnotation.get(descriptor); - } - - public static boolean isFullyAccessible(PropertyDescriptor descriptor) { - return isReadable(descriptor) && isWritable(descriptor); - } - - public static boolean isWritable(PropertyDescriptor descriptor) { - return descriptor.getWriteMethod() != null; - } - - public static boolean isReadable(PropertyDescriptor descriptor) { - return descriptor.getReadMethod() != null; - } - - public static boolean isDeclaredInClass(PropertyDescriptor propertyDescriptor, Class entityClass) { - Method readMethod = propertyDescriptor.getReadMethod(); - return readMethod != null && Objects.equals(readMethod.getDeclaringClass(), entityClass); - } - - public static boolean hasProperty(Object bean, String propertyName) { - return getPropertyDescriptorByName(bean, propertyName) != null; - } - - public static boolean hasProperty(Class beanClass, String propertyName) { - return getPropertyDescriptorByName(beanClass, propertyName) != null; - } - - public static Object getDefaultValueObject(Class type) { - if (type.isPrimitive()) { - if (type.equals(byte.class)) { - return Byte.valueOf((byte) 0); - } else if (type.equals(char.class)) { - return Character.valueOf('\0'); - } else if (type.equals(short.class)) { - return Short.valueOf((short) 0); - } else if (type.equals(int.class)) { - return Integer.valueOf(0); - } else if (type.equals(long.class)) { - return Long.valueOf(0L); - } else if (type.equals(float.class)) { - return Float.valueOf(0.0f); - } else if (type.equals(double.class)) { - return Double.valueOf(0.0); - } else if (type.equals(boolean.class)) { - return Boolean.valueOf(false); - } else if (type.equals(void.class)) { - return null; - } else { - throw new IllegalArgumentException("Unhandled primitive type: " + type); - } - } - - return null; - } - - public static String getQualifiedPropertyName(T bean, TypedPropertyGetter propertyGetter) { - Class beanClass = ClassUtils.getRealClass(bean); - return getQualifiedPropertyName(beanClass, propertyGetter); - } - - public static String getQualifiedPropertyName(Class type, TypedPropertyGetter propertyGetter) { - PropertyDescriptor propertyDescriptor = getPropertyDescriptor(type, propertyGetter); - return getQualifiedPropertyName(type, propertyDescriptor); - } - - public static String getQualifiedPropertyName(Object bean, PropertyDescriptor propertyDescriptor) { - return getQualifiedPropertyName(ClassUtils.getRealClass(bean), propertyDescriptor); - } - - public static String getQualifiedPropertyName(Class type, PropertyDescriptor propertyDescriptor) { - return getQualifiedPropertyName(type, propertyDescriptor.getName()); - } - - public static String getQualifiedPropertyName(Class type, String name) { - return type.getSimpleName() + "." + name; - } - - static String getQualifiedPropertyName(Object bean, Field field) { - return getQualifiedPropertyName(bean, field.getName()); - } - - private static String getQualifiedPropertyName(Object bean, String name) { - return getQualifiedPropertyName(ClassUtils.getRealClass(bean), name); - } - - public static boolean isCollectionType(PropertyDescriptor propertyDescriptor) { - return Collection.class.isAssignableFrom(propertyDescriptor.getPropertyType()); - } - - public static boolean isNotCollectionType(PropertyDescriptor propertyDescriptor) { - return !isCollectionType(propertyDescriptor); - } - - private interface AccessibleObjectFunction { - R access(T object) throws ReflectiveOperationException; - } - - private interface AccessibleObjectConsumer { - void access(T object) throws ReflectiveOperationException; - } - - private static void withAccessibleObject(T accessibleObject, AccessibleObjectConsumer accessibleObjectConsumer) throws ReflectiveOperationException { - withAccessibleObject(accessibleObject, obj -> { - accessibleObjectConsumer.access(obj); - return null; - }, true); - } - - private static R withAccessibleObject(T accessibleObject, AccessibleObjectFunction function, boolean force) throws ReflectiveOperationException { - boolean accessible = accessibleObject.isAccessible(); - try { - if (force && !accessible) { - accessibleObject.setAccessible(true); - } - return function.access(accessibleObject); - } finally { - if (force && !accessible) { - accessibleObject.setAccessible(false); - } - } - } - - @VisibleForTesting - static void removeClassFromCache(Class type) { - cache.remove(type); - } - + private static final ClassValue> cache = + ClassValues.create(PropertyDescriptorCache::new); + + private PropertyUtils() {} + + @Nullable + public static PropertyDescriptor getPropertyDescriptorByName(Object bean, String propertyName) { + return getPropertyDescriptorByName(ClassUtils.getRealClass(bean), propertyName); + } + + @Nullable + public static PropertyDescriptor getPropertyDescriptorByName( + Class beanClass, String propertyName) { + PropertyDescriptorCache propertyDescriptorCache = getCache(beanClass); + return propertyDescriptorCache.getDescriptorByName(propertyName); + } + + @NotNull + public static PropertyDescriptor getPropertyDescriptorByNameOrThrow( + Object bean, String propertyName) { + Class beanClass = ClassUtils.getRealClass(bean); + return getPropertyDescriptorByNameOrThrow(beanClass, propertyName); + } + + @NotNull + public static PropertyDescriptor getPropertyDescriptorByNameOrThrow( + Class beanClass, String propertyName) { + PropertyDescriptor propertyDescriptor = getPropertyDescriptorByName(beanClass, propertyName); + Assert.notNull( + propertyDescriptor, + () -> + String.format( + "Property '%s' not found for '%s'", propertyName, beanClass.getSimpleName())); + return propertyDescriptor; + } + + public static Collection getPropertyDescriptors(Class type) { + PropertyDescriptorCache propertyDescriptorCache = getCache(type); + return propertyDescriptorCache.getDescriptors(); + } + + public static Collection getPropertyDescriptors(Object object) { + return getPropertyDescriptors(ClassUtils.getRealClass(object)); + } + + public static + Map getPropertyDescriptorsWithAnnotation( + Object object, Class annotationClass) { + Class objectClass = ClassUtils.getRealClass(object); + return getPropertyDescriptorsWithAnnotation(objectClass, annotationClass); + } + + public static + Map getPropertyDescriptorsWithAnnotation( + Class type, Class annotationClass) { + PropertyDescriptorCache propertyDescriptorCache = getCache(type); + return propertyDescriptorCache.getDescriptorsForAnnotation(annotationClass); + } + + @SuppressWarnings("unchecked") + static PropertyDescriptorCache getCache(Class type) { + return (PropertyDescriptorCache) cache.get(type); + } + + public static T copyNonDefaultValues(T source, T destination) { + return copyNonDefaultValues(source, destination, Collections.emptySet()); + } + + public static T copyNonDefaultValues( + T source, T destination, PropertyDescriptor... excludedProperties) { + return copyNonDefaultValues( + source, destination, Stream.of(excludedProperties).collect(Collectors.toSet())); + } + + public static T copyNonDefaultValues( + T source, T destination, Collection excludedProperties) { + getPropertyDescriptors(source).stream() + .filter(property -> !excludedProperties.contains(property)) + .filter(PropertyUtils::isFullyAccessible) + .filter(propertyDescriptor -> !hasDefaultValue(source, propertyDescriptor)) + .forEach(propertyDescriptor -> copyValue(source, destination, propertyDescriptor)); + return destination; + } + + public static Object copyValue( + T source, T destination, PropertyDescriptor propertyDescriptor) { + Object value = read(source, propertyDescriptor); + write(destination, propertyDescriptor, value); + return value; + } + + public static boolean hasDefaultValue(T bean, PropertyDescriptor propertyDescriptor) { + Object value = read(bean, propertyDescriptor); + Class beanClass = ClassUtils.getRealClass(bean); + return isDefaultValue(beanClass, propertyDescriptor, value); + } + + public static boolean hasSameValue(T a, T b, PropertyDescriptor propertyDescriptor) { + Object valueFromA = read(a, propertyDescriptor); + Object valueFromB = read(b, propertyDescriptor); + return Objects.equals(valueFromA, valueFromB); + } + + public static boolean hasDifferentValue(T a, T b, PropertyDescriptor propertyDescriptor) { + return !hasSameValue(a, b, propertyDescriptor); + } + + public static boolean isDefaultValue( + Class objectClass, TypedPropertyGetter propertyGetter, Object value) { + return isDefaultValue(objectClass, getPropertyDescriptor(objectClass, propertyGetter), value); + } + + public static boolean isDefaultValue( + Class objectClass, PropertyDescriptor propertyDescriptor, Object value) { + Object defaultValue = getDefaultValue(objectClass, propertyDescriptor); + if (defaultValue instanceof Float && value instanceof Float) { + return (float) defaultValue == (float) value; + } else if (defaultValue instanceof Double && value instanceof Double) { + return (double) defaultValue == (double) value; + } else { + return Objects.equals(value, defaultValue); + } + } + + public static Object getDefaultValue( + Class objectClass, PropertyDescriptor propertyDescriptor) { + return getCache(objectClass).getDefaultValue(propertyDescriptor); + } + + public static void write(Object destination, String propertyName, Object value) { + PropertyDescriptor propertyDescriptor = + getPropertyDescriptorByNameOrThrow(destination, propertyName); + write(destination, propertyDescriptor, value); + } + + public static void writeIfPropertyExists( + Object destination, String propertyName, Supplier valueSupplier) { + PropertyDescriptor property = getPropertyDescriptorByName(destination, propertyName); + if (property != null) { + T value = valueSupplier.get(); + write(destination, property, value); + } + } + + public static void write( + Object destination, PropertyDescriptor propertyDescriptor, Object value) { + write(destination, propertyDescriptor, value, false); + } + + public static void write( + Object destination, PropertyDescriptor propertyDescriptor, Object value, boolean force) { + try { + if (!isWritable(propertyDescriptor)) { + if (force) { + writeDirectly(destination, propertyDescriptor, value); + } else { + throw new IllegalArgumentException(propertyDescriptor.getName() + " is not writable"); + } + } else { + Object[] args = new Object[] {value}; + Method writeMethod = propertyDescriptor.getWriteMethod(); + withAccessibleObject(writeMethod, method -> method.invoke(destination, args), force); + } + } catch (ReflectiveOperationException | RuntimeException e) { + throw new ReflectionRuntimeException( + "Failed to write " + getQualifiedPropertyName(destination, propertyDescriptor), e); + } + } + + public static void writeDirectly( + Object destination, PropertyDescriptor propertyDescriptor, Object value) { + writeDirectly(destination, propertyDescriptor.getName(), value); + } + + public static void writeDirectly(Object destination, String propertyName, Object value) { + try { + Field field = findField(destination.getClass(), propertyName); + writeDirectly(destination, field, value); + } catch (NoSuchFieldException e) { + throw new ReflectionRuntimeException( + "Failed to write " + getQualifiedPropertyName(destination, propertyName), e); + } + } + + public static void writeDirectly(Object destination, Field field, Object value) { + Assert.notNull(destination, () -> "Destination must not be null"); + try { + withAccessibleObject(field, f -> f.set(destination, value)); + } catch (ReflectiveOperationException e) { + throw new ReflectionRuntimeException( + "Failed to write " + getQualifiedPropertyName(destination, field), e); + } + } + + private static Field findField(Class objectClass, String propertyName) + throws NoSuchFieldException { + try { + return objectClass.getDeclaredField(propertyName); + } catch (NoSuchFieldException e) { + Class superclass = objectClass.getSuperclass(); + if (!superclass.equals(Object.class)) { + return findField(superclass, propertyName); + } + throw e; + } + } + + public static T readDirectly(Object object, PropertyDescriptor propertyDescriptor) { + return readDirectly(object, propertyDescriptor.getName()); + } + + public static T readDirectly(Object object, String propertyName) { + try { + Field field = findField(object.getClass(), propertyName); + return readDirectly(object, field); + } catch (NoSuchFieldException e) { + throw new ReflectionRuntimeException( + "Failed to read " + getQualifiedPropertyName(object, propertyName), e); + } + } + + public static T readDirectly(Object object, Field field) { + try { + return withAccessibleObject( + field, + f -> { + @SuppressWarnings("unchecked") + T value = (T) field.get(object); + return value; + }, + true); + } catch (ReflectiveOperationException e) { + throw new ReflectionRuntimeException( + "Failed to read " + getQualifiedPropertyName(object, field), e); + } + } + + public static T read(Object source, PropertyDescriptor propertyDescriptor) { + return read(source, propertyDescriptor, false); + } + + public static T read(Object source, PropertyDescriptor propertyDescriptor, boolean force) { + final Object result; + try { + if (!isReadable(propertyDescriptor)) { + if (force) { + return readDirectly(source, propertyDescriptor); + } else { + throw new IllegalArgumentException( + String.format("%s must be readable", propertyDescriptor.getName())); + } + } else { + Method readMethod = propertyDescriptor.getReadMethod(); + result = withAccessibleObject(readMethod, method -> readMethod.invoke(source), force); + } + } catch (ReflectiveOperationException | RuntimeException e) { + throw new ReflectionRuntimeException( + "Failed to read " + getQualifiedPropertyName(source, propertyDescriptor), e); + } + @SuppressWarnings("unchecked") + T castedResult = (T) result; + return castedResult; + } + + public static T readIfPropertyExists(Object source, String propertyName) { + PropertyDescriptor property = getPropertyDescriptorByName(source, propertyName); + if (property != null) { + return read(source, property); + } else { + return null; + } + } + + public static T readProperty( + Object entity, PropertyDescriptor propertyDescriptor, Class expectedType) { + Class clazz = ClassUtils.getRealClass(entity); + String propertyName = propertyDescriptor.getName(); + Class propertyType = propertyDescriptor.getPropertyType(); + if (!expectedType.isAssignableFrom(propertyType)) { + throw new IllegalArgumentException( + String.format( + "%s.%s is of type %s but %s is expected", + clazz, propertyName, propertyType, expectedType)); + } + return PropertyUtils.read(entity, propertyDescriptor); + } + + @NotNull + public static PropertyDescriptor getPropertyDescriptor( + T bean, TypedPropertyGetter propertyGetter) { + Class beanClass = ClassUtils.getRealClass(bean); + return getPropertyDescriptor(beanClass, propertyGetter); + } + + @NotNull + public static PropertyDescriptor getPropertyDescriptor( + Class beanClass, TypedPropertyGetter propertyGetter) { + Method method = getMethod(beanClass, propertyGetter); + PropertyDescriptor propertyDescriptor = getPropertyDescriptorByMethod(beanClass, method); + Assert.notNull( + propertyDescriptor, + () -> String.format("Found no property for %s on %s", method, beanClass)); + return propertyDescriptor; + } + + @NotNull + public static String getPropertyName( + Class beanClass, TypedPropertyGetter propertyGetter) { + PropertyDescriptor propertyDescriptor = getPropertyDescriptor(beanClass, propertyGetter); + return propertyDescriptor.getName(); + } + + @NotNull + public static String getPropertyName(T bean, TypedPropertyGetter propertyGetter) { + Class beanClass = ClassUtils.getRealClass(bean); + return getPropertyName(beanClass, propertyGetter); + } + + @Nullable + public static PropertyDescriptor getPropertyDescriptorByMethod( + Class beanClass, Method method) { + PropertyDescriptorCache propertyDescriptorCache = getCache(beanClass); + return propertyDescriptorCache.getDescriptorByMethod(method); + } + + @Nullable + public static PropertyDescriptor getPropertyDescriptorByField( + Class beanClass, Field field) { + PropertyDescriptorCache propertyDescriptorCache = getCache(beanClass); + return propertyDescriptorCache.getDescriptorByField(field); + } + + @NotNull + public static Method getMethod(Class beanClass, TypedPropertyGetter propertyGetter) { + PropertyDescriptorCache cache = getCache(beanClass); + return cache.getMethod(propertyGetter); + } + + public static Method findMethodByGetter( + Class beanClass, TypedPropertyGetter propertyGetter) { + if (RecordSupport.isRecord(beanClass)) { + return RecordSupport.findMethod(beanClass, propertyGetter); + } else { + MethodCaptor methodCaptor = new MethodCaptor(); + T proxy = createProxy(beanClass, methodCaptor); + + propertyGetter.get(proxy); + + return methodCaptor.getCapturedMethod(); + } + } + + private static T createProxy(Class beanClass, MethodCaptor methodCaptor) { + Class proxyClass = getCache(beanClass).getMethodCapturingProxy(); + try { + T proxyInstance = ObjenesisHelper.newInstance(proxyClass); + writeDirectly(proxyInstance, MethodCaptor.FIELD_NAME, methodCaptor); + return proxyInstance; + } catch (IllegalAccessError e) { + throw new ReflectionRuntimeException("Failed to create proxy on " + beanClass, e); + } + } + + public static boolean hasAnnotationOfProperty( + Class entityType, + PropertyDescriptor descriptor, + Class annotationClass) { + return getAnnotationOfProperty(entityType, descriptor, annotationClass) != null; + } + + public static A getAnnotationOfProperty( + Class entityType, TypedPropertyGetter propertyGetter, Class annotationClass) { + PropertyDescriptor propertyDescriptor = getPropertyDescriptor(entityType, propertyGetter); + return getAnnotationOfProperty(entityType, propertyDescriptor, annotationClass); + } + + public static A getAnnotationOfProperty( + Object object, PropertyDescriptor descriptor, Class annotationClass) { + Class objectClass = ClassUtils.getRealClass(object); + return getAnnotationOfProperty(objectClass, descriptor, annotationClass); + } + + public static A getAnnotationOfProperty( + Class entityType, PropertyDescriptor descriptor, Class annotationClass) { + PropertyDescriptorCache cache = getCache(entityType); + Map descriptorsForAnnotation = + cache.getDescriptorsForAnnotation(annotationClass); + return descriptorsForAnnotation.get(descriptor); + } + + public static boolean isFullyAccessible(PropertyDescriptor descriptor) { + return isReadable(descriptor) && isWritable(descriptor); + } + + public static boolean isWritable(PropertyDescriptor descriptor) { + return descriptor.getWriteMethod() != null; + } + + public static boolean isReadable(PropertyDescriptor descriptor) { + return descriptor.getReadMethod() != null; + } + + public static boolean isDeclaredInClass( + PropertyDescriptor propertyDescriptor, Class entityClass) { + Method readMethod = propertyDescriptor.getReadMethod(); + return readMethod != null && Objects.equals(readMethod.getDeclaringClass(), entityClass); + } + + public static boolean hasProperty(Object bean, String propertyName) { + return getPropertyDescriptorByName(bean, propertyName) != null; + } + + public static boolean hasProperty(Class beanClass, String propertyName) { + return getPropertyDescriptorByName(beanClass, propertyName) != null; + } + + public static Object getDefaultValueObject(Class type) { + if (type.isPrimitive()) { + if (type.equals(byte.class)) { + return Byte.valueOf((byte) 0); + } else if (type.equals(char.class)) { + return Character.valueOf('\0'); + } else if (type.equals(short.class)) { + return Short.valueOf((short) 0); + } else if (type.equals(int.class)) { + return Integer.valueOf(0); + } else if (type.equals(long.class)) { + return Long.valueOf(0L); + } else if (type.equals(float.class)) { + return Float.valueOf(0.0f); + } else if (type.equals(double.class)) { + return Double.valueOf(0.0); + } else if (type.equals(boolean.class)) { + return Boolean.valueOf(false); + } else if (type.equals(void.class)) { + return null; + } else { + throw new IllegalArgumentException("Unhandled primitive type: " + type); + } + } + + return null; + } + + public static String getQualifiedPropertyName( + T bean, TypedPropertyGetter propertyGetter) { + Class beanClass = ClassUtils.getRealClass(bean); + return getQualifiedPropertyName(beanClass, propertyGetter); + } + + public static String getQualifiedPropertyName( + Class type, TypedPropertyGetter propertyGetter) { + PropertyDescriptor propertyDescriptor = getPropertyDescriptor(type, propertyGetter); + return getQualifiedPropertyName(type, propertyDescriptor); + } + + public static String getQualifiedPropertyName( + Object bean, PropertyDescriptor propertyDescriptor) { + return getQualifiedPropertyName(ClassUtils.getRealClass(bean), propertyDescriptor); + } + + public static String getQualifiedPropertyName( + Class type, PropertyDescriptor propertyDescriptor) { + return getQualifiedPropertyName(type, propertyDescriptor.getName()); + } + + public static String getQualifiedPropertyName(Class type, String name) { + return type.getSimpleName() + "." + name; + } + + static String getQualifiedPropertyName(Object bean, Field field) { + return getQualifiedPropertyName(bean, field.getName()); + } + + private static String getQualifiedPropertyName(Object bean, String name) { + return getQualifiedPropertyName(ClassUtils.getRealClass(bean), name); + } + + public static boolean isCollectionType(PropertyDescriptor propertyDescriptor) { + return Collection.class.isAssignableFrom(propertyDescriptor.getPropertyType()); + } + + public static boolean isNotCollectionType(PropertyDescriptor propertyDescriptor) { + return !isCollectionType(propertyDescriptor); + } + + private interface AccessibleObjectFunction { + R access(T object) throws ReflectiveOperationException; + } + + private interface AccessibleObjectConsumer { + void access(T object) throws ReflectiveOperationException; + } + + private static void withAccessibleObject( + T accessibleObject, AccessibleObjectConsumer accessibleObjectConsumer) + throws ReflectiveOperationException { + withAccessibleObject( + accessibleObject, + obj -> { + accessibleObjectConsumer.access(obj); + return null; + }, + true); + } + + private static R withAccessibleObject( + T accessibleObject, AccessibleObjectFunction function, boolean force) + throws ReflectiveOperationException { + boolean accessible = accessibleObject.isAccessible(); + try { + if (force && !accessible) { + accessibleObject.setAccessible(true); + } + return function.access(accessibleObject); + } finally { + if (force && !accessible) { + accessibleObject.setAccessible(false); + } + } + } + + @VisibleForTesting + static void removeClassFromCache(Class type) { + cache.remove(type); + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/RecordSupport.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/RecordSupport.java index 4f9997a..d8d92bf 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/RecordSupport.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/RecordSupport.java @@ -16,296 +16,319 @@ import java.util.function.Function; import java.util.stream.Collectors; import java.util.stream.Stream; - +import net.bytebuddy.ByteBuddy; import org.jetbrains.annotations.VisibleForTesting; import org.objenesis.ObjenesisHelper; -import net.bytebuddy.ByteBuddy; - final class RecordSupport { - private static volatile boolean currentJvmIsKnownNotToSupportRecords = false; - private static WeakReference> cachedRecordClass = new WeakReference<>(null); - - private static final ClassValue> dummySubclasses = ClassValues.create(RecordSupport::createDummyProxyClass); - - private RecordSupport() { - } - - private static Class createDummyProxyClass(Class type) { - return new ByteBuddy() - .subclass(type) - .make() - .load(RecordSupport.class.getClassLoader()) - .getLoaded(); - } - - static boolean isRecord(Object bean) { - return isRecord(bean.getClass()); - } - - static boolean isRecord(Class beanClass) { - if (currentJvmIsKnownNotToSupportRecords) { - return false; - } - try { - Class recordClass = getRecordClass(); - return recordClass.isAssignableFrom(beanClass); - } catch (ClassNotFoundException e) { - currentJvmIsKnownNotToSupportRecords = true; - return false; - } - } - - private static Class getRecordClass() throws ClassNotFoundException { - Class recordClass = cachedRecordClass.get(); - if (recordClass == null) { - recordClass = Class.forName("java.lang.Record"); - cachedRecordClass = new WeakReference<>(recordClass); - } - return recordClass; - } - - static class RecordComponentInfo { - private final String name; - private final Class type; - private final Method accessor; - - RecordComponentInfo(String name, Class type, Method accessor) { - this.name = name; - this.type = type; - this.accessor = accessor; - } - - public String getName() { - return name; - } - - public Class getType() { - return type; - } - - public Method getAccessor() { - return accessor; - } - - public Object retrieveValueFrom(Object record) { - try { - return accessor.invoke(record); - } catch (ReflectiveOperationException e) { - throw new ReflectionRuntimeException(e); - } - } - } - - static Method findMethod(Class recordClass, TypedPropertyGetter componentAccessor) { - Object[] uniqueValues = buildUniqueValues(recordClass); - try { - Constructor recordConstructor = getRecordConstructor(recordClass); - T record = ClassUtils.createInstance(recordConstructor, uniqueValues); - - Object value = componentAccessor.get(record); - - if (needsFallbackToComponentSearch(uniqueValues, value)) { - return exhaustiveComponentSearch(value, recordClass, componentAccessor, uniqueValues, recordConstructor); - } - - int componentIndex = ArrayUtils.indexOf(uniqueValues, value); - Assert.isTrue(componentIndex >= 0, - () -> "Failed to find a component in " + recordClass.getName() + " for the given component accessor."); - return getRecordComponentAccessor(recordClass, componentIndex); - } catch (ReflectiveOperationException e) { - throw new ReflectionRuntimeException(e); - } - } - - static Stream getRecordComponents(Class recordClass) { - Assert.isTrue(isRecord(recordClass), () -> recordClass + " is not a record"); - Object[] recordComponents = invokeMethod(recordClass, "getRecordComponents"); - return Arrays.stream(recordComponents) - .map(recordComponent -> { - String name = invokeMethod(recordComponent, "getName"); - Class type = invokeMethod(recordComponent, "getType"); - Method accessor = invokeMethod(recordComponent, "getAccessor"); - return new RecordComponentInfo(name, type, accessor); - }); - } - - private static T invokeMethod(Object object, String methodName) { - try { - Method method = object.getClass().getMethod(methodName); - return (T) method.invoke(object); - } catch (ReflectiveOperationException e) { - throw new ReflectionRuntimeException(e); - } - } - - static Constructor getRecordConstructor(Class recordClass) throws NoSuchMethodException { - Class[] constructorTypes = getRecordComponents(recordClass) - .map(RecordComponentInfo::getType) - .toArray(Class[]::new); - return recordClass.getDeclaredConstructor(constructorTypes); - } - - private static Object[] buildUniqueValues(Class recordClass) { - return getRecordComponents(recordClass) - .map(RecordComponentInfo::getType) - .map(uniqueValueBuilder()) - .toArray(Object[]::new); - } - - private static Function, Object> uniqueValueBuilder() { - Map, Long> index = new IdentityHashMap<>(); - return type -> { - if (type.isAssignableFrom(boolean.class)) { - // Note: When the record has more than one primitive boolean component, - // we need to fall back to an exhaustive component search via exhaustiveComponentSearch(…) - return true; - } else if (type.isPrimitive() || type.isAssignableFrom(String.class) || Number.class.isAssignableFrom(type)) { - long currentIndex = index.compute(type, (k, value) -> value == null ? 1L : value + 1L); - if (type.isAssignableFrom(String.class)) { - return String.valueOf(currentIndex); - } else if (type.equals(byte.class) || type.equals(Byte.class)) { - return safeNumberCast(currentIndex, (byte) currentIndex); - } else if (type.equals(short.class) || type.equals(Short.class)) { - return safeNumberCast(currentIndex, (short) currentIndex); - } else if (type.equals(int.class) || type.equals(Integer.class)) { - return safeNumberCast(currentIndex, (int) currentIndex); - } else if (type.equals(long.class) || type.equals(Long.class)) { - return currentIndex; - } else if (type.equals(float.class) || type.equals(Float.class)) { - return safeNumberCast(currentIndex, (float) currentIndex); - } else if (type.equals(double.class) || type.equals(Double.class)) { - return safeNumberCast(currentIndex, (double) currentIndex); - } else if (type.equals(char.class)) { - return safeNumberCast(currentIndex, (char) currentIndex); - } - } - - if (type.isInterface() || Modifier.isAbstract(type.getModifiers())) { - Class dummyClass = dummySubclasses.get(type); - return ObjenesisHelper.newInstance(dummyClass); - } - return ObjenesisHelper.newInstance(type); - }; - } - - private static T safeNumberCast(long currentIndex, T castedValue) { - return safeNumberCast(currentIndex, castedValue, castedValue.longValue(), castedValue.getClass()); - } - - private static char safeNumberCast(long currentIndex, char castedValue) { - return safeNumberCast(currentIndex, castedValue, castedValue, char.class); - } - - private static T safeNumberCast(long currentIndex, T castedValue, long castedValueAsLong, Class valueType) { - // This is currently not possible to test since a record must not have more than 255 components - Assert.isTrue(castedValueAsLong == currentIndex, - () -> "Having more than " + (currentIndex - 1) + " record components of type " - + valueType.getName() + " is currently not supported"); - return castedValue; - } - - private static Method exhaustiveComponentSearch(Object currentValue, Class recordClass, - TypedPropertyGetter componentAccessor, - Object[] uniqueValues, - Constructor recordConstructor) throws ReflectiveOperationException { - Object[] values = Arrays.copyOf(uniqueValues, uniqueValues.length); - - int nextIndex; - while ((nextIndex = ArrayUtils.indexOf(values, currentValue)) >= 0) { - values[nextIndex] = getDefaultValue(currentValue); - T record = ClassUtils.createInstance(recordConstructor, values); - Object value = componentAccessor.get(record); - if (value == values[nextIndex]) { - return getRecordComponentAccessor(recordClass, nextIndex); - } - } - throw new IllegalArgumentException("Failed to find the component of type " + currentValue.getClass().getName() - + " in the record " + recordClass.getName() - + " using the provided component accessor."); - } - - private static Method getRecordComponentAccessor(Class recordClass, int componentIndex) { - return getRecordComponents(recordClass) - .skip(componentIndex) - .findFirst() - .map(RecordComponentInfo::getAccessor) - .orElseThrow(IllegalStateException::new); - } - - private static Object getDefaultValue(Object value) { - Assert.isTrue(value instanceof Boolean, () -> "This is currently only expected to happen for boolean types"); - return false; - } - - private static boolean needsFallbackToComponentSearch(Object[] uniqueValues, Object value) { - if (!(value instanceof Boolean)) { - return false; - } - int firstIndex = ArrayUtils.indexOf(uniqueValues, value); - int lastIndex = ArrayUtils.lastIndexOf(uniqueValues, value); - return firstIndex != lastIndex; - } - - static Collection collectPropertyDescriptorsOfRecord(Class type) { - return Stream.concat( - Stream.of(getPropertyDescriptorsOfObject()), - getRecordComponents(type) - .map(recordComponent -> toPropertyDescriptor(type, recordComponent))) - .collect(Collectors.toList()); - } - - private static PropertyDescriptor getPropertyDescriptorsOfObject() { - try { - BeanInfo beanInfo = Introspector.getBeanInfo(Object.class); - PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); - Assert.isTrue(propertyDescriptors.length == 1, - () -> "Expected one property descriptor but got " + propertyDescriptors.length); - return propertyDescriptors[0]; - } catch (IntrospectionException e) { - throw new ReflectionRuntimeException(e); - } - } - - private static PropertyDescriptor toPropertyDescriptor(Class type, RecordComponentInfo recordComponent) { - try { - return new PropertyDescriptor(recordComponent.getName(), type, recordComponent.getAccessor().getName(), null); - } catch (IntrospectionException e) { - throw new ReflectionRuntimeException(e); - } - } - - @VisibleForTesting - static final class ArrayUtils { - - private ArrayUtils() { - } - - static int indexOf(Object[] values, Object valueToFind) { - for (int i = 0; i < values.length; i++) { - if (areTheSame(values[i], valueToFind)) { - return i; - } - } - return -1; - } - - static int lastIndexOf(Object[] values, Object valueToFind) { - for (int i = values.length - 1; i >= 0; i--) { - if (areTheSame(values[i], valueToFind)) { - return i; - } - } - return -1; - } - - private static boolean areTheSame(Object one, Object other) { - if (one instanceof Float || one instanceof Double) { - return Objects.equals(one, other); - } - return one == other; - } - } - + private static volatile boolean currentJvmIsKnownNotToSupportRecords = false; + private static WeakReference> cachedRecordClass = new WeakReference<>(null); + + private static final ClassValue> dummySubclasses = + ClassValues.create(RecordSupport::createDummyProxyClass); + + private RecordSupport() {} + + private static Class createDummyProxyClass(Class type) { + return new ByteBuddy() + .subclass(type) + .make() + .load(RecordSupport.class.getClassLoader()) + .getLoaded(); + } + + static boolean isRecord(Object bean) { + return isRecord(bean.getClass()); + } + + static boolean isRecord(Class beanClass) { + if (currentJvmIsKnownNotToSupportRecords) { + return false; + } + try { + Class recordClass = getRecordClass(); + return recordClass.isAssignableFrom(beanClass); + } catch (ClassNotFoundException e) { + currentJvmIsKnownNotToSupportRecords = true; + return false; + } + } + + private static Class getRecordClass() throws ClassNotFoundException { + Class recordClass = cachedRecordClass.get(); + if (recordClass == null) { + recordClass = Class.forName("java.lang.Record"); + cachedRecordClass = new WeakReference<>(recordClass); + } + return recordClass; + } + + static class RecordComponentInfo { + private final String name; + private final Class type; + private final Method accessor; + + RecordComponentInfo(String name, Class type, Method accessor) { + this.name = name; + this.type = type; + this.accessor = accessor; + } + + public String getName() { + return name; + } + + public Class getType() { + return type; + } + + public Method getAccessor() { + return accessor; + } + + public Object retrieveValueFrom(Object record) { + try { + return accessor.invoke(record); + } catch (ReflectiveOperationException e) { + throw new ReflectionRuntimeException(e); + } + } + } + + static Method findMethod(Class recordClass, TypedPropertyGetter componentAccessor) { + Object[] uniqueValues = buildUniqueValues(recordClass); + try { + Constructor recordConstructor = getRecordConstructor(recordClass); + T record = ClassUtils.createInstance(recordConstructor, uniqueValues); + + Object value = componentAccessor.get(record); + + if (needsFallbackToComponentSearch(uniqueValues, value)) { + return exhaustiveComponentSearch( + value, recordClass, componentAccessor, uniqueValues, recordConstructor); + } + + int componentIndex = ArrayUtils.indexOf(uniqueValues, value); + Assert.isTrue( + componentIndex >= 0, + () -> + "Failed to find a component in " + + recordClass.getName() + + " for the given component accessor."); + return getRecordComponentAccessor(recordClass, componentIndex); + } catch (ReflectiveOperationException e) { + throw new ReflectionRuntimeException(e); + } + } + + static Stream getRecordComponents(Class recordClass) { + Assert.isTrue(isRecord(recordClass), () -> recordClass + " is not a record"); + Object[] recordComponents = invokeMethod(recordClass, "getRecordComponents"); + return Arrays.stream(recordComponents) + .map( + recordComponent -> { + String name = invokeMethod(recordComponent, "getName"); + Class type = invokeMethod(recordComponent, "getType"); + Method accessor = invokeMethod(recordComponent, "getAccessor"); + return new RecordComponentInfo(name, type, accessor); + }); + } + + private static T invokeMethod(Object object, String methodName) { + try { + Method method = object.getClass().getMethod(methodName); + return (T) method.invoke(object); + } catch (ReflectiveOperationException e) { + throw new ReflectionRuntimeException(e); + } + } + + static Constructor getRecordConstructor(Class recordClass) + throws NoSuchMethodException { + Class[] constructorTypes = + getRecordComponents(recordClass).map(RecordComponentInfo::getType).toArray(Class[]::new); + return recordClass.getDeclaredConstructor(constructorTypes); + } + + private static Object[] buildUniqueValues(Class recordClass) { + return getRecordComponents(recordClass) + .map(RecordComponentInfo::getType) + .map(uniqueValueBuilder()) + .toArray(Object[]::new); + } + + private static Function, Object> uniqueValueBuilder() { + Map, Long> index = new IdentityHashMap<>(); + return type -> { + if (type.isAssignableFrom(boolean.class)) { + // Note: When the record has more than one primitive boolean component, + // we need to fall back to an exhaustive component search via + // exhaustiveComponentSearch(…) + return true; + } else if (type.isPrimitive() + || type.isAssignableFrom(String.class) + || Number.class.isAssignableFrom(type)) { + long currentIndex = index.compute(type, (k, value) -> value == null ? 1L : value + 1L); + if (type.isAssignableFrom(String.class)) { + return String.valueOf(currentIndex); + } else if (type.equals(byte.class) || type.equals(Byte.class)) { + return safeNumberCast(currentIndex, (byte) currentIndex); + } else if (type.equals(short.class) || type.equals(Short.class)) { + return safeNumberCast(currentIndex, (short) currentIndex); + } else if (type.equals(int.class) || type.equals(Integer.class)) { + return safeNumberCast(currentIndex, (int) currentIndex); + } else if (type.equals(long.class) || type.equals(Long.class)) { + return currentIndex; + } else if (type.equals(float.class) || type.equals(Float.class)) { + return safeNumberCast(currentIndex, (float) currentIndex); + } else if (type.equals(double.class) || type.equals(Double.class)) { + return safeNumberCast(currentIndex, (double) currentIndex); + } else if (type.equals(char.class)) { + return safeNumberCast(currentIndex, (char) currentIndex); + } + } + + if (type.isInterface() || Modifier.isAbstract(type.getModifiers())) { + Class dummyClass = dummySubclasses.get(type); + return ObjenesisHelper.newInstance(dummyClass); + } + return ObjenesisHelper.newInstance(type); + }; + } + + private static T safeNumberCast(long currentIndex, T castedValue) { + return safeNumberCast( + currentIndex, castedValue, castedValue.longValue(), castedValue.getClass()); + } + + private static char safeNumberCast(long currentIndex, char castedValue) { + return safeNumberCast(currentIndex, castedValue, castedValue, char.class); + } + + private static T safeNumberCast( + long currentIndex, T castedValue, long castedValueAsLong, Class valueType) { + // This is currently not possible to test since a record must not have more than 255 components + Assert.isTrue( + castedValueAsLong == currentIndex, + () -> + "Having more than " + + (currentIndex - 1) + + " record components of type " + + valueType.getName() + + " is currently not supported"); + return castedValue; + } + + private static Method exhaustiveComponentSearch( + Object currentValue, + Class recordClass, + TypedPropertyGetter componentAccessor, + Object[] uniqueValues, + Constructor recordConstructor) + throws ReflectiveOperationException { + Object[] values = Arrays.copyOf(uniqueValues, uniqueValues.length); + + int nextIndex; + while ((nextIndex = ArrayUtils.indexOf(values, currentValue)) >= 0) { + values[nextIndex] = getDefaultValue(currentValue); + T record = ClassUtils.createInstance(recordConstructor, values); + Object value = componentAccessor.get(record); + if (value == values[nextIndex]) { + return getRecordComponentAccessor(recordClass, nextIndex); + } + } + throw new IllegalArgumentException( + "Failed to find the component of type " + + currentValue.getClass().getName() + + " in the record " + + recordClass.getName() + + " using the provided component accessor."); + } + + private static Method getRecordComponentAccessor(Class recordClass, int componentIndex) { + return getRecordComponents(recordClass) + .skip(componentIndex) + .findFirst() + .map(RecordComponentInfo::getAccessor) + .orElseThrow(IllegalStateException::new); + } + + private static Object getDefaultValue(Object value) { + Assert.isTrue( + value instanceof Boolean, + () -> "This is currently only expected to happen for boolean types"); + return false; + } + + private static boolean needsFallbackToComponentSearch(Object[] uniqueValues, Object value) { + if (!(value instanceof Boolean)) { + return false; + } + int firstIndex = ArrayUtils.indexOf(uniqueValues, value); + int lastIndex = ArrayUtils.lastIndexOf(uniqueValues, value); + return firstIndex != lastIndex; + } + + static Collection collectPropertyDescriptorsOfRecord(Class type) { + return Stream.concat( + Stream.of(getPropertyDescriptorsOfObject()), + getRecordComponents(type) + .map(recordComponent -> toPropertyDescriptor(type, recordComponent))) + .collect(Collectors.toList()); + } + + private static PropertyDescriptor getPropertyDescriptorsOfObject() { + try { + BeanInfo beanInfo = Introspector.getBeanInfo(Object.class); + PropertyDescriptor[] propertyDescriptors = beanInfo.getPropertyDescriptors(); + Assert.isTrue( + propertyDescriptors.length == 1, + () -> "Expected one property descriptor but got " + propertyDescriptors.length); + return propertyDescriptors[0]; + } catch (IntrospectionException e) { + throw new ReflectionRuntimeException(e); + } + } + + private static PropertyDescriptor toPropertyDescriptor( + Class type, RecordComponentInfo recordComponent) { + try { + return new PropertyDescriptor( + recordComponent.getName(), type, recordComponent.getAccessor().getName(), null); + } catch (IntrospectionException e) { + throw new ReflectionRuntimeException(e); + } + } + + @VisibleForTesting + static final class ArrayUtils { + + private ArrayUtils() {} + + static int indexOf(Object[] values, Object valueToFind) { + for (int i = 0; i < values.length; i++) { + if (areTheSame(values[i], valueToFind)) { + return i; + } + } + return -1; + } + + static int lastIndexOf(Object[] values, Object valueToFind) { + for (int i = values.length - 1; i >= 0; i--) { + if (areTheSame(values[i], valueToFind)) { + return i; + } + } + return -1; + } + + private static boolean areTheSame(Object one, Object other) { + if (one instanceof Float || one instanceof Double) { + return Objects.equals(one, other); + } + return one == other; + } + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/RecordUtils.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/RecordUtils.java index b48402b..576d148 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/RecordUtils.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/RecordUtils.java @@ -1,36 +1,41 @@ package io.fluent.builtin.reflection; +import io.fluent.builtin.reflection.immutable.ImmutableProxy; import java.lang.reflect.Constructor; import java.util.function.Function; -import io.fluent.builtin.reflection.immutable.ImmutableProxy; - public final class RecordUtils { - private static final ClassValue recordImmutabilityCache = ClassValues.create(recordClass -> { - return RecordSupport.getRecordComponents(recordClass) - .allMatch(recordComponentInfo -> ImmutableProxy.isImmutable(recordComponentInfo.getType())); - }); + private static final ClassValue recordImmutabilityCache = + ClassValues.create( + recordClass -> { + return RecordSupport.getRecordComponents(recordClass) + .allMatch( + recordComponentInfo -> + ImmutableProxy.isImmutable(recordComponentInfo.getType())); + }); - private RecordUtils() { - } + private RecordUtils() {} - public static boolean hasOnlyImmutableRecordComponents(Class recordClass) { - return recordImmutabilityCache.get(recordClass); - } + public static boolean hasOnlyImmutableRecordComponents(Class recordClass) { + return recordImmutabilityCache.get(recordClass); + } - public static T cloneRecord(T record, Function valueMapping) { - Object[] values = RecordSupport.getRecordComponents(record.getClass()) - .map(recordComponent -> { - Object value = recordComponent.retrieveValueFrom(record); - return valueMapping.apply(value); - }) - .toArray(Object[]::new); - try { - Constructor recordConstructor = RecordSupport.getRecordConstructor(ClassUtils.getRealClass(record)); - return ClassUtils.createInstance(recordConstructor, values); - } catch (ReflectiveOperationException e) { - throw new ReflectionRuntimeException(e); - } - } + public static T cloneRecord(T record, Function valueMapping) { + Object[] values = + RecordSupport.getRecordComponents(record.getClass()) + .map( + recordComponent -> { + Object value = recordComponent.retrieveValueFrom(record); + return valueMapping.apply(value); + }) + .toArray(Object[]::new); + try { + Constructor recordConstructor = + RecordSupport.getRecordConstructor(ClassUtils.getRealClass(record)); + return ClassUtils.createInstance(recordConstructor, values); + } catch (ReflectiveOperationException e) { + throw new ReflectionRuntimeException(e); + } + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/ReflectionRuntimeException.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/ReflectionRuntimeException.java index b11323f..ba21f3b 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/ReflectionRuntimeException.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/ReflectionRuntimeException.java @@ -2,14 +2,13 @@ public class ReflectionRuntimeException extends RuntimeException { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - ReflectionRuntimeException(Throwable cause) { - super(cause); - } - - ReflectionRuntimeException(String message, Throwable cause) { - super(message, cause); - } + ReflectionRuntimeException(Throwable cause) { + super(cause); + } + ReflectionRuntimeException(String message, Throwable cause) { + super(message, cause); + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/TypedPropertyGetter.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/TypedPropertyGetter.java index f2605c2..05c3ab5 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/TypedPropertyGetter.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/TypedPropertyGetter.java @@ -2,5 +2,5 @@ @FunctionalInterface public interface TypedPropertyGetter { - V get(T bean); + V get(T bean); } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/VoidMethod.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/VoidMethod.java index f68c913..3459de9 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/VoidMethod.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/VoidMethod.java @@ -2,5 +2,5 @@ @FunctionalInterface public interface VoidMethod { - void invoke(T bean) throws Exception; + void invoke(T bean) throws Exception; } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/GenericImmutableProxyForwarder.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/GenericImmutableProxyForwarder.java index 0010f2f..b65af2d 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/GenericImmutableProxyForwarder.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/GenericImmutableProxyForwarder.java @@ -1,5 +1,6 @@ package io.fluent.builtin.reflection.immutable; +import io.fluent.builtin.reflection.ClassUtils; import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.util.Collection; @@ -7,8 +8,6 @@ import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; - -import io.fluent.builtin.reflection.ClassUtils; import net.bytebuddy.description.method.MethodDescription; import net.bytebuddy.implementation.bind.annotation.AllArguments; import net.bytebuddy.implementation.bind.annotation.FieldValue; @@ -18,80 +17,93 @@ public final class GenericImmutableProxyForwarder { - private static final Map shouldProxyReturnValueCache = new ConcurrentHashMap<>(); - - private GenericImmutableProxyForwarder() { - } + private static final Map shouldProxyReturnValueCache = new ConcurrentHashMap<>(); - @RuntimeType - public static Object forward(@Origin Method method, - @FieldValue(ImmutableProxy.DELEGATE_FIELD_NAME) Object delegate, - @FieldValue(ImmutableProxy.OPTIONS) ImmutableProxyOption[] options, - @AllArguments Object[] args) throws InvocationTargetException, IllegalAccessException { - Object value = method.invoke(delegate, args); - if (ImmutableProxy.isImmutable(value)) { - return value; - } - if (!shouldProxyReturnValue(method)) { - return value; - } - if (value instanceof Collection) { - return createImmutableCollection(value, method); - } else if (value instanceof Map) { - return createImmutableMap(value, method); - } else { - return ImmutableProxy.create(value, options); - } - } + private GenericImmutableProxyForwarder() {} - @SuppressWarnings("boxing") - private static boolean shouldProxyReturnValue(Method method) { - return shouldProxyReturnValueCache.computeIfAbsent(method, m -> { - if (isCloneMethod(m)) { - return false; - } - ReadOnly readOnlyAnnotation = ClassUtils.findAnnotation(m, ReadOnly.class); - return readOnlyAnnotation == null - || readOnlyAnnotation.proxyReturnValue(); - }).booleanValue(); - } + @RuntimeType + public static Object forward( + @Origin Method method, + @FieldValue(ImmutableProxy.DELEGATE_FIELD_NAME) Object delegate, + @FieldValue(ImmutableProxy.OPTIONS) ImmutableProxyOption[] options, + @AllArguments Object[] args) + throws InvocationTargetException, IllegalAccessException { + Object value = method.invoke(delegate, args); + if (ImmutableProxy.isImmutable(value)) { + return value; + } + if (!shouldProxyReturnValue(method)) { + return value; + } + if (value instanceof Collection) { + return createImmutableCollection(value, method); + } else if (value instanceof Map) { + return createImmutableMap(value, method); + } else { + return ImmutableProxy.create(value, options); + } + } - private static boolean isCloneMethod(Method method) { - return ElementMatchers.isClone().matches(new MethodDescription.ForLoadedMethod(method)); - } + @SuppressWarnings("boxing") + private static boolean shouldProxyReturnValue(Method method) { + return shouldProxyReturnValueCache + .computeIfAbsent( + method, + m -> { + if (isCloneMethod(m)) { + return false; + } + ReadOnly readOnlyAnnotation = ClassUtils.findAnnotation(m, ReadOnly.class); + return readOnlyAnnotation == null || readOnlyAnnotation.proxyReturnValue(); + }) + .booleanValue(); + } - private static Object createImmutableCollection(Object value, Method method) { - Class returnType = method.getReturnType(); - if (returnType.equals(Set.class)) { - Set collection = (Set) value; - return ImmutableProxy.create(collection); - } else if (returnType.equals(List.class)) { - List collection = (List) value; - return ImmutableProxy.create(collection); - } else if (returnType.equals(Collection.class) || returnType.equals(Iterable.class)) { - Collection collection = (Collection) value; - return ImmutableProxy.create(collection); - } else { - throw new UnsupportedOperationException("Cannot create immutable collection for " + describeMethod(method) + "." - + " The return type is unknown or too specific: " + returnType + "." - + " Consider to define a more generic type: Set/List/Collection"); - } - } + private static boolean isCloneMethod(Method method) { + return ElementMatchers.isClone().matches(new MethodDescription.ForLoadedMethod(method)); + } - private static Object createImmutableMap(Object value, Method method) { - Class returnType = method.getReturnType(); - if (returnType.equals(Map.class)) { - Map map = (Map) value; - return ImmutableProxy.create(map); - } else { - throw new UnsupportedOperationException("Cannot create immutable map for " + describeMethod(method) + "." - + " The return type is unknown or too specific: " + returnType + "." - + " Consider to define a more generic type: Map"); - } - } + private static Object createImmutableCollection(Object value, Method method) { + Class returnType = method.getReturnType(); + if (returnType.equals(Set.class)) { + Set collection = (Set) value; + return ImmutableProxy.create(collection); + } else if (returnType.equals(List.class)) { + List collection = (List) value; + return ImmutableProxy.create(collection); + } else if (returnType.equals(Collection.class) || returnType.equals(Iterable.class)) { + Collection collection = (Collection) value; + return ImmutableProxy.create(collection); + } else { + throw new UnsupportedOperationException( + "Cannot create immutable collection for " + + describeMethod(method) + + "." + + " The return type is unknown or too specific: " + + returnType + + "." + + " Consider to define a more generic type: Set/List/Collection"); + } + } - private static String describeMethod(Method method) { - return method.getDeclaringClass().getSimpleName() + "." + method.getName(); - } + private static Object createImmutableMap(Object value, Method method) { + Class returnType = method.getReturnType(); + if (returnType.equals(Map.class)) { + Map map = (Map) value; + return ImmutableProxy.create(map); + } else { + throw new UnsupportedOperationException( + "Cannot create immutable map for " + + describeMethod(method) + + "." + + " The return type is unknown or too specific: " + + returnType + + "." + + " Consider to define a more generic type: Map"); + } + } + private static String describeMethod(Method method) { + return method.getDeclaringClass().getSimpleName() + "." + method.getName(); + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/Immutable.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/Immutable.java index 6d931d5..d1d31b4 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/Immutable.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/Immutable.java @@ -1,4 +1,3 @@ package io.fluent.builtin.reflection.immutable; -public interface Immutable { -} +public interface Immutable {} diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/ImmutableProxy.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/ImmutableProxy.java index 8eb042d..62ec040 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/ImmutableProxy.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/ImmutableProxy.java @@ -2,6 +2,14 @@ import static net.bytebuddy.matcher.ElementMatchers.*; +import io.fluent.builtin.reflection.ClassUtils; +import io.fluent.builtin.reflection.ClassValues; +import io.fluent.builtin.reflection.PropertyUtils; +import io.fluent.builtin.reflection.RecordUtils; +import io.fluent.builtin.reflection.immutable.collection.DeepImmutableCollection; +import io.fluent.builtin.reflection.immutable.collection.DeepImmutableList; +import io.fluent.builtin.reflection.immutable.collection.DeepImmutableMap; +import io.fluent.builtin.reflection.immutable.collection.DeepImmutableSet; import java.io.File; import java.lang.annotation.Annotation; import java.lang.reflect.Method; @@ -16,19 +24,6 @@ import java.util.Map; import java.util.Set; import java.util.UUID; - -import io.fluent.builtin.reflection.ClassUtils; -import io.fluent.builtin.reflection.ClassValues; -import io.fluent.builtin.reflection.PropertyUtils; -import io.fluent.builtin.reflection.RecordUtils; -import io.fluent.builtin.reflection.immutable.collection.DeepImmutableCollection; -import io.fluent.builtin.reflection.immutable.collection.DeepImmutableList; -import io.fluent.builtin.reflection.immutable.collection.DeepImmutableMap; -import io.fluent.builtin.reflection.immutable.collection.DeepImmutableSet; -import org.jetbrains.annotations.UnmodifiableView; -import org.jetbrains.annotations.VisibleForTesting; -import org.objenesis.ObjenesisHelper; - import net.bytebuddy.ByteBuddy; import net.bytebuddy.description.method.MethodDescription; import net.bytebuddy.description.method.MethodDescription.SignatureToken; @@ -39,280 +34,304 @@ import net.bytebuddy.matcher.ElementMatcher; import net.bytebuddy.matcher.ElementMatcher.Junction; import net.bytebuddy.matcher.ElementMatchers; +import org.jetbrains.annotations.UnmodifiableView; +import org.jetbrains.annotations.VisibleForTesting; +import org.objenesis.ObjenesisHelper; public final class ImmutableProxy { - static final String DELEGATE_FIELD_NAME = "$delegate"; - static final String OPTIONS = "$options"; - - private static final ClassValue> immutableProxyClassCache = ClassValues.create(ImmutableProxy::createProxyClass); - - private ImmutableProxy() { - } - - public static T create(T instance, ImmutableProxyOption... options) { - if (isImmutable(instance)) { - return instance; - } else if (instance instanceof List) { - @SuppressWarnings("unchecked") - T immutableList = (T) create((List) instance); - return immutableList; - } else if (instance instanceof Set) { - @SuppressWarnings("unchecked") - T immutableSet = (T) create((Set) instance); - return immutableSet; - } else if (instance instanceof Map) { - @SuppressWarnings("unchecked") - T immutableMap = (T) create((Map) instance); - return immutableMap; - } else if (ClassUtils.isRecord(instance)) { - if (isOptionEnabled(options, ImmutableProxyOption.ALLOW_CLONING_RECORDS)) { - return RecordUtils.cloneRecord(instance, ImmutableProxy::create); - } else { - throw new IllegalArgumentException( - instance.getClass() + " is a record that potentially contains mutable components." - + " Consider using ImmutableProxy.create(bean, " - + ImmutableProxyOption.class.getSimpleName() + "." + ImmutableProxyOption.ALLOW_CLONING_RECORDS - + ") to enable cloning of such records."); - } - } - Class proxyClass = getOrCreateProxyClass(instance); - T proxy = ObjenesisHelper.newInstance(proxyClass); - PropertyUtils.writeDirectly(proxy, DELEGATE_FIELD_NAME, instance); - if (options != null && options.length > 0) { - PropertyUtils.writeDirectly(proxy, OPTIONS, options); - } - return proxy; - } - - @UnmodifiableView - public static Collection create(Collection collection) { - return new DeepImmutableCollection<>(collection); - } - - @UnmodifiableView - public static List create(List list) { - return new DeepImmutableList<>(list); - } - - @UnmodifiableView - public static Set create(Set set) { - return new DeepImmutableSet<>(set); - } - - @UnmodifiableView - public static Map create(Map map) { - return new DeepImmutableMap<>(map); - } - - public static T unwrap(T immutableProxy) { - if (!isImmutableProxy(immutableProxy)) { - return immutableProxy; - } else { - return PropertyUtils.readDirectly(immutableProxy, DELEGATE_FIELD_NAME); - } - } - - static boolean isImmutable(Object value) { - if (value == null) { - return true; - } - return isImmutable(value.getClass()); - } - - public static boolean isImmutable(Class type) { - if (isImmutableProxyClass(type)) { - return true; - } else if (String.class.isAssignableFrom(type)) { - return true; - } else if (Byte.class.isAssignableFrom(type) || byte.class.isAssignableFrom(type)) { - return true; - } else if (Short.class.isAssignableFrom(type) || short.class.isAssignableFrom(type)) { - return true; - } else if (Integer.class.isAssignableFrom(type) || int.class.isAssignableFrom(type)) { - return true; - } else if (Long.class.isAssignableFrom(type) || long.class.isAssignableFrom(type)) { - return true; - } else if (Float.class.isAssignableFrom(type) || float.class.isAssignableFrom(type)) { - return true; - } else if (Double.class.isAssignableFrom(type) || double.class.isAssignableFrom(type)) { - return true; - } else if (Boolean.class.isAssignableFrom(type) || boolean.class.isAssignableFrom(type)) { - return true; - } else if (Character.class.isAssignableFrom(type) || char.class.isAssignableFrom(type)) { - return true; - } else if (BigDecimal.class.isAssignableFrom(type)) { - return true; - } else if (Temporal.class.isAssignableFrom(type)) { - return true; - } else if (TemporalAmount.class.isAssignableFrom(type)) { - return true; - } else if (UUID.class.isAssignableFrom(type)) { - return true; - } else if (File.class.isAssignableFrom(type)) { - return true; - } else if (Path.class.isAssignableFrom(type)) { - return true; - } else if (URI.class.isAssignableFrom(type)) { - return true; - } else if (isEnumType(type)) { - return true; - } else if (ClassUtils.isRecord(type)) { - return RecordUtils.hasOnlyImmutableRecordComponents(type); - } else { - return false; - } - } - - private static boolean isEnumType(Class type) { - return type.isEnum() || (type.getSuperclass() != null && type.getSuperclass().isEnum()); - } - - @SuppressWarnings("unchecked") - private static Class getOrCreateProxyClass(T instance) { - Class realClass = ClassUtils.getRealClass(instance); - return (Class) immutableProxyClassCache.get(realClass); - } - - private static Class createProxyClass(Class clazz) { - assertPublicMethodsAreNotFinal(clazz); - return new ByteBuddy() - .subclass(clazz) - .implement(Immutable.class) - .defineField(DELEGATE_FIELD_NAME, clazz) - .defineField(OPTIONS, ImmutableProxyOption[].class) - .method(any()) - .intercept(ExceptionMethod.throwing(UnsupportedOperationException.class, "This instance is immutable." - + " Annotate the method with @" + ReadOnly.class.getSimpleName() + " if this is a false-positive.")) - .method(isReadOnlyMethod()) - .intercept(MethodDelegation.to(GenericImmutableProxyForwarder.class)) - .method(isReadOnlyMethod().and(returns(Long.class).or(returns(long.class)))) - .intercept(MethodDelegation.to(ImmutableProxyForwarderLong.class)) - .method(isReadOnlyMethod().and(returns(Integer.class).or(returns(int.class)))) - .intercept(MethodDelegation.to(ImmutableProxyForwarderInteger.class)) - .method(isReadOnlyMethod().and(returns(Boolean.class).or(returns(boolean.class)))) - .intercept(MethodDelegation.to(ImmutableProxyForwarderBoolean.class)) - .method(isReadOnlyMethod().and(returns(String.class))) - .intercept(MethodDelegation.to(ImmutableProxyForwarderString.class)) - .make() - .load(ImmutableProxy.class.getClassLoader()) - .getLoaded(); - } - - private static void assertPublicMethodsAreNotFinal(Class clazz) { - for (Method method : clazz.getMethods()) { - if (Modifier.isFinal(method.getModifiers())) { - if (method.getDeclaringClass().equals(Object.class) - || isHashCodeMethod(method) - || isEqualsMethod(method) - || isToStringMethod(method) - || isCloneMethod(method) - || method.getDeclaredAnnotation(ReadOnly.class) != null) { - continue; - } - throw new IllegalArgumentException("Cannot create an immutable proxy for " + clazz + ". " - + "Method " + method + " is final."); - } - } - } - - private static boolean isHashCodeMethod(Method method) { - return method.getName().equals("hashCode") - && method.getReturnType().equals(int.class) - && method.getParameterCount() == 0; - } - - private static boolean isEqualsMethod(Method method) { - return method.getName().equals("equals") - && method.getReturnType().equals(boolean.class) - && method.getParameterCount() == 1 - && method.getParameterTypes()[0].equals(Object.class); - } - - static boolean isToStringMethod(Method method) { - return method.getName().equals("toString") - && method.getReturnType().equals(String.class) - && method.getParameterCount() == 0; - } - - static boolean isCloneMethod(Method method) { - return method.getName().equals("clone") - && method.getParameterCount() == 0; - } - - private static Junction isReadOnlyMethod() { - return not(isSetter()) - .and(isGetter() - .or(isHashCode()).or(isEquals()).or(isToString()).or(isClone()) - .or(isDeclaredBy(Object.class)) - .or(isAnnotatedWith(ReadOnly.class))); - } - - private static ElementMatcher isAnnotatedWith(Class annotation) { - return target -> { - TypeDefinition type = target.getDeclaringType(); - SignatureToken methodSignature = target.asSignatureToken(); - return isAnnotatedWith(methodSignature, type, annotation); - }; - } - - private static boolean isAnnotatedWith(SignatureToken methodSignature, TypeDefinition type, Class annotation) { - if (type == null || type.equals(TypeDescription.OBJECT)) { - return false; - } - - if (hasMethodAnnotatedWith(methodSignature, type, annotation)) { - return true; - } - - Iterable interfaces = type.getInterfaces(); - for (TypeDefinition interfaceType : interfaces) { - if (hasMethodAnnotatedWith(methodSignature, interfaceType, annotation)) { - return true; - } - for (TypeDescription.Generic interfaceSuperclass : interfaceType.getInterfaces()) { - if (isAnnotatedWith(methodSignature, interfaceSuperclass, annotation)) { - return true; - } - } - } - - return isAnnotatedWith(methodSignature, type.getSuperClass(), annotation); - } - - private static boolean hasMethodAnnotatedWith(SignatureToken methodSignature, TypeDefinition type, Class annotation) { - return !type.getDeclaredMethods() - .filter(hasMethodName(methodSignature.getName()) - .and(takesArguments(methodSignature.getParameterTypes())) - .and(ElementMatchers.isAnnotatedWith(annotation))) - .isEmpty(); - } - - public static boolean isImmutableProxy(Object object) { - if (object == null) { - return false; - } - return isImmutableProxyClass(object.getClass()); - } - - public static boolean isImmutableProxyClass(Class beanClass) { - return Immutable.class.isAssignableFrom(beanClass); - } - - @VisibleForTesting - static void removeClassFromCache(Class type) { - immutableProxyClassCache.remove(type); - } - - private static boolean isOptionEnabled(ImmutableProxyOption[] options, ImmutableProxyOption optionToTest) { - if (options == null) { - return false; - } - for (ImmutableProxyOption option : options) { - if (option == optionToTest) { - return true; - } - } - return false; - } + static final String DELEGATE_FIELD_NAME = "$delegate"; + static final String OPTIONS = "$options"; + + private static final ClassValue> immutableProxyClassCache = + ClassValues.create(ImmutableProxy::createProxyClass); + + private ImmutableProxy() {} + + public static T create(T instance, ImmutableProxyOption... options) { + if (isImmutable(instance)) { + return instance; + } else if (instance instanceof List) { + @SuppressWarnings("unchecked") + T immutableList = (T) create((List) instance); + return immutableList; + } else if (instance instanceof Set) { + @SuppressWarnings("unchecked") + T immutableSet = (T) create((Set) instance); + return immutableSet; + } else if (instance instanceof Map) { + @SuppressWarnings("unchecked") + T immutableMap = (T) create((Map) instance); + return immutableMap; + } else if (ClassUtils.isRecord(instance)) { + if (isOptionEnabled(options, ImmutableProxyOption.ALLOW_CLONING_RECORDS)) { + return RecordUtils.cloneRecord(instance, ImmutableProxy::create); + } else { + throw new IllegalArgumentException( + instance.getClass() + + " is a record that potentially contains mutable components." + + " Consider using ImmutableProxy.create(bean, " + + ImmutableProxyOption.class.getSimpleName() + + "." + + ImmutableProxyOption.ALLOW_CLONING_RECORDS + + ") to enable cloning of such records."); + } + } + Class proxyClass = getOrCreateProxyClass(instance); + T proxy = ObjenesisHelper.newInstance(proxyClass); + PropertyUtils.writeDirectly(proxy, DELEGATE_FIELD_NAME, instance); + if (options != null && options.length > 0) { + PropertyUtils.writeDirectly(proxy, OPTIONS, options); + } + return proxy; + } + + @UnmodifiableView + public static Collection create(Collection collection) { + return new DeepImmutableCollection<>(collection); + } + + @UnmodifiableView + public static List create(List list) { + return new DeepImmutableList<>(list); + } + + @UnmodifiableView + public static Set create(Set set) { + return new DeepImmutableSet<>(set); + } + + @UnmodifiableView + public static Map create(Map map) { + return new DeepImmutableMap<>(map); + } + + public static T unwrap(T immutableProxy) { + if (!isImmutableProxy(immutableProxy)) { + return immutableProxy; + } else { + return PropertyUtils.readDirectly(immutableProxy, DELEGATE_FIELD_NAME); + } + } + + static boolean isImmutable(Object value) { + if (value == null) { + return true; + } + return isImmutable(value.getClass()); + } + + public static boolean isImmutable(Class type) { + if (isImmutableProxyClass(type)) { + return true; + } else if (String.class.isAssignableFrom(type)) { + return true; + } else if (Byte.class.isAssignableFrom(type) || byte.class.isAssignableFrom(type)) { + return true; + } else if (Short.class.isAssignableFrom(type) || short.class.isAssignableFrom(type)) { + return true; + } else if (Integer.class.isAssignableFrom(type) || int.class.isAssignableFrom(type)) { + return true; + } else if (Long.class.isAssignableFrom(type) || long.class.isAssignableFrom(type)) { + return true; + } else if (Float.class.isAssignableFrom(type) || float.class.isAssignableFrom(type)) { + return true; + } else if (Double.class.isAssignableFrom(type) || double.class.isAssignableFrom(type)) { + return true; + } else if (Boolean.class.isAssignableFrom(type) || boolean.class.isAssignableFrom(type)) { + return true; + } else if (Character.class.isAssignableFrom(type) || char.class.isAssignableFrom(type)) { + return true; + } else if (BigDecimal.class.isAssignableFrom(type)) { + return true; + } else if (Temporal.class.isAssignableFrom(type)) { + return true; + } else if (TemporalAmount.class.isAssignableFrom(type)) { + return true; + } else if (UUID.class.isAssignableFrom(type)) { + return true; + } else if (File.class.isAssignableFrom(type)) { + return true; + } else if (Path.class.isAssignableFrom(type)) { + return true; + } else if (URI.class.isAssignableFrom(type)) { + return true; + } else if (isEnumType(type)) { + return true; + } else if (ClassUtils.isRecord(type)) { + return RecordUtils.hasOnlyImmutableRecordComponents(type); + } else { + return false; + } + } + + private static boolean isEnumType(Class type) { + return type.isEnum() || (type.getSuperclass() != null && type.getSuperclass().isEnum()); + } + + @SuppressWarnings("unchecked") + private static Class getOrCreateProxyClass(T instance) { + Class realClass = ClassUtils.getRealClass(instance); + return (Class) immutableProxyClassCache.get(realClass); + } + + private static Class createProxyClass(Class clazz) { + assertPublicMethodsAreNotFinal(clazz); + return new ByteBuddy() + .subclass(clazz) + .implement(Immutable.class) + .defineField(DELEGATE_FIELD_NAME, clazz) + .defineField(OPTIONS, ImmutableProxyOption[].class) + .method(any()) + .intercept( + ExceptionMethod.throwing( + UnsupportedOperationException.class, + "This instance is immutable." + + " Annotate the method with @" + + ReadOnly.class.getSimpleName() + + " if this is a false-positive.")) + .method(isReadOnlyMethod()) + .intercept(MethodDelegation.to(GenericImmutableProxyForwarder.class)) + .method(isReadOnlyMethod().and(returns(Long.class).or(returns(long.class)))) + .intercept(MethodDelegation.to(ImmutableProxyForwarderLong.class)) + .method(isReadOnlyMethod().and(returns(Integer.class).or(returns(int.class)))) + .intercept(MethodDelegation.to(ImmutableProxyForwarderInteger.class)) + .method(isReadOnlyMethod().and(returns(Boolean.class).or(returns(boolean.class)))) + .intercept(MethodDelegation.to(ImmutableProxyForwarderBoolean.class)) + .method(isReadOnlyMethod().and(returns(String.class))) + .intercept(MethodDelegation.to(ImmutableProxyForwarderString.class)) + .make() + .load(ImmutableProxy.class.getClassLoader()) + .getLoaded(); + } + + private static void assertPublicMethodsAreNotFinal(Class clazz) { + for (Method method : clazz.getMethods()) { + if (Modifier.isFinal(method.getModifiers())) { + if (method.getDeclaringClass().equals(Object.class) + || isHashCodeMethod(method) + || isEqualsMethod(method) + || isToStringMethod(method) + || isCloneMethod(method) + || method.getDeclaredAnnotation(ReadOnly.class) != null) { + continue; + } + throw new IllegalArgumentException( + "Cannot create an immutable proxy for " + + clazz + + ". " + + "Method " + + method + + " is final."); + } + } + } + + private static boolean isHashCodeMethod(Method method) { + return method.getName().equals("hashCode") + && method.getReturnType().equals(int.class) + && method.getParameterCount() == 0; + } + + private static boolean isEqualsMethod(Method method) { + return method.getName().equals("equals") + && method.getReturnType().equals(boolean.class) + && method.getParameterCount() == 1 + && method.getParameterTypes()[0].equals(Object.class); + } + + static boolean isToStringMethod(Method method) { + return method.getName().equals("toString") + && method.getReturnType().equals(String.class) + && method.getParameterCount() == 0; + } + + static boolean isCloneMethod(Method method) { + return method.getName().equals("clone") && method.getParameterCount() == 0; + } + + private static Junction isReadOnlyMethod() { + return not(isSetter()) + .and( + isGetter() + .or(isHashCode()) + .or(isEquals()) + .or(isToString()) + .or(isClone()) + .or(isDeclaredBy(Object.class)) + .or(isAnnotatedWith(ReadOnly.class))); + } + + private static ElementMatcher isAnnotatedWith( + Class annotation) { + return target -> { + TypeDefinition type = target.getDeclaringType(); + SignatureToken methodSignature = target.asSignatureToken(); + return isAnnotatedWith(methodSignature, type, annotation); + }; + } + + private static boolean isAnnotatedWith( + SignatureToken methodSignature, TypeDefinition type, Class annotation) { + if (type == null || type.equals(TypeDescription.OBJECT)) { + return false; + } + + if (hasMethodAnnotatedWith(methodSignature, type, annotation)) { + return true; + } + + Iterable interfaces = type.getInterfaces(); + for (TypeDefinition interfaceType : interfaces) { + if (hasMethodAnnotatedWith(methodSignature, interfaceType, annotation)) { + return true; + } + for (TypeDescription.Generic interfaceSuperclass : interfaceType.getInterfaces()) { + if (isAnnotatedWith(methodSignature, interfaceSuperclass, annotation)) { + return true; + } + } + } + + return isAnnotatedWith(methodSignature, type.getSuperClass(), annotation); + } + + private static boolean hasMethodAnnotatedWith( + SignatureToken methodSignature, TypeDefinition type, Class annotation) { + return !type.getDeclaredMethods() + .filter( + hasMethodName(methodSignature.getName()) + .and(takesArguments(methodSignature.getParameterTypes())) + .and(ElementMatchers.isAnnotatedWith(annotation))) + .isEmpty(); + } + + public static boolean isImmutableProxy(Object object) { + if (object == null) { + return false; + } + return isImmutableProxyClass(object.getClass()); + } + + public static boolean isImmutableProxyClass(Class beanClass) { + return Immutable.class.isAssignableFrom(beanClass); + } + + @VisibleForTesting + static void removeClassFromCache(Class type) { + immutableProxyClassCache.remove(type); + } + + private static boolean isOptionEnabled( + ImmutableProxyOption[] options, ImmutableProxyOption optionToTest) { + if (options == null) { + return false; + } + for (ImmutableProxyOption option : options) { + if (option == optionToTest) { + return true; + } + } + return false; + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/ImmutableProxyForwarderBoolean.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/ImmutableProxyForwarderBoolean.java index 1fd8109..07149f8 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/ImmutableProxyForwarderBoolean.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/ImmutableProxyForwarderBoolean.java @@ -2,20 +2,19 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; - import net.bytebuddy.implementation.bind.annotation.AllArguments; import net.bytebuddy.implementation.bind.annotation.FieldValue; import net.bytebuddy.implementation.bind.annotation.Origin; public final class ImmutableProxyForwarderBoolean { - private ImmutableProxyForwarderBoolean() { - } - - public static Boolean forward(@Origin Method method, - @FieldValue(ImmutableProxy.DELEGATE_FIELD_NAME) Object delegate, - @AllArguments Object[] args) throws InvocationTargetException, IllegalAccessException { - return (Boolean) method.invoke(delegate, args); - } + private ImmutableProxyForwarderBoolean() {} + public static Boolean forward( + @Origin Method method, + @FieldValue(ImmutableProxy.DELEGATE_FIELD_NAME) Object delegate, + @AllArguments Object[] args) + throws InvocationTargetException, IllegalAccessException { + return (Boolean) method.invoke(delegate, args); + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/ImmutableProxyForwarderInteger.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/ImmutableProxyForwarderInteger.java index 5e59fe3..f069d3d 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/ImmutableProxyForwarderInteger.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/ImmutableProxyForwarderInteger.java @@ -2,20 +2,19 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; - import net.bytebuddy.implementation.bind.annotation.AllArguments; import net.bytebuddy.implementation.bind.annotation.FieldValue; import net.bytebuddy.implementation.bind.annotation.Origin; public final class ImmutableProxyForwarderInteger { - private ImmutableProxyForwarderInteger() { - } - - public static Integer forward(@Origin Method method, - @FieldValue(ImmutableProxy.DELEGATE_FIELD_NAME) Object delegate, - @AllArguments Object[] args) throws InvocationTargetException, IllegalAccessException { - return (Integer) method.invoke(delegate, args); - } + private ImmutableProxyForwarderInteger() {} + public static Integer forward( + @Origin Method method, + @FieldValue(ImmutableProxy.DELEGATE_FIELD_NAME) Object delegate, + @AllArguments Object[] args) + throws InvocationTargetException, IllegalAccessException { + return (Integer) method.invoke(delegate, args); + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/ImmutableProxyForwarderLong.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/ImmutableProxyForwarderLong.java index 2ca0260..b2421b2 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/ImmutableProxyForwarderLong.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/ImmutableProxyForwarderLong.java @@ -2,20 +2,19 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; - import net.bytebuddy.implementation.bind.annotation.AllArguments; import net.bytebuddy.implementation.bind.annotation.FieldValue; import net.bytebuddy.implementation.bind.annotation.Origin; public final class ImmutableProxyForwarderLong { - private ImmutableProxyForwarderLong() { - } - - public static Long forward(@Origin Method method, - @FieldValue(ImmutableProxy.DELEGATE_FIELD_NAME) Object delegate, - @AllArguments Object[] args) throws InvocationTargetException, IllegalAccessException { - return (Long) method.invoke(delegate, args); - } + private ImmutableProxyForwarderLong() {} + public static Long forward( + @Origin Method method, + @FieldValue(ImmutableProxy.DELEGATE_FIELD_NAME) Object delegate, + @AllArguments Object[] args) + throws InvocationTargetException, IllegalAccessException { + return (Long) method.invoke(delegate, args); + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/ImmutableProxyForwarderString.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/ImmutableProxyForwarderString.java index fffa12e..f04e35e 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/ImmutableProxyForwarderString.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/ImmutableProxyForwarderString.java @@ -2,20 +2,19 @@ import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; - import net.bytebuddy.implementation.bind.annotation.AllArguments; import net.bytebuddy.implementation.bind.annotation.FieldValue; import net.bytebuddy.implementation.bind.annotation.Origin; public final class ImmutableProxyForwarderString { - private ImmutableProxyForwarderString() { - } - - public static String forward(@Origin Method method, - @FieldValue(ImmutableProxy.DELEGATE_FIELD_NAME) Object delegate, - @AllArguments Object[] args) throws InvocationTargetException, IllegalAccessException { - return (String) method.invoke(delegate, args); - } + private ImmutableProxyForwarderString() {} + public static String forward( + @Origin Method method, + @FieldValue(ImmutableProxy.DELEGATE_FIELD_NAME) Object delegate, + @AllArguments Object[] args) + throws InvocationTargetException, IllegalAccessException { + return (String) method.invoke(delegate, args); + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/ImmutableProxyOption.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/ImmutableProxyOption.java index 07589c5..81e97a0 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/ImmutableProxyOption.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/ImmutableProxyOption.java @@ -1,20 +1,18 @@ package io.fluent.builtin.reflection.immutable; public enum ImmutableProxyOption { - /** - * Allow cloning of records if at least one of the record components is not clearly an immutable type. - * - * Examples: - * - * - * record RecordWithPrimitives(int a, int b) {} - * - * record RecordWithList(List list) {} - * - * - * For records of type RecordWithPrimitives, no cloning is required since it only contains clearly immutable components. - * However, when creating an immutable proxy for an instance of RecordWithList, - * we need to clone the record and wrap the list component into an immutable proxy itself. - */ - ALLOW_CLONING_RECORDS + /** + * Allow cloning of records if at least one of the record components is not clearly an immutable + * type. + * + *

Examples: + * record RecordWithPrimitives(int a, int b) {} + * + * record RecordWithList(List list) {} + * For records of type RecordWithPrimitives, no cloning is required since it only contains + * clearly immutable components. However, when creating an immutable proxy for an instance of + * RecordWithList, we need to clone the record and wrap the list component into an immutable proxy + * itself. + */ + ALLOW_CLONING_RECORDS } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/ReadOnly.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/ReadOnly.java index b87b17b..fbbdddd 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/ReadOnly.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/ReadOnly.java @@ -6,9 +6,8 @@ import java.lang.annotation.Target; @Retention(RetentionPolicy.RUNTIME) -@Target({ ElementType.METHOD }) +@Target({ElementType.METHOD}) public @interface ReadOnly { - boolean proxyReturnValue() default true; - + boolean proxyReturnValue() default true; } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/collection/DeepImmutableCollection.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/collection/DeepImmutableCollection.java index 23fcf19..2b81d9b 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/collection/DeepImmutableCollection.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/collection/DeepImmutableCollection.java @@ -1,5 +1,7 @@ package io.fluent.builtin.reflection.immutable.collection; +import io.fluent.builtin.reflection.immutable.Immutable; +import io.fluent.builtin.reflection.immutable.ImmutableProxy; import java.io.Serializable; import java.util.AbstractCollection; import java.util.Collection; @@ -7,103 +9,99 @@ import java.util.Iterator; import java.util.Map; import java.util.Objects; - import org.jetbrains.annotations.NotNull; -import io.fluent.builtin.reflection.immutable.Immutable; -import io.fluent.builtin.reflection.immutable.ImmutableProxy; - -public class DeepImmutableCollection extends AbstractCollection implements Collection, Immutable, Serializable { - - private static final long serialVersionUID = 1L; - - private final String immutableMessage; - - private final Collection delegate; - - private final Map immutableProxyCache = new IdentityHashMap<>(); - - public DeepImmutableCollection(Collection delegate) { - this(delegate, "This collection is immutable"); - } - - DeepImmutableCollection(Collection delegate, String immutableMessage) { - this.delegate = Objects.requireNonNull(delegate); - this.immutableMessage = immutableMessage; - } - - E getImmutableElement(E element) { - return immutableProxyCache.computeIfAbsent(element, this::createImmutableElement); - } - - E createImmutableElement(E value) { - return ImmutableProxy.create(value); - } - - @Override - public int size() { - return delegate.size(); - } - - @Override - public boolean isEmpty() { - return delegate.isEmpty(); - } - - @Override - public boolean contains(Object o) { - return delegate.contains(o); - } - - @NotNull - @Override - public Iterator iterator() { - return new ImmutableIterator<>(this, delegate.iterator(), immutableMessage); - } - - @Override - public boolean containsAll(@NotNull Collection c) { - return delegate.containsAll(c); - } - - @Override - public boolean equals(Object o) { - return delegate.equals(o); - } - - @Override - public int hashCode() { - return delegate.hashCode(); - } - - @Override - public boolean add(E t) { - throw new UnsupportedOperationException(immutableMessage); - } - - @Override - public boolean remove(Object o) { - throw new UnsupportedOperationException(immutableMessage); - } - - @Override - public boolean addAll(@NotNull Collection c) { - throw new UnsupportedOperationException(immutableMessage); - } - - @Override - public boolean removeAll(@NotNull Collection c) { - throw new UnsupportedOperationException(immutableMessage); - } - - @Override - public boolean retainAll(@NotNull Collection c) { - throw new UnsupportedOperationException(immutableMessage); - } - - @Override - public void clear() { - throw new UnsupportedOperationException(immutableMessage); - } - +public class DeepImmutableCollection extends AbstractCollection + implements Collection, Immutable, Serializable { + + private static final long serialVersionUID = 1L; + + private final String immutableMessage; + + private final Collection delegate; + + private final Map immutableProxyCache = new IdentityHashMap<>(); + + public DeepImmutableCollection(Collection delegate) { + this(delegate, "This collection is immutable"); + } + + DeepImmutableCollection(Collection delegate, String immutableMessage) { + this.delegate = Objects.requireNonNull(delegate); + this.immutableMessage = immutableMessage; + } + + E getImmutableElement(E element) { + return immutableProxyCache.computeIfAbsent(element, this::createImmutableElement); + } + + E createImmutableElement(E value) { + return ImmutableProxy.create(value); + } + + @Override + public int size() { + return delegate.size(); + } + + @Override + public boolean isEmpty() { + return delegate.isEmpty(); + } + + @Override + public boolean contains(Object o) { + return delegate.contains(o); + } + + @NotNull + @Override + public Iterator iterator() { + return new ImmutableIterator<>(this, delegate.iterator(), immutableMessage); + } + + @Override + public boolean containsAll(@NotNull Collection c) { + return delegate.containsAll(c); + } + + @Override + public boolean equals(Object o) { + return delegate.equals(o); + } + + @Override + public int hashCode() { + return delegate.hashCode(); + } + + @Override + public boolean add(E t) { + throw new UnsupportedOperationException(immutableMessage); + } + + @Override + public boolean remove(Object o) { + throw new UnsupportedOperationException(immutableMessage); + } + + @Override + public boolean addAll(@NotNull Collection c) { + throw new UnsupportedOperationException(immutableMessage); + } + + @Override + public boolean removeAll(@NotNull Collection c) { + throw new UnsupportedOperationException(immutableMessage); + } + + @Override + public boolean retainAll(@NotNull Collection c) { + throw new UnsupportedOperationException(immutableMessage); + } + + @Override + public void clear() { + throw new UnsupportedOperationException(immutableMessage); + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/collection/DeepImmutableEntrySet.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/collection/DeepImmutableEntrySet.java index 0a33bd7..93be7e0 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/collection/DeepImmutableEntrySet.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/collection/DeepImmutableEntrySet.java @@ -3,50 +3,49 @@ import java.util.Map.Entry; import java.util.Set; -class DeepImmutableEntrySet extends DeepImmutableCollection> implements Set> { +class DeepImmutableEntrySet extends DeepImmutableCollection> + implements Set> { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - private final DeepImmutableMap immutableMap; + private final DeepImmutableMap immutableMap; - DeepImmutableEntrySet(Set> entrySet, DeepImmutableMap immutableMap) { - super(entrySet, DeepImmutableMap.IMMUTABLE_MESSAGE); - this.immutableMap = immutableMap; - } + DeepImmutableEntrySet(Set> entrySet, DeepImmutableMap immutableMap) { + super(entrySet, DeepImmutableMap.IMMUTABLE_MESSAGE); + this.immutableMap = immutableMap; + } - @Override - Entry createImmutableElement(Entry entry) { - return new ImmutableEntry<>(entry, immutableMap); - } + @Override + Entry createImmutableElement(Entry entry) { + return new ImmutableEntry<>(entry, immutableMap); + } - private static class ImmutableEntry implements Entry { + private static class ImmutableEntry implements Entry { - private final Entry delegate; + private final Entry delegate; - private transient final DeepImmutableMap immutableMap; + private final transient DeepImmutableMap immutableMap; - ImmutableEntry(Entry delegate, DeepImmutableMap immutableMap) { - this.delegate = delegate; - this.immutableMap = immutableMap; - } + ImmutableEntry(Entry delegate, DeepImmutableMap immutableMap) { + this.delegate = delegate; + this.immutableMap = immutableMap; + } - @Override - public K getKey() { - K key = delegate.getKey(); - return immutableMap.getImmutableKey(key); - } + @Override + public K getKey() { + K key = delegate.getKey(); + return immutableMap.getImmutableKey(key); + } - @Override - public V getValue() { - V value = delegate.getValue(); - return immutableMap.getImmutableValue(value); - } - - @Override - public V setValue(V value) { - throw new UnsupportedOperationException(DeepImmutableMap.IMMUTABLE_MESSAGE); - } - - } + @Override + public V getValue() { + V value = delegate.getValue(); + return immutableMap.getImmutableValue(value); + } + @Override + public V setValue(V value) { + throw new UnsupportedOperationException(DeepImmutableMap.IMMUTABLE_MESSAGE); + } + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/collection/DeepImmutableList.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/collection/DeepImmutableList.java index c6264df..ef00d7e 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/collection/DeepImmutableList.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/collection/DeepImmutableList.java @@ -6,91 +6,89 @@ import java.util.Comparator; import java.util.List; import java.util.ListIterator; - import org.jetbrains.annotations.NotNull; public class DeepImmutableList extends DeepImmutableCollection implements List { - private static final long serialVersionUID = 1L; - - private static final String IMMUTABLE_MESSAGE = "This list is immutable"; - - private final List listDelegate; - - public DeepImmutableList(List list) { - super(list, IMMUTABLE_MESSAGE); - this.listDelegate = list; - } - - public static DeepImmutableList of(T elements) { - return new DeepImmutableList<>(Collections.singletonList(elements)); - } - - public static DeepImmutableList of(T e1, T e2) { - return new DeepImmutableList<>(Arrays.asList(e1, e2)); - } - - public static DeepImmutableList of(T e1, T e2, T e3) { - return new DeepImmutableList<>(Arrays.asList(e1, e2, e3)); - } - - @Override - public E get(int index) { - E element = listDelegate.get(index); - return getImmutableElement(element); - } - - @Override - public int indexOf(Object o) { - return listDelegate.indexOf(o); - } - - @Override - public int lastIndexOf(Object o) { - return listDelegate.lastIndexOf(o); - } - - @NotNull - @Override - public ListIterator listIterator() { - return new ImmutableListIterator<>(this, listDelegate.listIterator()); - } - - @NotNull - @Override - public ListIterator listIterator(int index) { - return new ImmutableListIterator<>(this, listDelegate.listIterator(index)); - } - - @NotNull - @Override - public List subList(int fromIndex, int toIndex) { - return new DeepImmutableList<>(listDelegate.subList(fromIndex, toIndex)); - } - - @Override - public E set(int index, E element) { - throw new UnsupportedOperationException(IMMUTABLE_MESSAGE); - } - - @Override - public void add(int index, E element) { - throw new UnsupportedOperationException(IMMUTABLE_MESSAGE); - } - - @Override - public E remove(int index) { - throw new UnsupportedOperationException(IMMUTABLE_MESSAGE); - } - - @Override - public boolean addAll(int index, @NotNull Collection c) { - throw new UnsupportedOperationException(IMMUTABLE_MESSAGE); - } - - @Override - public void sort(Comparator c) { - throw new UnsupportedOperationException(IMMUTABLE_MESSAGE); - } - + private static final long serialVersionUID = 1L; + + private static final String IMMUTABLE_MESSAGE = "This list is immutable"; + + private final List listDelegate; + + public DeepImmutableList(List list) { + super(list, IMMUTABLE_MESSAGE); + this.listDelegate = list; + } + + public static DeepImmutableList of(T elements) { + return new DeepImmutableList<>(Collections.singletonList(elements)); + } + + public static DeepImmutableList of(T e1, T e2) { + return new DeepImmutableList<>(Arrays.asList(e1, e2)); + } + + public static DeepImmutableList of(T e1, T e2, T e3) { + return new DeepImmutableList<>(Arrays.asList(e1, e2, e3)); + } + + @Override + public E get(int index) { + E element = listDelegate.get(index); + return getImmutableElement(element); + } + + @Override + public int indexOf(Object o) { + return listDelegate.indexOf(o); + } + + @Override + public int lastIndexOf(Object o) { + return listDelegate.lastIndexOf(o); + } + + @NotNull + @Override + public ListIterator listIterator() { + return new ImmutableListIterator<>(this, listDelegate.listIterator()); + } + + @NotNull + @Override + public ListIterator listIterator(int index) { + return new ImmutableListIterator<>(this, listDelegate.listIterator(index)); + } + + @NotNull + @Override + public List subList(int fromIndex, int toIndex) { + return new DeepImmutableList<>(listDelegate.subList(fromIndex, toIndex)); + } + + @Override + public E set(int index, E element) { + throw new UnsupportedOperationException(IMMUTABLE_MESSAGE); + } + + @Override + public void add(int index, E element) { + throw new UnsupportedOperationException(IMMUTABLE_MESSAGE); + } + + @Override + public E remove(int index) { + throw new UnsupportedOperationException(IMMUTABLE_MESSAGE); + } + + @Override + public boolean addAll(int index, @NotNull Collection c) { + throw new UnsupportedOperationException(IMMUTABLE_MESSAGE); + } + + @Override + public void sort(Comparator c) { + throw new UnsupportedOperationException(IMMUTABLE_MESSAGE); + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/collection/DeepImmutableMap.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/collection/DeepImmutableMap.java index db72cd3..1ab37e0 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/collection/DeepImmutableMap.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/collection/DeepImmutableMap.java @@ -1,56 +1,54 @@ package io.fluent.builtin.reflection.immutable.collection; +import io.fluent.builtin.reflection.immutable.Immutable; +import io.fluent.builtin.reflection.immutable.ImmutableProxy; import java.io.Serializable; import java.util.AbstractMap; import java.util.IdentityHashMap; import java.util.Map; import java.util.Set; -import io.fluent.builtin.reflection.immutable.Immutable; -import io.fluent.builtin.reflection.immutable.ImmutableProxy; - public class DeepImmutableMap extends AbstractMap implements Immutable, Serializable { - private static final long serialVersionUID = 1L; - - static final String IMMUTABLE_MESSAGE = "This map is immutable"; + private static final long serialVersionUID = 1L; - private final Map delegate; + static final String IMMUTABLE_MESSAGE = "This map is immutable"; - private final Map immutableKeyCache = new IdentityHashMap<>(); - private final Map immutableValueCache = new IdentityHashMap<>(); + private final Map delegate; - public DeepImmutableMap(Map delegate) { - this.delegate = delegate; - } + private final Map immutableKeyCache = new IdentityHashMap<>(); + private final Map immutableValueCache = new IdentityHashMap<>(); - K getImmutableKey(K key) { - return immutableKeyCache.computeIfAbsent(key, ImmutableProxy::create); - } + public DeepImmutableMap(Map delegate) { + this.delegate = delegate; + } - V getImmutableValue(V value) { - return immutableValueCache.computeIfAbsent(value, ImmutableProxy::create); - } + K getImmutableKey(K key) { + return immutableKeyCache.computeIfAbsent(key, ImmutableProxy::create); + } - @Override - public V get(Object key) { - V value = delegate.get(key); - return getImmutableValue(value); - } + V getImmutableValue(V value) { + return immutableValueCache.computeIfAbsent(value, ImmutableProxy::create); + } - @Override - public Set> entrySet() { - return new DeepImmutableEntrySet<>(delegate.entrySet(), this); - } + @Override + public V get(Object key) { + V value = delegate.get(key); + return getImmutableValue(value); + } - @Override - public V put(K key, V value) { - throw new UnsupportedOperationException(IMMUTABLE_MESSAGE); - } + @Override + public Set> entrySet() { + return new DeepImmutableEntrySet<>(delegate.entrySet(), this); + } - @Override - public V remove(Object key) { - throw new UnsupportedOperationException(IMMUTABLE_MESSAGE); - } + @Override + public V put(K key, V value) { + throw new UnsupportedOperationException(IMMUTABLE_MESSAGE); + } + @Override + public V remove(Object key) { + throw new UnsupportedOperationException(IMMUTABLE_MESSAGE); + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/collection/DeepImmutableSet.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/collection/DeepImmutableSet.java index 56c16aa..fb72f2a 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/collection/DeepImmutableSet.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/collection/DeepImmutableSet.java @@ -7,22 +7,21 @@ public class DeepImmutableSet extends DeepImmutableCollection implements Set { - private static final long serialVersionUID = 1L; + private static final long serialVersionUID = 1L; - public DeepImmutableSet(Set set) { - super(set, "This set is immutable"); - } + public DeepImmutableSet(Set set) { + super(set, "This set is immutable"); + } - public static DeepImmutableSet of(T element) { - return new DeepImmutableSet<>(Collections.singleton(element)); - } + public static DeepImmutableSet of(T element) { + return new DeepImmutableSet<>(Collections.singleton(element)); + } - public static DeepImmutableSet of(T e1, T e2) { - return new DeepImmutableSet<>(new LinkedHashSet<>(Arrays.asList(e1, e2))); - } - - public static DeepImmutableSet of(T e1, T e2, T e3) { - return new DeepImmutableSet<>(new LinkedHashSet<>(Arrays.asList(e1, e2, e3))); - } + public static DeepImmutableSet of(T e1, T e2) { + return new DeepImmutableSet<>(new LinkedHashSet<>(Arrays.asList(e1, e2))); + } + public static DeepImmutableSet of(T e1, T e2, T e3) { + return new DeepImmutableSet<>(new LinkedHashSet<>(Arrays.asList(e1, e2, e3))); + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/collection/ImmutableIterator.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/collection/ImmutableIterator.java index b30853b..86b6295 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/collection/ImmutableIterator.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/collection/ImmutableIterator.java @@ -4,30 +4,30 @@ class ImmutableIterator implements Iterator { - private final DeepImmutableCollection collection; - private final Iterator delegate; - private final String immutableMessage; - - ImmutableIterator(DeepImmutableCollection collection, Iterator delegate, String immutableMessage) { - this.collection = collection; - this.delegate = delegate; - this.immutableMessage = immutableMessage; - } - - @Override - public boolean hasNext() { - return delegate.hasNext(); - } - - @Override - public E next() { - E element = delegate.next(); - return collection.getImmutableElement(element); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(immutableMessage); - } - + private final DeepImmutableCollection collection; + private final Iterator delegate; + private final String immutableMessage; + + ImmutableIterator( + DeepImmutableCollection collection, Iterator delegate, String immutableMessage) { + this.collection = collection; + this.delegate = delegate; + this.immutableMessage = immutableMessage; + } + + @Override + public boolean hasNext() { + return delegate.hasNext(); + } + + @Override + public E next() { + E element = delegate.next(); + return collection.getImmutableElement(element); + } + + @Override + public void remove() { + throw new UnsupportedOperationException(immutableMessage); + } } diff --git a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/collection/ImmutableListIterator.java b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/collection/ImmutableListIterator.java index c78f5a8..ebfbeaf 100644 --- a/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/collection/ImmutableListIterator.java +++ b/components/fluent-builtin/src/main/java/io/fluent/builtin/reflection/immutable/collection/ImmutableListIterator.java @@ -4,58 +4,58 @@ class ImmutableListIterator implements ListIterator { - private final DeepImmutableList list; - private final ListIterator delegate; - - ImmutableListIterator(DeepImmutableList list, ListIterator delegate) { - this.list = list; - this.delegate = delegate; - } - - @Override - public boolean hasNext() { - return delegate.hasNext(); - } - - @Override - public E next() { - E element = delegate.next(); - return list.getImmutableElement(element); - } - - @Override - public boolean hasPrevious() { - return delegate.hasPrevious(); - } - - @Override - public E previous() { - E element = delegate.previous(); - return list.getImmutableElement(element); - } - - @Override - public int nextIndex() { - return delegate.nextIndex(); - } - - @Override - public int previousIndex() { - return delegate.previousIndex(); - } - - @Override - public void remove() { - throw new UnsupportedOperationException("This list is immutable"); - } - - @Override - public void set(E t) { - throw new UnsupportedOperationException("This list is immutable"); - } - - @Override - public void add(E t) { - throw new UnsupportedOperationException("This list is immutable"); - } + private final DeepImmutableList list; + private final ListIterator delegate; + + ImmutableListIterator(DeepImmutableList list, ListIterator delegate) { + this.list = list; + this.delegate = delegate; + } + + @Override + public boolean hasNext() { + return delegate.hasNext(); + } + + @Override + public E next() { + E element = delegate.next(); + return list.getImmutableElement(element); + } + + @Override + public boolean hasPrevious() { + return delegate.hasPrevious(); + } + + @Override + public E previous() { + E element = delegate.previous(); + return list.getImmutableElement(element); + } + + @Override + public int nextIndex() { + return delegate.nextIndex(); + } + + @Override + public int previousIndex() { + return delegate.previousIndex(); + } + + @Override + public void remove() { + throw new UnsupportedOperationException("This list is immutable"); + } + + @Override + public void set(E t) { + throw new UnsupportedOperationException("This list is immutable"); + } + + @Override + public void add(E t) { + throw new UnsupportedOperationException("This list is immutable"); + } } diff --git a/components/fluent-builtin/src/test/java/io/fluent/builtin/config/AppConfigTest.java b/components/fluent-builtin/src/test/java/io/fluent/builtin/config/AppConfigTest.java index 05e1c13..0a43376 100644 --- a/components/fluent-builtin/src/test/java/io/fluent/builtin/config/AppConfigTest.java +++ b/components/fluent-builtin/src/test/java/io/fluent/builtin/config/AppConfigTest.java @@ -1,32 +1,31 @@ package io.fluent.builtin.config; +import static org.junit.jupiter.api.Assertions.*; + import io.qameta.allure.Story; import org.junit.jupiter.api.Test; -import static org.junit.jupiter.api.Assertions.*; - public class AppConfigTest { @Test - @Story( "Get All Configuration") - public void test_GetSetting(){ - var appConfig = AppConfig.create(); - assertNotNull(appConfig); + @Story("Get All Configuration") + public void test_GetSetting() { + var appConfig = AppConfig.create(); + assertNotNull(appConfig); } @Test - @Story( "Get Configuration Property") - public void test_LoadSetting(){ + @Story("Get Configuration Property") + public void test_LoadSetting() { var appConfig = AppConfig.create("config/app2.setting"); assertNotNull(appConfig); - assertEquals(appConfig.getConfigSetByGroupName("demo").get("user"),"root${demo.driver}"); + assertEquals(appConfig.getConfigSetByGroupName("demo").get("user"), "root${demo.driver}"); } - @Test - @Story( "Get Configuration to a Bean") - public void test_GetGroupSetting(){ + @Story("Get Configuration to a Bean") + public void test_GetGroupSetting() { var appConfig = AppConfig.create(); var bean = appConfig.getConfigSetBean(DemoSetting.class); - assertEquals(bean.getUser(),"root${demo.driver}"); + assertEquals(bean.getUser(), "root${demo.driver}"); } -} \ No newline at end of file +} diff --git a/components/fluent-builtin/src/test/java/io/fluent/builtin/config/DotEnvConfigTest.java b/components/fluent-builtin/src/test/java/io/fluent/builtin/config/DotEnvConfigTest.java index ba28376..d467b0f 100644 --- a/components/fluent-builtin/src/test/java/io/fluent/builtin/config/DotEnvConfigTest.java +++ b/components/fluent-builtin/src/test/java/io/fluent/builtin/config/DotEnvConfigTest.java @@ -1,14 +1,14 @@ package io.fluent.builtin.config; -import org.junit.jupiter.api.Test; - import static org.junit.jupiter.api.Assertions.*; +import org.junit.jupiter.api.Test; + class DotEnvConfigTest { - @Test - public void testGetValue(){ - var result = DotEnvConfig.getValue("TW_BEAR_TOKEN"); - System.out.println(result); - } -} \ No newline at end of file + @Test + public void testGetValue() { + var result = DotEnvConfig.getValue("TW_BEAR_TOKEN"); + System.out.println(result); + } +} diff --git a/components/fluent-builtin/src/test/java/io/fluent/builtin/strings/MatcherUtilsTest.java b/components/fluent-builtin/src/test/java/io/fluent/builtin/strings/MatcherUtilsTest.java index f34e4e9..984a36f 100644 --- a/components/fluent-builtin/src/test/java/io/fluent/builtin/strings/MatcherUtilsTest.java +++ b/components/fluent-builtin/src/test/java/io/fluent/builtin/strings/MatcherUtilsTest.java @@ -5,10 +5,8 @@ class MatcherUtilsTest { @Test - void match() { - } + void match() {} @Test - void containChinese() { - } -} \ No newline at end of file + void containChinese() {} +} diff --git a/components/fluent-builtin/src/test/java/io/fluent/builtin/strings/NamingUtilsTest.java b/components/fluent-builtin/src/test/java/io/fluent/builtin/strings/NamingUtilsTest.java index a5631c9..c69af4f 100644 --- a/components/fluent-builtin/src/test/java/io/fluent/builtin/strings/NamingUtilsTest.java +++ b/components/fluent-builtin/src/test/java/io/fluent/builtin/strings/NamingUtilsTest.java @@ -5,10 +5,8 @@ class NamingUtilsTest { @Test - void underscoreToCamel() { - } + void underscoreToCamel() {} @Test - void camelToUnderscore() { - } -} \ No newline at end of file + void camelToUnderscore() {} +} diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/annotation/DataDesc.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/annotation/DataDesc.java index f4d8655..eeb5f21 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/annotation/DataDesc.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/annotation/DataDesc.java @@ -1,21 +1,18 @@ package io.fluent.datafactory.api.annotation; - import io.fluent.datafactory.api.core.IAnnotationData; - import java.lang.annotation.*; - @Inherited @Documented @Target(ElementType.ANNOTATION_TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface DataDesc { - /** - * 数据条件实现类 - * @return 实现类 class - */ - Class value(); - + /** + * 数据条件实现类 + * + * @return 实现类 class + */ + Class value(); } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/annotation/DataFactory.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/annotation/DataFactory.java index 4fee3d9..edf723c 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/annotation/DataFactory.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/annotation/DataFactory.java @@ -1,12 +1,9 @@ package io.fluent.datafactory.api.annotation; - import io.fluent.datafactory.api.core.IAnnotationData; import io.fluent.datafactory.api.core.IData; - import java.lang.annotation.*; - @Inherited @Documented @Target(ElementType.FIELD) @@ -14,67 +11,62 @@ @DataDesc(value = IAnnotationData.class) public @interface DataFactory { - /** - * 是否忽略此字段 - * - * @return 默认不忽略 - */ - boolean ignore() default false; - - /** - * 数字整数部分最大值。 - * 只作用于数字类型的字段 - * - * @return 返回最大值 - */ - int max() default 100; + /** + * 是否忽略此字段 + * + * @return 默认不忽略 + */ + boolean ignore() default false; - /** - * 数字整数部分最小值。 - * 只作用于数字类型的字段 - * - * @return 返回最小值 - */ - int min() default 0; + /** + * 数字整数部分最大值。 只作用于数字类型的字段 + * + * @return 返回最大值 + */ + int max() default 100; - /** - * 精度。 - * 作用于Float、Double、BigDecimal 小数部分长度 - * - * @return 返回精度 - */ - int precision() default 2; + /** + * 数字整数部分最小值。 只作用于数字类型的字段 + * + * @return 返回最小值 + */ + int min() default 0; - /** - * 最大长度。只作用于String类型的字段 - * - * @return 返回最大长度 - */ - int maxLen() default 30; + /** + * 精度。 作用于Float、Double、BigDecimal 小数部分长度 + * + * @return 返回精度 + */ + int precision() default 2; - /** - * 最小长度。只作用于String类型的字段 - * - * @return 返回最小长度 - */ - int minLen() default 1; + /** + * 最大长度。只作用于String类型的字段 + * + * @return 返回最大长度 + */ + int maxLen() default 30; - /** - * 正则表达式 - * 1. 当前版本为了简单方便,如果 regex 存在,则直接忽略长度,精度等其他注解配置。 - * 2. 建议直接使用在 String 类型 - * 3. 如果使用其他类型,则必须保证提供了对应的 String 构造器。如{@link Long#Long(String)} - * 4. 基本类型会直接使用对应的包装类型。 - * @since 0.0.3 - * @return 表达式信息 - */ - String regex() default ""; + /** + * 最小长度。只作用于String类型的字段 + * + * @return 返回最小长度 + */ + int minLen() default 1; - /** - * 指定当前字段的类实现策略 - * @return 实现类 - * @since 0.0.6 - */ - Class data() default IData.class; + /** + * 正则表达式 1. 当前版本为了简单方便,如果 regex 存在,则直接忽略长度,精度等其他注解配置。 2. 建议直接使用在 String 类型 3. 如果使用其他类型,则必须保证提供了对应的 + * String 构造器。如{@link Long#Long(String)} 4. 基本类型会直接使用对应的包装类型。 + * + * @since 0.0.3 + * @return 表达式信息 + */ + String regex() default ""; + /** + * 指定当前字段的类实现策略 + * + * @return 实现类 + * @since 0.0.6 + */ + Class data() default IData.class; } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/annotation/package-info.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/annotation/package-info.java index 7c90e65..3127644 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/annotation/package-info.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/annotation/package-info.java @@ -1,6 +1,7 @@ /** * 注解相关 + * * @author binbin.hou * @since 0.0.2 */ -package io.fluent.datafactory.api.annotation; \ No newline at end of file +package io.fluent.datafactory.api.annotation; diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/core/IAnnotationData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/core/IAnnotationData.java index b41fd4a..539c2d9 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/core/IAnnotationData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/core/IAnnotationData.java @@ -1,19 +1,15 @@ package io.fluent.datafactory.api.core; - import java.lang.annotation.Annotation; -/** - * 注解约束规则接口 - * 注意:所有的实现类都需要提供无参构造函数。 - */ +/** 注解约束规则接口 注意:所有的实现类都需要提供无参构造函数。 */ public interface IAnnotationData extends IData { - /** - * 初始化映射关系 - * @param annotation 注解信息 - * @since 0.0.9 - */ - void initialize(A annotation); - + /** + * 初始化映射关系 + * + * @param annotation 注解信息 + * @since 0.0.9 + */ + void initialize(A annotation); } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/core/IData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/core/IData.java index a9f016d..ccb41e8 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/core/IData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/core/IData.java @@ -2,12 +2,12 @@ public interface IData { - /** - * 构建数据 - * @param context 运行上下文 - * @param tClass 对象类型 - * @return 构建结果 - */ - T build(final IDataFactoryContext context, final Class tClass); - + /** + * 构建数据 + * + * @param context 运行上下文 + * @param tClass 对象类型 + * @return 构建结果 + */ + T build(final IDataFactoryContext context, final Class tClass); } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/core/IDataFactoryContext.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/core/IDataFactoryContext.java index 5ee11e7..4fb199b 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/core/IDataFactoryContext.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/core/IDataFactoryContext.java @@ -1,36 +1,31 @@ package io.fluent.datafactory.api.core; - - import io.fluent.datafactory.api.annotation.DataFactory; - import java.lang.reflect.Field; import java.util.List; - public interface IDataFactoryContext { - /** - * 获取泛型列表 - * 1. 用于指定集合的泛型信息 - * 2. Map 的 K/V 按照顺序存储 - * 3. Iterable 的泛型,指定存储。 - * @return 泛型列表 - */ - List getGenericList(); - - /** - * 获取当前字段信息 - * @since 0.0.2 - * @return 当前字段信息 - */ - Field getCurrentField(); - - /** - * 获取注解信息 - * @since 0.0.2 - * @return 注解信息 - */ - DataFactory getDataFactory(); - + /** + * 获取泛型列表 1. 用于指定集合的泛型信息 2. Map 的 K/V 按照顺序存储 3. Iterable 的泛型,指定存储。 + * + * @return 泛型列表 + */ + List getGenericList(); + + /** + * 获取当前字段信息 + * + * @since 0.0.2 + * @return 当前字段信息 + */ + Field getCurrentField(); + + /** + * 获取注解信息 + * + * @since 0.0.2 + * @return 注解信息 + */ + DataFactory getDataFactory(); } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/core/IRegexGen.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/core/IRegexGen.java index aebbe48..6424882 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/core/IRegexGen.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/core/IRegexGen.java @@ -1,11 +1,10 @@ - - package io.fluent.datafactory.api.core; /** - *

正则表达式生成

+ * 正则表达式生成 * *
 Created: 2019/3/11 11:12 PM  
+ * *
 Project: data-factory  
* * @author houbinbin @@ -13,12 +12,11 @@ */ public interface IRegexGen { - /** - * 根据正则表达式生成随机的字符串 - * TODO:// 直接使用成熟框架,后期替换成为自己的实现。 - * @param regex 正则表达式 - * @return 结果 - */ - String generate(final String regex); - + /** + * 根据正则表达式生成随机的字符串 TODO:// 直接使用成熟框架,后期替换成为自己的实现。 + * + * @param regex 正则表达式 + * @return 结果 + */ + String generate(final String regex); } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/package-info.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/package-info.java index 0d1256e..6602fbe 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/package-info.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/api/package-info.java @@ -4,11 +4,12 @@ */ /** - *

API 文件夹

+ * API 文件夹 * *
 Created: 2019-02-25 21:40  
+ * *
 Project: data-factory  
* * @author houbinbin */ -package io.fluent.datafactory.api; \ No newline at end of file +package io.fluent.datafactory.api; diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/DataFactoryData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/DataFactoryData.java index 2c8d102..935c111 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/DataFactoryData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/DataFactoryData.java @@ -1,23 +1,20 @@ package io.fluent.datafactory.core; - import io.fluent.datafactory.api.core.IData; import io.fluent.datafactory.api.core.IDataFactoryContext; import io.fluent.datafactory.core.api.context.DefaultDataContext; import io.fluent.datafactory.core.support.factory.DataFactoryMapping; - import java.util.Objects; public class DataFactoryData implements IData { - @Override - @SuppressWarnings("all") - public T build(IDataFactoryContext context, Class tClass) { - if(Objects.isNull(context)) { - context = new DefaultDataContext(); - } - IData data = DataFactoryMapping.getData(tClass); - return (T) data.build(context, tClass); + @Override + @SuppressWarnings("all") + public T build(IDataFactoryContext context, Class tClass) { + if (Objects.isNull(context)) { + context = new DefaultDataContext(); } - + IData data = DataFactoryMapping.getData(tClass); + return (T) data.build(context, tClass); + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/context/DefaultDataContext.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/context/DefaultDataContext.java index 364dec8..032f7a1 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/context/DefaultDataContext.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/context/DefaultDataContext.java @@ -1,19 +1,15 @@ - - package io.fluent.datafactory.core.api.context; - - import io.fluent.datafactory.api.annotation.DataFactory; import io.fluent.datafactory.api.core.IDataFactoryContext; - import java.lang.reflect.Field; import java.util.List; /** - *

默认的数据上下文

+ * 默认的数据上下文 * *
 Created: 2019/2/27 9:31 PM  
+ * *
 Project: data-factory  
* * @author houbinbin @@ -21,47 +17,47 @@ */ public class DefaultDataContext implements IDataFactoryContext { - /** - * 泛型列表 - */ - private List genericList; - - /** - * 当前字段 - * @since 0.0.2 - */ - private Field currentField; - - /** - * 注解信息 - * @since 0.0.1 - */ - private DataFactory dataFactory; - - @Override - public List getGenericList() { - return genericList; - } - - @Override - public Field getCurrentField() { - return this.currentField; - } - - @Override - public DataFactory getDataFactory() { - return this.dataFactory; - } - - public void setGenericList(List genericList) { - this.genericList = genericList; - } - - public void setCurrentField(Field currentField) { - this.currentField = currentField; - } - - public void setDataFactory(DataFactory dataFactory) { - this.dataFactory = dataFactory; - } + /** 泛型列表 */ + private List genericList; + + /** + * 当前字段 + * + * @since 0.0.2 + */ + private Field currentField; + + /** + * 注解信息 + * + * @since 0.0.1 + */ + private DataFactory dataFactory; + + @Override + public List getGenericList() { + return genericList; + } + + @Override + public Field getCurrentField() { + return this.currentField; + } + + @Override + public DataFactory getDataFactory() { + return this.dataFactory; + } + + public void setGenericList(List genericList) { + this.genericList = genericList; + } + + public void setCurrentField(Field currentField) { + this.currentField = currentField; + } + + public void setDataFactory(DataFactory dataFactory) { + this.dataFactory = dataFactory; + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/aggregate/ArrayData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/aggregate/ArrayData.java index b5f1d7e..5f5faa4 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/aggregate/ArrayData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/aggregate/ArrayData.java @@ -1,30 +1,25 @@ package io.fluent.datafactory.core.api.data.aggregate; - - import io.fluent.datafactory.api.core.IData; import io.fluent.datafactory.api.core.IDataFactoryContext; import io.fluent.datafactory.core.util.DataFactoryDataUtil; import io.fluent.datafactory.core.util.InnerDataUtil; - import java.lang.reflect.Array; - public class ArrayData implements IData { - @Override - @SuppressWarnings("all") - public T[] build(IDataFactoryContext context, Class aClass) { - final Class itemClass = (Class) aClass.getComponentType(); - final int size = InnerDataUtil.randomSize(); - T[] arrays = (T[]) Array.newInstance(itemClass, size); - T item = DataFactoryDataUtil.build(itemClass); - - for(int i = 0; i < size; i++) { - Array.set(arrays, i, item); - } + @Override + @SuppressWarnings("all") + public T[] build(IDataFactoryContext context, Class aClass) { + final Class itemClass = (Class) aClass.getComponentType(); + final int size = InnerDataUtil.randomSize(); + T[] arrays = (T[]) Array.newInstance(itemClass, size); + T item = DataFactoryDataUtil.build(itemClass); - return arrays; + for (int i = 0; i < size; i++) { + Array.set(arrays, i, item); } + return arrays; + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/aggregate/BeanData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/aggregate/BeanData.java index dd0c417..71dc4d0 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/aggregate/BeanData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/aggregate/BeanData.java @@ -1,5 +1,7 @@ package io.fluent.datafactory.core.api.data.aggregate; +import com.github.houbb.heaven.util.lang.reflect.ClassTypeUtil; +import com.github.houbb.heaven.util.lang.reflect.ClassUtil; import io.fluent.datafactory.api.annotation.DataFactory; import io.fluent.datafactory.api.core.IAnnotationData; import io.fluent.datafactory.api.core.IData; @@ -9,9 +11,6 @@ import io.fluent.datafactory.core.exception.DataFactoryRuntimeException; import io.fluent.datafactory.core.util.DataFactoryDataUtil; import io.fluent.datafactory.core.util.InnerDataUtil; -import com.github.houbb.heaven.util.lang.reflect.ClassTypeUtil; -import com.github.houbb.heaven.util.lang.reflect.ClassUtil; - import java.lang.reflect.Field; import java.lang.reflect.Modifier; import java.lang.reflect.ParameterizedType; @@ -22,106 +21,107 @@ public class BeanData implements IData { - @Override - @SuppressWarnings("all") - public T build(IDataFactoryContext context, Class tClass) { - try { - List fieldList = ClassUtil.getAllFieldList(tClass); - T instance = ClassUtil.newInstance(tClass); - - for(Field field : fieldList) { - if(Modifier.isFinal(field.getModifiers())) { - continue; - } - // 初始化上下文 - buildContext(context, field); + @Override + @SuppressWarnings("all") + public T build(IDataFactoryContext context, Class tClass) { + try { + List fieldList = ClassUtil.getAllFieldList(tClass); + T instance = ClassUtil.newInstance(tClass); - // 字段的类型 - Object value = getFieldDataValue(field, context); - - // 设置对应的值 - field.set(instance, value); - } - return instance; - } catch (IllegalAccessException e) { - throw new DataFactoryRuntimeException(e); + for (Field field : fieldList) { + if (Modifier.isFinal(field.getModifiers())) { + continue; } - } + // 初始化上下文 + buildContext(context, field); - /** - * 获取字段对应的数据值 - * @param field 字段 - * @return 结果 - * @since 1.1.0 - */ - @SuppressWarnings("all") - private Object getFieldDataValue(final Field field, - final IDataFactoryContext context) { // 字段的类型 - Class fieldClass = field.getType(); - - // 是否为自定义注解 - IAnnotationData annotationData = InnerDataUtil.getDefineDataAnnotation(field); - - // 是否为对应的信息 - Object value = null; - DataFactory dataFactory = field.getAnnotation(DataFactory.class); - if(dataFactory != null) { - // 用户自定义的实现方式 - if(dataFactory.data() != IData.class) { - value = ClassUtil.newInstance(dataFactory.data()).build(context, fieldClass); - } else { - // 默认的实现 - value = DefaultDataFactoryAnnotationData.newInstance() - .setAnnotation(dataFactory) - .build(context, fieldClass); - } - } else if(annotationData != null) { - // 用户自定义注解 - value = annotationData.build(context, fieldClass); - } else { - // 没有任何注解的时候 - value = DataFactoryDataUtil.build(context, fieldClass); - } - - return value; + Object value = getFieldDataValue(field, context); + + // 设置对应的值 + field.set(instance, value); + } + return instance; + } catch (IllegalAccessException e) { + throw new DataFactoryRuntimeException(e); + } + } + + /** + * 获取字段对应的数据值 + * + * @param field 字段 + * @return 结果 + * @since 1.1.0 + */ + @SuppressWarnings("all") + private Object getFieldDataValue(final Field field, final IDataFactoryContext context) { + // 字段的类型 + Class fieldClass = field.getType(); + + // 是否为自定义注解 + IAnnotationData annotationData = InnerDataUtil.getDefineDataAnnotation(field); + + // 是否为对应的信息 + Object value = null; + DataFactory dataFactory = field.getAnnotation(DataFactory.class); + if (dataFactory != null) { + // 用户自定义的实现方式 + if (dataFactory.data() != IData.class) { + value = ClassUtil.newInstance(dataFactory.data()).build(context, fieldClass); + } else { + // 默认的实现 + value = + DefaultDataFactoryAnnotationData.newInstance() + .setAnnotation(dataFactory) + .build(context, fieldClass); + } + } else if (annotationData != null) { + // 用户自定义注解 + value = annotationData.build(context, fieldClass); + } else { + // 没有任何注解的时候 + value = DataFactoryDataUtil.build(context, fieldClass); } - /** - * 构建执行的上下文 - * @param context 执行的上下文 - * @param field 字段信息 - * @return 执行的上下问 - */ - @SuppressWarnings("all") - private IDataFactoryContext buildContext(IDataFactoryContext context, Field field) { - final Class fieldType = field.getType(); - Type type = field.getGenericType(); - - if(context instanceof DefaultDataContext) { - DefaultDataContext defaultDataContext = (DefaultDataContext)context; - defaultDataContext.setCurrentField(field); - if(type instanceof ParameterizedType) { - List genericTypeList = new ArrayList<>(); - // 可遍历的集合 - if(ClassTypeUtil.isIterable(fieldType)) { - Class genericType = (Class) ((ParameterizedType) type).getActualTypeArguments()[0]; - genericTypeList.add(genericType); - defaultDataContext.setGenericList(genericTypeList); - } - - // map - if(Map.class.isAssignableFrom(fieldType)) { - Class genericKeyType = (Class) ((ParameterizedType) type).getActualTypeArguments()[0]; - Class genericValueType = (Class) ((ParameterizedType) type).getActualTypeArguments()[0]; - genericTypeList.add(genericKeyType); - genericTypeList.add(genericValueType); - defaultDataContext.setGenericList(genericTypeList); - } - } + return value; + } + + /** + * 构建执行的上下文 + * + * @param context 执行的上下文 + * @param field 字段信息 + * @return 执行的上下问 + */ + @SuppressWarnings("all") + private IDataFactoryContext buildContext(IDataFactoryContext context, Field field) { + final Class fieldType = field.getType(); + Type type = field.getGenericType(); + + if (context instanceof DefaultDataContext) { + DefaultDataContext defaultDataContext = (DefaultDataContext) context; + defaultDataContext.setCurrentField(field); + if (type instanceof ParameterizedType) { + List genericTypeList = new ArrayList<>(); + // 可遍历的集合 + if (ClassTypeUtil.isIterable(fieldType)) { + Class genericType = (Class) ((ParameterizedType) type).getActualTypeArguments()[0]; + genericTypeList.add(genericType); + defaultDataContext.setGenericList(genericTypeList); } - return context; + // map + if (Map.class.isAssignableFrom(fieldType)) { + Class genericKeyType = (Class) ((ParameterizedType) type).getActualTypeArguments()[0]; + Class genericValueType = (Class) ((ParameterizedType) type).getActualTypeArguments()[0]; + genericTypeList.add(genericKeyType); + genericTypeList.add(genericValueType); + defaultDataContext.setGenericList(genericTypeList); + } + } } + return context; + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/aggregate/EnumData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/aggregate/EnumData.java index 781753e..f863872 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/aggregate/EnumData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/aggregate/EnumData.java @@ -3,21 +3,17 @@ import com.github.houbb.heaven.util.util.ArrayUtil; import io.fluent.datafactory.api.core.IData; import io.fluent.datafactory.api.core.IDataFactoryContext; - - import java.util.concurrent.ThreadLocalRandom; - public class EnumData implements IData { - @Override - public Enum build(IDataFactoryContext context, Class enumClass) { - Enum[] enums = enumClass.getEnumConstants(); - if(ArrayUtil.isNotEmpty(enums)) { - ThreadLocalRandom random = ThreadLocalRandom.current(); - return enums[random.nextInt(enums.length)]; - } - return null; + @Override + public Enum build(IDataFactoryContext context, Class enumClass) { + Enum[] enums = enumClass.getEnumConstants(); + if (ArrayUtil.isNotEmpty(enums)) { + ThreadLocalRandom random = ThreadLocalRandom.current(); + return enums[random.nextInt(enums.length)]; } - + return null; + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/aggregate/IterableData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/aggregate/IterableData.java index e13d2fb..7cdbe05 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/aggregate/IterableData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/aggregate/IterableData.java @@ -1,6 +1,5 @@ package io.fluent.datafactory.core.api.data.aggregate; - import com.github.houbb.heaven.util.lang.reflect.ClassUtil; import com.github.houbb.heaven.util.util.CollectionUtil; import io.fluent.datafactory.api.core.IData; @@ -8,7 +7,6 @@ import io.fluent.datafactory.core.exception.DataFactoryRuntimeException; import io.fluent.datafactory.core.util.DataFactoryDataUtil; import io.fluent.datafactory.core.util.InnerDataUtil; - import java.util.ArrayDeque; import java.util.ArrayList; import java.util.Collection; @@ -19,54 +17,54 @@ /** * map 集合的实现 - * @author binbin.hou - * date 2019/2/26 + * + * @author binbin.hou date 2019/2/26 * @since 0.0.1 */ public class IterableData implements IData> { - @Override - @SuppressWarnings("all") - public Iterable build(IDataFactoryContext context, Class> iterableClass) { - // 直接存放线性表 - Iterable result = newInstance(iterableClass); - if(CollectionUtil.isEmpty(context.getGenericList())) { - return result; - } - - // 获取元素类型 - final Class itemClass = context.getGenericList().get(0); - // 新增元素 - final int size = InnerDataUtil.randomSize(); - Collection collection = (Collection) result; - for(int i = 0; i < size; i++) { - final T object = DataFactoryDataUtil.build(context, itemClass); - collection.add(object); - } - - return result; + @Override + @SuppressWarnings("all") + public Iterable build(IDataFactoryContext context, Class> iterableClass) { + // 直接存放线性表 + Iterable result = newInstance(iterableClass); + if (CollectionUtil.isEmpty(context.getGenericList())) { + return result; } - /** - * 创建对应的实例 - * @param iterableClass 类 - * @return 结果 - */ - private Iterable newInstance(final Class> iterableClass) { - try { - return ClassUtil.newInstance(iterableClass); - } catch (Exception e) { - if(List.class.isAssignableFrom(iterableClass)) { - return new ArrayList<>(); - } - if(Set.class.isAssignableFrom(iterableClass)) { - return new HashSet<>(); - } - if(Queue.class.isAssignableFrom(iterableClass)) { - return new ArrayDeque<>(); - } - throw new DataFactoryRuntimeException(e); - } + // 获取元素类型 + final Class itemClass = context.getGenericList().get(0); + // 新增元素 + final int size = InnerDataUtil.randomSize(); + Collection collection = (Collection) result; + for (int i = 0; i < size; i++) { + final T object = DataFactoryDataUtil.build(context, itemClass); + collection.add(object); } + return result; + } + + /** + * 创建对应的实例 + * + * @param iterableClass 类 + * @return 结果 + */ + private Iterable newInstance(final Class> iterableClass) { + try { + return ClassUtil.newInstance(iterableClass); + } catch (Exception e) { + if (List.class.isAssignableFrom(iterableClass)) { + return new ArrayList<>(); + } + if (Set.class.isAssignableFrom(iterableClass)) { + return new HashSet<>(); + } + if (Queue.class.isAssignableFrom(iterableClass)) { + return new ArrayDeque<>(); + } + throw new DataFactoryRuntimeException(e); + } + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/aggregate/MapData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/aggregate/MapData.java index 88fe2d7..76a8e78 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/aggregate/MapData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/aggregate/MapData.java @@ -1,55 +1,54 @@ package io.fluent.datafactory.core.api.data.aggregate; +import com.github.houbb.heaven.util.lang.reflect.ClassUtil; +import com.github.houbb.heaven.util.util.CollectionUtil; import io.fluent.datafactory.api.core.IData; import io.fluent.datafactory.api.core.IDataFactoryContext; import io.fluent.datafactory.core.util.DataFactoryDataUtil; import io.fluent.datafactory.core.util.InnerDataUtil; -import com.github.houbb.heaven.util.lang.reflect.ClassUtil; -import com.github.houbb.heaven.util.util.CollectionUtil; - import java.util.HashMap; import java.util.List; import java.util.Map; /** * map 集合的实现 - * @author binbin.hou - * date 2019/2/26 + * + * @author binbin.hou date 2019/2/26 * @since 0.0.1 */ public class MapData implements IData { - @Override - @SuppressWarnings("all") - public Map build(IDataFactoryContext context, Class mapClass) { - final int size = InnerDataUtil.randomSize(); - Map map = new HashMap(size); - - List genericTypeList = context.getGenericList(); - if(CollectionUtil.isEmpty(genericTypeList)) { - return map; - } + @Override + @SuppressWarnings("all") + public Map build(IDataFactoryContext context, Class mapClass) { + final int size = InnerDataUtil.randomSize(); + Map map = new HashMap(size); - for(int i = 0; i < size; i++) { - final Object key = DataFactoryDataUtil.build(context, genericTypeList.get(0)); - final Object value = DataFactoryDataUtil.build(context, genericTypeList.get(1)); - map.put(key, value); - } - - return map; + List genericTypeList = context.getGenericList(); + if (CollectionUtil.isEmpty(genericTypeList)) { + return map; } - /** - * 创建对应的实例 - * @param mapClass 类 - * @return 结果 - */ - private Map newInstance(final Class mapClass) { - try { - return ClassUtil.newInstance(mapClass); - } catch (Exception e) { - return new HashMap<>(); - } + for (int i = 0; i < size; i++) { + final Object key = DataFactoryDataUtil.build(context, genericTypeList.get(0)); + final Object value = DataFactoryDataUtil.build(context, genericTypeList.get(1)); + map.put(key, value); } + return map; + } + + /** + * 创建对应的实例 + * + * @param mapClass 类 + * @return 结果 + */ + private Map newInstance(final Class mapClass) { + try { + return ClassUtil.newInstance(mapClass); + } catch (Exception e) { + return new HashMap<>(); + } + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/aggregate/NullData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/aggregate/NullData.java index 104f2b7..212e2e5 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/aggregate/NullData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/aggregate/NullData.java @@ -1,39 +1,35 @@ - - package io.fluent.datafactory.core.api.data.aggregate; +import com.github.houbb.heaven.util.lang.ObjectUtil; import io.fluent.datafactory.api.core.IData; import io.fluent.datafactory.api.core.IDataFactoryContext; -import com.github.houbb.heaven.util.lang.ObjectUtil; /** - * null 对象数据实现 - * 1. 使用空对象模式。 - * @author binbin.hou - * date 2019/2/26 + * null 对象数据实现 1. 使用空对象模式。 + * + * @author binbin.hou date 2019/2/26 * @since 0.0.1 */ public final class NullData implements IData { - /** - * 空对象模式实现 - */ - public static final IData INSTANCE = new NullData(); + /** 空对象模式实现 */ + public static final IData INSTANCE = new NullData(); - @Override - public Object build(IDataFactoryContext context, Class aClass) { - return null; - } + @Override + public Object build(IDataFactoryContext context, Class aClass) { + return null; + } - /** - * 是否为空对象模式 - * @param data 类型 - * @return 是否 - */ - public static boolean isNullData(final IData data) { - if(ObjectUtil.isNull(data)) { - return false; - } - return INSTANCE.getClass().equals(data.getClass()); + /** + * 是否为空对象模式 + * + * @param data 类型 + * @return 是否 + */ + public static boolean isNullData(final IData data) { + if (ObjectUtil.isNull(data)) { + return false; } + return INSTANCE.getClass().equals(data.getClass()); + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/aggregate/package-info.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/aggregate/package-info.java index 74a911d..1249c9c 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/aggregate/package-info.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/aggregate/package-info.java @@ -1,6 +1,7 @@ /** * 集合相关的实现 + * * @author binbin.hou * @since 0.0.1 */ -package io.fluent.datafactory.core.api.data.aggregate; \ No newline at end of file +package io.fluent.datafactory.core.api.data.aggregate; diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/annotation/AbstractAnnotationData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/annotation/AbstractAnnotationData.java index 9c56417..779f7d0 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/annotation/AbstractAnnotationData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/annotation/AbstractAnnotationData.java @@ -1,10 +1,8 @@ package io.fluent.datafactory.core.api.data.annotation; - import com.github.houbb.heaven.util.common.ArgUtil; import io.fluent.datafactory.api.core.IAnnotationData; import io.fluent.datafactory.api.core.IDataFactoryContext; - import java.lang.annotation.Annotation; /** @@ -15,53 +13,52 @@ */ public abstract class AbstractAnnotationData
implements IAnnotationData { - /** - * 注解信息 - */ - private A annotation; + /** 注解信息 */ + private A annotation; - /** - * 构建数据实现值 - * - * @param annotation 注解信息 - * @param context 上下文 - * @param tClass 类信息 - * @return 数据实现 - * @since 0.1.1 - */ - protected abstract Object buildDataValue(final A annotation, - IDataFactoryContext context, Class tClass); + /** + * 构建数据实现值 + * + * @param annotation 注解信息 + * @param context 上下文 + * @param tClass 类信息 + * @return 数据实现 + * @since 0.1.1 + */ + protected abstract Object buildDataValue( + final A annotation, IDataFactoryContext context, Class tClass); - /** - * 构建注解提示名称 - * - * @return 提示名称 - * @since 0.1.1 - */ - protected String annotationName() { - return "annotation"; - } + /** + * 构建注解提示名称 + * + * @return 提示名称 + * @since 0.1.1 + */ + protected String annotationName() { + return "annotation"; + } - @Override - public void initialize(A annotation) { - ArgUtil.notNull(annotation, annotationName()); - this.annotation = annotation; - } + @Override + public void initialize(A annotation) { + ArgUtil.notNull(annotation, annotationName()); + this.annotation = annotation; + } - @Override - public Object build(IDataFactoryContext context, Class tClass) { - return buildDataValue(this.annotation, context, tClass); - } + @Override + public Object build(IDataFactoryContext context, Class tClass) { + return buildDataValue(this.annotation, context, tClass); + } - /** - * 设置注解 - * @param annotation 注解 - * @since 1.1.0 - * @return this - */ - public AbstractAnnotationData setAnnotation(A annotation) { - this.annotation = annotation; + /** + * 设置注解 + * + * @param annotation 注解 + * @since 1.1.0 + * @return this + */ + public AbstractAnnotationData setAnnotation(A annotation) { + this.annotation = annotation; - return this; - } + return this; + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/annotation/AbstractNumberData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/annotation/AbstractNumberData.java index 26e6c44..1acc02e 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/annotation/AbstractNumberData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/annotation/AbstractNumberData.java @@ -1,137 +1,140 @@ package io.fluent.datafactory.core.api.data.annotation; - import com.github.houbb.heaven.util.lang.ObjectUtil; import com.github.houbb.heaven.util.lang.StringUtil; import io.fluent.datafactory.api.annotation.DataFactory; import io.fluent.datafactory.api.core.IDataFactoryContext; import io.fluent.datafactory.core.exception.DataFactoryRuntimeException; - import java.util.concurrent.ThreadLocalRandom; /** - * 数字相关处理 - * 1. short byte int long - * 2. double float - * 3. bigInteger bigDecimal - * 4. atomicLong atomicInteger + * 数字相关处理 1. short byte int long 2. double float 3. bigInteger bigDecimal 4. atomicLong + * atomicInteger + * * @author binbin.hou * @date 2019/3/9 * @since 0.0.2 */ public abstract class AbstractNumberData { - /** - * 获取最小值 - * @return 最小值 - */ - protected int getMin() { - return Integer.MIN_VALUE; + /** + * 获取最小值 + * + * @return 最小值 + */ + protected int getMin() { + return Integer.MIN_VALUE; + } + + /** + * 获取最大值 + * + * @return 最大值 + */ + protected int getMax() { + return Integer.MAX_VALUE; + } + + /** + * 构建整数部分字符串 + * + * @param context 上下文 + * @return 构建的结果 + */ + private String buildIntegerString(IDataFactoryContext context) { + // 2. 参数范围的处理 + int minResult = 0; + int maxResult = 100; + + // 1. 参数范围的校验 + DataFactory dataFactory = context.getDataFactory(); + if (ObjectUtil.isNotNull(dataFactory)) { + // 具体的参数校验 + paramCheck(dataFactory); + + minResult = dataFactory.min(); + maxResult = dataFactory.max(); } - /** - * 获取最大值 - * @return 最大值 - */ - protected int getMax() { - return Integer.MAX_VALUE; + ThreadLocalRandom random = ThreadLocalRandom.current(); + int randomInt = random.nextInt(minResult, maxResult); + return String.valueOf(randomInt); + } + + /** + * 参数校验 + * + * @param dataFactory 注解信息 + */ + private void paramCheck(final DataFactory dataFactory) { + int min = dataFactory.min(); + int max = dataFactory.max(); + if (min > max) { + throw new DataFactoryRuntimeException( + "DataFactory.min() is not allow great than dataFactory.max()."); } - /** - * 构建整数部分字符串 - * @param context 上下文 - * @return 构建的结果 - */ - private String buildIntegerString(IDataFactoryContext context) { - //2. 参数范围的处理 - int minResult = 0; - int maxResult = 100; - - //1. 参数范围的校验 - DataFactory dataFactory = context.getDataFactory(); - if(ObjectUtil.isNotNull(dataFactory)) { - // 具体的参数校验 - paramCheck(dataFactory); - - minResult = dataFactory.min(); - maxResult = dataFactory.max(); - } - - ThreadLocalRandom random = ThreadLocalRandom.current(); - int randomInt = random.nextInt(minResult, maxResult); - return String.valueOf(randomInt); + int minAllow = getMin(); + int maxAllow = getMax(); + if (min < minAllow) { + throw new DataFactoryRuntimeException("DataFactory.min() is not allow less than " + minAllow); } - - /** - * 参数校验 - * @param dataFactory 注解信息 - */ - private void paramCheck(final DataFactory dataFactory) { - int min = dataFactory.min(); - int max = dataFactory.max(); - if(min > max) { - throw new DataFactoryRuntimeException("DataFactory.min() is not allow great than dataFactory.max()."); - } - - int minAllow = getMin(); - int maxAllow = getMax(); - if(min < minAllow) { - throw new DataFactoryRuntimeException("DataFactory.min() is not allow less than " + minAllow); - } - if(max > maxAllow) { - throw new DataFactoryRuntimeException("DataFactory.max() is not allow great than " + maxAllow); - } + if (max > maxAllow) { + throw new DataFactoryRuntimeException( + "DataFactory.max() is not allow great than " + maxAllow); } - - /** - * 构建小数部分的字符串 - * @param context 上下文 - * @return 结果 - */ - private String buildDecimalString(IDataFactoryContext context) { - int precisionResult = 2; - - //1. 参数范围的校验 - DataFactory dataFactory = context.getDataFactory(); - if(ObjectUtil.isNotNull(dataFactory)) { - precisionResult = dataFactory.precision(); - if(precisionResult < 0) { - throw new DataFactoryRuntimeException("DataFactory.precision() is not allow less than 0."); - } - } - - - StringBuilder stringBuilder = new StringBuilder(); - ThreadLocalRandom random = ThreadLocalRandom.current(); - for(int i = 0; i < precisionResult; i++) { - int nextInt = random.nextInt(0, 9); - stringBuilder.append(nextInt); - } - return stringBuilder.toString(); + } + + /** + * 构建小数部分的字符串 + * + * @param context 上下文 + * @return 结果 + */ + private String buildDecimalString(IDataFactoryContext context) { + int precisionResult = 2; + + // 1. 参数范围的校验 + DataFactory dataFactory = context.getDataFactory(); + if (ObjectUtil.isNotNull(dataFactory)) { + precisionResult = dataFactory.precision(); + if (precisionResult < 0) { + throw new DataFactoryRuntimeException("DataFactory.precision() is not allow less than 0."); + } } - /** - * 将整数部分和小数部分联合起来 - * @param context 上下文信息 - * @return 结果 - */ - protected String contactIntDecimal(final IDataFactoryContext context) { - final String integerString = buildIntegerString(context); - final String decimalString = buildDecimalString(context); - if(StringUtil.isEmpty(decimalString)) { - return integerString; - } - - return integerString+"."+decimalString; + StringBuilder stringBuilder = new StringBuilder(); + ThreadLocalRandom random = ThreadLocalRandom.current(); + for (int i = 0; i < precisionResult; i++) { + int nextInt = random.nextInt(0, 9); + stringBuilder.append(nextInt); } - - /** - * 将整数部分和小数部分联合起来 - * @param context 上下文 - * @return 结果 - */ - protected String contactInt(final IDataFactoryContext context) { - return buildIntegerString(context); + return stringBuilder.toString(); + } + + /** + * 将整数部分和小数部分联合起来 + * + * @param context 上下文信息 + * @return 结果 + */ + protected String contactIntDecimal(final IDataFactoryContext context) { + final String integerString = buildIntegerString(context); + final String decimalString = buildDecimalString(context); + if (StringUtil.isEmpty(decimalString)) { + return integerString; } + return integerString + "." + decimalString; + } + + /** + * 将整数部分和小数部分联合起来 + * + * @param context 上下文 + * @return 结果 + */ + protected String contactInt(final IDataFactoryContext context) { + return buildIntegerString(context); + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/annotation/DefaultDataFactoryAnnotationData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/annotation/DefaultDataFactoryAnnotationData.java index a76adac..64e4dbc 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/annotation/DefaultDataFactoryAnnotationData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/annotation/DefaultDataFactoryAnnotationData.java @@ -1,6 +1,5 @@ package io.fluent.datafactory.core.api.data.annotation; - import com.github.houbb.heaven.util.lang.StringUtil; import io.fluent.datafactory.api.annotation.DataFactory; import io.fluent.datafactory.api.core.IDataFactoryContext; @@ -10,7 +9,6 @@ import io.fluent.datafactory.core.exception.DataFactoryRuntimeException; import io.fluent.datafactory.core.support.factory.DataFactoryMapping; import io.fluent.datafactory.core.util.DataPrimitiveUtil; - import java.lang.reflect.Constructor; import java.lang.reflect.Field; import java.lang.reflect.InvocationTargetException; @@ -22,74 +20,75 @@ */ public class DefaultDataFactoryAnnotationData extends AbstractAnnotationData { - /** - * 新建对象实例 - * - * @return 实现 - * @since 1.1.0 - */ - public static DefaultDataFactoryAnnotationData newInstance() { - return new DefaultDataFactoryAnnotationData(); - } - - @Override - protected Object buildDataValue(DataFactory dataFactory, - IDataFactoryContext context, - Class tClass) { - // 忽略字段,直接返回 null - if (dataFactory == null || dataFactory.ignore()) { - return null; - } + /** + * 新建对象实例 + * + * @return 实现 + * @since 1.1.0 + */ + public static DefaultDataFactoryAnnotationData newInstance() { + return new DefaultDataFactoryAnnotationData(); + } - Field field = context.getCurrentField(); - Class fieldType = field.getType(); + @Override + protected Object buildDataValue( + DataFactory dataFactory, IDataFactoryContext context, Class tClass) { + // 忽略字段,直接返回 null + if (dataFactory == null || dataFactory.ignore()) { + return null; + } - // 如果 regex 不为空,直接返回 regex 信息 - IRegexGen regexGen = new DefaultRegexGen(); - final String regex = dataFactory.regex(); - if(StringUtil.isNotEmpty(regex)) { - if(fieldType.isPrimitive()) { - fieldType = DataPrimitiveUtil.getReferenceType(fieldType); - } - final String regexResult = regexGen.generate(regex); - return newInstance(fieldType, regexResult); - } + Field field = context.getCurrentField(); + Class fieldType = field.getType(); - // 设置 DataFactory 注解信息,便于获得。 - if(context instanceof DefaultDataContext) { - DefaultDataContext defaultDataContext = (DefaultDataContext)context; - defaultDataContext.setDataFactory(dataFactory); - } + // 如果 regex 不为空,直接返回 regex 信息 + IRegexGen regexGen = new DefaultRegexGen(); + final String regex = dataFactory.regex(); + if (StringUtil.isNotEmpty(regex)) { + if (fieldType.isPrimitive()) { + fieldType = DataPrimitiveUtil.getReferenceType(fieldType); + } + final String regexResult = regexGen.generate(regex); + return newInstance(fieldType, regexResult); + } - return DataFactoryMapping.getData(fieldType).build(context, fieldType); + // 设置 DataFactory 注解信息,便于获得。 + if (context instanceof DefaultDataContext) { + DefaultDataContext defaultDataContext = (DefaultDataContext) context; + defaultDataContext.setDataFactory(dataFactory); } - /** - * 创建对应的实例 - * 1. 根据类的 class 直接创建。 - * @param fieldType 字段类型 - * @param string 字符串 - * @return 结果 - */ - private Object newInstance(Class fieldType, final String string) { - // 如果为字符串,考虑到性能开销,直接返回本身 - if(String.class.equals(fieldType)) { - return string; - } + return DataFactoryMapping.getData(fieldType).build(context, fieldType); + } - // 其他类型,当为空时,则视为 null - if(StringUtil.isEmpty(string)) { - return null; - } + /** + * 创建对应的实例 1. 根据类的 class 直接创建。 + * + * @param fieldType 字段类型 + * @param string 字符串 + * @return 结果 + */ + private Object newInstance(Class fieldType, final String string) { + // 如果为字符串,考虑到性能开销,直接返回本身 + if (String.class.equals(fieldType)) { + return string; + } - try { - // 获取所有的构造器,直接反射调用 constructor(string) - Constructor constructor = fieldType.getConstructor(String.class); - return constructor.newInstance(string); - } catch (NoSuchMethodException | IllegalAccessException | InstantiationException | InvocationTargetException e) { - //TODO: 这里应该考虑到有些没有提供 String 构造器的类。 - throw new DataFactoryRuntimeException(e); - } + // 其他类型,当为空时,则视为 null + if (StringUtil.isEmpty(string)) { + return null; } + try { + // 获取所有的构造器,直接反射调用 constructor(string) + Constructor constructor = fieldType.getConstructor(String.class); + return constructor.newInstance(string); + } catch (NoSuchMethodException + | IllegalAccessException + | InstantiationException + | InvocationTargetException e) { + // TODO: 这里应该考虑到有些没有提供 String 构造器的类。 + throw new DataFactoryRuntimeException(e); + } + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/lang/StringData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/lang/StringData.java index 2b02469..7ceb7ec 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/lang/StringData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/lang/StringData.java @@ -1,76 +1,74 @@ package io.fluent.datafactory.core.api.data.lang; - import com.github.houbb.heaven.util.lang.ObjectUtil; import com.google.auto.service.AutoService; import io.fluent.datafactory.api.annotation.DataFactory; import io.fluent.datafactory.api.core.IData; import io.fluent.datafactory.api.core.IDataFactoryContext; import io.fluent.datafactory.core.exception.DataFactoryRuntimeException; - import java.util.concurrent.ThreadLocalRandom; /** * 字符串数据实现 - * @author binbin.hou - * date 2019/2/26 + * + * @author binbin.hou date 2019/2/26 * @since 0.0.1 */ @AutoService(IData.class) public class StringData implements IData { - /** - * 基础字符 - */ - private static final char[] CHARS = "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray(); + /** 基础字符 */ + private static final char[] CHARS = + "0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ".toCharArray(); - @Override - public String build(IDataFactoryContext context, Class booleanClass) { - ThreadLocalRandom random = ThreadLocalRandom.current(); - int randomLength = getRandomLength(context, random); - StringBuilder stringBuilder = new StringBuilder(); - for(int i = 0; i < randomLength; i++) { - int charIndex = random.nextInt(CHARS.length); - stringBuilder.append(CHARS[charIndex]); - } - return stringBuilder.toString(); + @Override + public String build(IDataFactoryContext context, Class booleanClass) { + ThreadLocalRandom random = ThreadLocalRandom.current(); + int randomLength = getRandomLength(context, random); + StringBuilder stringBuilder = new StringBuilder(); + for (int i = 0; i < randomLength; i++) { + int charIndex = random.nextInt(CHARS.length); + stringBuilder.append(CHARS[charIndex]); } + return stringBuilder.toString(); + } - /** - * 获取随机的长度 - * 1-10 随机长度 - * @param context 执行上下文 - * @param random 随机 - * @return 长度 - */ - private int getRandomLength(final IDataFactoryContext context, final ThreadLocalRandom random) { - int minLenResult = 1; - int maxLenResult = 10; + /** + * 获取随机的长度 1-10 随机长度 + * + * @param context 执行上下文 + * @param random 随机 + * @return 长度 + */ + private int getRandomLength(final IDataFactoryContext context, final ThreadLocalRandom random) { + int minLenResult = 1; + int maxLenResult = 10; - DataFactory dataFactory = context.getDataFactory(); - if(ObjectUtil.isNotNull(dataFactory)) { - paramCheck(dataFactory); + DataFactory dataFactory = context.getDataFactory(); + if (ObjectUtil.isNotNull(dataFactory)) { + paramCheck(dataFactory); - minLenResult = dataFactory.minLen(); - maxLenResult = dataFactory.maxLen(); - } - return minLenResult+random.nextInt(maxLenResult-1); + minLenResult = dataFactory.minLen(); + maxLenResult = dataFactory.maxLen(); } + return minLenResult + random.nextInt(maxLenResult - 1); + } - /** - * 参数校验 - * @param dataFactory 注解 - */ - private void paramCheck(DataFactory dataFactory) { - int minLen = dataFactory.minLen(); - int maxLen = dataFactory.maxLen(); + /** + * 参数校验 + * + * @param dataFactory 注解 + */ + private void paramCheck(DataFactory dataFactory) { + int minLen = dataFactory.minLen(); + int maxLen = dataFactory.maxLen(); - if(minLen < 0) { - throw new DataFactoryRuntimeException("DataFactory.minLen() not allow less than 0."); - } - if(minLen > maxLen) { - throw new DataFactoryRuntimeException("DataFactory.maxLen() not allow less than DataFactory.minLen()."); - } + if (minLen < 0) { + throw new DataFactoryRuntimeException("DataFactory.minLen() not allow less than 0."); } - + if (minLen > maxLen) { + throw new DataFactoryRuntimeException( + "DataFactory.maxLen() not allow less than DataFactory.minLen()."); + } + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/lang/package-info.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/lang/package-info.java index c5a3a64..72c68a5 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/lang/package-info.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/lang/package-info.java @@ -1,6 +1,7 @@ /** * java.lang 包对应的信息处理 + * * @author binbin.hou * @since 0.0.1 */ -package io.fluent.datafactory.core.api.data.lang; \ No newline at end of file +package io.fluent.datafactory.core.api.data.lang; diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/math/BigDecimalData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/math/BigDecimalData.java index 20b125b..928997e 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/math/BigDecimalData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/math/BigDecimalData.java @@ -1,21 +1,17 @@ package io.fluent.datafactory.core.api.data.math; - import com.google.auto.service.AutoService; import io.fluent.datafactory.api.core.IData; import io.fluent.datafactory.api.core.IDataFactoryContext; import io.fluent.datafactory.core.api.data.annotation.AbstractNumberData; - import java.math.BigDecimal; - @AutoService(IData.class) public class BigDecimalData extends AbstractNumberData implements IData { - @Override - public BigDecimal build(IDataFactoryContext context, Class bigIntegerClass) { - final String string = super.contactIntDecimal(context); - return new BigDecimal(string); - } - + @Override + public BigDecimal build(IDataFactoryContext context, Class bigIntegerClass) { + final String string = super.contactIntDecimal(context); + return new BigDecimal(string); + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/math/BigIntegerData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/math/BigIntegerData.java index daa6655..d9f4231 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/math/BigIntegerData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/math/BigIntegerData.java @@ -4,17 +4,14 @@ import io.fluent.datafactory.api.core.IData; import io.fluent.datafactory.api.core.IDataFactoryContext; import io.fluent.datafactory.core.api.data.annotation.AbstractNumberData; - import java.math.BigInteger; - @AutoService(IData.class) public class BigIntegerData extends AbstractNumberData implements IData { - @Override - public BigInteger build(IDataFactoryContext context, Class bigIntegerClass) { - final String string = super.contactInt(context); - return new BigInteger(string); - } - + @Override + public BigInteger build(IDataFactoryContext context, Class bigIntegerClass) { + final String string = super.contactInt(context); + return new BigInteger(string); + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/math/package-info.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/math/package-info.java index 6f842ef..ba913cc 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/math/package-info.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/math/package-info.java @@ -1,6 +1,7 @@ /** * 数学相关类的处理 + * * @author binbin.hou * @since 0.0.1 */ -package io.fluent.datafactory.core.api.data.math; \ No newline at end of file +package io.fluent.datafactory.core.api.data.math; diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/package-info.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/package-info.java index 2fc1fd5..52cd3b3 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/package-info.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/package-info.java @@ -1,6 +1,7 @@ /** * 列表 map 数组 + * * @author binbin.hou * @since 0.0.1 */ -package io.fluent.datafactory.core.api.data; \ No newline at end of file +package io.fluent.datafactory.core.api.data; diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/BoolArrayData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/BoolArrayData.java index bb35f89..9861f1a 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/BoolArrayData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/BoolArrayData.java @@ -1,24 +1,21 @@ package io.fluent.datafactory.core.api.data.primitive; - import com.google.auto.service.AutoService; import io.fluent.datafactory.api.core.IData; import io.fluent.datafactory.api.core.IDataFactoryContext; import io.fluent.datafactory.core.util.DataFactoryDataUtil; import io.fluent.datafactory.core.util.InnerDataUtil; - @AutoService(IData.class) public class BoolArrayData implements IData { - @Override - public boolean[] build(IDataFactoryContext context, Class aClass) { - int size = InnerDataUtil.randomSize(); - boolean[] array = new boolean[size]; - for(int i = 0; i < size; i++) { - array[i] = DataFactoryDataUtil.build(boolean.class); - } - return array; + @Override + public boolean[] build(IDataFactoryContext context, Class aClass) { + int size = InnerDataUtil.randomSize(); + boolean[] array = new boolean[size]; + for (int i = 0; i < size; i++) { + array[i] = DataFactoryDataUtil.build(boolean.class); } - + return array; + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/BoolData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/BoolData.java index 848ae1f..b005bc3 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/BoolData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/BoolData.java @@ -1,18 +1,16 @@ package io.fluent.datafactory.core.api.data.primitive; + import com.google.auto.service.AutoService; import io.fluent.datafactory.api.core.IData; import io.fluent.datafactory.api.core.IDataFactoryContext; - import java.util.concurrent.ThreadLocalRandom; - @AutoService(IData.class) public class BoolData implements IData { - @Override - public Boolean build(IDataFactoryContext context, Class booleanClass) { - ThreadLocalRandom random = ThreadLocalRandom.current(); - return random.nextBoolean(); - } - + @Override + public Boolean build(IDataFactoryContext context, Class booleanClass) { + ThreadLocalRandom random = ThreadLocalRandom.current(); + return random.nextBoolean(); + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/ByteArrayData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/ByteArrayData.java index 32feb8c..b7c4b29 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/ByteArrayData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/ByteArrayData.java @@ -9,14 +9,13 @@ @AutoService(IData.class) public class ByteArrayData implements IData { - @Override - public byte[] build(IDataFactoryContext context, Class aClass) { - int size = InnerDataUtil.randomSize(); - byte[] array = new byte[size]; - for(int i = 0; i < size; i++) { - array[i] = DataFactoryDataUtil.build(byte.class); - } - return array; + @Override + public byte[] build(IDataFactoryContext context, Class aClass) { + int size = InnerDataUtil.randomSize(); + byte[] array = new byte[size]; + for (int i = 0; i < size; i++) { + array[i] = DataFactoryDataUtil.build(byte.class); } - + return array; + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/ByteData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/ByteData.java index 6414e53..122008c 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/ByteData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/ByteData.java @@ -8,19 +8,19 @@ @AutoService(IData.class) public class ByteData extends AbstractNumberData implements IData { - @Override - public Byte build(IDataFactoryContext context, Class booleanClass) { - String string = super.contactInt(context); - return Byte.valueOf(string); - } + @Override + public Byte build(IDataFactoryContext context, Class booleanClass) { + String string = super.contactInt(context); + return Byte.valueOf(string); + } - @Override - protected int getMin() { - return Byte.MIN_VALUE; - } + @Override + protected int getMin() { + return Byte.MIN_VALUE; + } - @Override - protected int getMax() { - return Byte.MAX_VALUE; - } + @Override + protected int getMax() { + return Byte.MAX_VALUE; + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/CharArrayData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/CharArrayData.java index 243d47c..c82d430 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/CharArrayData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/CharArrayData.java @@ -6,18 +6,16 @@ import io.fluent.datafactory.core.util.DataFactoryDataUtil; import io.fluent.datafactory.core.util.InnerDataUtil; - @AutoService(IData.class) public class CharArrayData implements IData { - @Override - public char[] build(IDataFactoryContext context, Class aClass) { - int size = InnerDataUtil.randomSize(); - char[] array = new char[size]; - for(int i = 0; i < size; i++) { - array[i] = DataFactoryDataUtil.build(char.class); - } - return array; + @Override + public char[] build(IDataFactoryContext context, Class aClass) { + int size = InnerDataUtil.randomSize(); + char[] array = new char[size]; + for (int i = 0; i < size; i++) { + array[i] = DataFactoryDataUtil.build(char.class); } - + return array; + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/CharData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/CharData.java index bf1e425..617c2e5 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/CharData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/CharData.java @@ -3,23 +3,18 @@ import com.google.auto.service.AutoService; import io.fluent.datafactory.api.core.IData; import io.fluent.datafactory.api.core.IDataFactoryContext; - import java.util.concurrent.ThreadLocalRandom; - @AutoService(IData.class) public class CharData implements IData { - /** - * 限制 - */ - private static final int LIMIT = 65535; - - @Override - public Character build(IDataFactoryContext context, Class booleanClass) { - ThreadLocalRandom random = ThreadLocalRandom.current(); - final int index = random.nextInt(LIMIT); - return (char) index; - } + /** 限制 */ + private static final int LIMIT = 65535; + @Override + public Character build(IDataFactoryContext context, Class booleanClass) { + ThreadLocalRandom random = ThreadLocalRandom.current(); + final int index = random.nextInt(LIMIT); + return (char) index; + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/DoubleArrayData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/DoubleArrayData.java index 1c6d30d..d5492c8 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/DoubleArrayData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/DoubleArrayData.java @@ -8,21 +8,20 @@ /** * double 数据实现 - * @author binbin.hou - * date 2019/2/26 + * + * @author binbin.hou date 2019/2/26 * @since 0.0.7 */ @AutoService(IData.class) public class DoubleArrayData implements IData { - @Override - public double[] build(IDataFactoryContext context, Class aClass) { - int size = InnerDataUtil.randomSize(); - double[] array = new double[size]; - for(int i = 0; i < size; i++) { - array[i] = DataFactoryDataUtil.build(double.class); - } - return array; + @Override + public double[] build(IDataFactoryContext context, Class aClass) { + int size = InnerDataUtil.randomSize(); + double[] array = new double[size]; + for (int i = 0; i < size; i++) { + array[i] = DataFactoryDataUtil.build(double.class); } - + return array; + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/DoubleData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/DoubleData.java index b85126f..19cd4dc 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/DoubleData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/DoubleData.java @@ -5,15 +5,12 @@ import io.fluent.datafactory.api.core.IDataFactoryContext; import io.fluent.datafactory.core.api.data.annotation.AbstractNumberData; - - @AutoService(IData.class) public class DoubleData extends AbstractNumberData implements IData { - @Override - public Double build(IDataFactoryContext context, Class booleanClass) { - final String string = super.contactIntDecimal(context); - return Double.valueOf(string); - } - + @Override + public Double build(IDataFactoryContext context, Class booleanClass) { + final String string = super.contactIntDecimal(context); + return Double.valueOf(string); + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/FloatArrayData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/FloatArrayData.java index 87a12e8..ed73e72 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/FloatArrayData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/FloatArrayData.java @@ -6,18 +6,16 @@ import io.fluent.datafactory.core.util.DataFactoryDataUtil; import io.fluent.datafactory.core.util.InnerDataUtil; - @AutoService(IData.class) public class FloatArrayData implements IData { - @Override - public float[] build(IDataFactoryContext context, Class aClass) { - int size = InnerDataUtil.randomSize(); - float[] array = new float[size]; - for(int i = 0; i < size; i++) { - array[i] = DataFactoryDataUtil.build(float.class); - } - return array; + @Override + public float[] build(IDataFactoryContext context, Class aClass) { + int size = InnerDataUtil.randomSize(); + float[] array = new float[size]; + for (int i = 0; i < size; i++) { + array[i] = DataFactoryDataUtil.build(float.class); } - + return array; + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/FloatData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/FloatData.java index 03b2d5a..f761acb 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/FloatData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/FloatData.java @@ -5,14 +5,12 @@ import io.fluent.datafactory.api.core.IDataFactoryContext; import io.fluent.datafactory.core.api.data.annotation.AbstractNumberData; - @AutoService(IData.class) public class FloatData extends AbstractNumberData implements IData { - @Override - public Float build(IDataFactoryContext context, Class booleanClass) { - final String string = super.contactIntDecimal(context); - return Float.valueOf(string); - } - + @Override + public Float build(IDataFactoryContext context, Class booleanClass) { + final String string = super.contactIntDecimal(context); + return Float.valueOf(string); + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/IntegerArrayData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/IntegerArrayData.java index 32ffc03..126b692 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/IntegerArrayData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/IntegerArrayData.java @@ -1,4 +1,5 @@ package io.fluent.datafactory.core.api.data.primitive; + import com.google.auto.service.AutoService; import io.fluent.datafactory.api.core.IData; import io.fluent.datafactory.api.core.IDataFactoryContext; @@ -7,21 +8,20 @@ /** * int 数据实现 - * @author binbin.hou - * date 2019/2/26 + * + * @author binbin.hou date 2019/2/26 * @since 0.0.7 */ @AutoService(IData.class) public class IntegerArrayData implements IData { - @Override - public int[] build(IDataFactoryContext context, Class aClass) { - int size = InnerDataUtil.randomSize(); - int[] array = new int[size]; - for(int i = 0; i < size; i++) { - array[i] = DataFactoryDataUtil.build(int.class); - } - return array; + @Override + public int[] build(IDataFactoryContext context, Class aClass) { + int size = InnerDataUtil.randomSize(); + int[] array = new int[size]; + for (int i = 0; i < size; i++) { + array[i] = DataFactoryDataUtil.build(int.class); } - + return array; + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/IntegerData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/IntegerData.java index 55ccfe1..84ca330 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/IntegerData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/IntegerData.java @@ -6,17 +6,15 @@ import io.fluent.datafactory.core.api.data.annotation.AbstractNumberData; /** - * @author binbin.hou - * date 2019/2/26 + * @author binbin.hou date 2019/2/26 * @since 0.0.1 */ @AutoService(IData.class) public class IntegerData extends AbstractNumberData implements IData { - @Override - public Integer build(IDataFactoryContext context, Class booleanClass) { - final String string = super.contactInt(context); - return Integer.valueOf(string); - } - + @Override + public Integer build(IDataFactoryContext context, Class booleanClass) { + final String string = super.contactInt(context); + return Integer.valueOf(string); + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/LongArrayData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/LongArrayData.java index cff4974..e2ab7df 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/LongArrayData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/LongArrayData.java @@ -6,18 +6,16 @@ import io.fluent.datafactory.core.util.DataFactoryDataUtil; import io.fluent.datafactory.core.util.InnerDataUtil; - @AutoService(IData.class) public class LongArrayData implements IData { - @Override - public long[] build(IDataFactoryContext context, Class aClass) { - int size = InnerDataUtil.randomSize(); - long[] array = new long[size]; - for(int i = 0; i < size; i++) { - array[i] = DataFactoryDataUtil.build(long.class); - } - return array; + @Override + public long[] build(IDataFactoryContext context, Class aClass) { + int size = InnerDataUtil.randomSize(); + long[] array = new long[size]; + for (int i = 0; i < size; i++) { + array[i] = DataFactoryDataUtil.build(long.class); } - + return array; + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/LongData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/LongData.java index ae1ccb5..08c4a32 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/LongData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/LongData.java @@ -6,17 +6,15 @@ import io.fluent.datafactory.core.api.data.annotation.AbstractNumberData; /** - * @author binbin.hou - * date 2019/2/26 + * @author binbin.hou date 2019/2/26 * @since 0.0.1 */ @AutoService(IData.class) public class LongData extends AbstractNumberData implements IData { - @Override - public Long build(IDataFactoryContext context, Class booleanClass) { - final String string = super.contactInt(context); - return Long.valueOf(string); - } - + @Override + public Long build(IDataFactoryContext context, Class booleanClass) { + final String string = super.contactInt(context); + return Long.valueOf(string); + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/ShortArrayData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/ShortArrayData.java index ecd555e..a6f5818 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/ShortArrayData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/ShortArrayData.java @@ -6,18 +6,16 @@ import io.fluent.datafactory.core.util.DataFactoryDataUtil; import io.fluent.datafactory.core.util.InnerDataUtil; - @AutoService(IData.class) public class ShortArrayData implements IData { - @Override - public short[] build(IDataFactoryContext context, Class aClass) { - int size = InnerDataUtil.randomSize(); - short[] array = new short[size]; - for(int i = 0; i < size; i++) { - array[i] = DataFactoryDataUtil.build(short.class); - } - return array; + @Override + public short[] build(IDataFactoryContext context, Class aClass) { + int size = InnerDataUtil.randomSize(); + short[] array = new short[size]; + for (int i = 0; i < size; i++) { + array[i] = DataFactoryDataUtil.build(short.class); } - + return array; + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/ShortData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/ShortData.java index 4f51271..d18a93b 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/ShortData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/ShortData.java @@ -5,23 +5,22 @@ import io.fluent.datafactory.api.core.IDataFactoryContext; import io.fluent.datafactory.core.api.data.annotation.AbstractNumberData; - @AutoService(IData.class) public class ShortData extends AbstractNumberData implements IData { - @Override - public Short build(IDataFactoryContext context, Class booleanClass) { - final String string = super.contactInt(context); - return Short.valueOf(string); - } + @Override + public Short build(IDataFactoryContext context, Class booleanClass) { + final String string = super.contactInt(context); + return Short.valueOf(string); + } - @Override - protected int getMin() { - return Short.MIN_VALUE; - } + @Override + protected int getMin() { + return Short.MIN_VALUE; + } - @Override - protected int getMax() { - return Short.MAX_VALUE; - } + @Override + protected int getMax() { + return Short.MAX_VALUE; + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/VoidData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/VoidData.java index 649e24e..124eee2 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/VoidData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/VoidData.java @@ -4,13 +4,11 @@ import io.fluent.datafactory.api.core.IData; import io.fluent.datafactory.api.core.IDataFactoryContext; - @AutoService(IData.class) public class VoidData implements IData { - @Override - public Void build(IDataFactoryContext context, Class booleanClass) { - return null; - } - + @Override + public Void build(IDataFactoryContext context, Class booleanClass) { + return null; + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/package-info.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/package-info.java index 9a6d3cd..318d1ad 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/package-info.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/primitive/package-info.java @@ -1,4 +1,2 @@ -/** - * 基本类型 - */ -package io.fluent.datafactory.core.api.data.primitive; \ No newline at end of file +/** 基本类型 */ +package io.fluent.datafactory.core.api.data.primitive; diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/time/LocalDateData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/time/LocalDateData.java index 3bf0cbe..7bc5b0a 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/time/LocalDateData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/time/LocalDateData.java @@ -3,15 +3,12 @@ import com.google.auto.service.AutoService; import io.fluent.datafactory.api.core.IData; import io.fluent.datafactory.api.core.IDataFactoryContext; - - import java.time.LocalDate; - @AutoService(IData.class) public class LocalDateData implements IData { - @Override - public LocalDate build(IDataFactoryContext context, Class localDateClass) { - return LocalDate.now(); - } + @Override + public LocalDate build(IDataFactoryContext context, Class localDateClass) { + return LocalDate.now(); + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/time/LocalDateTimeData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/time/LocalDateTimeData.java index 8167a15..191d106 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/time/LocalDateTimeData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/time/LocalDateTimeData.java @@ -1,18 +1,14 @@ package io.fluent.datafactory.core.api.data.time; - import com.google.auto.service.AutoService; import io.fluent.datafactory.api.core.IData; import io.fluent.datafactory.api.core.IDataFactoryContext; - - import java.time.LocalDateTime; - @AutoService(IData.class) public class LocalDateTimeData implements IData { - @Override - public LocalDateTime build(IDataFactoryContext context, Class localDateClass) { - return LocalDateTime.now(); - } + @Override + public LocalDateTime build(IDataFactoryContext context, Class localDateClass) { + return LocalDateTime.now(); + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/time/LocalTimeData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/time/LocalTimeData.java index 28d092f..3f187c4 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/time/LocalTimeData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/time/LocalTimeData.java @@ -1,19 +1,14 @@ package io.fluent.datafactory.core.api.data.time; - import com.google.auto.service.AutoService; import io.fluent.datafactory.api.core.IData; import io.fluent.datafactory.api.core.IDataFactoryContext; - - - import java.time.LocalTime; - @AutoService(IData.class) public class LocalTimeData implements IData { - @Override - public LocalTime build(IDataFactoryContext context, Class localDateClass) { - return LocalTime.now(); - } + @Override + public LocalTime build(IDataFactoryContext context, Class localDateClass) { + return LocalTime.now(); + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/time/YearData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/time/YearData.java index 7edafbd..c28fb2e 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/time/YearData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/time/YearData.java @@ -1,19 +1,14 @@ package io.fluent.datafactory.core.api.data.time; - import com.google.auto.service.AutoService; import io.fluent.datafactory.api.core.IData; import io.fluent.datafactory.api.core.IDataFactoryContext; - - -import java.time.LocalDate; import java.time.Year; - @AutoService(IData.class) public class YearData implements IData { - @Override - public Year build(IDataFactoryContext context, Class localDateClass) { - return Year.now(); - } + @Override + public Year build(IDataFactoryContext context, Class localDateClass) { + return Year.now(); + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/time/package-info.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/time/package-info.java index afefe6c..66077b9 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/time/package-info.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/time/package-info.java @@ -1,5 +1,6 @@ /** * 时间相关类 + * * @author houbinbin */ -package io.fluent.datafactory.core.api.data.time; \ No newline at end of file +package io.fluent.datafactory.core.api.data.time; diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/util/CurrencyData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/util/CurrencyData.java index 022f292..4595160 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/util/CurrencyData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/util/CurrencyData.java @@ -3,15 +3,13 @@ import com.google.auto.service.AutoService; import io.fluent.datafactory.api.core.IData; import io.fluent.datafactory.api.core.IDataFactoryContext; - import java.util.Currency; import java.util.Locale; - @AutoService(IData.class) public class CurrencyData implements IData { - @Override - public Currency build(IDataFactoryContext context, Class dateClass) { - return Currency.getInstance(Locale.CHINA); - } + @Override + public Currency build(IDataFactoryContext context, Class dateClass) { + return Currency.getInstance(Locale.CHINA); + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/util/DateData.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/util/DateData.java index b5258e0..6f7920b 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/util/DateData.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/util/DateData.java @@ -1,22 +1,20 @@ package io.fluent.datafactory.core.api.data.util; - import com.google.auto.service.AutoService; import io.fluent.datafactory.api.core.IData; import io.fluent.datafactory.api.core.IDataFactoryContext; - import java.util.Date; /** * 日期类数据初始化 - * @author binbin.hou - * date 2019/2/26 + * + * @author binbin.hou date 2019/2/26 * @since 0.0.1 */ @AutoService(IData.class) public class DateData implements IData { - @Override - public Date build(IDataFactoryContext context, Class dateClass) { - return new Date(); - } + @Override + public Date build(IDataFactoryContext context, Class dateClass) { + return new Date(); + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/util/package-info.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/util/package-info.java index ed82357..cc2b0b7 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/util/package-info.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/data/util/package-info.java @@ -1 +1 @@ -package io.fluent.datafactory.core.api.data.util; \ No newline at end of file +package io.fluent.datafactory.core.api.data.util; diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/package-info.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/package-info.java index 850e864..93fa840 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/package-info.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/package-info.java @@ -1,6 +1,7 @@ /** * 存放 api 对应的实现 + * * @author binbin.hou * @since 0.0.1 */ -package io.fluent.datafactory.core.api; \ No newline at end of file +package io.fluent.datafactory.core.api; diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/regex/DefaultRegexGen.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/regex/DefaultRegexGen.java index 35c6e81..43fac81 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/regex/DefaultRegexGen.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/api/regex/DefaultRegexGen.java @@ -1,21 +1,20 @@ package io.fluent.datafactory.core.api.regex; - import com.mifmif.common.regex.Generex; import io.fluent.datafactory.api.core.IRegexGen; /** * 默认的 regex 生成方式 + * * @author binbin.hou * @date 2019/3/12 * @since 0.0.3 */ public class DefaultRegexGen implements IRegexGen { - @Override - public String generate(String regex) { - Generex generex = new Generex(regex); - return generex.random(); - } - + @Override + public String generate(String regex) { + Generex generex = new Generex(regex); + return generex.random(); + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/exception/DataFactoryRuntimeException.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/exception/DataFactoryRuntimeException.java index 9f2c2f9..4fee817 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/exception/DataFactoryRuntimeException.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/exception/DataFactoryRuntimeException.java @@ -2,28 +2,28 @@ /** * 运行时异常 - * @author binbin.hou - * date 2019/2/26 + * + * @author binbin.hou date 2019/2/26 * @since 0.0.1 */ public class DataFactoryRuntimeException extends RuntimeException { - public DataFactoryRuntimeException() { - } + public DataFactoryRuntimeException() {} - public DataFactoryRuntimeException(String message) { - super(message); - } + public DataFactoryRuntimeException(String message) { + super(message); + } - public DataFactoryRuntimeException(String message, Throwable cause) { - super(message, cause); - } + public DataFactoryRuntimeException(String message, Throwable cause) { + super(message, cause); + } - public DataFactoryRuntimeException(Throwable cause) { - super(cause); - } + public DataFactoryRuntimeException(Throwable cause) { + super(cause); + } - public DataFactoryRuntimeException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { - super(message, cause, enableSuppression, writableStackTrace); - } + public DataFactoryRuntimeException( + String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/package-info.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/package-info.java index 6c123e5..5e9c4b3 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/package-info.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/package-info.java @@ -4,11 +4,12 @@ */ /** - *

核心实现包

+ * 核心实现包 * *
 Created: 2019-02-25 21:42  
+ * *
 Project: data-factory  
* * @author houbinbin */ -package io.fluent.datafactory.core; \ No newline at end of file +package io.fluent.datafactory.core; diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/support/factory/DataFactoryMapping.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/support/factory/DataFactoryMapping.java index 89dec49..e499b9d 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/support/factory/DataFactoryMapping.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/support/factory/DataFactoryMapping.java @@ -1,6 +1,5 @@ package io.fluent.datafactory.core.support.factory; - import com.github.houbb.heaven.util.lang.ObjectUtil; import com.github.houbb.heaven.util.lang.reflect.ClassTypeUtil; import com.github.houbb.heaven.util.util.MapUtil; @@ -14,7 +13,6 @@ import io.fluent.datafactory.core.api.data.util.DateData; import io.fluent.datafactory.core.util.DataClassUtil; import io.fluent.datafactory.core.util.DataPrimitiveUtil; - import java.math.BigDecimal; import java.math.BigInteger; import java.time.LocalDate; @@ -23,125 +21,125 @@ import java.time.Year; import java.util.*; - public final class DataFactoryMapping { - private DataFactoryMapping(){} - - /** - * 存放数据实现的 map - */ - private static final Map DATA_CLASS_MAP = new HashMap<>(); - - static { - DATA_CLASS_MAP.put(String.class, new StringData()); - DATA_CLASS_MAP.put(BigDecimal.class, new BigDecimalData()); - DATA_CLASS_MAP.put(BigInteger.class, new BigIntegerData()); - DATA_CLASS_MAP.put(Boolean.class, new BoolData()); - DATA_CLASS_MAP.put(Byte.class, new ByteData()); - DATA_CLASS_MAP.put(Character.class, new CharData()); - DATA_CLASS_MAP.put(Double.class, new DoubleData()); - DATA_CLASS_MAP.put(Float.class, new FloatData()); - DATA_CLASS_MAP.put(Integer.class, new IntegerData()); - DATA_CLASS_MAP.put(Long.class, new LongData()); - DATA_CLASS_MAP.put(Short.class, new ShortData()); - DATA_CLASS_MAP.put(Void.class, new VoidData()); - DATA_CLASS_MAP.put(LocalDate.class, new LocalDateData()); - DATA_CLASS_MAP.put(LocalDateTime.class, new LocalDateTimeData()); - DATA_CLASS_MAP.put(LocalTime.class, new LocalTimeData()); - DATA_CLASS_MAP.put(Year.class, new YearData()); - DATA_CLASS_MAP.put(Currency.class, new CurrencyData()); - DATA_CLASS_MAP.put(Date.class, new DateData()); - DATA_CLASS_MAP.put(int[].class, new IntegerArrayData()); - DATA_CLASS_MAP.put(short[].class, new ShortArrayData()); - DATA_CLASS_MAP.put(long[].class, new LongArrayData()); - DATA_CLASS_MAP.put(byte[].class, new ByteArrayData()); - DATA_CLASS_MAP.put(char[].class, new CharArrayData()); - DATA_CLASS_MAP.put(double[].class, new DoubleArrayData()); - DATA_CLASS_MAP.put(float[].class, new FloatArrayData()); - DATA_CLASS_MAP.put(boolean[].class, new BoolArrayData()); - } - - /** - * 初始化数据工厂 - * 这种写法虽然优雅,但是总会有用户不开启运行时注解。 - * @since 0.0.5 - */ - @Deprecated - private static void initDataFactory() { - synchronized (DATA_CLASS_MAP) { - ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); - ServiceLoader dataLoader = ServiceLoader.load(IData.class, classLoader); - - for (IData data : dataLoader) { - final Class clazz = data.getClass(); - if(isDataFactoryClass(clazz)) { - final Class genericType = DataClassUtil.getGenericType(clazz, IData.class, 0); - System.out.println(String.format("DATA_CLASS_MAP.put(%s.class, new %s());", genericType.getSimpleName(), - data.getClass().getSimpleName())); - DATA_CLASS_MAP.put(genericType, data); - } - } + private DataFactoryMapping() {} + + /** 存放数据实现的 map */ + private static final Map DATA_CLASS_MAP = new HashMap<>(); + + static { + DATA_CLASS_MAP.put(String.class, new StringData()); + DATA_CLASS_MAP.put(BigDecimal.class, new BigDecimalData()); + DATA_CLASS_MAP.put(BigInteger.class, new BigIntegerData()); + DATA_CLASS_MAP.put(Boolean.class, new BoolData()); + DATA_CLASS_MAP.put(Byte.class, new ByteData()); + DATA_CLASS_MAP.put(Character.class, new CharData()); + DATA_CLASS_MAP.put(Double.class, new DoubleData()); + DATA_CLASS_MAP.put(Float.class, new FloatData()); + DATA_CLASS_MAP.put(Integer.class, new IntegerData()); + DATA_CLASS_MAP.put(Long.class, new LongData()); + DATA_CLASS_MAP.put(Short.class, new ShortData()); + DATA_CLASS_MAP.put(Void.class, new VoidData()); + DATA_CLASS_MAP.put(LocalDate.class, new LocalDateData()); + DATA_CLASS_MAP.put(LocalDateTime.class, new LocalDateTimeData()); + DATA_CLASS_MAP.put(LocalTime.class, new LocalTimeData()); + DATA_CLASS_MAP.put(Year.class, new YearData()); + DATA_CLASS_MAP.put(Currency.class, new CurrencyData()); + DATA_CLASS_MAP.put(Date.class, new DateData()); + DATA_CLASS_MAP.put(int[].class, new IntegerArrayData()); + DATA_CLASS_MAP.put(short[].class, new ShortArrayData()); + DATA_CLASS_MAP.put(long[].class, new LongArrayData()); + DATA_CLASS_MAP.put(byte[].class, new ByteArrayData()); + DATA_CLASS_MAP.put(char[].class, new CharArrayData()); + DATA_CLASS_MAP.put(double[].class, new DoubleArrayData()); + DATA_CLASS_MAP.put(float[].class, new FloatArrayData()); + DATA_CLASS_MAP.put(boolean[].class, new BoolArrayData()); + } + + /** + * 初始化数据工厂 这种写法虽然优雅,但是总会有用户不开启运行时注解。 + * + * @since 0.0.5 + */ + @Deprecated + private static void initDataFactory() { + synchronized (DATA_CLASS_MAP) { + ClassLoader classLoader = Thread.currentThread().getContextClassLoader(); + ServiceLoader dataLoader = ServiceLoader.load(IData.class, classLoader); + + for (IData data : dataLoader) { + final Class clazz = data.getClass(); + if (isDataFactoryClass(clazz)) { + final Class genericType = DataClassUtil.getGenericType(clazz, IData.class, 0); + System.out.println( + String.format( + "DATA_CLASS_MAP.put(%s.class, new %s());", + genericType.getSimpleName(), data.getClass().getSimpleName())); + DATA_CLASS_MAP.put(genericType, data); } + } } - - /** - * 判断是否为当前项目的实现,防止外部实现对现有的对象造成影响 - * @param clazz 对象类型 - * @return 是否 - */ - private static boolean isDataFactoryClass(final Class clazz) { - final String packageName = clazz.getPackage().getName(); - return packageName.startsWith("com.github.houbb.data.factory.core.api.data."); + } + + /** + * 判断是否为当前项目的实现,防止外部实现对现有的对象造成影响 + * + * @param clazz 对象类型 + * @return 是否 + */ + private static boolean isDataFactoryClass(final Class clazz) { + final String packageName = clazz.getPackage().getName(); + return packageName.startsWith("com.github.houbb.data.factory.core.api.data."); + } + + /** + * 获取对应的 data 实现 + * + * @param clazz 字段类型 + * @return 结果 + */ + @SuppressWarnings("all") + public static IData getData(final Class clazz) { + // 快速返回 + if (ObjectUtil.isNull(clazz)) { + return NullData.INSTANCE; } - /** - * 获取对应的 data 实现 - * @param clazz 字段类型 - * @return 结果 - */ - @SuppressWarnings("all") - public static IData getData(final Class clazz) { - // 快速返回 - if(ObjectUtil.isNull(clazz)) { - return NullData.INSTANCE; - } - - // 数组/map/集合/bean对象 - if(clazz.isArray()) { - final IData data = DATA_CLASS_MAP.get(clazz); - if(ObjectUtil.isNull(data)) { - return new ArrayData(); - } + // 数组/map/集合/bean对象 + if (clazz.isArray()) { + final IData data = DATA_CLASS_MAP.get(clazz); + if (ObjectUtil.isNull(data)) { + return new ArrayData(); + } - // 对应的基本类型数组 - return data; - } - if(ClassTypeUtil.isIterable(clazz)) { - return new IterableData(); - } - if(Map.class.isAssignableFrom(clazz)) { - return new MapData(); - } - if(clazz.isEnum()) { - return new EnumData(); - } - - // JDK 相关类型 - if(ClassTypeUtil.isJdk(clazz)) { - Class realClazz = DataPrimitiveUtil.getReferenceType(clazz); - if(MapUtil.isEmpty(DATA_CLASS_MAP)) { - initDataFactory(); - } - final IData data = DATA_CLASS_MAP.get(realClazz); - if(ObjectUtil.isNull(data)) { - return NullData.INSTANCE; - } - return data; - } + // 对应的基本类型数组 + return data; + } + if (ClassTypeUtil.isIterable(clazz)) { + return new IterableData(); + } + if (Map.class.isAssignableFrom(clazz)) { + return new MapData(); + } + if (clazz.isEnum()) { + return new EnumData(); + } - // 用户自定义 java bean - return new BeanData(); + // JDK 相关类型 + if (ClassTypeUtil.isJdk(clazz)) { + Class realClazz = DataPrimitiveUtil.getReferenceType(clazz); + if (MapUtil.isEmpty(DATA_CLASS_MAP)) { + initDataFactory(); + } + final IData data = DATA_CLASS_MAP.get(realClazz); + if (ObjectUtil.isNull(data)) { + return NullData.INSTANCE; + } + return data; } + // 用户自定义 java bean + return new BeanData(); + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/support/factory/package-info.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/support/factory/package-info.java index de3cb6c..365e549 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/support/factory/package-info.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/support/factory/package-info.java @@ -1 +1 @@ -package io.fluent.datafactory.core.support.factory; \ No newline at end of file +package io.fluent.datafactory.core.support.factory; diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/support/package-info.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/support/package-info.java index cfa9866..e01ccd8 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/support/package-info.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/support/package-info.java @@ -1 +1 @@ -package io.fluent.datafactory.core.support; \ No newline at end of file +package io.fluent.datafactory.core.support; diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/util/DataClassUtil.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/util/DataClassUtil.java index 522799a..7633e6e 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/util/DataClassUtil.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/util/DataClassUtil.java @@ -2,66 +2,61 @@ import com.github.houbb.heaven.util.lang.ObjectUtil; import com.github.houbb.heaven.util.util.ArrayUtil; - import java.lang.reflect.ParameterizedType; import java.lang.reflect.Type; import java.util.*; /** * 类工具类 - * @author binbin.hou - * date 2019/2/26 + * + * @author binbin.hou date 2019/2/26 * @since 0.0.1 */ public class DataClassUtil { - - /** - * 获取当前类的泛型接口信息 - * @param clazz 类 - * @return 泛型接口信息 - */ - private static List getGenericInterfaces(final Class clazz) { - Set typeSet = new HashSet<>(); - - // 添加当前类的泛型接口信息 - Type[] types = clazz.getGenericInterfaces(); - if(ArrayUtil.isNotEmpty(types)) { - typeSet.addAll(Arrays.asList(types)); - } - - // 当前类的泛型父类信息 - Type superType = clazz.getGenericSuperclass(); - if(ObjectUtil.isNotNull(superType) - && superType.getClass().isInterface()) { - typeSet.add(superType); - } - - return new ArrayList<>(typeSet); + /** + * 获取当前类的泛型接口信息 + * + * @param clazz 类 + * @return 泛型接口信息 + */ + private static List getGenericInterfaces(final Class clazz) { + Set typeSet = new HashSet<>(); + + // 添加当前类的泛型接口信息 + Type[] types = clazz.getGenericInterfaces(); + if (ArrayUtil.isNotEmpty(types)) { + typeSet.addAll(Arrays.asList(types)); } + // 当前类的泛型父类信息 + Type superType = clazz.getGenericSuperclass(); + if (ObjectUtil.isNotNull(superType) && superType.getClass().isInterface()) { + typeSet.add(superType); + } - /** - * 获取泛型类型 - * @param clazz 数据类型 - * @param interfaceClass 接口对应的 class 信息 - * @param index 泛型的下标志位置 - * @return 对应的泛型类型 - */ - public static Class getGenericType(final Class clazz, - final Class interfaceClass, - final int index) { - List typeList = DataClassUtil.getGenericInterfaces(clazz); - for(Type type : typeList) { - if(type instanceof ParameterizedType - && interfaceClass.equals(((ParameterizedType) type).getRawType()) - ) { - ParameterizedType p = (ParameterizedType)type; - return (Class) p.getActualTypeArguments()[index]; - } - } - - return Object.class; + return new ArrayList<>(typeSet); + } + + /** + * 获取泛型类型 + * + * @param clazz 数据类型 + * @param interfaceClass 接口对应的 class 信息 + * @param index 泛型的下标志位置 + * @return 对应的泛型类型 + */ + public static Class getGenericType( + final Class clazz, final Class interfaceClass, final int index) { + List typeList = DataClassUtil.getGenericInterfaces(clazz); + for (Type type : typeList) { + if (type instanceof ParameterizedType + && interfaceClass.equals(((ParameterizedType) type).getRawType())) { + ParameterizedType p = (ParameterizedType) type; + return (Class) p.getActualTypeArguments()[index]; + } } + return Object.class; + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/util/DataFactoryDataUtil.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/util/DataFactoryDataUtil.java index 1619b58..ffb2f97 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/util/DataFactoryDataUtil.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/util/DataFactoryDataUtil.java @@ -1,35 +1,35 @@ package io.fluent.datafactory.core.util; - import io.fluent.datafactory.api.core.IData; import io.fluent.datafactory.api.core.IDataFactoryContext; import io.fluent.datafactory.core.DataFactoryData; public final class DataFactoryDataUtil { - private DataFactoryDataUtil(){} - - /** - * 构建结果 - * @param clazz 类型 - * @return 构建结果 - * @param 泛型 - */ - public static T build(final Class clazz) { - return build(null, clazz); - } + private DataFactoryDataUtil() {} - /** - * 构建结果 - * @param context 执行上下文 - * @param clazz 类型 - * @return 构建结果 - * @param 泛型 - */ - @SuppressWarnings("all") - public static T build(final IDataFactoryContext context, final Class clazz) { - IData data = new DataFactoryData(); - return (T) data.build(context, clazz); - } + /** + * 构建结果 + * + * @param clazz 类型 + * @return 构建结果 + * @param 泛型 + */ + public static T build(final Class clazz) { + return build(null, clazz); + } + /** + * 构建结果 + * + * @param context 执行上下文 + * @param clazz 类型 + * @return 构建结果 + * @param 泛型 + */ + @SuppressWarnings("all") + public static T build(final IDataFactoryContext context, final Class clazz) { + IData data = new DataFactoryData(); + return (T) data.build(context, clazz); + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/util/DataPrimitiveUtil.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/util/DataPrimitiveUtil.java index 937443c..e0c20e5 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/util/DataPrimitiveUtil.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/util/DataPrimitiveUtil.java @@ -5,36 +5,36 @@ /** * 基本类型工具类 - * @author binbin.hou - * date 2019/2/26 + * + * @author binbin.hou date 2019/2/26 * @since 0.0.1 */ public class DataPrimitiveUtil { - private static final Map PRIMITIVE_REFERENCE_MAP = new HashMap<>(); + private static final Map PRIMITIVE_REFERENCE_MAP = new HashMap<>(); - static { - PRIMITIVE_REFERENCE_MAP.put(int.class, Integer.class); - PRIMITIVE_REFERENCE_MAP.put(boolean.class, Boolean.class); - PRIMITIVE_REFERENCE_MAP.put(byte.class, Byte.class); - PRIMITIVE_REFERENCE_MAP.put(char.class, Character.class); - PRIMITIVE_REFERENCE_MAP.put(short.class, Short.class); - PRIMITIVE_REFERENCE_MAP.put(long.class, Long.class); - PRIMITIVE_REFERENCE_MAP.put(float.class, Float.class); - PRIMITIVE_REFERENCE_MAP.put(double.class, Double.class); - PRIMITIVE_REFERENCE_MAP.put(void.class, Void.class); - } + static { + PRIMITIVE_REFERENCE_MAP.put(int.class, Integer.class); + PRIMITIVE_REFERENCE_MAP.put(boolean.class, Boolean.class); + PRIMITIVE_REFERENCE_MAP.put(byte.class, Byte.class); + PRIMITIVE_REFERENCE_MAP.put(char.class, Character.class); + PRIMITIVE_REFERENCE_MAP.put(short.class, Short.class); + PRIMITIVE_REFERENCE_MAP.put(long.class, Long.class); + PRIMITIVE_REFERENCE_MAP.put(float.class, Float.class); + PRIMITIVE_REFERENCE_MAP.put(double.class, Double.class); + PRIMITIVE_REFERENCE_MAP.put(void.class, Void.class); + } - /** - * 获取基础类型的引用类型 - * @param clazz 基础类型 - * @return 引用类型 - */ - public static Class getReferenceType(final Class clazz) { - if(clazz.isPrimitive()) { - return PRIMITIVE_REFERENCE_MAP.get(clazz); - } - return clazz; + /** + * 获取基础类型的引用类型 + * + * @param clazz 基础类型 + * @return 引用类型 + */ + public static Class getReferenceType(final Class clazz) { + if (clazz.isPrimitive()) { + return PRIMITIVE_REFERENCE_MAP.get(clazz); } - + return clazz; + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/util/InnerDataUtil.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/util/InnerDataUtil.java index c19a3cb..f4221c1 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/util/InnerDataUtil.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/core/util/InnerDataUtil.java @@ -1,85 +1,85 @@ package io.fluent.datafactory.core.util; - import com.github.houbb.heaven.util.common.ArgUtil; import com.github.houbb.heaven.util.lang.ObjectUtil; import com.github.houbb.heaven.util.lang.reflect.ClassUtil; import com.github.houbb.heaven.util.util.ArrayUtil; import io.fluent.datafactory.api.annotation.DataDesc; import io.fluent.datafactory.api.core.IAnnotationData; - import java.lang.annotation.Annotation; import java.lang.reflect.Field; import java.util.concurrent.ThreadLocalRandom; /** * 内部工具类 + * * @author binbin.hou * @since 0.0.7 */ public final class InnerDataUtil { - private InnerDataUtil(){} + private InnerDataUtil() {} - /** - * 随机生成大小 - * @param min 最小值 - * @param max 最大值 - * @return 结果 - * @since 0.0.7 - */ - public static int randomSize(final int min, final int max) { - ArgUtil.notNegative(min, "最小值"); - ArgUtil.assertTrue(max >= min, "最大值必须大于等于最小值"); + /** + * 随机生成大小 + * + * @param min 最小值 + * @param max 最大值 + * @return 结果 + * @since 0.0.7 + */ + public static int randomSize(final int min, final int max) { + ArgUtil.notNegative(min, "最小值"); + ArgUtil.assertTrue(max >= min, "最大值必须大于等于最小值"); - ThreadLocalRandom random = ThreadLocalRandom.current(); - return random.nextInt(min, max); - } + ThreadLocalRandom random = ThreadLocalRandom.current(); + return random.nextInt(min, max); + } - /** - * 随机的大小 - * @return 大小 - * @since 0.0.8 - */ - public static int randomSize() { - return randomSize(1, 10); - } + /** + * 随机的大小 + * + * @return 大小 + * @since 0.0.8 + */ + public static int randomSize() { + return randomSize(1, 10); + } - /** - * 获取用户自定义的注解信息 - * - * 说明:属性的生成,只会返回第一个符合条件的属性。 - * - * @param field 字段注解 - * @return 结果 - * @since 1.0.0 - */ - @SuppressWarnings("all") - public static IAnnotationData getDefineDataAnnotation(final Field field) { - // 注解列表为空 - Annotation[] annotations = field.getAnnotations(); + /** + * 获取用户自定义的注解信息 + * + *

说明:属性的生成,只会返回第一个符合条件的属性。 + * + * @param field 字段注解 + * @return 结果 + * @since 1.0.0 + */ + @SuppressWarnings("all") + public static IAnnotationData getDefineDataAnnotation(final Field field) { + // 注解列表为空 + Annotation[] annotations = field.getAnnotations(); - if(ArrayUtil.isEmpty(annotations)) { - return null; - } + if (ArrayUtil.isEmpty(annotations)) { + return null; + } - for(Annotation annotation : annotations) { - DataDesc dataMeta = annotation.annotationType().getAnnotation(DataDesc.class); - if (ObjectUtil.isNotNull(dataMeta)) { - Class clazz = dataMeta.value(); + for (Annotation annotation : annotations) { + DataDesc dataMeta = annotation.annotationType().getAnnotation(DataDesc.class); + if (ObjectUtil.isNotNull(dataMeta)) { + Class clazz = dataMeta.value(); - // 如果不是默认的注解,则返回对应的实现 - if(!IAnnotationData.class.equals(clazz)) { - IAnnotationData annotationData = ClassUtil.newInstance(clazz); - // 初始化注解信息 - annotationData.initialize(annotation); - return annotationData; - } - } + // 如果不是默认的注解,则返回对应的实现 + if (!IAnnotationData.class.equals(clazz)) { + IAnnotationData annotationData = ClassUtil.newInstance(clazz); + // 初始化注解信息 + annotationData.initialize(annotation); + return annotationData; } - - // 没有匹配的信息 - return null; + } } + // 没有匹配的信息 + return null; + } } diff --git a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/package-info.java b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/package-info.java index f80964b..94f9050 100644 --- a/components/fluent-datafactory/src/main/java/io/fluent/datafactory/package-info.java +++ b/components/fluent-datafactory/src/main/java/io/fluent/datafactory/package-info.java @@ -1 +1 @@ -package io.fluent.datafactory; \ No newline at end of file +package io.fluent.datafactory; diff --git a/components/fluent-datafactory/src/test/java/io/fluent/datafactory/core/DataFactoryDataTest.java b/components/fluent-datafactory/src/test/java/io/fluent/datafactory/core/DataFactoryDataTest.java index 5fc20c8..da21340 100644 --- a/components/fluent-datafactory/src/test/java/io/fluent/datafactory/core/DataFactoryDataTest.java +++ b/components/fluent-datafactory/src/test/java/io/fluent/datafactory/core/DataFactoryDataTest.java @@ -1,22 +1,15 @@ package io.fluent.datafactory.core; import io.fluent.datafactory.core.util.DataFactoryDataUtil; - import org.junit.jupiter.api.Test; -import org.qstd.QuickSqlTestData; - -import javax.sql.DataSource; class DataFactoryDataTest { - @Test - public void testUserdata(){ - User user = DataFactoryDataUtil.build(User.class); - System.out.println(user); - UserAnnotationNumber userNumber = DataFactoryDataUtil.build(UserAnnotationNumber.class); - System.out.println(userNumber); - } - - - -} \ No newline at end of file + @Test + public void testUserdata() { + User user = DataFactoryDataUtil.build(User.class); + System.out.println(user); + UserAnnotationNumber userNumber = DataFactoryDataUtil.build(UserAnnotationNumber.class); + System.out.println(userNumber); + } +} diff --git a/components/fluent-datafactory/src/test/java/io/fluent/datafactory/core/DataSourceBuilder.java b/components/fluent-datafactory/src/test/java/io/fluent/datafactory/core/DataSourceBuilder.java index fa2e90c..abe0680 100644 --- a/components/fluent-datafactory/src/test/java/io/fluent/datafactory/core/DataSourceBuilder.java +++ b/components/fluent-datafactory/src/test/java/io/fluent/datafactory/core/DataSourceBuilder.java @@ -14,21 +14,19 @@ import com.zaxxer.hikari.HikariConfig; import com.zaxxer.hikari.HikariDataSource; - import javax.sql.DataSource; class DataSourceBuilder { - static final DataSourceBuilder INSTANCE = new DataSourceBuilder(); - - private DataSourceBuilder() { } + static final DataSourceBuilder INSTANCE = new DataSourceBuilder(); - static DataSource build(String jdbcUrl, String dbUserName, String dbPassword) { - HikariConfig hikariConfig = new HikariConfig(); - hikariConfig.setJdbcUrl(jdbcUrl); - hikariConfig.setUsername(dbUserName); - hikariConfig.setPassword(dbPassword); - return new HikariDataSource(hikariConfig); - } + private DataSourceBuilder() {} + static DataSource build(String jdbcUrl, String dbUserName, String dbPassword) { + HikariConfig hikariConfig = new HikariConfig(); + hikariConfig.setJdbcUrl(jdbcUrl); + hikariConfig.setUsername(dbUserName); + hikariConfig.setPassword(dbPassword); + return new HikariDataSource(hikariConfig); + } } diff --git a/components/fluent-datafactory/src/test/java/io/fluent/datafactory/core/PostgreSqlTest.java b/components/fluent-datafactory/src/test/java/io/fluent/datafactory/core/PostgreSqlTest.java index 45aad63..30edc43 100644 --- a/components/fluent-datafactory/src/test/java/io/fluent/datafactory/core/PostgreSqlTest.java +++ b/components/fluent-datafactory/src/test/java/io/fluent/datafactory/core/PostgreSqlTest.java @@ -12,6 +12,13 @@ */ package io.fluent.datafactory.core; +import static io.fluent.datafactory.core.TestTable.TestTableAssert.assertThat; +import static io.fluent.datafactory.core.TestTable.buildUniqueTable; +import static org.assertj.core.api.Assertions.assertThat; + +import java.util.List; +import java.util.Random; +import javax.sql.DataSource; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.*; import org.junit.jupiter.params.ParameterizedTest; @@ -19,476 +26,444 @@ import org.qstd.QuickSqlTestData; import org.testcontainers.containers.PostgreSQLContainer; -import javax.sql.DataSource; -import java.util.List; -import java.util.Random; - -import static io.fluent.datafactory.core.TestTable.TestTableAssert.assertThat; -import static io.fluent.datafactory.core.TestTable.buildUniqueTable; -import static org.assertj.core.api.Assertions.assertThat; - - public class PostgreSqlTest { - private static final String DB_USER_NAME = "user"; - - private static final String DB_PASSWORD = "pwd"; - - private static final PostgreSQLContainer POSTGRESQL_CONTAINER - = new PostgreSQLContainer<>("postgres:12.3") - .withDatabaseName("postgresql") - .withUsername(DB_USER_NAME) - .withPassword(DB_PASSWORD); - - private static DataSource DATA_SOURCE; - - private static SqlExecutor SQL_EXECUTOR; - - @BeforeAll - public static void beforeAll() { - POSTGRESQL_CONTAINER.start(); - String jdbcUrl = POSTGRESQL_CONTAINER.getJdbcUrl(); - DATA_SOURCE = DataSourceBuilder.INSTANCE.build(jdbcUrl, DB_USER_NAME, DB_PASSWORD); - SQL_EXECUTOR = new SqlExecutor(DATA_SOURCE); - } - - @AfterAll - public static void stopContainer() { - POSTGRESQL_CONTAINER.stop(); - } - - @Test public void - should_generate_working_insert_from_a_select_statement() { - - // GIVEN - TestTable playerTable = - buildUniqueTable(DATA_SOURCE - , "Player" - , " id bigint" - + ", firstName varchar(255)" - + ", lastName varchar(255)") - .create() - .insertValues("1, 'Paul', 'Pogba'") - .insertValues("2, 'Antoine', 'Griezmann'"); - - // WHEN - String playerTableName = playerTable.getTableName(); - String select = "SELECT * FROM " + playerTableName; - QuickSqlTestData quickSqlTestData = QuickSqlTestData.buildFrom(DATA_SOURCE); - String insertScript = quickSqlTestData.generateInsertScriptFor(select); - - // THEN - playerTable.recreate(); - SQL_EXECUTOR.execute(insertScript); - assertThat(playerTable).withScript(insertScript) - .hasNumberOfRows(2) - .row(0).column(0).hasValues(1, 2) - .row(0).column(1).hasValues("Paul", "Antoine") - .row(0).column(2).hasValues("Pogba", "Griezmann"); - - } - - @Test public void - should_generate_an_insert_statement_with_columns_declared_in_the_same_order_as_in_the_table() { - - // GIVEN - TestTable playerTable = - buildUniqueTable(DATA_SOURCE - , "player" - , "id bigint" - + ", firstName varchar(255)" - + ", lastName varchar(255)") - .create() - .insertValues("1, 'Paul', 'Pogba'"); - - // WHEN - String playerTableName = playerTable.getTableName(); - String select = "SELECT * FROM " + playerTableName; - QuickSqlTestData quickSqlTestData = QuickSqlTestData.buildFrom(DATA_SOURCE); - String insertScript = quickSqlTestData.generateInsertScriptFor(select); - - // THEN - assertThat(insertScript).contains("id, firstname, lastname"); - - playerTable.recreate(); - SQL_EXECUTOR.execute(insertScript); - assertThat(playerTable).withScript(insertScript) - .hasNumberOfRows(1); - - } - - @Test public void - should_generate_an_insert_with_selected_columns_only() { - - // GIVEN - TestTable playerTable = - buildUniqueTable(DATA_SOURCE - , "Player" - , "id bigint" - + ", firstName varchar(255)" - + ", lastName varchar(255)" - ) - .create() - .insertValues("1, 'Paul', 'Pogba'"); - - // WHEN - String playerTableName = playerTable.getTableName(); - String select = "SELECT firstName FROM " + playerTableName; - QuickSqlTestData quickSqlTestData = QuickSqlTestData.buildFrom(DATA_SOURCE); - String insertScript = quickSqlTestData.generateInsertScriptFor(select); - - // THEN - playerTable.recreate(); - SQL_EXECUTOR.execute(insertScript); - assertThat(playerTable).withScript(insertScript) - .hasNumberOfRows(1) - .row(0).column(1).hasValues("Paul"); - - } - - @Test public void - should_generate_an_insert_statement_with_not_null_columns() { - - // GIVEN - TestTable playerTable = - buildUniqueTable(DATA_SOURCE - , "Player" - , " id bigint not null" - + ", firstName varchar(255) not null" - + ", lastName varchar(255) not null" - ) - .create() - .insertValues("1, 'Paul', 'Pogba'"); - - String select = "SELECT id FROM " + playerTable.getTableName() - + " WHERE lastName = 'Pogba'"; - - // WHEN - QuickSqlTestData quickSqlTestData = QuickSqlTestData.buildFrom(DATA_SOURCE); - String insertScript = quickSqlTestData.generateInsertScriptFor(select); - - // THEN - playerTable.recreate(); - SQL_EXECUTOR.execute(insertScript); - assertThat(playerTable).withScript(insertScript) - .hasNumberOfRows(1) - .row(0).hasValues(1,"Paul", "Pogba"); - - } - - @RepeatedTest(9) public void - should_sort_insert_statements_following_table_dependencies() { - - // GIVEN - TestTable teamTable = - buildUniqueTable(DATA_SOURCE - , "Team" - ," id bigint not null" + - ", name varchar(255)" + - ", primary key (id)" - ) - .create() - .insertValues("1, 'Manchester United'"); - - String playerTableConstraint = "add constraint player_team_fk" + generateRandomPositiveInt() - + " foreign key (team_id)" - + " references " + teamTable.getTableName(); - TestTable playerTable = - buildUniqueTable(DATA_SOURCE - , "Player" - , "id bigint not null" - + ", firstName varchar(255)" - + ", lastName varchar(255)" - + ", team_id bigint" - + ", primary key (id)" - ) - .create() - .alter(playerTableConstraint) - .insertValues("1, 'Paul', 'Pogba', 1"); - - String playerSelect = "SELECT * FROM " + playerTable.getTableName(); - String teamSelect = "SELECT * FROM " + teamTable.getTableName(); - - // WHEN - QuickSqlTestData quickSqlTestData = QuickSqlTestData.buildFrom(DATA_SOURCE); - String insertScript = quickSqlTestData - .generateInsertScriptFor(playerSelect, teamSelect); - - // THEN - playerTable.drop(); - teamTable.drop().create(); - playerTable.create().alter(playerTableConstraint); - SQL_EXECUTOR.execute(insertScript); - assertThat(playerTable).withScript(insertScript) - .hasNumberOfRows(1); - assertThat(teamTable).withScript(insertScript) - .hasNumberOfRows(1); - - } - - private int generateRandomPositiveInt() { - Random random = new Random(); - return Math.abs(random.nextInt()); - } - - @Test public void - should_add_rows_related_to_a_not_null_foreign_key() { - - // GIVEN - TestTable teamTable = - buildUniqueTable(DATA_SOURCE - , "Team" - ," id bigint not null" + - ", name varchar(255)" + - ", primary key (id)" - ) - .create() - .insertValues("1, 'Manchester United'"); - - String playerTableConstraint = "add constraint player_team_fk" + generateRandomPositiveInt() - + " foreign key (team_id)" - + " references " + teamTable.getTableName(); - TestTable playerTable = - buildUniqueTable(DATA_SOURCE - , "Player" - , "id bigint not null" - + ", firstName varchar(255)" - + ", lastName varchar(255)" - + ", team_id bigint not null" - + ", primary key (id)" - ) - .create() - .alter(playerTableConstraint) - .insertValues("1, 'Paul', 'Pogba', 1"); - - // WHEN - String playerSelect = "SELECT * FROM " + playerTable.getTableName(); - QuickSqlTestData quickSqlTestData = QuickSqlTestData.buildFrom(DATA_SOURCE); - String insertScript = quickSqlTestData.generateInsertScriptFor(playerSelect); - - // THEN - playerTable.drop(); - teamTable.drop().create(); - playerTable.create().alter(playerTableConstraint); - SQL_EXECUTOR.execute(insertScript); - assertThat(playerTable).withScript(insertScript) - .hasNumberOfRows(1); - assertThat(teamTable).withScript(insertScript) - .hasNumberOfRows(1); - - } - - @RepeatedTest(9) public void - should_sort_insert_statements_following_primary_keys() { - - // GIVEN - TestTable table = - buildUniqueTable(DATA_SOURCE - , "comp_pk" - , "col_id1 integer," + - "col_id2 integer, " + - "colA varchar(20), " + - "colB varchar(20), " + - "constraint comp_pk_pk" + generateRandomPositiveInt() + " primary key (col_id2, col_id1)" - ) - .create() - .insertValues("1, 2, 'colA_r1_value', 'colB_r1_value'") - .insertValues("1, 1, 'colA_r1_value', 'colB_r1_value'") - .insertValues("2, 2, 'colA_r1_value', 'colB_r1_value'") - .insertValues("2, 1, 'colA_r1_value', 'colB_r1_value'"); - - // WHEN - String selectAll = "SELECT * FROM " + table.getTableName(); - QuickSqlTestData quickSqlTestData = QuickSqlTestData.buildFrom(DATA_SOURCE); - List insertStatements = quickSqlTestData.generateInsertListFor(selectAll); - - // THEN - String insertQueriesAsString = insertStatements.toString(); - - String firstInsert = insertStatements.get(0); - assertThat(firstInsert).as(insertQueriesAsString).contains("VALUES(1, 1"); - - String secondInsert = insertStatements.get(1); - assertThat(secondInsert).as(insertQueriesAsString).contains("VALUES(2, 1"); - - String thirdInsert = insertStatements.get(2); - assertThat(thirdInsert).as(insertQueriesAsString).contains("VALUES(1, 2"); - - String fourthInsert = insertStatements.get(3); - assertThat(fourthInsert).as(insertQueriesAsString).contains("VALUES(2, 2"); - - } - - // Not possible to both repeat and parameterize a JUnit 5 test - @ParameterizedTest - @ValueSource(strings = {"INT", "SMALLINT", "BIGINT"}) - public void - should_sort_insert_statements_following_an_integer_primary_key(String intType) { - - TestTable table = - buildUniqueTable(DATA_SOURCE - , "table_with_int_pk" - , "col_id " + intType + "," + - "colA varchar(20), " + - "colB varchar(20), " + - "constraint int_pk" + generateRandomPositiveInt() + " primary key (col_id)" - ) - .create() - .insertValues("2, 'A', 'B'") - .insertValues("10, 'C', 'D'") - .insertValues("1, 'E', 'F'"); - - String selectAll = "SELECT * FROM " + table.getTableName(); - QuickSqlTestData quickSqlTestData = QuickSqlTestData.buildFrom(DATA_SOURCE); - - // WHEN - List insertStatements = quickSqlTestData.generateInsertListFor(selectAll); - - // THEN - String insertStatementsAsString = insertStatements.toString(); - - String firstQuery = insertStatements.get(0); - assertThat(firstQuery).as(insertStatementsAsString).contains("VALUES(1"); - - String secondQuery = insertStatements.get(1); - assertThat(secondQuery).as(insertStatementsAsString).contains("VALUES(2"); - - String thirdQuery = insertStatements.get(2); - assertThat(thirdQuery).as(insertStatementsAsString).contains("VALUES(10"); - - } - - @Test public void - should_generate_an_insert_statement_with_a_date_type() { - - // GIVEN - TestTable playerTable = - buildUniqueTable(DATA_SOURCE - , "Table" - , "date Date" - ) - .create() - .insertValues("'2012-09-17'"); - - // WHEN - String playerTableName = playerTable.getTableName(); - String select = "SELECT * FROM " + playerTableName; - QuickSqlTestData quickSqlTestData = QuickSqlTestData.buildFrom(DATA_SOURCE); - String insertScript = quickSqlTestData.generateInsertScriptFor(select); - - // THEN - playerTable.recreate(); - SQL_EXECUTOR.execute(insertScript); - assertThat(playerTable).withScript(insertScript) - .hasNumberOfRows(1) - .row(0).hasValues("2012-09-17"); - - } - - @Test public void - should_generate_an_insert_statement_with_a_timestamp_type() { - - // GIVEN - TestTable playerTable = - buildUniqueTable(DATA_SOURCE - , "Table" - , "timestampCol TIMESTAMP" - ) - .create() - .insertValues("'2012-09-17 19:56:47.32'"); - - // WHEN - String playerTableName = playerTable.getTableName(); - String select = "SELECT * FROM " + playerTableName; - QuickSqlTestData quickSqlTestData = QuickSqlTestData.buildFrom(DATA_SOURCE); - String insertScript = quickSqlTestData.generateInsertScriptFor(select); - - // THEN - playerTable.recreate(); - SQL_EXECUTOR.execute(insertScript); - assertThat(playerTable).withScript(insertScript) - .hasNumberOfRows(1); - Assertions.assertThat(insertScript).contains("'2012-09-17 19:56:47.32'"); - - } - - @Test public void - should_generate_an_insert_statement_with_a_timestamp_with_time_zone_type() { - - // GIVEN - TestTable playerTable = - buildUniqueTable(DATA_SOURCE - , "Table" - , "col TIMESTAMP WITH TIME ZONE" - ) - .create() - .insertValues("'2012-09-17 19:56:47.32 UTC'"); - - // WHEN - String playerTableName = playerTable.getTableName(); - String select = "SELECT * FROM " + playerTableName; - QuickSqlTestData quickSqlTestData = QuickSqlTestData.buildFrom(DATA_SOURCE); - String insertScript = quickSqlTestData.generateInsertScriptFor(select); - - // THEN - playerTable.recreate(); - SQL_EXECUTOR.execute(insertScript); - assertThat(playerTable).withScript(insertScript) - .hasNumberOfRows(1); - - } - - @Test public void - should_generate_an_insert_statement_with_a_time_type() { - - // GIVEN - TestTable playerTable = - buildUniqueTable(DATA_SOURCE - , "Table" - , "col TIME" - ) - .create() - .insertValues("'23:59:59'"); - - // WHEN - String playerTableName = playerTable.getTableName(); - String select = "SELECT * FROM " + playerTableName; - QuickSqlTestData quickSqlTestData = QuickSqlTestData.buildFrom(DATA_SOURCE); - String insertScript = quickSqlTestData.generateInsertScriptFor(select); - - // THEN - playerTable.recreate(); - SQL_EXECUTOR.execute(insertScript); - assertThat(playerTable).withScript(insertScript) - .hasNumberOfRows(1) - .row(0).hasValues("23:59:59"); - - } - - @Test public void - should_generate_an_insert_statement_with_a_time_with_timezone_type() { - - // GIVEN - TestTable playerTable = - buildUniqueTable(DATA_SOURCE - , "Table" - , "col TIME WITH TIME ZONE" - ) - .create() - .insertValues("'23:59:59 UTC'"); - - // WHEN - String playerTableName = playerTable.getTableName(); - String select = "SELECT * FROM " + playerTableName; - QuickSqlTestData quickSqlTestData = QuickSqlTestData.buildFrom(DATA_SOURCE); - String insertScript = quickSqlTestData.generateInsertScriptFor(select); - - // THEN - playerTable.recreate(); - SQL_EXECUTOR.execute(insertScript); - assertThat(playerTable).withScript(insertScript) - .hasNumberOfRows(1); - - } - + private static final String DB_USER_NAME = "user"; + + private static final String DB_PASSWORD = "pwd"; + + private static final PostgreSQLContainer POSTGRESQL_CONTAINER = + new PostgreSQLContainer<>("postgres:12.3") + .withDatabaseName("postgresql") + .withUsername(DB_USER_NAME) + .withPassword(DB_PASSWORD); + + private static DataSource DATA_SOURCE; + + private static SqlExecutor SQL_EXECUTOR; + + @BeforeAll + public static void beforeAll() { + POSTGRESQL_CONTAINER.start(); + String jdbcUrl = POSTGRESQL_CONTAINER.getJdbcUrl(); + DATA_SOURCE = DataSourceBuilder.INSTANCE.build(jdbcUrl, DB_USER_NAME, DB_PASSWORD); + SQL_EXECUTOR = new SqlExecutor(DATA_SOURCE); + } + + @AfterAll + public static void stopContainer() { + POSTGRESQL_CONTAINER.stop(); + } + + @Test + public void should_generate_working_insert_from_a_select_statement() { + + // GIVEN + TestTable playerTable = + buildUniqueTable( + DATA_SOURCE, + "Player", + " id bigint" + ", firstName varchar(255)" + ", lastName varchar(255)") + .create() + .insertValues("1, 'Paul', 'Pogba'") + .insertValues("2, 'Antoine', 'Griezmann'"); + + // WHEN + String playerTableName = playerTable.getTableName(); + String select = "SELECT * FROM " + playerTableName; + QuickSqlTestData quickSqlTestData = QuickSqlTestData.buildFrom(DATA_SOURCE); + String insertScript = quickSqlTestData.generateInsertScriptFor(select); + + // THEN + playerTable.recreate(); + SQL_EXECUTOR.execute(insertScript); + assertThat(playerTable) + .withScript(insertScript) + .hasNumberOfRows(2) + .row(0) + .column(0) + .hasValues(1, 2) + .row(0) + .column(1) + .hasValues("Paul", "Antoine") + .row(0) + .column(2) + .hasValues("Pogba", "Griezmann"); + } + + @Test + public void + should_generate_an_insert_statement_with_columns_declared_in_the_same_order_as_in_the_table() { + + // GIVEN + TestTable playerTable = + buildUniqueTable( + DATA_SOURCE, + "player", + "id bigint" + ", firstName varchar(255)" + ", lastName varchar(255)") + .create() + .insertValues("1, 'Paul', 'Pogba'"); + + // WHEN + String playerTableName = playerTable.getTableName(); + String select = "SELECT * FROM " + playerTableName; + QuickSqlTestData quickSqlTestData = QuickSqlTestData.buildFrom(DATA_SOURCE); + String insertScript = quickSqlTestData.generateInsertScriptFor(select); + + // THEN + assertThat(insertScript).contains("id, firstname, lastname"); + + playerTable.recreate(); + SQL_EXECUTOR.execute(insertScript); + assertThat(playerTable).withScript(insertScript).hasNumberOfRows(1); + } + + @Test + public void should_generate_an_insert_with_selected_columns_only() { + + // GIVEN + TestTable playerTable = + buildUniqueTable( + DATA_SOURCE, + "Player", + "id bigint" + ", firstName varchar(255)" + ", lastName varchar(255)") + .create() + .insertValues("1, 'Paul', 'Pogba'"); + + // WHEN + String playerTableName = playerTable.getTableName(); + String select = "SELECT firstName FROM " + playerTableName; + QuickSqlTestData quickSqlTestData = QuickSqlTestData.buildFrom(DATA_SOURCE); + String insertScript = quickSqlTestData.generateInsertScriptFor(select); + + // THEN + playerTable.recreate(); + SQL_EXECUTOR.execute(insertScript); + assertThat(playerTable) + .withScript(insertScript) + .hasNumberOfRows(1) + .row(0) + .column(1) + .hasValues("Paul"); + } + + @Test + public void should_generate_an_insert_statement_with_not_null_columns() { + + // GIVEN + TestTable playerTable = + buildUniqueTable( + DATA_SOURCE, + "Player", + " id bigint not null" + + ", firstName varchar(255) not null" + + ", lastName varchar(255) not null") + .create() + .insertValues("1, 'Paul', 'Pogba'"); + + String select = "SELECT id FROM " + playerTable.getTableName() + " WHERE lastName = 'Pogba'"; + + // WHEN + QuickSqlTestData quickSqlTestData = QuickSqlTestData.buildFrom(DATA_SOURCE); + String insertScript = quickSqlTestData.generateInsertScriptFor(select); + + // THEN + playerTable.recreate(); + SQL_EXECUTOR.execute(insertScript); + assertThat(playerTable) + .withScript(insertScript) + .hasNumberOfRows(1) + .row(0) + .hasValues(1, "Paul", "Pogba"); + } + + @RepeatedTest(9) + public void should_sort_insert_statements_following_table_dependencies() { + + // GIVEN + TestTable teamTable = + buildUniqueTable( + DATA_SOURCE, + "Team", + " id bigint not null" + ", name varchar(255)" + ", primary key (id)") + .create() + .insertValues("1, 'Manchester United'"); + + String playerTableConstraint = + "add constraint player_team_fk" + + generateRandomPositiveInt() + + " foreign key (team_id)" + + " references " + + teamTable.getTableName(); + TestTable playerTable = + buildUniqueTable( + DATA_SOURCE, + "Player", + "id bigint not null" + + ", firstName varchar(255)" + + ", lastName varchar(255)" + + ", team_id bigint" + + ", primary key (id)") + .create() + .alter(playerTableConstraint) + .insertValues("1, 'Paul', 'Pogba', 1"); + + String playerSelect = "SELECT * FROM " + playerTable.getTableName(); + String teamSelect = "SELECT * FROM " + teamTable.getTableName(); + + // WHEN + QuickSqlTestData quickSqlTestData = QuickSqlTestData.buildFrom(DATA_SOURCE); + String insertScript = quickSqlTestData.generateInsertScriptFor(playerSelect, teamSelect); + + // THEN + playerTable.drop(); + teamTable.drop().create(); + playerTable.create().alter(playerTableConstraint); + SQL_EXECUTOR.execute(insertScript); + assertThat(playerTable).withScript(insertScript).hasNumberOfRows(1); + assertThat(teamTable).withScript(insertScript).hasNumberOfRows(1); + } + + private int generateRandomPositiveInt() { + Random random = new Random(); + return Math.abs(random.nextInt()); + } + + @Test + public void should_add_rows_related_to_a_not_null_foreign_key() { + + // GIVEN + TestTable teamTable = + buildUniqueTable( + DATA_SOURCE, + "Team", + " id bigint not null" + ", name varchar(255)" + ", primary key (id)") + .create() + .insertValues("1, 'Manchester United'"); + + String playerTableConstraint = + "add constraint player_team_fk" + + generateRandomPositiveInt() + + " foreign key (team_id)" + + " references " + + teamTable.getTableName(); + TestTable playerTable = + buildUniqueTable( + DATA_SOURCE, + "Player", + "id bigint not null" + + ", firstName varchar(255)" + + ", lastName varchar(255)" + + ", team_id bigint not null" + + ", primary key (id)") + .create() + .alter(playerTableConstraint) + .insertValues("1, 'Paul', 'Pogba', 1"); + + // WHEN + String playerSelect = "SELECT * FROM " + playerTable.getTableName(); + QuickSqlTestData quickSqlTestData = QuickSqlTestData.buildFrom(DATA_SOURCE); + String insertScript = quickSqlTestData.generateInsertScriptFor(playerSelect); + + // THEN + playerTable.drop(); + teamTable.drop().create(); + playerTable.create().alter(playerTableConstraint); + SQL_EXECUTOR.execute(insertScript); + assertThat(playerTable).withScript(insertScript).hasNumberOfRows(1); + assertThat(teamTable).withScript(insertScript).hasNumberOfRows(1); + } + + @RepeatedTest(9) + public void should_sort_insert_statements_following_primary_keys() { + + // GIVEN + TestTable table = + buildUniqueTable( + DATA_SOURCE, + "comp_pk", + "col_id1 integer," + + "col_id2 integer, " + + "colA varchar(20), " + + "colB varchar(20), " + + "constraint comp_pk_pk" + + generateRandomPositiveInt() + + " primary key (col_id2, col_id1)") + .create() + .insertValues("1, 2, 'colA_r1_value', 'colB_r1_value'") + .insertValues("1, 1, 'colA_r1_value', 'colB_r1_value'") + .insertValues("2, 2, 'colA_r1_value', 'colB_r1_value'") + .insertValues("2, 1, 'colA_r1_value', 'colB_r1_value'"); + + // WHEN + String selectAll = "SELECT * FROM " + table.getTableName(); + QuickSqlTestData quickSqlTestData = QuickSqlTestData.buildFrom(DATA_SOURCE); + List insertStatements = quickSqlTestData.generateInsertListFor(selectAll); + + // THEN + String insertQueriesAsString = insertStatements.toString(); + + String firstInsert = insertStatements.get(0); + assertThat(firstInsert).as(insertQueriesAsString).contains("VALUES(1, 1"); + + String secondInsert = insertStatements.get(1); + assertThat(secondInsert).as(insertQueriesAsString).contains("VALUES(2, 1"); + + String thirdInsert = insertStatements.get(2); + assertThat(thirdInsert).as(insertQueriesAsString).contains("VALUES(1, 2"); + + String fourthInsert = insertStatements.get(3); + assertThat(fourthInsert).as(insertQueriesAsString).contains("VALUES(2, 2"); + } + + // Not possible to both repeat and parameterize a JUnit 5 test + @ParameterizedTest + @ValueSource(strings = {"INT", "SMALLINT", "BIGINT"}) + public void should_sort_insert_statements_following_an_integer_primary_key(String intType) { + + TestTable table = + buildUniqueTable( + DATA_SOURCE, + "table_with_int_pk", + "col_id " + + intType + + "," + + "colA varchar(20), " + + "colB varchar(20), " + + "constraint int_pk" + + generateRandomPositiveInt() + + " primary key (col_id)") + .create() + .insertValues("2, 'A', 'B'") + .insertValues("10, 'C', 'D'") + .insertValues("1, 'E', 'F'"); + + String selectAll = "SELECT * FROM " + table.getTableName(); + QuickSqlTestData quickSqlTestData = QuickSqlTestData.buildFrom(DATA_SOURCE); + + // WHEN + List insertStatements = quickSqlTestData.generateInsertListFor(selectAll); + + // THEN + String insertStatementsAsString = insertStatements.toString(); + + String firstQuery = insertStatements.get(0); + assertThat(firstQuery).as(insertStatementsAsString).contains("VALUES(1"); + + String secondQuery = insertStatements.get(1); + assertThat(secondQuery).as(insertStatementsAsString).contains("VALUES(2"); + + String thirdQuery = insertStatements.get(2); + assertThat(thirdQuery).as(insertStatementsAsString).contains("VALUES(10"); + } + + @Test + public void should_generate_an_insert_statement_with_a_date_type() { + + // GIVEN + TestTable playerTable = + buildUniqueTable(DATA_SOURCE, "Table", "date Date").create().insertValues("'2012-09-17'"); + + // WHEN + String playerTableName = playerTable.getTableName(); + String select = "SELECT * FROM " + playerTableName; + QuickSqlTestData quickSqlTestData = QuickSqlTestData.buildFrom(DATA_SOURCE); + String insertScript = quickSqlTestData.generateInsertScriptFor(select); + + // THEN + playerTable.recreate(); + SQL_EXECUTOR.execute(insertScript); + assertThat(playerTable) + .withScript(insertScript) + .hasNumberOfRows(1) + .row(0) + .hasValues("2012-09-17"); + } + + @Test + public void should_generate_an_insert_statement_with_a_timestamp_type() { + + // GIVEN + TestTable playerTable = + buildUniqueTable(DATA_SOURCE, "Table", "timestampCol TIMESTAMP") + .create() + .insertValues("'2012-09-17 19:56:47.32'"); + + // WHEN + String playerTableName = playerTable.getTableName(); + String select = "SELECT * FROM " + playerTableName; + QuickSqlTestData quickSqlTestData = QuickSqlTestData.buildFrom(DATA_SOURCE); + String insertScript = quickSqlTestData.generateInsertScriptFor(select); + + // THEN + playerTable.recreate(); + SQL_EXECUTOR.execute(insertScript); + assertThat(playerTable).withScript(insertScript).hasNumberOfRows(1); + Assertions.assertThat(insertScript).contains("'2012-09-17 19:56:47.32'"); + } + + @Test + public void should_generate_an_insert_statement_with_a_timestamp_with_time_zone_type() { + + // GIVEN + TestTable playerTable = + buildUniqueTable(DATA_SOURCE, "Table", "col TIMESTAMP WITH TIME ZONE") + .create() + .insertValues("'2012-09-17 19:56:47.32 UTC'"); + + // WHEN + String playerTableName = playerTable.getTableName(); + String select = "SELECT * FROM " + playerTableName; + QuickSqlTestData quickSqlTestData = QuickSqlTestData.buildFrom(DATA_SOURCE); + String insertScript = quickSqlTestData.generateInsertScriptFor(select); + + // THEN + playerTable.recreate(); + SQL_EXECUTOR.execute(insertScript); + assertThat(playerTable).withScript(insertScript).hasNumberOfRows(1); + } + + @Test + public void should_generate_an_insert_statement_with_a_time_type() { + + // GIVEN + TestTable playerTable = + buildUniqueTable(DATA_SOURCE, "Table", "col TIME").create().insertValues("'23:59:59'"); + + // WHEN + String playerTableName = playerTable.getTableName(); + String select = "SELECT * FROM " + playerTableName; + QuickSqlTestData quickSqlTestData = QuickSqlTestData.buildFrom(DATA_SOURCE); + String insertScript = quickSqlTestData.generateInsertScriptFor(select); + + // THEN + playerTable.recreate(); + SQL_EXECUTOR.execute(insertScript); + assertThat(playerTable) + .withScript(insertScript) + .hasNumberOfRows(1) + .row(0) + .hasValues("23:59:59"); + } + + @Test + public void should_generate_an_insert_statement_with_a_time_with_timezone_type() { + + // GIVEN + TestTable playerTable = + buildUniqueTable(DATA_SOURCE, "Table", "col TIME WITH TIME ZONE") + .create() + .insertValues("'23:59:59 UTC'"); + + // WHEN + String playerTableName = playerTable.getTableName(); + String select = "SELECT * FROM " + playerTableName; + QuickSqlTestData quickSqlTestData = QuickSqlTestData.buildFrom(DATA_SOURCE); + String insertScript = quickSqlTestData.generateInsertScriptFor(select); + + // THEN + playerTable.recreate(); + SQL_EXECUTOR.execute(insertScript); + assertThat(playerTable).withScript(insertScript).hasNumberOfRows(1); + } } diff --git a/components/fluent-datafactory/src/test/java/io/fluent/datafactory/core/SqlExecutor.java b/components/fluent-datafactory/src/test/java/io/fluent/datafactory/core/SqlExecutor.java index 312e200..a5a3b24 100644 --- a/components/fluent-datafactory/src/test/java/io/fluent/datafactory/core/SqlExecutor.java +++ b/components/fluent-datafactory/src/test/java/io/fluent/datafactory/core/SqlExecutor.java @@ -12,33 +12,32 @@ */ package io.fluent.datafactory.core; -import javax.sql.DataSource; import java.sql.Connection; import java.sql.PreparedStatement; import java.sql.SQLException; import java.util.List; +import javax.sql.DataSource; public class SqlExecutor { - private final DataSource dataSource; + private final DataSource dataSource; - SqlExecutor(DataSource dataSource) { - this.dataSource = dataSource; - } + SqlExecutor(DataSource dataSource) { + this.dataSource = dataSource; + } - void execute(List queries) { - for (String query : queries) { - execute(query); - } + void execute(List queries) { + for (String query : queries) { + execute(query); } + } - void execute(String sql) { - try (Connection connection = dataSource.getConnection(); - PreparedStatement statement = connection.prepareStatement(sql)) { - statement.execute(); - } catch (SQLException e) { - throw new IllegalStateException("Unable to execute " + System.lineSeparator() + sql, e); - } + void execute(String sql) { + try (Connection connection = dataSource.getConnection(); + PreparedStatement statement = connection.prepareStatement(sql)) { + statement.execute(); + } catch (SQLException e) { + throw new IllegalStateException("Unable to execute " + System.lineSeparator() + sql, e); } - + } } diff --git a/components/fluent-datafactory/src/test/java/io/fluent/datafactory/core/TestTable.java b/components/fluent-datafactory/src/test/java/io/fluent/datafactory/core/TestTable.java index ddea297..7562b24 100644 --- a/components/fluent-datafactory/src/test/java/io/fluent/datafactory/core/TestTable.java +++ b/components/fluent-datafactory/src/test/java/io/fluent/datafactory/core/TestTable.java @@ -12,121 +12,115 @@ */ package io.fluent.datafactory.core; +import java.util.List; +import java.util.Random; +import javax.sql.DataSource; import org.assertj.core.api.AbstractAssert; import org.assertj.db.api.Assertions; import org.assertj.db.api.TableAssert; import org.assertj.db.api.TableRowAssert; import org.assertj.db.type.Table; -import javax.sql.DataSource; -import java.util.List; -import java.util.Random; - class TestTable { - private final String tableName; + private final String tableName; - private final String creationScript; + private final String creationScript; - private final DataSource dataSource; + private final DataSource dataSource; - private final SqlExecutor sqlExecutor; + private final SqlExecutor sqlExecutor; - TestTable(DataSource dataSource, String tableName, String creationScript) { - this.tableName = tableName; - this.creationScript = creationScript; - this.dataSource = dataSource; - this.sqlExecutor = new SqlExecutor(dataSource); - } + TestTable(DataSource dataSource, String tableName, String creationScript) { + this.tableName = tableName; + this.creationScript = creationScript; + this.dataSource = dataSource; + this.sqlExecutor = new SqlExecutor(dataSource); + } - static TestTable buildUniqueTable(DataSource dataSource - , String baseTableName - , String colDescsAndConstraints) { - String tableName = buildUniqueTableName(baseTableName); - String creationScript = "create table " + tableName - + "(" + colDescsAndConstraints + ")"; - return new TestTable(dataSource, tableName, creationScript); - } + static TestTable buildUniqueTable( + DataSource dataSource, String baseTableName, String colDescsAndConstraints) { + String tableName = buildUniqueTableName(baseTableName); + String creationScript = "create table " + tableName + "(" + colDescsAndConstraints + ")"; + return new TestTable(dataSource, tableName, creationScript); + } - private static String buildUniqueTableName(String baseTableName) { - return baseTableName + "_" + generateRandomPositiveInt(); - } + private static String buildUniqueTableName(String baseTableName) { + return baseTableName + "_" + generateRandomPositiveInt(); + } - private static int generateRandomPositiveInt() { - Random random = new Random(); - return Math.abs(random.nextInt()); - } + private static int generateRandomPositiveInt() { + Random random = new Random(); + return Math.abs(random.nextInt()); + } - TestTable recreate() { - drop(); - create(); - return this; - } + TestTable recreate() { + drop(); + create(); + return this; + } - TestTable drop() { - sqlExecutor.execute("drop table " + tableName); - return this; - } + TestTable drop() { + sqlExecutor.execute("drop table " + tableName); + return this; + } + + TestTable create() { + sqlExecutor.execute(creationScript); + return this; + } + + TestTable insertValues(String valuesSeparatedWithCommas) { + String insert = "INSERT INTO " + tableName + " VALUES (" + valuesSeparatedWithCommas + ")"; + sqlExecutor.execute(insert); + return this; + } - TestTable create() { - sqlExecutor.execute(creationScript); - return this; + String getTableName() { + return tableName; + } + + TestTable alter(String alterCode) { + sqlExecutor.execute("alter table " + tableName + " " + alterCode); + return this; + } + + static class TestTableAssert extends AbstractAssert { + + private static final String LINE_SEPARATOR = System.lineSeparator(); + private Table assertJDbTable; + + TestTableAssert(TestTable testTable, Class selfType) { + super(testTable, TestTableAssert.class); } - TestTable insertValues(String valuesSeparatedWithCommas) { - String insert = "INSERT INTO " + tableName + " VALUES (" +valuesSeparatedWithCommas + ")"; - sqlExecutor.execute(insert); - return this; + static TestTableAssert assertThat(TestTable testTable) { + TestTableAssert testTableAssert = new TestTableAssert(testTable, TestTableAssert.class); + testTableAssert.assertJDbTable = new Table(testTable.dataSource, testTable.tableName); + return testTableAssert; } - String getTableName() { - return tableName; + TableAssert hasNumberOfRows(int expected) { + return Assertions.assertThat(assertJDbTable).hasNumberOfRows(expected); } - TestTable alter(String alterCode) { - sqlExecutor.execute("alter table " + tableName + " " + alterCode); - return this; + TableAssert withScript(String sqlScript) { + String description = + LINE_SEPARATOR + "SQL script: " + LINE_SEPARATOR + sqlScript + LINE_SEPARATOR; + return Assertions.assertThat(assertJDbTable).as(description); } - static class TestTableAssert extends AbstractAssert { - - private static final String LINE_SEPARATOR = System.lineSeparator(); - private Table assertJDbTable; - - TestTableAssert(TestTable testTable, Class selfType) { - super(testTable, TestTableAssert.class); - } - - static TestTableAssert assertThat(TestTable testTable) { - TestTableAssert testTableAssert = new TestTableAssert(testTable, TestTableAssert.class); - testTableAssert.assertJDbTable = new Table(testTable.dataSource, testTable.tableName); - return testTableAssert; - } - - TableAssert hasNumberOfRows(int expected) { - return Assertions.assertThat(assertJDbTable).hasNumberOfRows(expected); - } - - TableAssert withScript(String sqlScript) { - String description = LINE_SEPARATOR - + "SQL script: " - + LINE_SEPARATOR - + sqlScript - + LINE_SEPARATOR; - return Assertions.assertThat(assertJDbTable).as(description); - } - - TableRowAssert row(int index) { - return Assertions.assertThat(assertJDbTable).row(index); - } - - TableAssert withGeneratedInserts(List generatedInsertStatements) { - String description = LINE_SEPARATOR - + "Queries: " - + LINE_SEPARATOR - + String.join(LINE_SEPARATOR, generatedInsertStatements); - return Assertions.assertThat(assertJDbTable).as(description); - } + TableRowAssert row(int index) { + return Assertions.assertThat(assertJDbTable).row(index); } + TableAssert withGeneratedInserts(List generatedInsertStatements) { + String description = + LINE_SEPARATOR + + "Queries: " + + LINE_SEPARATOR + + String.join(LINE_SEPARATOR, generatedInsertStatements); + return Assertions.assertThat(assertJDbTable).as(description); + } + } } diff --git a/components/fluent-datafactory/src/test/java/io/fluent/datafactory/core/User.java b/components/fluent-datafactory/src/test/java/io/fluent/datafactory/core/User.java index 0d9c01b..b5c208d 100644 --- a/components/fluent-datafactory/src/test/java/io/fluent/datafactory/core/User.java +++ b/components/fluent-datafactory/src/test/java/io/fluent/datafactory/core/User.java @@ -1,25 +1,24 @@ package io.fluent.datafactory.core; -import lombok.Data; - import java.util.Date; import java.util.List; import java.util.Map; +import lombok.Data; @Data public class User { - private String name; + private String name; + + private int age; - private int age; + private Date birthday; - private Date birthday; + private List stringList; - private List stringList; + // S/F 的枚举 - //S/F 的枚举 + private Map map; - private Map map; - - //Getter & Setter -} \ No newline at end of file + // Getter & Setter +} diff --git a/components/fluent-datafactory/src/test/java/io/fluent/datafactory/core/UserAnnotationNumber.java b/components/fluent-datafactory/src/test/java/io/fluent/datafactory/core/UserAnnotationNumber.java index 0d5fe61..0968d3f 100644 --- a/components/fluent-datafactory/src/test/java/io/fluent/datafactory/core/UserAnnotationNumber.java +++ b/components/fluent-datafactory/src/test/java/io/fluent/datafactory/core/UserAnnotationNumber.java @@ -1,38 +1,37 @@ package io.fluent.datafactory.core; import io.fluent.datafactory.api.annotation.DataFactory; -import lombok.Data; - import java.math.BigDecimal; import java.math.BigInteger; +import lombok.Data; @Data public class UserAnnotationNumber { - @DataFactory(min = 10, max = 20) - private Byte aByte; + @DataFactory(min = 10, max = 20) + private Byte aByte; + + @DataFactory(min = 10, max = 20) + private Short aShort; - @DataFactory(min = 10, max = 20) - private Short aShort; + @DataFactory(min = 10, max = 20) + private Integer integer; - @DataFactory(min = 10, max = 20) - private Integer integer; + @DataFactory(min = 10, max = 20) + private Long aLong; - @DataFactory(min = 10, max = 20) - private Long aLong; + @DataFactory(min = 10, max = 20, precision = 3) + private Double aDouble; - @DataFactory(min = 10, max = 20, precision = 3) - private Double aDouble; + @DataFactory(min = 10, max = 20, precision = 3) + private Float aFloat; - @DataFactory(min = 10, max = 20, precision = 3) - private Float aFloat; + @DataFactory(min = 10, max = 20, precision = 3) + private BigDecimal bigDecimal; - @DataFactory(min = 10, max = 20, precision = 3) - private BigDecimal bigDecimal; + @DataFactory(min = 10, max = 20) + private BigInteger bigInteger; - @DataFactory(min = 10, max = 20) - private BigInteger bigInteger; - - //getter & setter + // getter & setter -} \ No newline at end of file +} diff --git a/components/fluent-excel/src/main/java/io/fluentqa/excel/ExcelReadWriter.java b/components/fluent-excel/src/main/java/io/fluentqa/excel/ExcelReadWriter.java index 4ff2faf..83765cf 100644 --- a/components/fluent-excel/src/main/java/io/fluentqa/excel/ExcelReadWriter.java +++ b/components/fluent-excel/src/main/java/io/fluentqa/excel/ExcelReadWriter.java @@ -2,25 +2,24 @@ import com.github.crab2died.ExcelUtils; import com.github.crab2died.exceptions.Excel4JException; - import java.io.IOException; import java.util.List; public class ExcelReadWriter { - public List readExcel(String fileName, Class clazz) { - try { - return ExcelUtils.getInstance().readExcel2Objects(fileName, clazz); - } catch (Excel4JException | IOException e) { - throw new RuntimeException(e); - } + public List readExcel(String fileName, Class clazz) { + try { + return ExcelUtils.getInstance().readExcel2Objects(fileName, clazz); + } catch (Excel4JException | IOException e) { + throw new RuntimeException(e); } + } - public void writeExcel(List data, String fileName, Class clazz) { - try { - ExcelUtils.getInstance().exportObjects2Excel(data, clazz, true, fileName); - } catch (Excel4JException | IOException e) { - throw new RuntimeException(e); - } + public void writeExcel(List data, String fileName, Class clazz) { + try { + ExcelUtils.getInstance().exportObjects2Excel(data, clazz, true, fileName); + } catch (Excel4JException | IOException e) { + throw new RuntimeException(e); } + } } diff --git a/components/fluent-excel/src/main/java/io/fluentqa/excel/package-info.java b/components/fluent-excel/src/main/java/io/fluentqa/excel/package-info.java index 1e13488..a033ad3 100644 --- a/components/fluent-excel/src/main/java/io/fluentqa/excel/package-info.java +++ b/components/fluent-excel/src/main/java/io/fluentqa/excel/package-info.java @@ -1 +1 @@ -package io.fluentqa.excel; \ No newline at end of file +package io.fluentqa.excel; diff --git a/components/fluent-excel/src/test/java/io/fluentqa/excel/DemoExcelModel.java b/components/fluent-excel/src/test/java/io/fluentqa/excel/DemoExcelModel.java index 4a68914..0cbbcc5 100644 --- a/components/fluent-excel/src/test/java/io/fluentqa/excel/DemoExcelModel.java +++ b/components/fluent-excel/src/test/java/io/fluentqa/excel/DemoExcelModel.java @@ -1,6 +1,5 @@ package io.fluentqa.excel; - import com.github.crab2died.annotation.ExcelField; import lombok.AllArgsConstructor; import lombok.Data; @@ -10,8 +9,9 @@ @AllArgsConstructor @NoArgsConstructor public class DemoExcelModel { - @ExcelField(title = "名称") - private String name; - @ExcelField(title = "年纪") - private Integer age; + @ExcelField(title = "名称") + private String name; + + @ExcelField(title = "年纪") + private Integer age; } diff --git a/components/fluent-excel/src/test/java/io/fluentqa/excel/ExcelUtilsTest.java b/components/fluent-excel/src/test/java/io/fluentqa/excel/ExcelUtilsTest.java index 1492d6a..1742770 100644 --- a/components/fluent-excel/src/test/java/io/fluentqa/excel/ExcelUtilsTest.java +++ b/components/fluent-excel/src/test/java/io/fluentqa/excel/ExcelUtilsTest.java @@ -1,38 +1,33 @@ package io.fluentqa.excel; - - -import org.apache.commons.io.FileUtils; -import org.junit.jupiter.api.AfterAll; -import org.junit.jupiter.api.Order; -import org.junit.jupiter.api.Test; - import java.io.File; import java.io.IOException; import java.util.Arrays; import java.util.List; +import org.apache.commons.io.FileUtils; +import org.junit.jupiter.api.AfterAll; +import org.junit.jupiter.api.Order; +import org.junit.jupiter.api.Test; public class ExcelUtilsTest { ExcelReadWriter readWriter = new ExcelReadWriter(); - List data = Arrays.asList(new DemoExcelModel("k", 12), - new DemoExcelModel("y", 10)); + List data = + Arrays.asList(new DemoExcelModel("k", 12), new DemoExcelModel("y", 10)); @Test void testWriteToExcel() throws IOException { - readWriter.writeExcel(data,"demo.xlsx",DemoExcelModel.class); + readWriter.writeExcel(data, "demo.xlsx", DemoExcelModel.class); } - @Test - @Order(100) - void testReadExcel() { - List models =readWriter.readExcel("demo.xlsx", - DemoExcelModel.class); - System.out.println(models); - } + @Test + @Order(100) + void testReadExcel() { + List models = readWriter.readExcel("demo.xlsx", DemoExcelModel.class); + System.out.println(models); + } @AfterAll - public static void cleanUp() throws IOException { - FileUtils.delete( new File("demo.xlsx")); + public static void cleanUp() throws IOException { + FileUtils.delete(new File("demo.xlsx")); } - -} \ No newline at end of file +} diff --git a/components/fluent-httpclients/src/main/java/io/fluent/clients/base/HttpClientOption.java b/components/fluent-httpclients/src/main/java/io/fluent/clients/base/HttpClientOption.java index ad866cc..f29ece2 100644 --- a/components/fluent-httpclients/src/main/java/io/fluent/clients/base/HttpClientOption.java +++ b/components/fluent-httpclients/src/main/java/io/fluent/clients/base/HttpClientOption.java @@ -1,41 +1,29 @@ package io.fluent.clients.base; +import java.net.Proxy; import lombok.Data; import okhttp3.logging.HttpLoggingInterceptor; -import java.net.Proxy; - - @Data -public class HttpClientOption extends HttpRequestModel{ +public class HttpClientOption extends HttpRequestModel { - /** - * 日志等级 - */ + /** 日志等级 */ private HttpLoggingInterceptor.Level loggLevel = HttpLoggingInterceptor.Level.BODY; - /** - * 读取超时时间,秒 - */ + /** 读取超时时间,秒 */ private long readTimeout = 30; - /** - * 链接超时时间 - */ + /** 链接超时时间 */ private long connectTimeout = 30; + private boolean followRedirects = false; - /** - * 最大的连接数 - */ + /** 最大的连接数 */ private int maxIdleConnections = 5; - /** - * 最大的kepAlive 时间 秒 - */ + /** 最大的kepAlive 时间 秒 */ private long keepAliveDuration = 5; // private String userAgent = "OKHTTP"; private String referer = ""; - /** - * 是否支持cookie - */ + /** 是否支持cookie */ private boolean cookie = false; + private ProxyConfig proxy; private boolean useProxy = false; @@ -58,6 +46,4 @@ public HttpClientOption defineProxy(ProxyConfig proxyConfig) { this.useProxy = true; return this; } - - } diff --git a/components/fluent-httpclients/src/main/java/io/fluent/clients/base/HttpException.java b/components/fluent-httpclients/src/main/java/io/fluent/clients/base/HttpException.java index e7b2f6e..016a32b 100644 --- a/components/fluent-httpclients/src/main/java/io/fluent/clients/base/HttpException.java +++ b/components/fluent-httpclients/src/main/java/io/fluent/clients/base/HttpException.java @@ -1,10 +1,8 @@ package io.fluent.clients.base; -import okhttp3.Response; - import java.util.List; import java.util.Map; - +import okhttp3.Response; public class HttpException extends RuntimeException { @@ -25,23 +23,28 @@ public HttpException(String message, int code) { this.code = code; } - public HttpException(String message, Throwable throwable, - int code, Map> responseHeaders, - String responseBody) { + public HttpException( + String message, + Throwable throwable, + int code, + Map> responseHeaders, + String responseBody) { super(message, throwable); this.code = code; this.responseHeaders = responseHeaders; this.responseBody = responseBody; } - public HttpException(String message, int code, Map> responseHeaders, String responseBody) { + public HttpException( + String message, int code, Map> responseHeaders, String responseBody) { super(message); this.code = code; this.responseHeaders = responseHeaders; this.responseBody = responseBody; } - public HttpException(String message, Throwable throwable, int code, Map> responseHeaders) { + public HttpException( + String message, Throwable throwable, int code, Map> responseHeaders) { super(message, throwable); this.code = code; this.responseHeaders = responseHeaders; @@ -51,6 +54,6 @@ public HttpException(Response response) { super(response.message()); this.code = 15000 + response.code(); this.responseHeaders = response.headers().toMultimap(); - //this.responseBody = response.body().string(); + // this.responseBody = response.body().string(); } } diff --git a/components/fluent-httpclients/src/main/java/io/fluent/clients/base/HttpRequestModel.java b/components/fluent-httpclients/src/main/java/io/fluent/clients/base/HttpRequestModel.java index 1b16719..4129a34 100644 --- a/components/fluent-httpclients/src/main/java/io/fluent/clients/base/HttpRequestModel.java +++ b/components/fluent-httpclients/src/main/java/io/fluent/clients/base/HttpRequestModel.java @@ -1,15 +1,14 @@ package io.fluent.clients.base; import cn.hutool.json.JSONUtil; +import java.util.HashMap; +import java.util.Map; import lombok.Data; import okhttp3.Headers; import okhttp3.MediaType; import okhttp3.Request; import okhttp3.RequestBody; -import java.util.HashMap; -import java.util.Map; - @Data public class HttpRequestModel { private String baseUrl; @@ -53,13 +52,14 @@ public HttpRequestModel addHeader(String key, String value) { return this; } - public Request toOkHttRequest(){ - //TODO: How to handler FILE - Request.Builder requestBuilder = new Request.Builder().url(this.getRequestPath()) - .headers(Headers.of(this.headers)); - if (requestBody!=null){ - RequestBody body = RequestBody.create(JSONUtil.toJsonStr(requestBody), MediaType.get("application/json")); - requestBuilder.method(method.toString(),body); + public Request toOkHttRequest() { + // TODO: How to handler FILE + Request.Builder requestBuilder = + new Request.Builder().url(this.getRequestPath()).headers(Headers.of(this.headers)); + if (requestBody != null) { + RequestBody body = + RequestBody.create(JSONUtil.toJsonStr(requestBody), MediaType.get("application/json")); + requestBuilder.method(method.toString(), body); } return requestBuilder.build(); } diff --git a/components/fluent-httpclients/src/main/java/io/fluent/clients/base/HttpResponseModel.java b/components/fluent-httpclients/src/main/java/io/fluent/clients/base/HttpResponseModel.java index a4ddf89..0122c3e 100644 --- a/components/fluent-httpclients/src/main/java/io/fluent/clients/base/HttpResponseModel.java +++ b/components/fluent-httpclients/src/main/java/io/fluent/clients/base/HttpResponseModel.java @@ -1,13 +1,12 @@ package io.fluent.clients.base; -import lombok.Data; - import java.util.Map; +import lombok.Data; @Data public class HttpResponseModel { private String url; - private Map headers; + private Map headers; private String method; private Object body; private int statusCode; diff --git a/components/fluent-httpclients/src/main/java/io/fluent/clients/base/MediaTypeEnum.java b/components/fluent-httpclients/src/main/java/io/fluent/clients/base/MediaTypeEnum.java index 067ef99..6f2c0f3 100644 --- a/components/fluent-httpclients/src/main/java/io/fluent/clients/base/MediaTypeEnum.java +++ b/components/fluent-httpclients/src/main/java/io/fluent/clients/base/MediaTypeEnum.java @@ -4,58 +4,48 @@ import okhttp3.MediaType; import org.apache.commons.lang3.StringUtils; - public enum MediaTypeEnum { - /** - * Content Type 为JSON - */ - JSON(MediaType.parse("application/json;charset=utf-8")), - FORM(MediaType.parse("application/x-www-form-urlencoded;charset=UTF-8")), - FORM_DATA(MediaType.parse("multipart/form-data")), - XML(MediaType.parse("text/xml;charset=UTF-8")), - /** - * 纯文本格式 - */ - PLAIN(MediaType.parse("text/plain;charset=UTF-8")), - HTML(MediaType.parse("text/html;charset=UTF-8")), - /** - * 二进制流数据(如常见的文件下载) - */ - OCTET_STREAM(MediaType.parse("application/octet-stream")), - OTHER(null); - - - /** - * Content Type 类型 - */ - @Getter - private final MediaType mediaType; - - MediaTypeEnum(MediaType mediaType) { - this.mediaType = mediaType; - } - - public static MediaTypeEnum of(Object contentType) { - if (contentType instanceof MediaTypeEnum) { - return (MediaTypeEnum) contentType; - } else if (contentType instanceof String) { - String contentStr = (String) contentType; - //application/json;charset=utf-8 application/json; - contentType = StringUtils.substringBefore(contentStr, ";"); - String type = StringUtils.substringBefore(contentStr, "/"); - String subType = StringUtils.substringAfter(contentStr, "/"); - for (MediaTypeEnum mediaType : MediaTypeEnum.values()) { - if (mediaType.getMediaType().type().equals(type) && mediaType.getMediaType().subtype().equals(subType)) { - return mediaType; - } - } + /** Content Type 为JSON */ + JSON(MediaType.parse("application/json;charset=utf-8")), + FORM(MediaType.parse("application/x-www-form-urlencoded;charset=UTF-8")), + FORM_DATA(MediaType.parse("multipart/form-data")), + XML(MediaType.parse("text/xml;charset=UTF-8")), + /** 纯文本格式 */ + PLAIN(MediaType.parse("text/plain;charset=UTF-8")), + HTML(MediaType.parse("text/html;charset=UTF-8")), + /** 二进制流数据(如常见的文件下载) */ + OCTET_STREAM(MediaType.parse("application/octet-stream")), + OTHER(null); + + /** Content Type 类型 */ + @Getter private final MediaType mediaType; + + MediaTypeEnum(MediaType mediaType) { + this.mediaType = mediaType; + } + + public static MediaTypeEnum of(Object contentType) { + if (contentType instanceof MediaTypeEnum) { + return (MediaTypeEnum) contentType; + } else if (contentType instanceof String) { + String contentStr = (String) contentType; + // application/json;charset=utf-8 application/json; + contentType = StringUtils.substringBefore(contentStr, ";"); + String type = StringUtils.substringBefore(contentStr, "/"); + String subType = StringUtils.substringAfter(contentStr, "/"); + for (MediaTypeEnum mediaType : MediaTypeEnum.values()) { + if (mediaType.getMediaType().type().equals(type) + && mediaType.getMediaType().subtype().equals(subType)) { + return mediaType; } - - return MediaTypeEnum.OTHER; + } } - @Override - public String toString() { - return mediaType.toString(); - } + return MediaTypeEnum.OTHER; + } + + @Override + public String toString() { + return mediaType.toString(); + } } diff --git a/components/fluent-httpclients/src/main/java/io/fluent/clients/base/MethodEnum.java b/components/fluent-httpclients/src/main/java/io/fluent/clients/base/MethodEnum.java index e4342cd..e46e6c0 100644 --- a/components/fluent-httpclients/src/main/java/io/fluent/clients/base/MethodEnum.java +++ b/components/fluent-httpclients/src/main/java/io/fluent/clients/base/MethodEnum.java @@ -1,6 +1,13 @@ package io.fluent.clients.base; - public enum MethodEnum { - GET, POST, HEAD, OPTIONS, PUT, DELETE, TRACE, CONNECT, PATCH + GET, + POST, + HEAD, + OPTIONS, + PUT, + DELETE, + TRACE, + CONNECT, + PATCH } diff --git a/components/fluent-httpclients/src/main/java/io/fluent/clients/factory/HttpClientFactory.java b/components/fluent-httpclients/src/main/java/io/fluent/clients/factory/HttpClientFactory.java index bc90787..a05f28d 100644 --- a/components/fluent-httpclients/src/main/java/io/fluent/clients/factory/HttpClientFactory.java +++ b/components/fluent-httpclients/src/main/java/io/fluent/clients/factory/HttpClientFactory.java @@ -1,52 +1,61 @@ package io.fluent.clients.factory; +import static java.net.CookiePolicy.ACCEPT_ORIGINAL_SERVER; import io.fluent.clients.base.HttpClientOption; -import okhttp3.ConnectionPool; -import okhttp3.Credentials; -import okhttp3.JavaNetCookieJar; -import okhttp3.OkHttpClient; -import org.apache.commons.lang3.StringUtils; - import java.net.CookieManager; import java.net.InetSocketAddress; import java.net.Proxy; import java.time.Duration; import java.util.concurrent.TimeUnit; - -import static java.net.CookiePolicy.ACCEPT_ORIGINAL_SERVER; - +import okhttp3.ConnectionPool; +import okhttp3.Credentials; +import okhttp3.JavaNetCookieJar; +import okhttp3.OkHttpClient; +import org.apache.commons.lang3.StringUtils; public class HttpClientFactory { public OkHttpClient okHttpClient(HttpClientOption httpConfig) { - ConnectionPool connectionPool = new ConnectionPool(httpConfig.getMaxIdleConnections(), - httpConfig.getKeepAliveDuration(), TimeUnit.SECONDS); + ConnectionPool connectionPool = + new ConnectionPool( + httpConfig.getMaxIdleConnections(), + httpConfig.getKeepAliveDuration(), + TimeUnit.SECONDS); - OkHttpClient.Builder builder = new OkHttpClient.Builder() - .connectionPool(connectionPool) - //跳转由自己控制 - .followRedirects(false) - .readTimeout(Duration.ofSeconds(httpConfig.getReadTimeout())) - .connectTimeout(Duration.ofSeconds(httpConfig.getReadTimeout())); + OkHttpClient.Builder builder = + new OkHttpClient.Builder() + .connectionPool(connectionPool) + // 跳转由自己控制 + .followRedirects(false) + .readTimeout(Duration.ofSeconds(httpConfig.getReadTimeout())) + .connectTimeout(Duration.ofSeconds(httpConfig.getReadTimeout())); if (httpConfig.isCookie()) { CookieManager cookieManager = new CookieManager(null, ACCEPT_ORIGINAL_SERVER); builder.cookieJar(new JavaNetCookieJar(cookieManager)); } - //proxy + // proxy if (httpConfig.isUseProxy()) { - builder.proxy(new Proxy(httpConfig.getProxy().getType(), - new InetSocketAddress(httpConfig.getProxy().getHost(), httpConfig.getProxy().getPort()))); + builder.proxy( + new Proxy( + httpConfig.getProxy().getType(), + new InetSocketAddress( + httpConfig.getProxy().getHost(), httpConfig.getProxy().getPort()))); if (StringUtils.isNotBlank(httpConfig.getProxy().getPassword())) { - builder.proxyAuthenticator((route, response) -> { - //设置代理服务器账号密码 - String credential = Credentials.basic(httpConfig.getProxy().getUserName(), httpConfig.getProxy().getPassword()); - return response.request().newBuilder() - .header("Proxy-Authorization", credential) - .build(); - }); + builder.proxyAuthenticator( + (route, response) -> { + // 设置代理服务器账号密码 + String credential = + Credentials.basic( + httpConfig.getProxy().getUserName(), httpConfig.getProxy().getPassword()); + return response + .request() + .newBuilder() + .header("Proxy-Authorization", credential) + .build(); + }); } } return builder.build(); diff --git a/components/fluent-httpclients/src/main/java/io/fluent/clients/factory/HttpClientProcessor.java b/components/fluent-httpclients/src/main/java/io/fluent/clients/factory/HttpClientProcessor.java index c35a010..5713a3d 100644 --- a/components/fluent-httpclients/src/main/java/io/fluent/clients/factory/HttpClientProcessor.java +++ b/components/fluent-httpclients/src/main/java/io/fluent/clients/factory/HttpClientProcessor.java @@ -2,11 +2,10 @@ import io.fluent.clients.base.HttpClientOption; import io.fluent.clients.base.HttpRequestModel; +import java.io.IOException; import okhttp3.OkHttpClient; import okhttp3.Response; -import java.io.IOException; - public class HttpClientProcessor { private HttpClientOption httpClientConfig; diff --git a/components/fluent-httpclients/src/main/java/io/fluent/clients/interceptors/CustomCallback.java b/components/fluent-httpclients/src/main/java/io/fluent/clients/interceptors/CustomCallback.java index 4ff8828..210094d 100644 --- a/components/fluent-httpclients/src/main/java/io/fluent/clients/interceptors/CustomCallback.java +++ b/components/fluent-httpclients/src/main/java/io/fluent/clients/interceptors/CustomCallback.java @@ -5,5 +5,5 @@ import retrofit2.Response; public interface CustomCallback extends Callback { - void onFailResponse(int errorCode, Call call, Response response); -} \ No newline at end of file + void onFailResponse(int errorCode, Call call, Response response); +} diff --git a/components/fluent-httpclients/src/main/java/io/fluent/clients/interceptors/HttpRequestHeaderInterceptor.java b/components/fluent-httpclients/src/main/java/io/fluent/clients/interceptors/HttpRequestHeaderInterceptor.java index a5795ed..23933c7 100644 --- a/components/fluent-httpclients/src/main/java/io/fluent/clients/interceptors/HttpRequestHeaderInterceptor.java +++ b/components/fluent-httpclients/src/main/java/io/fluent/clients/interceptors/HttpRequestHeaderInterceptor.java @@ -1,21 +1,18 @@ package io.fluent.clients.interceptors; +import java.io.IOException; import okhttp3.Interceptor; import okhttp3.Request; import okhttp3.Response; import org.jetbrains.annotations.NotNull; -import java.io.IOException; - public class HttpRequestHeaderInterceptor implements Interceptor { - - @NotNull @Override public Response intercept(@NotNull Chain chain) throws IOException { Request request = chain.request(); - //TODO: add interceptor + // TODO: add interceptor return null; } } diff --git a/components/fluent-httpclients/src/main/java/io/fluent/clients/interceptors/retry/RetryCallback.java b/components/fluent-httpclients/src/main/java/io/fluent/clients/interceptors/retry/RetryCallback.java index a256246..9fb7adc 100644 --- a/components/fluent-httpclients/src/main/java/io/fluent/clients/interceptors/retry/RetryCallback.java +++ b/components/fluent-httpclients/src/main/java/io/fluent/clients/interceptors/retry/RetryCallback.java @@ -32,7 +32,6 @@ public void onResponse(Call call, Response response) { } } - @Override public void onFailure(Call call, Throwable t) { onFinalFailure(call, t); @@ -43,19 +42,13 @@ public void onFailResponse(int errorCode, Call call, Response response) { onFinalFail(response.code(), call, response); } - public void onFinalResponse(Call call, Response response) { - - } + public void onFinalResponse(Call call, Response response) {} - public void onFinalFailure(Call call, Throwable t) { + public void onFinalFailure(Call call, Throwable t) {} - } - - public void onFinalFail(int errorCode, Call call, Response response) { - - } + public void onFinalFail(int errorCode, Call call, Response response) {} private void retry() { call.clone().enqueue(this); } -} \ No newline at end of file +} diff --git a/components/fluent-httpclients/src/main/java/io/fluent/clients/interceptors/retry/RetryHelper.java b/components/fluent-httpclients/src/main/java/io/fluent/clients/interceptors/retry/RetryHelper.java index 1d79726..0de519a 100644 --- a/components/fluent-httpclients/src/main/java/io/fluent/clients/interceptors/retry/RetryHelper.java +++ b/components/fluent-httpclients/src/main/java/io/fluent/clients/interceptors/retry/RetryHelper.java @@ -5,42 +5,43 @@ import retrofit2.Response; public class RetryHelper { - private static final int DEFAULT_RETRIES = 0; - private static int SUCCESS_CODE = 200; - - public static void enqueueRetry(Call call, final int retryCount, final CustomCallback callback) { - call.enqueue(new RetryCallback(call, retryCount) { - @Override - public void onFinalFail(int errorCode, Call call, Response response) { - callback.onFailResponse(errorCode, call, response); - } - - @Override - public void onFinalResponse(Call call, Response response) { - callback.onResponse(call, response); - } - - @Override - public void onFinalFailure(Call call, Throwable t) { - callback.onFailure(call, t); - } + private static final int DEFAULT_RETRIES = 0; + private static int SUCCESS_CODE = 200; + + public static void enqueueRetry( + Call call, final int retryCount, final CustomCallback callback) { + call.enqueue( + new RetryCallback(call, retryCount) { + @Override + public void onFinalFail(int errorCode, Call call, Response response) { + callback.onFailResponse(errorCode, call, response); + } + + @Override + public void onFinalResponse(Call call, Response response) { + callback.onResponse(call, response); + } + + @Override + public void onFinalFailure(Call call, Throwable t) { + callback.onFailure(call, t); + } }); - } + } - public static void enqueueRetry(Call call, final CustomCallback callback) { - enqueueRetry(call, DEFAULT_RETRIES, callback); - } + public static void enqueueRetry(Call call, final CustomCallback callback) { + enqueueRetry(call, DEFAULT_RETRIES, callback); + } - static boolean isCallSuccess(Response response) { - return response.code() == SUCCESS_CODE; - } + static boolean isCallSuccess(Response response) { + return response.code() == SUCCESS_CODE; + } - public static int getSuccessCode() { - return SUCCESS_CODE; - } + public static int getSuccessCode() { + return SUCCESS_CODE; + } - public static void setSuccessCode(int successCode) { - RetryHelper.SUCCESS_CODE = successCode; - } - -} \ No newline at end of file + public static void setSuccessCode(int successCode) { + RetryHelper.SUCCESS_CODE = successCode; + } +} diff --git a/components/fluent-httpclients/src/main/java/io/fluent/clients/rest/RestAssuredClient.java b/components/fluent-httpclients/src/main/java/io/fluent/clients/rest/RestAssuredClient.java index 50d180a..fa34e84 100644 --- a/components/fluent-httpclients/src/main/java/io/fluent/clients/rest/RestAssuredClient.java +++ b/components/fluent-httpclients/src/main/java/io/fluent/clients/rest/RestAssuredClient.java @@ -1,36 +1,35 @@ package io.fluent.clients.rest; + import io.fluent.clients.base.HttpClientOption; import io.fluent.clients.base.HttpRequestModel; import io.restassured.RestAssured; import io.restassured.response.Response; import io.restassured.specification.RequestSpecification; -//https://github.com/rest-assured/rest-assured/wiki/Usage +// https://github.com/rest-assured/rest-assured/wiki/Usage public class RestAssuredClient { private RequestSpecification reqClient; - public RestAssuredClient create(HttpClientOption option){ - reqClient = RestAssured.given().baseUri(option.getBaseUrl()). - headers(option.getHeaders()); - return this; + public RestAssuredClient create(HttpClientOption option) { + reqClient = RestAssured.given().baseUri(option.getBaseUrl()).headers(option.getHeaders()); + return this; } - public Response invoke(HttpRequestModel request){ + public Response invoke(HttpRequestModel request) { reqClient.headers(request.getHeaders()); - if(request.getMethod().toString().equalsIgnoreCase("GET")) { - return reqClient.get(request.getRequestPath()); - } - if(request.getMethod().toString().equalsIgnoreCase("POST")) { - return reqClient.post(request.getRequestPath(),request.getRequestBody()); + if (request.getMethod().toString().equalsIgnoreCase("GET")) { + return reqClient.get(request.getRequestPath()); + } + if (request.getMethod().toString().equalsIgnoreCase("POST")) { + return reqClient.post(request.getRequestPath(), request.getRequestBody()); } - if(request.getMethod().toString().equalsIgnoreCase("PUT")) { - return reqClient.put(request.getRequestPath(),request.getRequestBody()); + if (request.getMethod().toString().equalsIgnoreCase("PUT")) { + return reqClient.put(request.getRequestPath(), request.getRequestBody()); } - if(request.getMethod().toString().equalsIgnoreCase("DELETE")) { + if (request.getMethod().toString().equalsIgnoreCase("DELETE")) { return reqClient.delete(request.getRequestPath()); } - throw new RuntimeException("Not Support Method Right now: "+request.getMethod()); + throw new RuntimeException("Not Support Method Right now: " + request.getMethod()); } - } diff --git a/components/fluent-httpclients/src/test/java/io/fluent/clients/base/HttpRequestModelTest.java b/components/fluent-httpclients/src/test/java/io/fluent/clients/base/HttpRequestModelTest.java index 860b368..00c992e 100644 --- a/components/fluent-httpclients/src/test/java/io/fluent/clients/base/HttpRequestModelTest.java +++ b/components/fluent-httpclients/src/test/java/io/fluent/clients/base/HttpRequestModelTest.java @@ -1,8 +1,8 @@ -//package io.fluentqa.clients.base; +// package io.fluentqa.clients.base; // -//import org.junit.jupiter.api.Test; +// import org.junit.jupiter.api.Test; // -//class HttpRequestModelTest { +// class HttpRequestModelTest { // // @Test // void getRequestPath() { @@ -10,4 +10,4 @@ // requestModel.setUrlPath("/test"); // // } -//} \ No newline at end of file +// } diff --git a/components/fluent-httpclients/src/test/java/io/fluent/clients/factory/HttpClientFactoryTest.java b/components/fluent-httpclients/src/test/java/io/fluent/clients/factory/HttpClientFactoryTest.java index 310a88a..df97f58 100644 --- a/components/fluent-httpclients/src/test/java/io/fluent/clients/factory/HttpClientFactoryTest.java +++ b/components/fluent-httpclients/src/test/java/io/fluent/clients/factory/HttpClientFactoryTest.java @@ -1,20 +1,20 @@ -//package io.fluentqa.clients.factory; +// package io.fluentqa.clients.factory; // -//import io.fluentqa.builtin.jsons.JSONUtils; -//import io.fluentqa.clients.base.HttpClientOption; -//import io.fluentqa.clients.base.HttpRequestModel; -//import okhttp3.OkHttpClient; -//import okhttp3.Request; -//import okhttp3.RequestBody; -//import okhttp3.Response; -//import org.junit.jupiter.api.Test; +// import io.fluentqa.builtin.jsons.JSONUtils; +// import io.fluentqa.clients.base.HttpClientOption; +// import io.fluentqa.clients.base.HttpRequestModel; +// import okhttp3.OkHttpClient; +// import okhttp3.Request; +// import okhttp3.RequestBody; +// import okhttp3.Response; +// import org.junit.jupiter.api.Test; // -//import java.io.IOException; -//import java.nio.charset.StandardCharsets; +// import java.io.IOException; +// import java.nio.charset.StandardCharsets; // -//import static org.junit.jupiter.api.Assertions.*; +// import static org.junit.jupiter.api.Assertions.*; // -//public class HttpClientFactoryTest { +// public class HttpClientFactoryTest { // HttpClientFactory factory = new HttpClientFactory(); // HttpClientOption config = new HttpClientOption(); // OkHttpClient client = factory.okHttpClient(config); @@ -34,7 +34,8 @@ // // String tokenRespones = "{\"user_info\":{\"id\":1,\"name\":\"prest\",\"username\":\"prest\"," + // "\"metadata\":null},\"token\":" + -// "\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySW5mbyI6eyJpZCI6MSwibWV0YWRhdGEiOm51bGwsIm5hbWUiOiJwcmVzdCIsInVzZXJuYW1lIjoicHJlc3QifSwiZXhwIjoxNjgzNTY2MTMzLCJuYmYiOjE2ODM1NDQ1MzN9.4xSD5TiEnauLrLwLRbEHxwK6lduXIjvwijiPLXvYdYo\"}\n"; +// +// "\"eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJVc2VySW5mbyI6eyJpZCI6MSwibWV0YWRhdGEiOm51bGwsIm5hbWUiOiJwcmVzdCIsInVzZXJuYW1lIjoicHJlc3QifSwiZXhwIjoxNjgzNTY2MTMzLCJuYmYiOjE2ODM1NDQ1MzN9.4xSD5TiEnauLrLwLRbEHxwK6lduXIjvwijiPLXvYdYo\"}\n"; // // @Test // void testPrestdGetSchema() { @@ -106,8 +107,10 @@ // @Test // void querySupabaseService(){ // String baseUrl = "http://localhost:54321/rest/v1/users"; -// String serviceKey ="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU"; -// String apiKey ="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0"; +// String serviceKey +// ="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU"; +// String apiKey +// ="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0"; // Request request = new Request.Builder().url(baseUrl) // .addHeader("Authorization", "Bearer %s".formatted(serviceKey)) // .addHeader("apikey", apiKey) @@ -117,9 +120,12 @@ // // @Test // void functionCall(){ -// String baseUrl = "http://localhost:54321/rest/v1/rpc/get_key_by_email?in_email=test_1@163.com"; -// String serviceKey ="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU"; -// String apiKey ="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0"; +// String baseUrl = +// "http://localhost:54321/rest/v1/rpc/get_key_by_email?in_email=test_1@163.com"; +// String serviceKey +// ="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6InNlcnZpY2Vfcm9sZSIsImV4cCI6MTk4MzgxMjk5Nn0.EGIM96RAZx35lJzdJsyH-qQwv8Hdp7fsn3W0YpN81IU"; +// String apiKey +// ="eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJzdXBhYmFzZS1kZW1vIiwicm9sZSI6ImFub24iLCJleHAiOjE5ODM4MTI5OTZ9.CRXP1A7WOeoJeXxjNni43kdQwgnWNReilDMblYTn_I0"; // Request request = new Request.Builder().url(baseUrl) // .addHeader("Authorization", "Bearer %s".formatted(serviceKey)) // .addHeader("apikey", apiKey) @@ -135,4 +141,4 @@ // processor.invoke(request); // // } -//} \ No newline at end of file +// } diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/api/MindMapAccessor.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/api/MindMapAccessor.java index e469d48..aefed58 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/api/MindMapAccessor.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/api/MindMapAccessor.java @@ -2,37 +2,33 @@ import io.fluentqa.mindmap.freemind.FreeMindTransformer; import io.fluentqa.mindmap.xmind.XmindTransformer; - import java.util.List; - public class MindMapAccessor { - public List readMindMapToBean(String fileName, Class clazz){ - MindMapTransformer transformer = selectTransformer(fileName); - return transformer.readMindMapToList(fileName,clazz); - } - - public List readMindMapToBean(String fileName, Class clazz,MindMapConvertConfig config){ - MindMapTransformer transformer = selectTransformer(fileName); - return transformer.readMindMapToList(fileName,clazz,config); - } - public List readMindMap(String fileName) { - MindMapTransformer transformer = selectTransformer(fileName); - return transformer.readMindMapToList(fileName); + public List readMindMapToBean(String fileName, Class clazz) { + MindMapTransformer transformer = selectTransformer(fileName); + return transformer.readMindMapToList(fileName, clazz); + } + + public List readMindMapToBean( + String fileName, Class clazz, MindMapConvertConfig config) { + MindMapTransformer transformer = selectTransformer(fileName); + return transformer.readMindMapToList(fileName, clazz, config); + } + + public List readMindMap(String fileName) { + MindMapTransformer transformer = selectTransformer(fileName); + return transformer.readMindMapToList(fileName); + } + + private MindMapTransformer selectTransformer(String fileName) { + switch (MindmapTypeEnum.XMIND.parse(fileName)) { + case FREEMIND: + return new FreeMindTransformer(); + case XMIND: + default: + return new XmindTransformer(); } - - private MindMapTransformer selectTransformer(String fileName) { - switch (MindmapTypeEnum.XMIND.parse(fileName)) { - case FREEMIND: - return new FreeMindTransformer(); - case XMIND: - default: - return new XmindTransformer(); - } - } - - - - + } } diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/api/MindMapConvertConfig.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/api/MindMapConvertConfig.java index e664d5a..05e5b64 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/api/MindMapConvertConfig.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/api/MindMapConvertConfig.java @@ -1,24 +1,23 @@ package io.fluentqa.mindmap.api; -import lombok.AllArgsConstructor; -import lombok.Data; - import java.util.ArrayList; import java.util.List; +import lombok.AllArgsConstructor; +import lombok.Data; @Data public class MindMapConvertConfig { - private List configs = new ArrayList<>(); + private List configs = new ArrayList<>(); - @Data - @AllArgsConstructor - public static class LevelConfig{ - private String key; - private Integer level; - } + @Data + @AllArgsConstructor + public static class LevelConfig { + private String key; + private Integer level; + } - public MindMapConvertConfig add(LevelConfig config){ - this.configs.add(config); - return this; - } + public MindMapConvertConfig add(LevelConfig config) { + this.configs.add(config); + return this; + } } diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/api/MindMapPath.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/api/MindMapPath.java index 079d83c..861f6dc 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/api/MindMapPath.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/api/MindMapPath.java @@ -1,32 +1,31 @@ package io.fluentqa.mindmap.api; -import lombok.Data; - import java.util.LinkedList; +import lombok.Data; @Data public class MindMapPath implements Cloneable { - private T root; + private T root; - private LinkedList pathNodes = new LinkedList<>(); + private LinkedList pathNodes = new LinkedList<>(); - public MindMapPath(T root) { - this.root = root; - this.pathNodes.add(root); - } + public MindMapPath(T root) { + this.root = root; + this.pathNodes.add(root); + } - public T root() { - return root; - } + public T root() { + return root; + } - public LinkedList pathNodes() { - return this.pathNodes; - } + public LinkedList pathNodes() { + return this.pathNodes; + } - @Override - public MindMapPath clone() { - MindMapPath path = new MindMapPath(this.getRoot()); - path.setPathNodes((LinkedList) this.pathNodes.clone()); - return path; - } + @Override + public MindMapPath clone() { + MindMapPath path = new MindMapPath(this.getRoot()); + path.setPathNodes((LinkedList) this.pathNodes.clone()); + return path; + } } diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/api/MindMapPathRecord.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/api/MindMapPathRecord.java index 77cf28d..c0e7d12 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/api/MindMapPathRecord.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/api/MindMapPathRecord.java @@ -1,74 +1,71 @@ package io.fluentqa.mindmap.api; import cn.hutool.core.bean.BeanUtil; - import io.fluent.builtin.meta.ReflectionUtils; -import lombok.Data; -import lombok.extern.slf4j.Slf4j; - import java.lang.reflect.Field; import java.util.*; import java.util.function.Function; - +import lombok.Data; +import lombok.extern.slf4j.Slf4j; @Data @Slf4j public class MindMapPathRecord { - private Map mindMapLevels = new HashMap<>(); - - private Integer currentLevel = 0; + private Map mindMapLevels = new HashMap<>(); - private synchronized void increaseTreeLevel() { - this.currentLevel++; - } + private Integer currentLevel = 0; - public void add(String value) { - increaseTreeLevel(); - mindMapLevels.put(this.currentLevel, value); - } + private synchronized void increaseTreeLevel() { + this.currentLevel++; + } - public Map getMindMapLevels() { - return mindMapLevels; - } + public void add(String value) { + increaseTreeLevel(); + mindMapLevels.put(this.currentLevel, value); + } + public Map getMindMapLevels() { + return mindMapLevels; + } - public T toBean(Class clazz, MindMapConvertConfig config) { - T instance = ReflectionUtils.newInstance(clazz); - for (MindMapConvertConfig.LevelConfig levelConfig : config.getConfigs()) { - try{ - BeanUtil.setFieldValue(instance, levelConfig.getKey(), this.mindMapLevels.get(levelConfig.getLevel())); - }catch (Exception e){ - log.error("ignore the error=",e); - } - } - return instance; + public T toBean(Class clazz, MindMapConvertConfig config) { + T instance = ReflectionUtils.newInstance(clazz); + for (MindMapConvertConfig.LevelConfig levelConfig : config.getConfigs()) { + try { + BeanUtil.setFieldValue( + instance, levelConfig.getKey(), this.mindMapLevels.get(levelConfig.getLevel())); + } catch (Exception e) { + log.error("ignore the error=", e); + } } + return instance; + } - public T toBean(Class clazz) { - T instance = ReflectionUtils.newInstance(clazz); - Field[] fields = ReflectionUtils.getFields(clazz); - for (Field field : fields) { - NodeLevel a = field.getAnnotation(NodeLevel.class); - if (a != null) { - ReflectionUtils.setFieldValue(instance, field, this.mindMapLevels.get(a.value())); - } - } - return instance; + public T toBean(Class clazz) { + T instance = ReflectionUtils.newInstance(clazz); + Field[] fields = ReflectionUtils.getFields(clazz); + for (Field field : fields) { + NodeLevel a = field.getAnnotation(NodeLevel.class); + if (a != null) { + ReflectionUtils.setFieldValue(instance, field, this.mindMapLevels.get(a.value())); + } } + return instance; + } - public static MindMapPathRecord fromMindMapPath(MindMapPath path, - Function extractValueFunc) { - MindMapPathRecord record = new MindMapPathRecord(); - for (T pathNode : path.getPathNodes()) { - record.add(extractValueFunc.apply(pathNode)); - } - return record; + public static MindMapPathRecord fromMindMapPath( + MindMapPath path, Function extractValueFunc) { + MindMapPathRecord record = new MindMapPathRecord(); + for (T pathNode : path.getPathNodes()) { + record.add(extractValueFunc.apply(pathNode)); } + return record; + } - public static List fromMindMapPaths(List> paths, - Function extractValueFunc) { - List records = new ArrayList<>(); - paths.forEach((t) -> records.add(fromMindMapPath(t, extractValueFunc))); - return records; - } + public static List fromMindMapPaths( + List> paths, Function extractValueFunc) { + List records = new ArrayList<>(); + paths.forEach((t) -> records.add(fromMindMapPath(t, extractValueFunc))); + return records; + } } diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/api/MindMapTransformer.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/api/MindMapTransformer.java index c343905..16477f6 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/api/MindMapTransformer.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/api/MindMapTransformer.java @@ -3,10 +3,10 @@ import java.util.List; public interface MindMapTransformer { - public List> readMindMapToList(String mindMapPath); - public List readMindMapToList(String mindMapPath,Class clazz); - public List readMindMapToList(String mindMapPath,Class clazz,MindMapConvertConfig config); - + public List> readMindMapToList(String mindMapPath); + public List readMindMapToList(String mindMapPath, Class clazz); + public List readMindMapToList( + String mindMapPath, Class clazz, MindMapConvertConfig config); } diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/api/MindmapTypeEnum.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/api/MindmapTypeEnum.java index 460060b..0e8dc1b 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/api/MindmapTypeEnum.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/api/MindmapTypeEnum.java @@ -1,31 +1,29 @@ package io.fluentqa.mindmap.api; - import io.fluent.builtin.JavaProjectFileUtils; public enum MindmapTypeEnum { - FREEMIND("mm"), //FREEMIND file - XMIND("xmind") //XMIND file - ; - - MindmapTypeEnum(String fileSuffix) { - this.fileSuffix = fileSuffix; - } - - private String fileSuffix; - - public String getFileSuffix() { - return fileSuffix; - } - - - public MindmapTypeEnum parse(String fileName){ - String suffix = JavaProjectFileUtils.getSuffix(fileName); - for (MindmapTypeEnum value : values()) { - if(value.getFileSuffix().equalsIgnoreCase(suffix)){ - return value; - } - } - return XMIND; + FREEMIND("mm"), // FREEMIND file + XMIND("xmind") // XMIND file +; + + MindmapTypeEnum(String fileSuffix) { + this.fileSuffix = fileSuffix; + } + + private String fileSuffix; + + public String getFileSuffix() { + return fileSuffix; + } + + public MindmapTypeEnum parse(String fileName) { + String suffix = JavaProjectFileUtils.getSuffix(fileName); + for (MindmapTypeEnum value : values()) { + if (value.getFileSuffix().equalsIgnoreCase(suffix)) { + return value; + } } + return XMIND; + } } diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/api/NodeLevel.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/api/NodeLevel.java index e5cac9e..267af71 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/api/NodeLevel.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/api/NodeLevel.java @@ -2,9 +2,7 @@ import java.lang.annotation.*; -/** - * - */ +/** */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD, ElementType.TYPE}) @Documented diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/exception/MindMapException.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/exception/MindMapException.java index 1ec0fa7..6ddf5ff 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/exception/MindMapException.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/exception/MindMapException.java @@ -1,22 +1,22 @@ package io.fluentqa.mindmap.exception; -public class MindMapException extends RuntimeException{ - public MindMapException() { - } +public class MindMapException extends RuntimeException { + public MindMapException() {} - public MindMapException(String message) { - super(message); - } + public MindMapException(String message) { + super(message); + } - public MindMapException(String message, Throwable cause) { - super(message, cause); - } + public MindMapException(String message, Throwable cause) { + super(message, cause); + } - public MindMapException(Throwable cause) { - super(cause); - } + public MindMapException(Throwable cause) { + super(cause); + } - public MindMapException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { - super(message, cause, enableSuppression, writableStackTrace); - } + public MindMapException( + String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + super(message, cause, enableSuppression, writableStackTrace); + } } diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/FreeMindNode.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/FreeMindNode.java index b0018ce..a2cb3e2 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/FreeMindNode.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/FreeMindNode.java @@ -3,22 +3,22 @@ import io.fluentqa.mindmap.api.MindMapPath; import io.fluentqa.mindmap.freemind.model.Node; -public class FreeMindNode extends MindMapPath { +public class FreeMindNode extends MindMapPath { - public FreeMindNode(Node root) { - super(root); - } + public FreeMindNode(Node root) { + super(root); + } - /** - * COPY nodes in new LinedList - * - * @return - */ -// @Override -// protected FreeMindNode clone() { -// FreeMindNode path = new FreeMindNode(this.getRoot()); -// path.setPathNodes((LinkedList) this.getPathNodes().clone()); -// return path; -// } + /** + * COPY nodes in new LinedList + * + * @return + */ + // @Override + // protected FreeMindNode clone() { + // FreeMindNode path = new FreeMindNode(this.getRoot()); + // path.setPathNodes((LinkedList) this.getPathNodes().clone()); + // return path; + // } } diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/FreeMindTransformer.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/FreeMindTransformer.java index 06860db..c994778 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/FreeMindTransformer.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/FreeMindTransformer.java @@ -7,80 +7,73 @@ import io.fluentqa.mindmap.api.MindMapTransformer; import io.fluentqa.mindmap.freemind.model.Map; import io.fluentqa.mindmap.freemind.model.Node; - - import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; -/** - * 1. READ FreeMind Files - * 2. Convert - */ +/** 1. READ FreeMind Files 2. Convert */ public class FreeMindTransformer implements MindMapTransformer { + @Override + public List> readMindMapToList(String mindMapContent) { + return convertToList(mindMapContent); + } - @Override - public List> readMindMapToList(String mindMapContent) { - return convertToList(mindMapContent); - } - - @Override - public List readMindMapToList(String mindMapPath, Class clazz) { - List> paths = convertToList(mindMapPath); - List records = MindMapPathRecord.fromMindMapPaths(paths,Node::getTEXT); - return records.stream().map(mindMapPathRecord -> mindMapPathRecord.toBean(clazz)).collect(Collectors.toList()); - } - - @Override - public List readMindMapToList(String mindMapPath, Class clazz, MindMapConvertConfig config) { - List> paths = convertToList(mindMapPath); - List records = MindMapPathRecord.fromMindMapPaths(paths,Node::getTEXT); - return records.stream().map(mindMapPathRecord -> mindMapPathRecord.toBean(clazz,config)).collect(Collectors.toList()); - } + @Override + public List readMindMapToList(String mindMapPath, Class clazz) { + List> paths = convertToList(mindMapPath); + List records = MindMapPathRecord.fromMindMapPaths(paths, Node::getTEXT); + return records.stream() + .map(mindMapPathRecord -> mindMapPathRecord.toBean(clazz)) + .collect(Collectors.toList()); + } - private List> convertToList(String mindmapFilePath) { - Map freeMindMap = XmlUtils.readXmlToObject(XmlUtils.readXML(mindmapFilePath), Map.class); - FreeMindNode root = new FreeMindNode(freeMindMap.getNode()); - List> result = new ArrayList<>(); - populateNodes(List.of(root), result); - return result; - } + @Override + public List readMindMapToList( + String mindMapPath, Class clazz, MindMapConvertConfig config) { + List> paths = convertToList(mindMapPath); + List records = MindMapPathRecord.fromMindMapPaths(paths, Node::getTEXT); + return records.stream() + .map(mindMapPathRecord -> mindMapPathRecord.toBean(clazz, config)) + .collect(Collectors.toList()); + } - /** - * ->Node1 - * currentNode | - * ->Node2 - * convert to: - * [ currentNode->Node1, - * currentNode->Node2] - * - * @param current: Current Node - * @return OUT: A List of MindMapPath - */ - private List> populateNextLevel(MindMapPath current) { - Node lastNode = current.pathNodes().getLast(); - List> mindMapPaths = new ArrayList<>(); - for (Object o : lastNode.getArrowlinkOrAttributeOrAttributeLayout()) { - MindMapPath path = current.clone(); - if (o instanceof Node) { - path.pathNodes().add((Node) o); - } - mindMapPaths.add(path); - } + private List> convertToList(String mindmapFilePath) { + Map freeMindMap = XmlUtils.readXmlToObject(XmlUtils.readXML(mindmapFilePath), Map.class); + FreeMindNode root = new FreeMindNode(freeMindMap.getNode()); + List> result = new ArrayList<>(); + populateNodes(List.of(root), result); + return result; + } - return mindMapPaths; + /** + * ->Node1 currentNode | ->Node2 convert to: [ currentNode->Node1, currentNode->Node2] + * + * @param current: Current Node + * @return OUT: A List of MindMapPath + */ + private List> populateNextLevel(MindMapPath current) { + Node lastNode = current.pathNodes().getLast(); + List> mindMapPaths = new ArrayList<>(); + for (Object o : lastNode.getArrowlinkOrAttributeOrAttributeLayout()) { + MindMapPath path = current.clone(); + if (o instanceof Node) { + path.pathNodes().add((Node) o); + } + mindMapPaths.add(path); } + return mindMapPaths; + } - private void populateNodes(List> nodes, List> resultPaths) { + private void populateNodes(List> nodes, List> resultPaths) { - for (MindMapPath current : nodes) { - if (current.pathNodes().getLast().getArrowlinkOrAttributeOrAttributeLayout().size() == 0) { - resultPaths.add(current); - } else { - populateNodes(populateNextLevel(current), resultPaths); - } - } + for (MindMapPath current : nodes) { + if (current.pathNodes().getLast().getArrowlinkOrAttributeOrAttributeLayout().size() == 0) { + resultPaths.add(current); + } else { + populateNodes(populateNextLevel(current), resultPaths); + } } + } } diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Arrowlink.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Arrowlink.java index d2118cc..4e29899 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Arrowlink.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Arrowlink.java @@ -5,14 +5,12 @@ // 生成时间: 2022.09.23 时间 08:46:06 PM CST // - package io.fluentqa.mindmap.freemind.model; import jakarta.xml.bind.annotation.*; - /** - *

anonymous complex type的 Java 类。 + * anonymous complex type的 Java 类。 * *

以下模式片段指定包含在此类中的预期内容。 * @@ -31,195 +29,156 @@ * </complexContent> * </complexType> * - * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "arrowlink") public class Arrowlink { - @XmlAttribute(name = "COLOR") - protected String color; - @XmlAttribute(name = "DESTINATION", required = true) - protected String destination; - @XmlAttribute(name = "ENDARROW") - protected String endarrow; - @XmlAttribute(name = "ENDINCLINATION") - protected String endinclination; - @XmlAttribute(name = "ID") - protected String id; - @XmlAttribute(name = "STARTARROW") - protected String startarrow; - @XmlAttribute(name = "STARTINCLINATION") - protected String startinclination; - - /** - * 获取color属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getCOLOR() { - return color; - } - - /** - * 设置color属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCOLOR(String value) { - this.color = value; - } - - /** - * 获取destination属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getDESTINATION() { - return destination; - } - - /** - * 设置destination属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setDESTINATION(String value) { - this.destination = value; - } - - /** - * 获取endarrow属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getENDARROW() { - return endarrow; - } - - /** - * 设置endarrow属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setENDARROW(String value) { - this.endarrow = value; - } - - /** - * 获取endinclination属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getENDINCLINATION() { - return endinclination; - } - - /** - * 设置endinclination属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setENDINCLINATION(String value) { - this.endinclination = value; - } - - /** - * 获取id属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getID() { - return id; - } - - /** - * 设置id属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setID(String value) { - this.id = value; - } - - /** - * 获取startarrow属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getSTARTARROW() { - return startarrow; - } - - /** - * 设置startarrow属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setSTARTARROW(String value) { - this.startarrow = value; - } - - /** - * 获取startinclination属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getSTARTINCLINATION() { - return startinclination; - } - - /** - * 设置startinclination属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setSTARTINCLINATION(String value) { - this.startinclination = value; - } - + @XmlAttribute(name = "COLOR") + protected String color; + + @XmlAttribute(name = "DESTINATION", required = true) + protected String destination; + + @XmlAttribute(name = "ENDARROW") + protected String endarrow; + + @XmlAttribute(name = "ENDINCLINATION") + protected String endinclination; + + @XmlAttribute(name = "ID") + protected String id; + + @XmlAttribute(name = "STARTARROW") + protected String startarrow; + + @XmlAttribute(name = "STARTINCLINATION") + protected String startinclination; + + /** + * 获取color属性的值。 + * + * @return possible object is {@link String } + */ + public String getCOLOR() { + return color; + } + + /** + * 设置color属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setCOLOR(String value) { + this.color = value; + } + + /** + * 获取destination属性的值。 + * + * @return possible object is {@link String } + */ + public String getDESTINATION() { + return destination; + } + + /** + * 设置destination属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setDESTINATION(String value) { + this.destination = value; + } + + /** + * 获取endarrow属性的值。 + * + * @return possible object is {@link String } + */ + public String getENDARROW() { + return endarrow; + } + + /** + * 设置endarrow属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setENDARROW(String value) { + this.endarrow = value; + } + + /** + * 获取endinclination属性的值。 + * + * @return possible object is {@link String } + */ + public String getENDINCLINATION() { + return endinclination; + } + + /** + * 设置endinclination属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setENDINCLINATION(String value) { + this.endinclination = value; + } + + /** + * 获取id属性的值。 + * + * @return possible object is {@link String } + */ + public String getID() { + return id; + } + + /** + * 设置id属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setID(String value) { + this.id = value; + } + + /** + * 获取startarrow属性的值。 + * + * @return possible object is {@link String } + */ + public String getSTARTARROW() { + return startarrow; + } + + /** + * 设置startarrow属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setSTARTARROW(String value) { + this.startarrow = value; + } + + /** + * 获取startinclination属性的值。 + * + * @return possible object is {@link String } + */ + public String getSTARTINCLINATION() { + return startinclination; + } + + /** + * 设置startinclination属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setSTARTINCLINATION(String value) { + this.startinclination = value; + } } diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Attribute.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Attribute.java index c9acb47..beabd13 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Attribute.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Attribute.java @@ -5,14 +5,12 @@ // 生成时间: 2022.09.23 时间 08:46:06 PM CST // - package io.fluentqa.mindmap.freemind.model; import jakarta.xml.bind.annotation.*; - /** - *

anonymous complex type的 Java 类。 + * anonymous complex type的 Java 类。 * *

以下模式片段指定包含在此类中的预期内容。 * @@ -26,65 +24,51 @@ * </complexContent> * </complexType> * - * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "attribute") public class Attribute { - @XmlAttribute(name = "NAME", required = true) - protected String name; - @XmlAttribute(name = "VALUE", required = true) - protected String value; + @XmlAttribute(name = "NAME", required = true) + protected String name; - /** - * 获取name属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getNAME() { - return name; - } + @XmlAttribute(name = "VALUE", required = true) + protected String value; - /** - * 设置name属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setNAME(String value) { - this.name = value; - } + /** + * 获取name属性的值。 + * + * @return possible object is {@link String } + */ + public String getNAME() { + return name; + } - /** - * 获取value属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getVALUE() { - return value; - } + /** + * 设置name属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setNAME(String value) { + this.name = value; + } - /** - * 设置value属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setVALUE(String value) { - this.value = value; - } + /** + * 获取value属性的值。 + * + * @return possible object is {@link String } + */ + public String getVALUE() { + return value; + } + /** + * 设置value属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setVALUE(String value) { + this.value = value; + } } diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/AttributeLayout.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/AttributeLayout.java index e15a94b..4b8836e 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/AttributeLayout.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/AttributeLayout.java @@ -5,16 +5,13 @@ // 生成时间: 2022.09.23 时间 08:46:06 PM CST // - package io.fluentqa.mindmap.freemind.model; import jakarta.xml.bind.annotation.*; - import java.math.BigInteger; - /** - *

anonymous complex type的 Java 类。 + * anonymous complex type的 Java 类。 * *

以下模式片段指定包含在此类中的预期内容。 * @@ -28,65 +25,51 @@ * </complexContent> * </complexType> * - * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "attribute_layout") public class AttributeLayout { - @XmlAttribute(name = "NAME_WIDTH", required = true) - protected BigInteger namewidth; - @XmlAttribute(name = "VALUE_WIDTH") - protected BigInteger valuewidth; + @XmlAttribute(name = "NAME_WIDTH", required = true) + protected BigInteger namewidth; - /** - * 获取namewidth属性的值。 - * - * @return - * possible object is - * {@link BigInteger } - * - */ - public BigInteger getNAMEWIDTH() { - return namewidth; - } + @XmlAttribute(name = "VALUE_WIDTH") + protected BigInteger valuewidth; - /** - * 设置namewidth属性的值。 - * - * @param value - * allowed object is - * {@link BigInteger } - * - */ - public void setNAMEWIDTH(BigInteger value) { - this.namewidth = value; - } + /** + * 获取namewidth属性的值。 + * + * @return possible object is {@link BigInteger } + */ + public BigInteger getNAMEWIDTH() { + return namewidth; + } - /** - * 获取valuewidth属性的值。 - * - * @return - * possible object is - * {@link BigInteger } - * - */ - public BigInteger getVALUEWIDTH() { - return valuewidth; - } + /** + * 设置namewidth属性的值。 + * + * @param value allowed object is {@link BigInteger } + */ + public void setNAMEWIDTH(BigInteger value) { + this.namewidth = value; + } - /** - * 设置valuewidth属性的值。 - * - * @param value - * allowed object is - * {@link BigInteger } - * - */ - public void setVALUEWIDTH(BigInteger value) { - this.valuewidth = value; - } + /** + * 获取valuewidth属性的值。 + * + * @return possible object is {@link BigInteger } + */ + public BigInteger getVALUEWIDTH() { + return valuewidth; + } + /** + * 设置valuewidth属性的值。 + * + * @param value allowed object is {@link BigInteger } + */ + public void setVALUEWIDTH(BigInteger value) { + this.valuewidth = value; + } } diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Cloud.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Cloud.java index b3e1e2a..f2cfc2a 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Cloud.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Cloud.java @@ -5,14 +5,12 @@ // 生成时间: 2022.09.23 时间 08:46:06 PM CST // - package io.fluentqa.mindmap.freemind.model; import jakarta.xml.bind.annotation.*; - /** - *

anonymous complex type的 Java 类。 + * anonymous complex type的 Java 类。 * *

以下模式片段指定包含在此类中的预期内容。 * @@ -25,39 +23,30 @@ * </complexContent> * </complexType> * - * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "cloud") public class Cloud { - @XmlAttribute(name = "COLOR") - protected String color; - - /** - * 获取color属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getCOLOR() { - return color; - } - - /** - * 设置color属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCOLOR(String value) { - this.color = value; - } - + @XmlAttribute(name = "COLOR") + protected String color; + + /** + * 获取color属性的值。 + * + * @return possible object is {@link String } + */ + public String getCOLOR() { + return color; + } + + /** + * 设置color属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setCOLOR(String value) { + this.color = value; + } } diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Edge.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Edge.java index a3ff7d2..6719d30 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Edge.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Edge.java @@ -5,14 +5,12 @@ // 生成时间: 2022.09.23 时间 08:46:06 PM CST // - package io.fluentqa.mindmap.freemind.model; import jakarta.xml.bind.annotation.*; - /** - *

anonymous complex type的 Java 类。 + * anonymous complex type的 Java 类。 * *

以下模式片段指定包含在此类中的预期内容。 * @@ -27,91 +25,72 @@ * </complexContent> * </complexType> * - * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "edge") public class Edge { - @XmlAttribute(name = "COLOR") - protected String color; - @XmlAttribute(name = "STYLE") - protected String style; - @XmlAttribute(name = "WIDTH") - protected String width; + @XmlAttribute(name = "COLOR") + protected String color; + + @XmlAttribute(name = "STYLE") + protected String style; - /** - * 获取color属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getCOLOR() { - return color; - } + @XmlAttribute(name = "WIDTH") + protected String width; - /** - * 设置color属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCOLOR(String value) { - this.color = value; - } + /** + * 获取color属性的值。 + * + * @return possible object is {@link String } + */ + public String getCOLOR() { + return color; + } - /** - * 获取style属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getSTYLE() { - return style; - } + /** + * 设置color属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setCOLOR(String value) { + this.color = value; + } - /** - * 设置style属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setSTYLE(String value) { - this.style = value; - } + /** + * 获取style属性的值。 + * + * @return possible object is {@link String } + */ + public String getSTYLE() { + return style; + } - /** - * 获取width属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getWIDTH() { - return width; - } + /** + * 设置style属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setSTYLE(String value) { + this.style = value; + } - /** - * 设置width属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setWIDTH(String value) { - this.width = value; - } + /** + * 获取width属性的值。 + * + * @return possible object is {@link String } + */ + public String getWIDTH() { + return width; + } + /** + * 设置width属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setWIDTH(String value) { + this.width = value; + } } diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Font.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Font.java index 1c81a7d..34bc2c1 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Font.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Font.java @@ -5,16 +5,13 @@ // 生成时间: 2022.09.23 时间 08:46:06 PM CST // - package io.fluentqa.mindmap.freemind.model; import jakarta.xml.bind.annotation.*; - import java.math.BigInteger; - /** - *

anonymous complex type的 Java 类。 + * anonymous complex type的 Java 类。 * *

以下模式片段指定包含在此类中的预期内容。 * @@ -43,117 +40,93 @@ * </complexContent> * </complexType> * - * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "font") public class Font { - @XmlAttribute(name = "BOLD") - protected String bold; - @XmlAttribute(name = "ITALIC") - protected String italic; - @XmlAttribute(name = "NAME", required = true) - protected String name; - @XmlAttribute(name = "SIZE", required = true) - protected BigInteger size; - - /** - * 获取bold属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getBOLD() { - return bold; - } - - /** - * 设置bold属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setBOLD(String value) { - this.bold = value; - } - - /** - * 获取italic属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getITALIC() { - return italic; - } - - /** - * 设置italic属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setITALIC(String value) { - this.italic = value; - } - - /** - * 获取name属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getNAME() { - return name; - } - - /** - * 设置name属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setNAME(String value) { - this.name = value; - } - - /** - * 获取size属性的值。 - * - * @return - * possible object is - * {@link BigInteger } - * - */ - public BigInteger getSIZE() { - return size; - } - - /** - * 设置size属性的值。 - * - * @param value - * allowed object is - * {@link BigInteger } - * - */ - public void setSIZE(BigInteger value) { - this.size = value; - } - + @XmlAttribute(name = "BOLD") + protected String bold; + + @XmlAttribute(name = "ITALIC") + protected String italic; + + @XmlAttribute(name = "NAME", required = true) + protected String name; + + @XmlAttribute(name = "SIZE", required = true) + protected BigInteger size; + + /** + * 获取bold属性的值。 + * + * @return possible object is {@link String } + */ + public String getBOLD() { + return bold; + } + + /** + * 设置bold属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setBOLD(String value) { + this.bold = value; + } + + /** + * 获取italic属性的值。 + * + * @return possible object is {@link String } + */ + public String getITALIC() { + return italic; + } + + /** + * 设置italic属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setITALIC(String value) { + this.italic = value; + } + + /** + * 获取name属性的值。 + * + * @return possible object is {@link String } + */ + public String getNAME() { + return name; + } + + /** + * 设置name属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setNAME(String value) { + this.name = value; + } + + /** + * 获取size属性的值。 + * + * @return possible object is {@link BigInteger } + */ + public BigInteger getSIZE() { + return size; + } + + /** + * 设置size属性的值。 + * + * @param value allowed object is {@link BigInteger } + */ + public void setSIZE(BigInteger value) { + this.size = value; + } } diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Hook.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Hook.java index 83a4943..f6930c0 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Hook.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Hook.java @@ -5,14 +5,12 @@ // 生成时间: 2022.09.23 时间 08:46:06 PM CST // - package io.fluentqa.mindmap.freemind.model; import jakarta.xml.bind.annotation.*; - /** - *

anonymous complex type的 Java 类。 + * anonymous complex type的 Java 类。 * *

以下模式片段指定包含在此类中的预期内容。 * @@ -29,93 +27,73 @@ * </complexContent> * </complexType> * - * - * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "parameters", - "text" -}) +@XmlType( + name = "", + propOrder = {"parameters", "text"}) @XmlRootElement(name = "hook") public class Hook { - @XmlElement(name = "Parameters") - protected Parameters parameters; - protected Text text; - @XmlAttribute(name = "NAME", required = true) - protected String name; + @XmlElement(name = "Parameters") + protected Parameters parameters; + + protected Text text; - /** - * 获取parameters属性的值。 - * - * @return - * possible object is - * {@link Parameters } - * - */ - public Parameters getParameters() { - return parameters; - } + @XmlAttribute(name = "NAME", required = true) + protected String name; - /** - * 设置parameters属性的值。 - * - * @param value - * allowed object is - * {@link Parameters } - * - */ - public void setParameters(Parameters value) { - this.parameters = value; - } + /** + * 获取parameters属性的值。 + * + * @return possible object is {@link Parameters } + */ + public Parameters getParameters() { + return parameters; + } - /** - * 获取text属性的值。 - * - * @return - * possible object is - * {@link Text } - * - */ - public Text getText() { - return text; - } + /** + * 设置parameters属性的值。 + * + * @param value allowed object is {@link Parameters } + */ + public void setParameters(Parameters value) { + this.parameters = value; + } - /** - * 设置text属性的值。 - * - * @param value - * allowed object is - * {@link Text } - * - */ - public void setText(Text value) { - this.text = value; - } + /** + * 获取text属性的值。 + * + * @return possible object is {@link Text } + */ + public Text getText() { + return text; + } - /** - * 获取name属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getNAME() { - return name; - } + /** + * 设置text属性的值。 + * + * @param value allowed object is {@link Text } + */ + public void setText(Text value) { + this.text = value; + } - /** - * 设置name属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setNAME(String value) { - this.name = value; - } + /** + * 获取name属性的值。 + * + * @return possible object is {@link String } + */ + public String getNAME() { + return name; + } + /** + * 设置name属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setNAME(String value) { + this.name = value; + } } diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Html.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Html.java index eb0a40c..5b9a44f 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Html.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Html.java @@ -5,18 +5,15 @@ // 生成时间: 2022.09.23 时间 08:46:06 PM CST // - package io.fluentqa.mindmap.freemind.model; import jakarta.xml.bind.annotation.*; -import org.w3c.dom.Element; - import java.util.ArrayList; import java.util.List; - +import org.w3c.dom.Element; /** - *

anonymous complex type的 Java 类。 + * anonymous complex type的 Java 类。 * *

以下模式片段指定包含在此类中的预期内容。 * @@ -31,46 +28,35 @@ * </complexContent> * </complexType> * - * - * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "any" -}) +@XmlType( + name = "", + propOrder = {"any"}) @XmlRootElement(name = "html") public class Html { - @XmlAnyElement - protected List any; - - /** - * Gets the value of the any property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the any property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getAny().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link Element } - * - * - */ - public List getAny() { - if (any == null) { - any = new ArrayList(); - } - return this.any; + @XmlAnyElement protected List any; + + /** + * Gets the value of the any property. + * + *

This accessor method returns a reference to the live list, not a snapshot. Therefore any + * modification you make to the returned list will be present inside the JAXB object. This is why + * there is not a set method for the any property. + * + *

For example, to add a new item, do as follows: + * + *

+   *    getAny().add(newItem);
+   * 
+ * + *

Objects of the following type(s) are allowed in the list {@link Element } + */ + public List getAny() { + if (any == null) { + any = new ArrayList(); } - + return this.any; + } } diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Icon.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Icon.java index cfe3673..f50b327 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Icon.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Icon.java @@ -5,14 +5,12 @@ // 生成时间: 2022.09.23 时间 08:46:06 PM CST // - package io.fluentqa.mindmap.freemind.model; import jakarta.xml.bind.annotation.*; - /** - *

anonymous complex type的 Java 类。 + * anonymous complex type的 Java 类。 * *

以下模式片段指定包含在此类中的预期内容。 * @@ -25,39 +23,30 @@ * </complexContent> * </complexType> * - * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "icon") public class Icon { - @XmlAttribute(name = "BUILTIN", required = true) - protected String builtin; - - /** - * 获取builtin属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getBUILTIN() { - return builtin; - } - - /** - * 设置builtin属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setBUILTIN(String value) { - this.builtin = value; - } - + @XmlAttribute(name = "BUILTIN", required = true) + protected String builtin; + + /** + * 获取builtin属性的值。 + * + * @return possible object is {@link String } + */ + public String getBUILTIN() { + return builtin; + } + + /** + * 设置builtin属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setBUILTIN(String value) { + this.builtin = value; + } } diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Linktarget.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Linktarget.java index 957ec51..17b25c0 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Linktarget.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Linktarget.java @@ -5,14 +5,12 @@ // 生成时间: 2022.09.23 时间 08:46:06 PM CST // - package io.fluentqa.mindmap.freemind.model; import jakarta.xml.bind.annotation.*; - /** - *

anonymous complex type的 Java 类。 + * anonymous complex type的 Java 类。 * *

以下模式片段指定包含在此类中的预期内容。 * @@ -32,221 +30,177 @@ * </complexContent> * </complexType> * - * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "linktarget") public class Linktarget { - @XmlAttribute(name = "COLOR") - protected String color; - @XmlAttribute(name = "SOURCE", required = true) - protected String source; - @XmlAttribute(name = "DESTINATION", required = true) - protected String destination; - @XmlAttribute(name = "ENDARROW") - protected String endarrow; - @XmlAttribute(name = "ENDINCLINATION") - protected String endinclination; - @XmlAttribute(name = "ID") - protected String id; - @XmlAttribute(name = "STARTARROW") - protected String startarrow; - @XmlAttribute(name = "STARTINCLINATION") - protected String startinclination; - - /** - * 获取color属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getCOLOR() { - return color; - } - - /** - * 设置color属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCOLOR(String value) { - this.color = value; - } - - /** - * 获取source属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getSOURCE() { - return source; - } - - /** - * 设置source属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setSOURCE(String value) { - this.source = value; - } - - /** - * 获取destination属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getDESTINATION() { - return destination; - } - - /** - * 设置destination属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setDESTINATION(String value) { - this.destination = value; - } - - /** - * 获取endarrow属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getENDARROW() { - return endarrow; - } - - /** - * 设置endarrow属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setENDARROW(String value) { - this.endarrow = value; - } - - /** - * 获取endinclination属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getENDINCLINATION() { - return endinclination; - } - - /** - * 设置endinclination属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setENDINCLINATION(String value) { - this.endinclination = value; - } - - /** - * 获取id属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getID() { - return id; - } - - /** - * 设置id属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setID(String value) { - this.id = value; - } - - /** - * 获取startarrow属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getSTARTARROW() { - return startarrow; - } - - /** - * 设置startarrow属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setSTARTARROW(String value) { - this.startarrow = value; - } - - /** - * 获取startinclination属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getSTARTINCLINATION() { - return startinclination; - } - - /** - * 设置startinclination属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setSTARTINCLINATION(String value) { - this.startinclination = value; - } - + @XmlAttribute(name = "COLOR") + protected String color; + + @XmlAttribute(name = "SOURCE", required = true) + protected String source; + + @XmlAttribute(name = "DESTINATION", required = true) + protected String destination; + + @XmlAttribute(name = "ENDARROW") + protected String endarrow; + + @XmlAttribute(name = "ENDINCLINATION") + protected String endinclination; + + @XmlAttribute(name = "ID") + protected String id; + + @XmlAttribute(name = "STARTARROW") + protected String startarrow; + + @XmlAttribute(name = "STARTINCLINATION") + protected String startinclination; + + /** + * 获取color属性的值。 + * + * @return possible object is {@link String } + */ + public String getCOLOR() { + return color; + } + + /** + * 设置color属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setCOLOR(String value) { + this.color = value; + } + + /** + * 获取source属性的值。 + * + * @return possible object is {@link String } + */ + public String getSOURCE() { + return source; + } + + /** + * 设置source属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setSOURCE(String value) { + this.source = value; + } + + /** + * 获取destination属性的值。 + * + * @return possible object is {@link String } + */ + public String getDESTINATION() { + return destination; + } + + /** + * 设置destination属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setDESTINATION(String value) { + this.destination = value; + } + + /** + * 获取endarrow属性的值。 + * + * @return possible object is {@link String } + */ + public String getENDARROW() { + return endarrow; + } + + /** + * 设置endarrow属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setENDARROW(String value) { + this.endarrow = value; + } + + /** + * 获取endinclination属性的值。 + * + * @return possible object is {@link String } + */ + public String getENDINCLINATION() { + return endinclination; + } + + /** + * 设置endinclination属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setENDINCLINATION(String value) { + this.endinclination = value; + } + + /** + * 获取id属性的值。 + * + * @return possible object is {@link String } + */ + public String getID() { + return id; + } + + /** + * 设置id属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setID(String value) { + this.id = value; + } + + /** + * 获取startarrow属性的值。 + * + * @return possible object is {@link String } + */ + public String getSTARTARROW() { + return startarrow; + } + + /** + * 设置startarrow属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setSTARTARROW(String value) { + this.startarrow = value; + } + + /** + * 获取startinclination属性的值。 + * + * @return possible object is {@link String } + */ + public String getSTARTINCLINATION() { + return startinclination; + } + + /** + * 设置startinclination属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setSTARTINCLINATION(String value) { + this.startinclination = value; + } } diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Map.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Map.java index 63db26e..62af792 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Map.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Map.java @@ -5,16 +5,12 @@ // 生成时间: 2022.09.23 时间 08:46:06 PM CST // - package io.fluentqa.mindmap.freemind.model; - - import jakarta.xml.bind.annotation.*; - /** - *

anonymous complex type的 Java 类。 + * anonymous complex type的 Java 类。 * *

以下模式片段指定包含在此类中的预期内容。 * @@ -30,67 +26,53 @@ * </complexContent> * </complexType> * - * - * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "node" -}) +@XmlType( + name = "", + propOrder = {"node"}) @XmlRootElement(name = "map") public class Map { - @XmlElement(required = true) - protected Node node; - @XmlAttribute(name = "version", required = true) - protected String version; + @XmlElement(required = true) + protected Node node; - /** - * 获取node属性的值。 - * - * @return - * possible object is - * {@link Node } - * - */ - public Node getNode() { - return node; - } + @XmlAttribute(name = "version", required = true) + protected String version; - /** - * 设置node属性的值。 - * - * @param value - * allowed object is - * {@link Node } - * - */ - public void setNode(Node value) { - this.node = value; - } + /** + * 获取node属性的值。 + * + * @return possible object is {@link Node } + */ + public Node getNode() { + return node; + } - /** - * 获取version属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getVersion() { - return version; - } + /** + * 设置node属性的值。 + * + * @param value allowed object is {@link Node } + */ + public void setNode(Node value) { + this.node = value; + } - /** - * 设置version属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setVersion(String value) { - this.version = value; - } + /** + * 获取version属性的值。 + * + * @return possible object is {@link String } + */ + public String getVersion() { + return version; + } + /** + * 设置version属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setVersion(String value) { + this.version = value; + } } diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Node.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Node.java index 64418bf..4f97a80 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Node.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Node.java @@ -5,20 +5,17 @@ // 生成时间: 2022.09.23 时间 08:46:06 PM CST // - package io.fluentqa.mindmap.freemind.model; import jakarta.xml.bind.annotation.*; import jakarta.xml.bind.annotation.adapters.CollapsedStringAdapter; import jakarta.xml.bind.annotation.adapters.XmlJavaTypeAdapter; - import java.math.BigInteger; import java.util.ArrayList; import java.util.List; - /** - *

anonymous complex type的 Java 类。 + * anonymous complex type的 Java 类。 * *

以下模式片段指定包含在此类中的预期内容。 * @@ -71,435 +68,347 @@ * </complexContent> * </complexType> * - * - * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "arrowlinkOrAttributeOrAttributeLayout" -}) +@XmlType( + name = "", + propOrder = {"arrowlinkOrAttributeOrAttributeLayout"}) @XmlRootElement(name = "node") public class Node { - @XmlElements({ - @XmlElement(name = "arrowlink", type = Arrowlink.class), - @XmlElement(name = "attribute", type = Attribute.class), - @XmlElement(name = "attribute_layout", type = AttributeLayout.class), - @XmlElement(name = "linktarget", type = Linktarget.class), - @XmlElement(name = "cloud", type = Cloud.class), - @XmlElement(name = "edge", type = Edge.class), - @XmlElement(name = "font", type = Font.class), - @XmlElement(name = "hook", type = Hook.class), - @XmlElement(name = "icon", type = Icon.class), - @XmlElement(name = "node", type = Node.class), - @XmlElement(name = "richcontent", type = Richcontent.class) - }) - protected List arrowlinkOrAttributeOrAttributeLayout; - @XmlAttribute(name = "BACKGROUND_COLOR") - protected String backgroundcolor; - @XmlAttribute(name = "COLOR") - protected String color; - @XmlAttribute(name = "FOLDED") - protected String folded; - @XmlAttribute(name = "ID") - @XmlJavaTypeAdapter(CollapsedStringAdapter.class) - @XmlID - @XmlSchemaType(name = "ID") - protected String id; - @XmlAttribute(name = "LINK") - protected String link; - @XmlAttribute(name = "POSITION") - protected String position; - @XmlAttribute(name = "STYLE") - protected String style; - @XmlAttribute(name = "TEXT") - protected String text; - @XmlAttribute(name = "CREATED") - protected BigInteger created; - @XmlAttribute(name = "MODIFIED") - protected BigInteger modified; - @XmlAttribute(name = "HGAP") - protected BigInteger hgap; - @XmlAttribute(name = "VGAP") - protected BigInteger vgap; - @XmlAttribute(name = "VSHIFT") - protected BigInteger vshift; - @XmlAttribute(name = "ENCRYPTED_CONTENT") - protected String encryptedcontent; - - /** - * Gets the value of the arrowlinkOrAttributeOrAttributeLayout property. - * - *

- * This accessor method returns a reference to the live list, - * not a snapshot. Therefore any modification you make to the - * returned list will be present inside the JAXB object. - * This is why there is not a set method for the arrowlinkOrAttributeOrAttributeLayout property. - * - *

- * For example, to add a new item, do as follows: - *

-     *    getArrowlinkOrAttributeOrAttributeLayout().add(newItem);
-     * 
- * - * - *

- * Objects of the following type(s) are allowed in the list - * {@link Arrowlink } - * {@link Attribute } - * {@link AttributeLayout } - * {@link Linktarget } - * {@link Cloud } - * {@link Edge } - * {@link Font } - * {@link Hook } - * {@link Icon } - * {@link Node } - * {@link Richcontent } - * - * - */ - public List getArrowlinkOrAttributeOrAttributeLayout() { - if (arrowlinkOrAttributeOrAttributeLayout == null) { - arrowlinkOrAttributeOrAttributeLayout = new ArrayList(); - } - return this.arrowlinkOrAttributeOrAttributeLayout; - } - - /** - * 获取backgroundcolor属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getBACKGROUNDCOLOR() { - return backgroundcolor; - } - - /** - * 设置backgroundcolor属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setBACKGROUNDCOLOR(String value) { - this.backgroundcolor = value; - } - - /** - * 获取color属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getCOLOR() { - return color; - } - - /** - * 设置color属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCOLOR(String value) { - this.color = value; - } - - /** - * 获取folded属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getFOLDED() { - return folded; - } - - /** - * 设置folded属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setFOLDED(String value) { - this.folded = value; - } - - /** - * 获取id属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getID() { - return id; - } - - /** - * 设置id属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setID(String value) { - this.id = value; - } - - /** - * 获取link属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getLINK() { - return link; - } - - /** - * 设置link属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setLINK(String value) { - this.link = value; - } - - /** - * 获取position属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getPOSITION() { - return position; - } - - /** - * 设置position属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setPOSITION(String value) { - this.position = value; - } - - /** - * 获取style属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getSTYLE() { - return style; + @XmlElements({ + @XmlElement(name = "arrowlink", type = Arrowlink.class), + @XmlElement(name = "attribute", type = Attribute.class), + @XmlElement(name = "attribute_layout", type = AttributeLayout.class), + @XmlElement(name = "linktarget", type = Linktarget.class), + @XmlElement(name = "cloud", type = Cloud.class), + @XmlElement(name = "edge", type = Edge.class), + @XmlElement(name = "font", type = Font.class), + @XmlElement(name = "hook", type = Hook.class), + @XmlElement(name = "icon", type = Icon.class), + @XmlElement(name = "node", type = Node.class), + @XmlElement(name = "richcontent", type = Richcontent.class) + }) + protected List arrowlinkOrAttributeOrAttributeLayout; + + @XmlAttribute(name = "BACKGROUND_COLOR") + protected String backgroundcolor; + + @XmlAttribute(name = "COLOR") + protected String color; + + @XmlAttribute(name = "FOLDED") + protected String folded; + + @XmlAttribute(name = "ID") + @XmlJavaTypeAdapter(CollapsedStringAdapter.class) + @XmlID + @XmlSchemaType(name = "ID") + protected String id; + + @XmlAttribute(name = "LINK") + protected String link; + + @XmlAttribute(name = "POSITION") + protected String position; + + @XmlAttribute(name = "STYLE") + protected String style; + + @XmlAttribute(name = "TEXT") + protected String text; + + @XmlAttribute(name = "CREATED") + protected BigInteger created; + + @XmlAttribute(name = "MODIFIED") + protected BigInteger modified; + + @XmlAttribute(name = "HGAP") + protected BigInteger hgap; + + @XmlAttribute(name = "VGAP") + protected BigInteger vgap; + + @XmlAttribute(name = "VSHIFT") + protected BigInteger vshift; + + @XmlAttribute(name = "ENCRYPTED_CONTENT") + protected String encryptedcontent; + + /** + * Gets the value of the arrowlinkOrAttributeOrAttributeLayout property. + * + *

This accessor method returns a reference to the live list, not a snapshot. Therefore any + * modification you make to the returned list will be present inside the JAXB object. This is why + * there is not a set method for the arrowlinkOrAttributeOrAttributeLayout property. + * + *

For example, to add a new item, do as follows: + * + *

+   *    getArrowlinkOrAttributeOrAttributeLayout().add(newItem);
+   * 
+ * + *

Objects of the following type(s) are allowed in the list {@link Arrowlink } {@link Attribute + * } {@link AttributeLayout } {@link Linktarget } {@link Cloud } {@link Edge } {@link Font } + * {@link Hook } {@link Icon } {@link Node } {@link Richcontent } + */ + public List getArrowlinkOrAttributeOrAttributeLayout() { + if (arrowlinkOrAttributeOrAttributeLayout == null) { + arrowlinkOrAttributeOrAttributeLayout = new ArrayList(); } - - /** - * 设置style属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setSTYLE(String value) { - this.style = value; - } - - /** - * 获取text属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getTEXT() { - return text; - } - - /** - * 设置text属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTEXT(String value) { - this.text = value; - } - - /** - * 获取created属性的值。 - * - * @return - * possible object is - * {@link BigInteger } - * - */ - public BigInteger getCREATED() { - return created; - } - - /** - * 设置created属性的值。 - * - * @param value - * allowed object is - * {@link BigInteger } - * - */ - public void setCREATED(BigInteger value) { - this.created = value; - } - - /** - * 获取modified属性的值。 - * - * @return - * possible object is - * {@link BigInteger } - * - */ - public BigInteger getMODIFIED() { - return modified; - } - - /** - * 设置modified属性的值。 - * - * @param value - * allowed object is - * {@link BigInteger } - * - */ - public void setMODIFIED(BigInteger value) { - this.modified = value; - } - - /** - * 获取hgap属性的值。 - * - * @return - * possible object is - * {@link BigInteger } - * - */ - public BigInteger getHGAP() { - return hgap; - } - - /** - * 设置hgap属性的值。 - * - * @param value - * allowed object is - * {@link BigInteger } - * - */ - public void setHGAP(BigInteger value) { - this.hgap = value; - } - - /** - * 获取vgap属性的值。 - * - * @return - * possible object is - * {@link BigInteger } - * - */ - public BigInteger getVGAP() { - return vgap; - } - - /** - * 设置vgap属性的值。 - * - * @param value - * allowed object is - * {@link BigInteger } - * - */ - public void setVGAP(BigInteger value) { - this.vgap = value; - } - - /** - * 获取vshift属性的值。 - * - * @return - * possible object is - * {@link BigInteger } - * - */ - public BigInteger getVSHIFT() { - return vshift; - } - - /** - * 设置vshift属性的值。 - * - * @param value - * allowed object is - * {@link BigInteger } - * - */ - public void setVSHIFT(BigInteger value) { - this.vshift = value; - } - - /** - * 获取encryptedcontent属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getENCRYPTEDCONTENT() { - return encryptedcontent; - } - - /** - * 设置encryptedcontent属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setENCRYPTEDCONTENT(String value) { - this.encryptedcontent = value; - } - + return this.arrowlinkOrAttributeOrAttributeLayout; + } + + /** + * 获取backgroundcolor属性的值。 + * + * @return possible object is {@link String } + */ + public String getBACKGROUNDCOLOR() { + return backgroundcolor; + } + + /** + * 设置backgroundcolor属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setBACKGROUNDCOLOR(String value) { + this.backgroundcolor = value; + } + + /** + * 获取color属性的值。 + * + * @return possible object is {@link String } + */ + public String getCOLOR() { + return color; + } + + /** + * 设置color属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setCOLOR(String value) { + this.color = value; + } + + /** + * 获取folded属性的值。 + * + * @return possible object is {@link String } + */ + public String getFOLDED() { + return folded; + } + + /** + * 设置folded属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setFOLDED(String value) { + this.folded = value; + } + + /** + * 获取id属性的值。 + * + * @return possible object is {@link String } + */ + public String getID() { + return id; + } + + /** + * 设置id属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setID(String value) { + this.id = value; + } + + /** + * 获取link属性的值。 + * + * @return possible object is {@link String } + */ + public String getLINK() { + return link; + } + + /** + * 设置link属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setLINK(String value) { + this.link = value; + } + + /** + * 获取position属性的值。 + * + * @return possible object is {@link String } + */ + public String getPOSITION() { + return position; + } + + /** + * 设置position属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setPOSITION(String value) { + this.position = value; + } + + /** + * 获取style属性的值。 + * + * @return possible object is {@link String } + */ + public String getSTYLE() { + return style; + } + + /** + * 设置style属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setSTYLE(String value) { + this.style = value; + } + + /** + * 获取text属性的值。 + * + * @return possible object is {@link String } + */ + public String getTEXT() { + return text; + } + + /** + * 设置text属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setTEXT(String value) { + this.text = value; + } + + /** + * 获取created属性的值。 + * + * @return possible object is {@link BigInteger } + */ + public BigInteger getCREATED() { + return created; + } + + /** + * 设置created属性的值。 + * + * @param value allowed object is {@link BigInteger } + */ + public void setCREATED(BigInteger value) { + this.created = value; + } + + /** + * 获取modified属性的值。 + * + * @return possible object is {@link BigInteger } + */ + public BigInteger getMODIFIED() { + return modified; + } + + /** + * 设置modified属性的值。 + * + * @param value allowed object is {@link BigInteger } + */ + public void setMODIFIED(BigInteger value) { + this.modified = value; + } + + /** + * 获取hgap属性的值。 + * + * @return possible object is {@link BigInteger } + */ + public BigInteger getHGAP() { + return hgap; + } + + /** + * 设置hgap属性的值。 + * + * @param value allowed object is {@link BigInteger } + */ + public void setHGAP(BigInteger value) { + this.hgap = value; + } + + /** + * 获取vgap属性的值。 + * + * @return possible object is {@link BigInteger } + */ + public BigInteger getVGAP() { + return vgap; + } + + /** + * 设置vgap属性的值。 + * + * @param value allowed object is {@link BigInteger } + */ + public void setVGAP(BigInteger value) { + this.vgap = value; + } + + /** + * 获取vshift属性的值。 + * + * @return possible object is {@link BigInteger } + */ + public BigInteger getVSHIFT() { + return vshift; + } + + /** + * 设置vshift属性的值。 + * + * @param value allowed object is {@link BigInteger } + */ + public void setVSHIFT(BigInteger value) { + this.vshift = value; + } + + /** + * 获取encryptedcontent属性的值。 + * + * @return possible object is {@link String } + */ + public String getENCRYPTEDCONTENT() { + return encryptedcontent; + } + + /** + * 设置encryptedcontent属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setENCRYPTEDCONTENT(String value) { + this.encryptedcontent = value; + } } diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/ObjectFactory.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/ObjectFactory.java index 99f53c0..efc3dd1 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/ObjectFactory.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/ObjectFactory.java @@ -5,155 +5,100 @@ // 生成时间: 2022.09.23 时间 08:46:06 PM CST // - package io.fluentqa.mindmap.freemind.model; import jakarta.xml.bind.annotation.XmlRegistry; - /** - * This object contains factory methods for each - * Java content interface and Java element interface + * This object contains factory methods for each Java content interface and Java element interface * generated in the io.fluent.qabox.mindmapping.freemind.model package. - *

An ObjectFactory allows you to programatically - * construct new instances of the Java representation - * for XML content. The Java representation of XML - * content can consist of schema derived interfaces - * and classes representing the binding of schema - * type definitions, element declarations and model - * groups. Factory methods for each of these are - * provided in this class. * + *

An ObjectFactory allows you to programatically construct new instances of the Java + * representation for XML content. The Java representation of XML content can consist of schema + * derived interfaces and classes representing the binding of schema type definitions, element + * declarations and model groups. Factory methods for each of these are provided in this class. */ @XmlRegistry public class ObjectFactory { - - /** - * Create a new ObjectFactory that can be used to create new instances of schema derived classes for package: io.fluent.qabox.mindmapping.freemind.model - * - */ - public ObjectFactory() { - } - - /** - * Create an instance of {@link Arrowlink } - * - */ - public Arrowlink createArrowlink() { - return new Arrowlink(); - } - - /** - * Create an instance of {@link Richcontent } - * - */ - public Richcontent createRichcontent() { - return new Richcontent(); - } - - /** - * Create an instance of {@link Html } - * - */ - public Html createHtml() { - return new Html(); - } - - /** - * Create an instance of {@link Parameters } - * - */ - public Parameters createParameters() { - return new Parameters(); - } - - /** - * Create an instance of {@link Icon } - * - */ - public Icon createIcon() { - return new Icon(); - } - - /** - * Create an instance of {@link AttributeLayout } - * - */ - public AttributeLayout createAttributeLayout() { - return new AttributeLayout(); - } - - /** - * Create an instance of {@link Linktarget } - * - */ - public Linktarget createLinktarget() { - return new Linktarget(); - } - - /** - * Create an instance of {@link Cloud } - * - */ - public Cloud createCloud() { - return new Cloud(); - } - - /** - * Create an instance of {@link Node } - * - */ - public Node createNode() { - return new Node(); - } - - /** - * Create an instance of {@link Attribute } - * - */ - public Attribute createAttribute() { - return new Attribute(); - } - - /** - * Create an instance of {@link Edge } - * - */ - public Edge createEdge() { - return new Edge(); - } - - /** - * Create an instance of {@link Font } - * - */ - public Font createFont() { - return new Font(); - } - - /** - * Create an instance of {@link Hook } - * - */ - public Hook createHook() { - return new Hook(); - } - - /** - * Create an instance of {@link Text } - * - */ - public Text createText() { - return new Text(); - } - - /** - * Create an instance of {@link Map } - * - */ - public Map createMap() { - return new Map(); - } - + /** + * Create a new ObjectFactory that can be used to create new instances of schema derived classes + * for package: io.fluent.qabox.mindmapping.freemind.model + */ + public ObjectFactory() {} + + /** Create an instance of {@link Arrowlink } */ + public Arrowlink createArrowlink() { + return new Arrowlink(); + } + + /** Create an instance of {@link Richcontent } */ + public Richcontent createRichcontent() { + return new Richcontent(); + } + + /** Create an instance of {@link Html } */ + public Html createHtml() { + return new Html(); + } + + /** Create an instance of {@link Parameters } */ + public Parameters createParameters() { + return new Parameters(); + } + + /** Create an instance of {@link Icon } */ + public Icon createIcon() { + return new Icon(); + } + + /** Create an instance of {@link AttributeLayout } */ + public AttributeLayout createAttributeLayout() { + return new AttributeLayout(); + } + + /** Create an instance of {@link Linktarget } */ + public Linktarget createLinktarget() { + return new Linktarget(); + } + + /** Create an instance of {@link Cloud } */ + public Cloud createCloud() { + return new Cloud(); + } + + /** Create an instance of {@link Node } */ + public Node createNode() { + return new Node(); + } + + /** Create an instance of {@link Attribute } */ + public Attribute createAttribute() { + return new Attribute(); + } + + /** Create an instance of {@link Edge } */ + public Edge createEdge() { + return new Edge(); + } + + /** Create an instance of {@link Font } */ + public Font createFont() { + return new Font(); + } + + /** Create an instance of {@link Hook } */ + public Hook createHook() { + return new Hook(); + } + + /** Create an instance of {@link Text } */ + public Text createText() { + return new Text(); + } + + /** Create an instance of {@link Map } */ + public Map createMap() { + return new Map(); + } } diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Parameters.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Parameters.java index 7b86d5a..a639fbb 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Parameters.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Parameters.java @@ -5,16 +5,13 @@ // 生成时间: 2022.09.23 时间 08:46:06 PM CST // - package io.fluentqa.mindmap.freemind.model; import jakarta.xml.bind.annotation.*; - import java.math.BigInteger; - /** - *

anonymous complex type的 Java 类。 + * anonymous complex type的 Java 类。 * *

以下模式片段指定包含在此类中的预期内容。 * @@ -38,325 +35,261 @@ * </complexContent> * </complexType> * - * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "Parameters") public class Parameters { - @XmlAttribute(name = "REMINDUSERAT") - protected BigInteger reminduserat; - @XmlAttribute(name = "ORIGINAL_ID") - protected String originalid; - @XmlAttribute(name = "XML_STORAGE_MAP_LAT") - protected String xmlstoragemaplat; - @XmlAttribute(name = "XML_STORAGE_MAP_LON") - protected String xmlstoragemaplon; - @XmlAttribute(name = "XML_STORAGE_MAP_TOOLTIP_LOCATION") - protected String xmlstoragemaptooltiplocation; - @XmlAttribute(name = "XML_STORAGE_POS_LAT") - protected String xmlstorageposlat; - @XmlAttribute(name = "XML_STORAGE_POS_LON") - protected String xmlstorageposlon; - @XmlAttribute(name = "XML_STORAGE_TILE_SOURCE") - protected String xmlstoragetilesource; - @XmlAttribute(name = "XML_STORAGE_ZOOM") - protected String xmlstoragezoom; - @XmlAttribute(name = "CLONE_ID") - protected String cloneid; - @XmlAttribute(name = "CLONE_IDS") - protected String cloneids; - @XmlAttribute(name = "CLONE_ITSELF") - protected String cloneitself; - - /** - * 获取reminduserat属性的值。 - * - * @return - * possible object is - * {@link BigInteger } - * - */ - public BigInteger getREMINDUSERAT() { - return reminduserat; - } - - /** - * 设置reminduserat属性的值。 - * - * @param value - * allowed object is - * {@link BigInteger } - * - */ - public void setREMINDUSERAT(BigInteger value) { - this.reminduserat = value; - } - - /** - * 获取originalid属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getORIGINALID() { - return originalid; - } - - /** - * 设置originalid属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setORIGINALID(String value) { - this.originalid = value; - } - - /** - * 获取xmlstoragemaplat属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getXMLSTORAGEMAPLAT() { - return xmlstoragemaplat; - } - - /** - * 设置xmlstoragemaplat属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setXMLSTORAGEMAPLAT(String value) { - this.xmlstoragemaplat = value; - } - - /** - * 获取xmlstoragemaplon属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getXMLSTORAGEMAPLON() { - return xmlstoragemaplon; - } - - /** - * 设置xmlstoragemaplon属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setXMLSTORAGEMAPLON(String value) { - this.xmlstoragemaplon = value; - } - - /** - * 获取xmlstoragemaptooltiplocation属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getXMLSTORAGEMAPTOOLTIPLOCATION() { - return xmlstoragemaptooltiplocation; - } - - /** - * 设置xmlstoragemaptooltiplocation属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setXMLSTORAGEMAPTOOLTIPLOCATION(String value) { - this.xmlstoragemaptooltiplocation = value; - } - - /** - * 获取xmlstorageposlat属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getXMLSTORAGEPOSLAT() { - return xmlstorageposlat; - } - - /** - * 设置xmlstorageposlat属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setXMLSTORAGEPOSLAT(String value) { - this.xmlstorageposlat = value; - } - - /** - * 获取xmlstorageposlon属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getXMLSTORAGEPOSLON() { - return xmlstorageposlon; - } - - /** - * 设置xmlstorageposlon属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setXMLSTORAGEPOSLON(String value) { - this.xmlstorageposlon = value; - } - - /** - * 获取xmlstoragetilesource属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getXMLSTORAGETILESOURCE() { - return xmlstoragetilesource; - } - - /** - * 设置xmlstoragetilesource属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setXMLSTORAGETILESOURCE(String value) { - this.xmlstoragetilesource = value; - } - - /** - * 获取xmlstoragezoom属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getXMLSTORAGEZOOM() { - return xmlstoragezoom; - } - - /** - * 设置xmlstoragezoom属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setXMLSTORAGEZOOM(String value) { - this.xmlstoragezoom = value; - } - - /** - * 获取cloneid属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getCLONEID() { - return cloneid; - } - - /** - * 设置cloneid属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCLONEID(String value) { - this.cloneid = value; - } - - /** - * 获取cloneids属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getCLONEIDS() { - return cloneids; - } - - /** - * 设置cloneids属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCLONEIDS(String value) { - this.cloneids = value; - } - - /** - * 获取cloneitself属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getCLONEITSELF() { - return cloneitself; - } - - /** - * 设置cloneitself属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setCLONEITSELF(String value) { - this.cloneitself = value; - } - + @XmlAttribute(name = "REMINDUSERAT") + protected BigInteger reminduserat; + + @XmlAttribute(name = "ORIGINAL_ID") + protected String originalid; + + @XmlAttribute(name = "XML_STORAGE_MAP_LAT") + protected String xmlstoragemaplat; + + @XmlAttribute(name = "XML_STORAGE_MAP_LON") + protected String xmlstoragemaplon; + + @XmlAttribute(name = "XML_STORAGE_MAP_TOOLTIP_LOCATION") + protected String xmlstoragemaptooltiplocation; + + @XmlAttribute(name = "XML_STORAGE_POS_LAT") + protected String xmlstorageposlat; + + @XmlAttribute(name = "XML_STORAGE_POS_LON") + protected String xmlstorageposlon; + + @XmlAttribute(name = "XML_STORAGE_TILE_SOURCE") + protected String xmlstoragetilesource; + + @XmlAttribute(name = "XML_STORAGE_ZOOM") + protected String xmlstoragezoom; + + @XmlAttribute(name = "CLONE_ID") + protected String cloneid; + + @XmlAttribute(name = "CLONE_IDS") + protected String cloneids; + + @XmlAttribute(name = "CLONE_ITSELF") + protected String cloneitself; + + /** + * 获取reminduserat属性的值。 + * + * @return possible object is {@link BigInteger } + */ + public BigInteger getREMINDUSERAT() { + return reminduserat; + } + + /** + * 设置reminduserat属性的值。 + * + * @param value allowed object is {@link BigInteger } + */ + public void setREMINDUSERAT(BigInteger value) { + this.reminduserat = value; + } + + /** + * 获取originalid属性的值。 + * + * @return possible object is {@link String } + */ + public String getORIGINALID() { + return originalid; + } + + /** + * 设置originalid属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setORIGINALID(String value) { + this.originalid = value; + } + + /** + * 获取xmlstoragemaplat属性的值。 + * + * @return possible object is {@link String } + */ + public String getXMLSTORAGEMAPLAT() { + return xmlstoragemaplat; + } + + /** + * 设置xmlstoragemaplat属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setXMLSTORAGEMAPLAT(String value) { + this.xmlstoragemaplat = value; + } + + /** + * 获取xmlstoragemaplon属性的值。 + * + * @return possible object is {@link String } + */ + public String getXMLSTORAGEMAPLON() { + return xmlstoragemaplon; + } + + /** + * 设置xmlstoragemaplon属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setXMLSTORAGEMAPLON(String value) { + this.xmlstoragemaplon = value; + } + + /** + * 获取xmlstoragemaptooltiplocation属性的值。 + * + * @return possible object is {@link String } + */ + public String getXMLSTORAGEMAPTOOLTIPLOCATION() { + return xmlstoragemaptooltiplocation; + } + + /** + * 设置xmlstoragemaptooltiplocation属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setXMLSTORAGEMAPTOOLTIPLOCATION(String value) { + this.xmlstoragemaptooltiplocation = value; + } + + /** + * 获取xmlstorageposlat属性的值。 + * + * @return possible object is {@link String } + */ + public String getXMLSTORAGEPOSLAT() { + return xmlstorageposlat; + } + + /** + * 设置xmlstorageposlat属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setXMLSTORAGEPOSLAT(String value) { + this.xmlstorageposlat = value; + } + + /** + * 获取xmlstorageposlon属性的值。 + * + * @return possible object is {@link String } + */ + public String getXMLSTORAGEPOSLON() { + return xmlstorageposlon; + } + + /** + * 设置xmlstorageposlon属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setXMLSTORAGEPOSLON(String value) { + this.xmlstorageposlon = value; + } + + /** + * 获取xmlstoragetilesource属性的值。 + * + * @return possible object is {@link String } + */ + public String getXMLSTORAGETILESOURCE() { + return xmlstoragetilesource; + } + + /** + * 设置xmlstoragetilesource属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setXMLSTORAGETILESOURCE(String value) { + this.xmlstoragetilesource = value; + } + + /** + * 获取xmlstoragezoom属性的值。 + * + * @return possible object is {@link String } + */ + public String getXMLSTORAGEZOOM() { + return xmlstoragezoom; + } + + /** + * 设置xmlstoragezoom属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setXMLSTORAGEZOOM(String value) { + this.xmlstoragezoom = value; + } + + /** + * 获取cloneid属性的值。 + * + * @return possible object is {@link String } + */ + public String getCLONEID() { + return cloneid; + } + + /** + * 设置cloneid属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setCLONEID(String value) { + this.cloneid = value; + } + + /** + * 获取cloneids属性的值。 + * + * @return possible object is {@link String } + */ + public String getCLONEIDS() { + return cloneids; + } + + /** + * 设置cloneids属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setCLONEIDS(String value) { + this.cloneids = value; + } + + /** + * 获取cloneitself属性的值。 + * + * @return possible object is {@link String } + */ + public String getCLONEITSELF() { + return cloneitself; + } + + /** + * 设置cloneitself属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setCLONEITSELF(String value) { + this.cloneitself = value; + } } diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Richcontent.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Richcontent.java index 1ebb491..0e91af4 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Richcontent.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Richcontent.java @@ -5,14 +5,12 @@ // 生成时间: 2022.09.23 时间 08:46:06 PM CST // - package io.fluentqa.mindmap.freemind.model; import jakarta.xml.bind.annotation.*; - /** - *

anonymous complex type的 Java 类。 + * anonymous complex type的 Java 类。 * *

以下模式片段指定包含在此类中的预期内容。 * @@ -35,67 +33,53 @@ * </complexContent> * </complexType> * - * - * */ @XmlAccessorType(XmlAccessType.FIELD) -@XmlType(name = "", propOrder = { - "html" -}) +@XmlType( + name = "", + propOrder = {"html"}) @XmlRootElement(name = "richcontent") public class Richcontent { - @XmlElement(required = true) - protected Html html; - @XmlAttribute(name = "TYPE", required = true) - protected String type; + @XmlElement(required = true) + protected Html html; - /** - * 获取html属性的值。 - * - * @return - * possible object is - * {@link Html } - * - */ - public Html getHtml() { - return html; - } + @XmlAttribute(name = "TYPE", required = true) + protected String type; - /** - * 设置html属性的值。 - * - * @param value - * allowed object is - * {@link Html } - * - */ - public void setHtml(Html value) { - this.html = value; - } + /** + * 获取html属性的值。 + * + * @return possible object is {@link Html } + */ + public Html getHtml() { + return html; + } - /** - * 获取type属性的值。 - * - * @return - * possible object is - * {@link String } - * - */ - public String getTYPE() { - return type; - } + /** + * 设置html属性的值。 + * + * @param value allowed object is {@link Html } + */ + public void setHtml(Html value) { + this.html = value; + } - /** - * 设置type属性的值。 - * - * @param value - * allowed object is - * {@link String } - * - */ - public void setTYPE(String value) { - this.type = value; - } + /** + * 获取type属性的值。 + * + * @return possible object is {@link String } + */ + public String getTYPE() { + return type; + } + /** + * 设置type属性的值。 + * + * @param value allowed object is {@link String } + */ + public void setTYPE(String value) { + this.type = value; + } } diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Text.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Text.java index db5b102..d6e535f 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Text.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/freemind/model/Text.java @@ -5,7 +5,6 @@ // 生成时间: 2022.09.23 时间 08:46:06 PM CST // - package io.fluentqa.mindmap.freemind.model; import jakarta.xml.bind.annotation.XmlAccessType; @@ -13,10 +12,8 @@ import jakarta.xml.bind.annotation.XmlRootElement; import jakarta.xml.bind.annotation.XmlType; - - /** - *

anonymous complex type的 Java 类。 + * anonymous complex type的 Java 类。 * *

以下模式片段指定包含在此类中的预期内容。 * @@ -28,13 +25,8 @@ * </complexContent> * </complexType> * - * - * */ @XmlAccessorType(XmlAccessType.FIELD) @XmlType(name = "") @XmlRootElement(name = "text") -public class Text { - - -} +public class Text {} diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/package-info.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/package-info.java index 79e3b1f..3ce5b18 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/package-info.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/package-info.java @@ -1 +1 @@ -package io.fluentqa.mindmap; \ No newline at end of file +package io.fluentqa.mindmap; diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/XMindNode.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/XMindNode.java index ec9b824..45b8b42 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/XMindNode.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/XMindNode.java @@ -3,10 +3,8 @@ import io.fluentqa.mindmap.api.MindMapPath; import io.fluentqa.mindmap.xmind.model.Attached; - - public class XMindNode extends MindMapPath implements Cloneable { - public XMindNode(Attached root) { - super(root); - } + public XMindNode(Attached root) { + super(root); + } } diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/XMindUtil.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/XMindUtil.java index f22fd11..b78516a 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/XMindUtil.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/XMindUtil.java @@ -6,7 +6,6 @@ import cn.hutool.core.util.ZipUtil; import io.fluentqa.mindmap.exception.MindMapException; import io.fluentqa.mindmap.xmind.model.XmindRawData; - import java.io.IOException; import java.io.InputStream; import java.nio.charset.Charset; @@ -14,49 +13,52 @@ import java.util.zip.ZipFile; public class XMindUtil { - private static String XML_FILE_NAME = "content.xml"; - private static String JSON_FILE_NAME = "content.json"; - - public static XmindRawData readXMindFile(String filePath) { - XmindRawData.XmindRawDataBuilder builder = XmindRawData.builder(); - try (ZipFile zipFile = ZipUtil.toZipFile(FileUtil.file(filePath), StandardCharsets.UTF_8)) { - ZipUtil.read(zipFile, zipEntry -> { - // 读取到content.xml,存储起来 - if (XML_FILE_NAME.equalsIgnoreCase(zipEntry.getName())) { - try (InputStream zipStream = ZipUtil.getStream(zipFile, zipEntry)) { - builder.contentXml(new String(IoUtil.readBytes(zipStream))); - } catch (IOException e) { - throw new MindMapException(e); - } - } - // 读取到content.json,存储起来,说明当前读取的xmind是zen格式 - if (JSON_FILE_NAME.equalsIgnoreCase(zipEntry.getName())) { - try (InputStream zipStream = ZipUtil.getStream(zipFile, zipEntry)) { - builder.contentJson(new String(IoUtil.readBytes(zipStream))); - } catch (IOException e) { - throw new MindMapException(e); - } - } - }); - } catch (Exception e) { - throw new MindMapException("解析失败!" + e.getLocalizedMessage()); - } - return builder.build(); - } + private static String XML_FILE_NAME = "content.xml"; + private static String JSON_FILE_NAME = "content.json"; - public static XmindRawData readXmindFile(InputStream in) { - XmindRawData.XmindRawDataBuilder builder = XmindRawData.builder(); - ZipReader reader = new ZipReader(in, Charset.defaultCharset()); - reader.read(zipEntry -> { + public static XmindRawData readXMindFile(String filePath) { + XmindRawData.XmindRawDataBuilder builder = XmindRawData.builder(); + try (ZipFile zipFile = ZipUtil.toZipFile(FileUtil.file(filePath), StandardCharsets.UTF_8)) { + ZipUtil.read( + zipFile, + zipEntry -> { // 读取到content.xml,存储起来 if (XML_FILE_NAME.equalsIgnoreCase(zipEntry.getName())) { - builder.contentXml(new String(IoUtil.readBytes(in))); + try (InputStream zipStream = ZipUtil.getStream(zipFile, zipEntry)) { + builder.contentXml(new String(IoUtil.readBytes(zipStream))); + } catch (IOException e) { + throw new MindMapException(e); + } } // 读取到content.json,存储起来,说明当前读取的xmind是zen格式 if (JSON_FILE_NAME.equalsIgnoreCase(zipEntry.getName())) { - builder.contentJson(new String(IoUtil.readBytes(in))); + try (InputStream zipStream = ZipUtil.getStream(zipFile, zipEntry)) { + builder.contentJson(new String(IoUtil.readBytes(zipStream))); + } catch (IOException e) { + throw new MindMapException(e); + } } - }); - return builder.build(); + }); + } catch (Exception e) { + throw new MindMapException("解析失败!" + e.getLocalizedMessage()); } + return builder.build(); + } + + public static XmindRawData readXmindFile(InputStream in) { + XmindRawData.XmindRawDataBuilder builder = XmindRawData.builder(); + ZipReader reader = new ZipReader(in, Charset.defaultCharset()); + reader.read( + zipEntry -> { + // 读取到content.xml,存储起来 + if (XML_FILE_NAME.equalsIgnoreCase(zipEntry.getName())) { + builder.contentXml(new String(IoUtil.readBytes(in))); + } + // 读取到content.json,存储起来,说明当前读取的xmind是zen格式 + if (JSON_FILE_NAME.equalsIgnoreCase(zipEntry.getName())) { + builder.contentJson(new String(IoUtil.readBytes(in))); + } + }); + return builder.build(); + } } diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/XmindTransformer.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/XmindTransformer.java index 86c0f1b..f5ef381 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/XmindTransformer.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/XmindTransformer.java @@ -8,85 +8,80 @@ import io.fluentqa.mindmap.xmind.model.Attached; import io.fluentqa.mindmap.xmind.model.JsonRootBean; import io.fluentqa.mindmap.xmind.model.XmindRawData; - import java.util.ArrayList; import java.util.List; import java.util.stream.Collectors; -/** - * 1. READ XMIND Files - * 2. Convert to List - */ +/** 1. READ XMIND Files 2. Convert to List */ public class XmindTransformer implements MindMapTransformer { + @Override + public List> readMindMapToList(String mindMapPath) { + return convertToList(mindMapPath); + } - @Override - public List> readMindMapToList(String mindMapPath) { - return convertToList(mindMapPath); - } - - @Override - public List readMindMapToList(String mindMapPath, Class clazz) { - List> paths = convertToList(mindMapPath); - List records = MindMapPathRecord.fromMindMapPaths(paths,Attached::getTitle); - return records.stream().map(mindMapPathRecord -> mindMapPathRecord.toBean(clazz)).collect(Collectors.toList()); - } - - @Override - public List readMindMapToList(String mindMapPath, Class clazz, MindMapConvertConfig config) { - List> paths = convertToList(mindMapPath); - List records = MindMapPathRecord.fromMindMapPaths(paths,Attached::getTitle); - return records.stream().map(mindMapPathRecord -> mindMapPathRecord.toBean(clazz,config)).collect(Collectors.toList()); - } + @Override + public List readMindMapToList(String mindMapPath, Class clazz) { + List> paths = convertToList(mindMapPath); + List records = MindMapPathRecord.fromMindMapPaths(paths, Attached::getTitle); + return records.stream() + .map(mindMapPathRecord -> mindMapPathRecord.toBean(clazz)) + .collect(Collectors.toList()); + } - private List> convertToList(String xmindFilePath) { - XmindRawData rawData = XMindUtil.readXMindFile(xmindFilePath); - List root = JSONUtil.toList(rawData.getContentJson(), JsonRootBean.class); - List attachedNodes = root.get(0).getRootTopic().getChildren().getAttached(); - List> result = new ArrayList<>(); - for (Attached attachedMindMapPath : attachedNodes) { - XMindNode xmindNode = new XMindNode(attachedMindMapPath); - populateNodes(List.of(xmindNode), result); - } + @Override + public List readMindMapToList( + String mindMapPath, Class clazz, MindMapConvertConfig config) { + List> paths = convertToList(mindMapPath); + List records = MindMapPathRecord.fromMindMapPaths(paths, Attached::getTitle); + return records.stream() + .map(mindMapPathRecord -> mindMapPathRecord.toBean(clazz, config)) + .collect(Collectors.toList()); + } - return result; + private List> convertToList(String xmindFilePath) { + XmindRawData rawData = XMindUtil.readXMindFile(xmindFilePath); + List root = JSONUtil.toList(rawData.getContentJson(), JsonRootBean.class); + List attachedNodes = root.get(0).getRootTopic().getChildren().getAttached(); + List> result = new ArrayList<>(); + for (Attached attachedMindMapPath : attachedNodes) { + XMindNode xmindNode = new XMindNode(attachedMindMapPath); + populateNodes(List.of(xmindNode), result); } - /** - * ->Node1 - * currentNode | - * ->Node2 - * convert to: - * [ currentNode->Node1, - * currentNode->Node2] - * - * @param current: Current Node - * @return OUT: A List of MindMapPath - */ - private List> populateNextLevel(MindMapPath current) { - Attached lastNode = current.pathNodes().getLast(); - List> mindMapPaths = new ArrayList<>(); - for (Attached o : lastNode.getChildren().getAttached()) { - MindMapPath path = current.clone(); - if (o != null) { - path.pathNodes().add(o); - } - mindMapPaths.add(path); - } + return result; + } - return mindMapPaths; + /** + * ->Node1 currentNode | ->Node2 convert to: [ currentNode->Node1, currentNode->Node2] + * + * @param current: Current Node + * @return OUT: A List of MindMapPath + */ + private List> populateNextLevel(MindMapPath current) { + Attached lastNode = current.pathNodes().getLast(); + List> mindMapPaths = new ArrayList<>(); + for (Attached o : lastNode.getChildren().getAttached()) { + MindMapPath path = current.clone(); + if (o != null) { + path.pathNodes().add(o); + } + mindMapPaths.add(path); } + return mindMapPaths; + } - private void populateNodes(List> nodes, List> resultPaths) { + private void populateNodes( + List> nodes, List> resultPaths) { - for (MindMapPath current : nodes) { - if (current.pathNodes().getLast().getChildren() == null || - current.pathNodes().getLast().getChildren().getAttached() == null) { - resultPaths.add(current); - } else { - populateNodes(populateNextLevel(current), resultPaths); - } - } + for (MindMapPath current : nodes) { + if (current.pathNodes().getLast().getChildren() == null + || current.pathNodes().getLast().getChildren().getAttached() == null) { + resultPaths.add(current); + } else { + populateNodes(populateNextLevel(current), resultPaths); + } } + } } diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/model/Attached.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/model/Attached.java index 7fd9820..d39006d 100755 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/model/Attached.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/model/Attached.java @@ -1,18 +1,14 @@ - package io.fluentqa.mindmap.xmind.model; -import lombok.Data; import java.util.List; - +import lombok.Data; @Data public class Attached { - private String id; - private String title; - private Notes notes; - private List comments; - private Children children; - - -} \ No newline at end of file + private String id; + private String title; + private Notes notes; + private List comments; + private Children children; +} diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/model/Children.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/model/Children.java index db75693..96a5cb5 100755 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/model/Children.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/model/Children.java @@ -1,12 +1,10 @@ package io.fluentqa.mindmap.xmind.model; -import lombok.Data; import java.util.List; - +import lombok.Data; @Data public class Children { - private List attached; - -} \ No newline at end of file + private List attached; +} diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/model/Comments.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/model/Comments.java index 617959d..72b7b70 100755 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/model/Comments.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/model/Comments.java @@ -1,14 +1,11 @@ - package io.fluentqa.mindmap.xmind.model; import lombok.Data; - @Data public class Comments { - private long creationTime; - private String author; - private String content; - -} \ No newline at end of file + private long creationTime; + private String author; + private String content; +} diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/model/JsonRootBean.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/model/JsonRootBean.java index 5b8c059..20e984d 100755 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/model/JsonRootBean.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/model/JsonRootBean.java @@ -1,13 +1,11 @@ - package io.fluentqa.mindmap.xmind.model; -import lombok.Data; +import lombok.Data; @Data public class JsonRootBean { - private String id; - private String title; - private RootTopic rootTopic; - -} \ No newline at end of file + private String id; + private String title; + private RootTopic rootTopic; +} diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/model/Notes.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/model/Notes.java index c57939f..c563e3d 100755 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/model/Notes.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/model/Notes.java @@ -1,13 +1,9 @@ - package io.fluentqa.mindmap.xmind.model; import lombok.Data; - @Data public class Notes { - private String content; - - -} \ No newline at end of file + private String content; +} diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/model/RootTopic.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/model/RootTopic.java index 160305d..53dcbe9 100755 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/model/RootTopic.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/model/RootTopic.java @@ -1,19 +1,14 @@ - package io.fluentqa.mindmap.xmind.model; -import lombok.Data; import java.util.List; - +import lombok.Data; @Data public class RootTopic { - private String id; - private String title; - private Notes notes; - private List comments; - private Children children; - - - -} \ No newline at end of file + private String id; + private String title; + private Notes notes; + private List comments; + private Children children; +} diff --git a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/model/XmindRawData.java b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/model/XmindRawData.java index 9fba02c..2761267 100644 --- a/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/model/XmindRawData.java +++ b/components/fluent-mindmap/src/main/java/io/fluentqa/mindmap/xmind/model/XmindRawData.java @@ -5,35 +5,37 @@ import cn.hutool.json.JSONUtil; import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.dataformat.xml.XmlMapper; +import java.util.stream.Collectors; import lombok.Builder; import lombok.Data; - -import java.util.stream.Collectors; - @Data @Builder public class XmindRawData { - private String contentJson; - private String contentXml; + private String contentJson; + private String contentXml; - public boolean isZenVersion() { - return StrUtil.isNotBlank(this.contentJson); - } - - public String fetchContentJson() { - if (StrUtil.isNotBlank(this.contentJson)) { - return contentJson; - } + public boolean isZenVersion() { + return StrUtil.isNotBlank(this.contentJson); + } - if (StrUtil.isNotBlank(this.contentXml)) { - try { - return JSONUtil.toJsonPrettyStr(new XmlMapper().readValue(this.contentXml, JSONArray.class).stream().skip(1).collect(Collectors.toList())); - } catch (JsonProcessingException e) { - throw new RuntimeException(e); - } - } + public String fetchContentJson() { + if (StrUtil.isNotBlank(this.contentJson)) { + return contentJson; + } - return StrUtil.EMPTY; + if (StrUtil.isNotBlank(this.contentXml)) { + try { + return JSONUtil.toJsonPrettyStr( + new XmlMapper() + .readValue(this.contentXml, JSONArray.class).stream() + .skip(1) + .collect(Collectors.toList())); + } catch (JsonProcessingException e) { + throw new RuntimeException(e); + } } + + return StrUtil.EMPTY; + } } diff --git a/components/fluent-mindmap/src/test/java/io/fluentqa/mindmap/api/DemoBean.java b/components/fluent-mindmap/src/test/java/io/fluentqa/mindmap/api/DemoBean.java index d1a9e94..36d160b 100644 --- a/components/fluent-mindmap/src/test/java/io/fluentqa/mindmap/api/DemoBean.java +++ b/components/fluent-mindmap/src/test/java/io/fluentqa/mindmap/api/DemoBean.java @@ -4,18 +4,18 @@ @Data public class DemoBean { - @NodeLevel(1) - private String moduleName; - @NodeLevel(2) + @NodeLevel(1) + private String moduleName; - private String featureName; - @NodeLevel(3) + @NodeLevel(2) + private String featureName; - private String testCase; - @NodeLevel(4) + @NodeLevel(3) + private String testCase; - private String testSteps; - @NodeLevel(5) + @NodeLevel(4) + private String testSteps; - private String expectedResult; + @NodeLevel(5) + private String expectedResult; } diff --git a/components/fluent-mindmap/src/test/java/io/fluentqa/mindmap/api/DemoBeanConfig.java b/components/fluent-mindmap/src/test/java/io/fluentqa/mindmap/api/DemoBeanConfig.java index e19e4e1..0e33039 100644 --- a/components/fluent-mindmap/src/test/java/io/fluentqa/mindmap/api/DemoBeanConfig.java +++ b/components/fluent-mindmap/src/test/java/io/fluentqa/mindmap/api/DemoBeanConfig.java @@ -2,13 +2,14 @@ public class DemoBeanConfig { - public static MindMapConvertConfig loadConfig(){ - MindMapConvertConfig configs = new MindMapConvertConfig(); - configs.add(new MindMapConvertConfig.LevelConfig("moduleName",1)) - .add(new MindMapConvertConfig.LevelConfig("featureName",2)) - .add(new MindMapConvertConfig.LevelConfig("testCase",3)) - .add(new MindMapConvertConfig.LevelConfig("testSteps",4)) - .add(new MindMapConvertConfig.LevelConfig("expectedResult",5)); - return configs; - } + public static MindMapConvertConfig loadConfig() { + MindMapConvertConfig configs = new MindMapConvertConfig(); + configs + .add(new MindMapConvertConfig.LevelConfig("moduleName", 1)) + .add(new MindMapConvertConfig.LevelConfig("featureName", 2)) + .add(new MindMapConvertConfig.LevelConfig("testCase", 3)) + .add(new MindMapConvertConfig.LevelConfig("testSteps", 4)) + .add(new MindMapConvertConfig.LevelConfig("expectedResult", 5)); + return configs; + } } diff --git a/components/fluent-mindmap/src/test/java/io/fluentqa/mindmap/api/DemoBeanWOLevel.java b/components/fluent-mindmap/src/test/java/io/fluentqa/mindmap/api/DemoBeanWOLevel.java index 0fc4799..77b9a7d 100644 --- a/components/fluent-mindmap/src/test/java/io/fluentqa/mindmap/api/DemoBeanWOLevel.java +++ b/components/fluent-mindmap/src/test/java/io/fluentqa/mindmap/api/DemoBeanWOLevel.java @@ -4,13 +4,13 @@ @Data public class DemoBeanWOLevel { - private String moduleName; + private String moduleName; - private String featureName; + private String featureName; - private String testCase; + private String testCase; - private String testSteps; + private String testSteps; - private String expectedResult; + private String expectedResult; } diff --git a/components/fluent-mindmap/src/test/java/io/fluentqa/mindmap/api/MindMapAccessorTest.java b/components/fluent-mindmap/src/test/java/io/fluentqa/mindmap/api/MindMapAccessorTest.java index 5886f56..2cadd5b 100644 --- a/components/fluent-mindmap/src/test/java/io/fluentqa/mindmap/api/MindMapAccessorTest.java +++ b/components/fluent-mindmap/src/test/java/io/fluentqa/mindmap/api/MindMapAccessorTest.java @@ -1,21 +1,24 @@ package io.fluentqa.mindmap.api; -import org.junit.jupiter.api.Test; import java.util.List; +import org.junit.jupiter.api.Test; public class MindMapAccessorTest { - MindMapAccessor accessor = new MindMapAccessor(); - @Test - public void testMindMapAccessorTest(){ - String xmindFile = "./Xmind10+.xmind"; - List freeMindBeans = accessor.readMindMapToBean(xmindFile,DemoBean.class); - System.out.println(freeMindBeans); - } + MindMapAccessor accessor = new MindMapAccessor(); + + @Test + public void testMindMapAccessorTest() { + String xmindFile = "./Xmind10+.xmind"; + List freeMindBeans = accessor.readMindMapToBean(xmindFile, DemoBean.class); + System.out.println(freeMindBeans); + } - @Test - public void testFreeMindBeanConfigAccessorTest(){ - String freeMindfile = "./元件管理用例.mm"; - List freeMindBeans = accessor.readMindMapToBean(freeMindfile,DemoBeanWOLevel.class,DemoBeanConfig.loadConfig()); - System.out.println(freeMindBeans); - } + @Test + public void testFreeMindBeanConfigAccessorTest() { + String freeMindfile = "./元件管理用例.mm"; + List freeMindBeans = + accessor.readMindMapToBean( + freeMindfile, DemoBeanWOLevel.class, DemoBeanConfig.loadConfig()); + System.out.println(freeMindBeans); + } } diff --git a/components/fluent-mindmap/src/test/java/io/fluentqa/mindmap/freemind/FreeMindConverterTest.java b/components/fluent-mindmap/src/test/java/io/fluentqa/mindmap/freemind/FreeMindConverterTest.java index 8dd5a52..9f5727e 100644 --- a/components/fluent-mindmap/src/test/java/io/fluentqa/mindmap/freemind/FreeMindConverterTest.java +++ b/components/fluent-mindmap/src/test/java/io/fluentqa/mindmap/freemind/FreeMindConverterTest.java @@ -2,21 +2,17 @@ import io.fluentqa.mindmap.api.MindMapPath; import io.fluentqa.mindmap.freemind.model.Node; -import org.junit.jupiter.api.BeforeEach; - import java.util.List; - +import org.junit.jupiter.api.BeforeEach; public class FreeMindConverterTest { - @BeforeEach - public void setup(){ - - } - @org.junit.jupiter.api.Test - void testToList() { - FreeMindTransformer converter = new FreeMindTransformer(); - List> result = converter.readMindMapToList("./t2.mm"); - System.out.println(result); - } + @BeforeEach + public void setup() {} -} \ No newline at end of file + @org.junit.jupiter.api.Test + void testToList() { + FreeMindTransformer converter = new FreeMindTransformer(); + List> result = converter.readMindMapToList("./t2.mm"); + System.out.println(result); + } +} diff --git a/components/fluent-mindmap/src/test/java/io/fluentqa/mindmap/xmind/XMindUtilTest.java b/components/fluent-mindmap/src/test/java/io/fluentqa/mindmap/xmind/XMindUtilTest.java index 19c98b4..cc7bec9 100644 --- a/components/fluent-mindmap/src/test/java/io/fluentqa/mindmap/xmind/XMindUtilTest.java +++ b/components/fluent-mindmap/src/test/java/io/fluentqa/mindmap/xmind/XMindUtilTest.java @@ -5,22 +5,21 @@ class XMindUtilTest { - @Test - void readXMindFile_ZEN() { - XmindRawData data = XMindUtil.readXMindFile("./XmindZen.xmind"); - System.out.println(data); - } + @Test + void readXMindFile_ZEN() { + XmindRawData data = XMindUtil.readXMindFile("./XmindZen.xmind"); + System.out.println(data); + } - @Test - void readXMindFile_XMIND() { - XmindRawData data = XMindUtil.readXMindFile("./Xmind10+.xmind"); - System.out.println(data); - } + @Test + void readXMindFile_XMIND() { + XmindRawData data = XMindUtil.readXMindFile("./Xmind10+.xmind"); + System.out.println(data); + } - @Test - void readXMindFile_XMIND8() { - XmindRawData data = XMindUtil.readXMindFile("./Xmind8.xmind"); - System.out.println(data); - } - -} \ No newline at end of file + @Test + void readXMindFile_XMIND8() { + XmindRawData data = XMindUtil.readXMindFile("./Xmind8.xmind"); + System.out.println(data); + } +} diff --git a/components/fluent-mindmap/src/test/java/io/fluentqa/mindmap/xmind/XmindTransformerTest.java b/components/fluent-mindmap/src/test/java/io/fluentqa/mindmap/xmind/XmindTransformerTest.java index 7be0e73..f307acc 100644 --- a/components/fluent-mindmap/src/test/java/io/fluentqa/mindmap/xmind/XmindTransformerTest.java +++ b/components/fluent-mindmap/src/test/java/io/fluentqa/mindmap/xmind/XmindTransformerTest.java @@ -2,20 +2,18 @@ import io.fluentqa.mindmap.api.MindMapPath; import io.fluentqa.mindmap.xmind.model.Attached; -import org.junit.jupiter.api.Test; - import java.util.List; +import org.junit.jupiter.api.Test; class XmindTransformerTest { - XmindTransformer xmindTransformer = new XmindTransformer(); + XmindTransformer xmindTransformer = new XmindTransformer(); - @Test - void convertFromFileContent() { - } + @Test + void convertFromFileContent() {} - @Test - void convertFromFilePath() { - List> result = xmindTransformer.readMindMapToList("./Xmind10+.xmind"); - System.out.println(result); - } -} \ No newline at end of file + @Test + void convertFromFilePath() { + List> result = xmindTransformer.readMindMapToList("./Xmind10+.xmind"); + System.out.println(result); + } +} diff --git a/components/fluent-openapi/pom.xml b/components/fluent-openapi/pom.xml index c6d66f8..865d565 100644 --- a/components/fluent-openapi/pom.xml +++ b/components/fluent-openapi/pom.xml @@ -26,6 +26,11 @@ openapi-diff-core 2.0.1 + + io.swagger.parser.v3 + swagger-parser + 2.1.22 + diff --git a/components/fluent-openapi/src/main/java/io/fluent/differ/OpenApiDiffer.java b/components/fluent-openapi/src/main/java/io/fluent/differ/OpenApiDiffer.java index 1562e5b..ab60227 100644 --- a/components/fluent-openapi/src/main/java/io/fluent/differ/OpenApiDiffer.java +++ b/components/fluent-openapi/src/main/java/io/fluent/differ/OpenApiDiffer.java @@ -29,5 +29,4 @@ public String apiDifferences(String oriLocation, String newLocation, Render rend ChangedOpenApi diff = OpenApiCompare.fromLocations(oriLocation, newLocation); return render.render(diff); } - } diff --git a/components/fluent-openapi/src/main/java/io/fluent/postman/PostmanParser.java b/components/fluent-openapi/src/main/java/io/fluent/postman/PostmanParser.java index 1d66252..c1bafe9 100644 --- a/components/fluent-openapi/src/main/java/io/fluent/postman/PostmanParser.java +++ b/components/fluent-openapi/src/main/java/io/fluent/postman/PostmanParser.java @@ -3,22 +3,21 @@ import cn.hutool.json.JSON; import cn.hutool.json.JSONUtil; import io.fluent.postman.model.PostmanCollection; - import java.io.File; import java.nio.charset.Charset; public class PostmanParser { - public PostmanCollection toPostmanCollection(String jsonString){ - return JSONUtil.toBean(jsonString,PostmanCollection.class,true); - } + public PostmanCollection toPostmanCollection(String jsonString) { + return JSONUtil.toBean(jsonString, PostmanCollection.class, true); + } - public PostmanCollection toPostmanCollectionFromFile(String filePath){ - JSON json = JSONUtil.readJSON(new File(filePath), Charset.defaultCharset()); - return JSONUtil.toBean(json,PostmanCollection.class,true); - } + public PostmanCollection toPostmanCollectionFromFile(String filePath) { + JSON json = JSONUtil.readJSON(new File(filePath), Charset.defaultCharset()); + return JSONUtil.toBean(json, PostmanCollection.class, true); + } - public static PostmanParser create(){ - return new PostmanParser(); - } + public static PostmanParser create() { + return new PostmanParser(); + } } diff --git a/components/fluent-openapi/src/main/java/io/fluent/postman/ValueUtils.java b/components/fluent-openapi/src/main/java/io/fluent/postman/ValueUtils.java index ff3d787..ed1a9a5 100644 --- a/components/fluent-openapi/src/main/java/io/fluent/postman/ValueUtils.java +++ b/components/fluent-openapi/src/main/java/io/fluent/postman/ValueUtils.java @@ -5,28 +5,36 @@ import java.util.Map; public class ValueUtils { - // TODO: replace substring(...) solution for matching with (safer) regex matching, using java matcher groups - private static final String[] patterns = {".environment.set", ".setGlobalVariable", ".setEnvironmentVariable", ".globals.set"}; + // TODO: replace substring(...) solution for matching with (safer) regex matching, using java + // matcher groups + private static final String[] patterns = { + ".environment.set", ".setGlobalVariable", ".setEnvironmentVariable", ".globals.set" + }; - public static String value(String value) { - if (value != null && value.contains("{{") && value.contains("}}")) { - value = value.replace("{{", "${"); - value = value.replace("}}", "}"); - } - return value; + public static String value(String value) { + if (value != null && value.contains("{{") && value.contains("}}")) { + value = value.replace("{{", "${"); + value = value.replace("}}", "}"); } + return value; + } - public static Map extractVariablesWithValues(List execs) { - Map variableAssignments = new HashMap<>(); // TODO: better use SortedMap to preserve order? any advantages as opposed to HashMap? - for (String exec : execs) { - if (exec.contains(patterns[0]) || exec.contains(patterns[1]) || exec.contains(patterns[2]) || exec.contains(patterns[3])) { - String variable = exec.substring(exec.indexOf("(") + 1, exec.indexOf(",")); - variable = variable.trim().replace("\'", "").replace("\"", ""); - String value = exec.substring(exec.indexOf(",") + 1, exec.indexOf(")")); - value = value.trim(); - variableAssignments.put(variable, value); - } - } - return variableAssignments; + public static Map extractVariablesWithValues(List execs) { + Map variableAssignments = + new HashMap<>(); // TODO: better use SortedMap to preserve order? any advantages as opposed + // to HashMap? + for (String exec : execs) { + if (exec.contains(patterns[0]) + || exec.contains(patterns[1]) + || exec.contains(patterns[2]) + || exec.contains(patterns[3])) { + String variable = exec.substring(exec.indexOf("(") + 1, exec.indexOf(",")); + variable = variable.trim().replace("\'", "").replace("\"", ""); + String value = exec.substring(exec.indexOf(",") + 1, exec.indexOf(")")); + value = value.trim(); + variableAssignments.put(variable, value); + } } + return variableAssignments; + } } diff --git a/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanBody.java b/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanBody.java index df060ed..eba7db6 100644 --- a/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanBody.java +++ b/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanBody.java @@ -3,71 +3,67 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import io.fluent.postman.ValueUtils; - - import java.util.ArrayList; import java.util.List; @JsonIgnoreProperties(ignoreUnknown = true) public class PostmanBody { - @JsonProperty("mode") - private String mode = ResponseBodyMode.EMPTY.getMode(); - - @JsonProperty("file") - private PostmanFileBody file; + @JsonProperty("mode") + private String mode = ResponseBodyMode.EMPTY.getMode(); - @JsonProperty("urlencoded") - private List urlEncodes = new ArrayList<>(); + @JsonProperty("file") + private PostmanFileBody file; - @JsonProperty("raw") - private PostmanRawBody raw; + @JsonProperty("urlencoded") + private List urlEncodes = new ArrayList<>(); - @JsonProperty("formdata") - private List formDataList = new ArrayList<>(); + @JsonProperty("raw") + private PostmanRawBody raw; + @JsonProperty("formdata") + private List formDataList = new ArrayList<>(); - public PostmanBody() { - } + public PostmanBody() {} - public String getMode() { - return mode; - } + public String getMode() { + return mode; + } - public void setMode(String mode) { - this.mode = mode; - } + public void setMode(String mode) { + this.mode = mode; + } - public PostmanFileBody getFile() { - return file; - } + public PostmanFileBody getFile() { + return file; + } - public void setFile(PostmanFileBody file) { - this.file = file; - } + public void setFile(PostmanFileBody file) { + this.file = file; + } - public List getUrlEncodes() { - return urlEncodes; - } + public List getUrlEncodes() { + return urlEncodes; + } - public void setUrlEncodes(List urlEncodes) { - this.urlEncodes = urlEncodes; - } + public void setUrlEncodes(List urlEncodes) { + this.urlEncodes = urlEncodes; + } - public PostmanRawBody getRaw() { - return raw; - } + public PostmanRawBody getRaw() { + return raw; + } - public void setRaw(PostmanRawBody raw) { - this.raw = raw; - this.raw.setValue(ValueUtils.value(raw.getValue())); - } + public void setRaw(PostmanRawBody raw) { + this.raw = raw; + this.raw.setValue(ValueUtils.value(raw.getValue())); + } - public List getFormDataList() { - return formDataList; - } + public List getFormDataList() { + return formDataList; + } - public void setFormDataList(List formDataList) { - this.formDataList = formDataList; - } + public void setFormDataList(List formDataList) { + this.formDataList = formDataList; + } } diff --git a/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanCollection.java b/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanCollection.java index 6de919d..5fef976 100644 --- a/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanCollection.java +++ b/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanCollection.java @@ -1,15 +1,14 @@ package io.fluent.postman.model; -import lombok.Data; - import java.util.List; import java.util.Map; +import lombok.Data; @Data public class PostmanCollection { - private PostmanCollectionInfo info; - private List item; - private List variable; - private Map auth; + private PostmanCollectionInfo info; + private List item; + private List variable; + private Map auth; } diff --git a/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanCollectionInfo.java b/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanCollectionInfo.java index 9908cdb..749dcc1 100644 --- a/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanCollectionInfo.java +++ b/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanCollectionInfo.java @@ -5,7 +5,7 @@ @Data public class PostmanCollectionInfo { - private String _postman_id; - private String name; - private String schema; + private String _postman_id; + private String name; + private String schema; } diff --git a/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanEvent.java b/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanEvent.java index 926e9f6..5feef84 100644 --- a/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanEvent.java +++ b/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanEvent.java @@ -1,18 +1,15 @@ package io.fluent.postman.model; -import lombok.Data; - import java.util.ArrayList; import java.util.List; +import lombok.Data; @Data public class PostmanEvent { - private List variables = new ArrayList<>(); - private List variableValues = new ArrayList<>(); - private String listen; - private PostmanScript script; + private String listen; + private PostmanScript script; } diff --git a/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanFileBody.java b/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanFileBody.java index da6881d..bd4fb6d 100644 --- a/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanFileBody.java +++ b/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanFileBody.java @@ -4,5 +4,5 @@ @Data public class PostmanFileBody { - private String fileBody ; + private String fileBody; } diff --git a/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanFormDataBody.java b/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanFormDataBody.java index 3891ee2..8c2ce39 100644 --- a/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanFormDataBody.java +++ b/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanFormDataBody.java @@ -7,57 +7,56 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class PostmanFormDataBody { - @JsonProperty("key") - private String key; + @JsonProperty("key") + private String key; - @JsonProperty("value") - private String value; + @JsonProperty("value") + private String value; - @JsonProperty("description") - private String description; + @JsonProperty("description") + private String description; - @JsonProperty("type") - private String type; + @JsonProperty("type") + private String type; - public PostmanFormDataBody() { - } + public PostmanFormDataBody() {} - public PostmanFormDataBody(String key, String value, String description, String type) { - this.key = key; - this.value = value; - this.description = description; - this.type = type; - } + public PostmanFormDataBody(String key, String value, String description, String type) { + this.key = key; + this.value = value; + this.description = description; + this.type = type; + } - public String getKey() { - return key; - } + public String getKey() { + return key; + } - public void setKey(String key) { - this.key = key; - } + public void setKey(String key) { + this.key = key; + } - public String getValue() { - return value; - } + public String getValue() { + return value; + } - public void setValue(String value) { - this.value = ValueUtils.value(value); - } + public void setValue(String value) { + this.value = ValueUtils.value(value); + } - public String getDescription() { - return description; - } + public String getDescription() { + return description; + } - public void setDescription(String description) { - this.description = description; - } + public void setDescription(String description) { + this.description = description; + } - public String getType() { - return type; - } + public String getType() { + return type; + } - public void setType(String type) { - this.type = type; - } + public void setType(String type) { + this.type = type; + } } diff --git a/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanItem.java b/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanItem.java index 0be7626..17ff9b4 100644 --- a/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanItem.java +++ b/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanItem.java @@ -1,23 +1,22 @@ package io.fluent.postman.model; +import java.util.List; import lombok.Data; import lombok.Getter; import lombok.Setter; -import java.util.List; - @Data public class PostmanItem { - private String name; - private List event; - private PostmanRequest request; - private List response; - private List item; - private ProtocolProfileBehavior protocolProfileBehavior; + private String name; + private List event; + private PostmanRequest request; + private List response; + private List item; + private ProtocolProfileBehavior protocolProfileBehavior; - @Getter - @Setter - public class ProtocolProfileBehavior { - private Boolean followRedirects = true; - } + @Getter + @Setter + public class ProtocolProfileBehavior { + private Boolean followRedirects = true; + } } diff --git a/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanKeyValue.java b/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanKeyValue.java index be4f0e9..b845bb3 100644 --- a/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanKeyValue.java +++ b/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanKeyValue.java @@ -4,17 +4,16 @@ @Data public class PostmanKeyValue { - private String key; - private String value; - private String type; - private String description; - private String contentType; + private String key; + private String value; + private String type; + private String description; + private String contentType; - public PostmanKeyValue() { - } + public PostmanKeyValue() {} - public PostmanKeyValue(String key, String value) { - this.key = key; - this.value = value; - } + public PostmanKeyValue(String key, String value) { + this.key = key; + this.value = value; + } } diff --git a/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanQuery.java b/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanQuery.java index 14a68f8..f5a69ab 100644 --- a/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanQuery.java +++ b/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanQuery.java @@ -2,46 +2,45 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import io.fluent.postman.ValueUtils; + @JsonIgnoreProperties(ignoreUnknown = true) public class PostmanQuery { - private String key; - private String value; - private String description; - private String disabled; - + private String key; + private String value; + private String description; + private String disabled; - public PostmanQuery() { - } + public PostmanQuery() {} - public String getKey() { - return key; - } + public String getKey() { + return key; + } - public void setKey(String key) { - this.key = ValueUtils.value(key); - } + public void setKey(String key) { + this.key = ValueUtils.value(key); + } - public String getValue() { - return value; - } + public String getValue() { + return value; + } - public void setValue(String value) { - this.value = ValueUtils.value(value); - } + public void setValue(String value) { + this.value = ValueUtils.value(value); + } - public String getDescription() { - return description; - } + public String getDescription() { + return description; + } - public void setDescription(String description) { - this.description = description; - } + public void setDescription(String description) { + this.description = description; + } - public String getDisabled() { - return disabled; - } + public String getDisabled() { + return disabled; + } - public void setDisabled(String disabled) { - this.disabled = disabled; - } + public void setDisabled(String disabled) { + this.disabled = disabled; + } } diff --git a/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanRawBody.java b/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanRawBody.java index 6e0bcdf..5fd6a77 100644 --- a/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanRawBody.java +++ b/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanRawBody.java @@ -2,23 +2,23 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import io.fluent.postman.ValueUtils; + @JsonIgnoreProperties(ignoreUnknown = true) public class PostmanRawBody { - private String value; + private String value; - public PostmanRawBody() { - } + public PostmanRawBody() {} - public PostmanRawBody(String value) { - this.value = value; - } + public PostmanRawBody(String value) { + this.value = value; + } - public String getValue() { - return value; - } + public String getValue() { + return value; + } - public void setValue(String value) { - this.value = ValueUtils.value(value); - } + public void setValue(String value) { + this.value = ValueUtils.value(value); + } } diff --git a/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanRequest.java b/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanRequest.java index c226cb5..1de0683 100644 --- a/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanRequest.java +++ b/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanRequest.java @@ -1,20 +1,18 @@ package io.fluent.postman.model; - -import lombok.Data; - import java.util.List; import java.util.Map; +import lombok.Data; @Data public class PostmanRequest { - private String method; - private String schema; - private List header; - private Map body; - private PostmanQuery query; - private Map auth; - private PostmanUrl url; - private String description; + private String method; + private String schema; + private List header; + private Map body; + private PostmanQuery query; + private Map auth; + private PostmanUrl url; + private String description; } diff --git a/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanResponse.java b/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanResponse.java index f01d400..ee95017 100644 --- a/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanResponse.java +++ b/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanResponse.java @@ -1,20 +1,19 @@ package io.fluent.postman.model; -import lombok.Data; - import java.util.List; +import lombok.Data; @Data public class PostmanResponse { - private Integer code; - private Integer responseTime; - private String name; - private PostmanRequest originalRequest; - private String status; - private List header; - private String body; - private String jsonSchema; - private PostmanUrl url; - private String description; + private Integer code; + private Integer responseTime; + private String name; + private PostmanRequest originalRequest; + private String status; + private List header; + private String body; + private String jsonSchema; + private PostmanUrl url; + private String description; } diff --git a/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanScript.java b/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanScript.java index 947d630..96486e6 100644 --- a/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanScript.java +++ b/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanScript.java @@ -1,11 +1,10 @@ package io.fluent.postman.model; -import lombok.Data; - import java.util.List; +import lombok.Data; @Data public class PostmanScript { - private List exec; - private String type; + private List exec; + private String type; } diff --git a/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanUrl.java b/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanUrl.java index fe31744..6aa2e4e 100644 --- a/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanUrl.java +++ b/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanUrl.java @@ -3,39 +3,37 @@ import com.fasterxml.jackson.annotation.JsonIgnoreProperties; import com.fasterxml.jackson.annotation.JsonProperty; import io.fluent.postman.ValueUtils; - import java.util.ArrayList; import java.util.List; @JsonIgnoreProperties(ignoreUnknown = true) public class PostmanUrl { - @JsonProperty("raw") - private String raw; + @JsonProperty("raw") + private String raw; - @JsonProperty("query") - private List queries = new ArrayList<>(); + @JsonProperty("query") + private List queries = new ArrayList<>(); - public PostmanUrl() { - } + public PostmanUrl() {} - public PostmanUrl(String raw) { - this.raw = ValueUtils.value(raw); - } + public PostmanUrl(String raw) { + this.raw = ValueUtils.value(raw); + } - public String getRaw() { - return raw; - } + public String getRaw() { + return raw; + } - public void setRaw(String raw) { - this.raw = ValueUtils.value(raw); - } + public void setRaw(String raw) { + this.raw = ValueUtils.value(raw); + } - public List getQueries() { - return queries; - } + public List getQueries() { + return queries; + } - public void setQueries(List queries) { - this.queries = queries; - } + public void setQueries(List queries) { + this.queries = queries; + } } diff --git a/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanUrlEncodedBody.java b/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanUrlEncodedBody.java index d07b170..f70d411 100644 --- a/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanUrlEncodedBody.java +++ b/components/fluent-openapi/src/main/java/io/fluent/postman/model/PostmanUrlEncodedBody.java @@ -7,57 +7,56 @@ @JsonIgnoreProperties(ignoreUnknown = true) public class PostmanUrlEncodedBody { - @JsonProperty("key") - private String key; + @JsonProperty("key") + private String key; - @JsonProperty("value") - private String value; + @JsonProperty("value") + private String value; - @JsonProperty("description") - private String description; + @JsonProperty("description") + private String description; - @JsonProperty("type") - private String type; + @JsonProperty("type") + private String type; - public PostmanUrlEncodedBody() { - } + public PostmanUrlEncodedBody() {} - public PostmanUrlEncodedBody(String key, String value, String description, String type) { - this.key = key; - this.value = value; - this.description = description; - this.type = type; - } + public PostmanUrlEncodedBody(String key, String value, String description, String type) { + this.key = key; + this.value = value; + this.description = description; + this.type = type; + } - public String getKey() { - return key; - } + public String getKey() { + return key; + } - public void setKey(String key) { - this.key = key; - } + public void setKey(String key) { + this.key = key; + } - public String getValue() { - return value; - } + public String getValue() { + return value; + } - public void setValue(String value) { - this.value = ValueUtils.value(value); - } + public void setValue(String value) { + this.value = ValueUtils.value(value); + } - public String getDescription() { - return description; - } + public String getDescription() { + return description; + } - public void setDescription(String description) { - this.description = description; - } + public void setDescription(String description) { + this.description = description; + } - public String getType() { - return type; - } + public String getType() { + return type; + } - public void setType(String type) { - this.type = type; - } + public void setType(String type) { + this.type = type; + } } diff --git a/components/fluent-openapi/src/main/java/io/fluent/postman/model/ResponseBodyMode.java b/components/fluent-openapi/src/main/java/io/fluent/postman/model/ResponseBodyMode.java index 12da053..f0a2922 100644 --- a/components/fluent-openapi/src/main/java/io/fluent/postman/model/ResponseBodyMode.java +++ b/components/fluent-openapi/src/main/java/io/fluent/postman/model/ResponseBodyMode.java @@ -1,31 +1,29 @@ package io.fluent.postman.model; - public enum ResponseBodyMode { + URL_ENCODED("urlencoded"), + FILE("file"), + RAW("raw"), + FORM_DATA("formdata"), + EMPTY("empty"); - URL_ENCODED("urlencoded"), - FILE("file"), - RAW("raw"), - FORM_DATA("formdata"), - EMPTY("empty"); - - private String mode; + private String mode; - ResponseBodyMode(String mode) { - this.mode = mode; - } + ResponseBodyMode(String mode) { + this.mode = mode; + } - public String getMode(){ - return this.mode; - } + public String getMode() { + return this.mode; + } - public static ResponseBodyMode from(String mode){ - for (ResponseBodyMode value : ResponseBodyMode.values()) { + public static ResponseBodyMode from(String mode) { + for (ResponseBodyMode value : ResponseBodyMode.values()) { - if(value.mode.equalsIgnoreCase(mode)){ - return value; - } + if (value.mode.equalsIgnoreCase(mode)) { + return value; } - throw new IllegalArgumentException("%s is not a valid mode".formatted(mode)); } -} \ No newline at end of file + throw new IllegalArgumentException("%s is not a valid mode".formatted(mode)); + } +} diff --git a/components/fluent-openapi/src/main/java/io/fluent/postman/package-info.java b/components/fluent-openapi/src/main/java/io/fluent/postman/package-info.java index 817610e..0f89527 100644 --- a/components/fluent-openapi/src/main/java/io/fluent/postman/package-info.java +++ b/components/fluent-openapi/src/main/java/io/fluent/postman/package-info.java @@ -1 +1 @@ -package io.fluent.postman; \ No newline at end of file +package io.fluent.postman; diff --git a/components/fluent-openapi/src/main/java/io/fluent/swagger/SwaggerParser.java b/components/fluent-openapi/src/main/java/io/fluent/swagger/SwaggerParser.java new file mode 100644 index 0000000..9aface7 --- /dev/null +++ b/components/fluent-openapi/src/main/java/io/fluent/swagger/SwaggerParser.java @@ -0,0 +1,13 @@ +package io.fluent.swagger; + +import io.swagger.v3.oas.models.OpenAPI; +import io.swagger.v3.parser.OpenAPIV3Parser; + +public class SwaggerParser { + private OpenAPIV3Parser parser = new OpenAPIV3Parser(); + + public OpenAPI toCollection(String swaggerUrl) { + + return parser.read(swaggerUrl); + } +} diff --git a/components/fluent-openapi/src/main/java/io/fluent/swagger/model/SwaggerApi.java b/components/fluent-openapi/src/main/java/io/fluent/swagger/model/SwaggerApi.java index 3b2e971..e09c9bf 100644 --- a/components/fluent-openapi/src/main/java/io/fluent/swagger/model/SwaggerApi.java +++ b/components/fluent-openapi/src/main/java/io/fluent/swagger/model/SwaggerApi.java @@ -1,18 +1,17 @@ package io.fluent.swagger.model; import cn.hutool.json.JSONObject; -import lombok.Data; - import java.util.List; +import lombok.Data; @Data public class SwaggerApi { - private String swagger; - private SwaggerInfo info; - private String host; - private String basePath; - private List schemes; - private List tags; - private JSONObject paths; - private JSONObject definitions; + private String swagger; + private SwaggerInfo info; + private String host; + private String basePath; + private List schemes; + private List tags; + private JSONObject paths; + private JSONObject definitions; } diff --git a/components/fluent-openapi/src/main/java/io/fluent/swagger/model/SwaggerInfo.java b/components/fluent-openapi/src/main/java/io/fluent/swagger/model/SwaggerInfo.java index 769fbbd..dfcde77 100644 --- a/components/fluent-openapi/src/main/java/io/fluent/swagger/model/SwaggerInfo.java +++ b/components/fluent-openapi/src/main/java/io/fluent/swagger/model/SwaggerInfo.java @@ -4,8 +4,8 @@ @Data public class SwaggerInfo { - private String version; - private String title; - private String description; - private String termsOfService; + private String version; + private String title; + private String description; + private String termsOfService; } diff --git a/components/fluent-openapi/src/main/java/io/fluent/swagger/model/SwaggerParameter.java b/components/fluent-openapi/src/main/java/io/fluent/swagger/model/SwaggerParameter.java index b3ecadb..3bca4ff 100644 --- a/components/fluent-openapi/src/main/java/io/fluent/swagger/model/SwaggerParameter.java +++ b/components/fluent-openapi/src/main/java/io/fluent/swagger/model/SwaggerParameter.java @@ -4,10 +4,10 @@ @Data public class SwaggerParameter { - private String name; - private String in; - private String description; - private Boolean required; - private String type; - private String format; + private String name; + private String in; + private String description; + private Boolean required; + private String type; + private String format; } diff --git a/components/fluent-openapi/src/main/java/io/fluent/swagger/model/SwaggerRequest.java b/components/fluent-openapi/src/main/java/io/fluent/swagger/model/SwaggerRequest.java index a25c728..3d77c2d 100644 --- a/components/fluent-openapi/src/main/java/io/fluent/swagger/model/SwaggerRequest.java +++ b/components/fluent-openapi/src/main/java/io/fluent/swagger/model/SwaggerRequest.java @@ -1,16 +1,15 @@ package io.fluent.swagger.model; -import lombok.Data; - import java.util.List; +import lombok.Data; @Data public class SwaggerRequest { - private List tags; - private String summary; - private String description; - private String operationId; - private List consumes; - private List produces; - private List parameters; + private List tags; + private String summary; + private String description; + private String operationId; + private List consumes; + private List produces; + private List parameters; } diff --git a/components/fluent-openapi/src/main/java/io/fluent/swagger/model/SwaggerTag.java b/components/fluent-openapi/src/main/java/io/fluent/swagger/model/SwaggerTag.java index 8052317..819d4c9 100644 --- a/components/fluent-openapi/src/main/java/io/fluent/swagger/model/SwaggerTag.java +++ b/components/fluent-openapi/src/main/java/io/fluent/swagger/model/SwaggerTag.java @@ -4,6 +4,6 @@ @Data public class SwaggerTag { - private String name; - private String description; + private String name; + private String description; } diff --git a/components/fluent-openapi/src/main/java/io/fluent/swagger/package-info.java b/components/fluent-openapi/src/main/java/io/fluent/swagger/package-info.java index 8fb262e..a344516 100644 --- a/components/fluent-openapi/src/main/java/io/fluent/swagger/package-info.java +++ b/components/fluent-openapi/src/main/java/io/fluent/swagger/package-info.java @@ -1 +1 @@ -package io.fluent.swagger; \ No newline at end of file +package io.fluent.swagger; diff --git a/components/fluent-openapi/src/main/java/io/fluent/utils/TypeUtils.java b/components/fluent-openapi/src/main/java/io/fluent/utils/TypeUtils.java index bf2c624..bd06037 100644 --- a/components/fluent-openapi/src/main/java/io/fluent/utils/TypeUtils.java +++ b/components/fluent-openapi/src/main/java/io/fluent/utils/TypeUtils.java @@ -5,83 +5,83 @@ public class TypeUtils { - public static boolean isLong(String value) { - if (isEmpty(value)) { - return false; - } - try { - Long.parseLong(value); - } catch (NumberFormatException e) { - return false; - } - return true; + public static boolean isLong(String value) { + if (isEmpty(value)) { + return false; } - - public static boolean isInteger(String value) { - if (isEmpty(value)) { - return false; - } - try { - Integer.parseInt(value); - } catch (NumberFormatException e) { - return false; - } - return true; + try { + Long.parseLong(value); + } catch (NumberFormatException e) { + return false; } + return true; + } - public static boolean isEmpty(String value) { - return value == null || "".equals(value); + public static boolean isInteger(String value) { + if (isEmpty(value)) { + return false; } - - public static boolean isEmpty(Collection collection) { - return collection == null || collection.size() == 0; + try { + Integer.parseInt(value); + } catch (NumberFormatException e) { + return false; } + return true; + } - public static boolean isEmpty(Map map) { - return map == null || map.size() == 0; - } + public static boolean isEmpty(String value) { + return value == null || "".equals(value); + } - public static boolean isEmpty(Object[] array) { - return array == null || array.length == 0; - } + public static boolean isEmpty(Collection collection) { + return collection == null || collection.size() == 0; + } - public static boolean isNotEmpty(String value) { - return !isEmpty(value); - } + public static boolean isEmpty(Map map) { + return map == null || map.size() == 0; + } - public static boolean isNotEmpty(Collection collection) { - return !isEmpty(collection); - } + public static boolean isEmpty(Object[] array) { + return array == null || array.length == 0; + } - public static boolean isNotEmpty(Map map) { - return !isEmpty(map); - } + public static boolean isNotEmpty(String value) { + return !isEmpty(value); + } - public static boolean isNotEmpty(Object[] array) { - return !isEmpty(array); - } + public static boolean isNotEmpty(Collection collection) { + return !isEmpty(collection); + } + + public static boolean isNotEmpty(Map map) { + return !isEmpty(map); + } + + public static boolean isNotEmpty(Object[] array) { + return !isEmpty(array); + } - public static String join(String[] strs, String joinChar) { - if (isNotEmpty(strs) && isNotEmpty(joinChar)) { - String result = ""; - for (String str : strs) { - result += str; - result += joinChar; - } - return result.substring(0, result.length() - joinChar.length()); - } - return ""; + public static String join(String[] strs, String joinChar) { + if (isNotEmpty(strs) && isNotEmpty(joinChar)) { + String result = ""; + for (String str : strs) { + result += str; + result += joinChar; + } + return result.substring(0, result.length() - joinChar.length()); } + return ""; + } - public static String join(Collection strs, String joinChar) { - if (isNotEmpty(strs) && isNotEmpty(joinChar)) { - String result = ""; - for (String str : strs) { - result += str; - result += joinChar; - } - return result.substring(0, result.length() - joinChar.length()); - } - return ""; + public static String join(Collection strs, String joinChar) { + if (isNotEmpty(strs) && isNotEmpty(joinChar)) { + String result = ""; + for (String str : strs) { + result += str; + result += joinChar; + } + return result.substring(0, result.length() - joinChar.length()); } + return ""; + } } diff --git a/components/fluent-openapi/src/main/java/io/fluent/utils/UrlUtils.java b/components/fluent-openapi/src/main/java/io/fluent/utils/UrlUtils.java index f932605..df59eab 100644 --- a/components/fluent-openapi/src/main/java/io/fluent/utils/UrlUtils.java +++ b/components/fluent-openapi/src/main/java/io/fluent/utils/UrlUtils.java @@ -6,74 +6,74 @@ import java.util.regex.Pattern; public class UrlUtils { - private static String URL_VARIABLE_PATTERN = "\\$\\{(.*?)}"; + private static String URL_VARIABLE_PATTERN = "\\$\\{(.*?)}"; - private static String URL_PARTITIONS_PATTERN = "^((http[s]?|ftp):\\/)?\\/?([^:\\/\\s]+)(:([^\\/]*))?((\\/?(?:[^\\/\\?#]+\\/+)*)([^\\?#]*))(\\?([^#]*))?(#(.*))?$"; + private static String URL_PARTITIONS_PATTERN = + "^((http[s]?|ftp):\\/)?\\/?([^:\\/\\s]+)(:([^\\/]*))?((\\/?(?:[^\\/\\?#]+\\/+)*)([^\\?#]*))(\\?([^#]*))?(#(.*))?$"; - private static Pattern pattern = Pattern.compile(URL_VARIABLE_PATTERN); + private static Pattern pattern = Pattern.compile(URL_VARIABLE_PATTERN); - private static Pattern urlPartitionPattern = Pattern.compile(URL_PARTITIONS_PATTERN); + private static Pattern urlPartitionPattern = Pattern.compile(URL_PARTITIONS_PATTERN); - - public static URL getUrl(String httpUrl) throws MalformedURLException { - if (!httpUrl.startsWith("http") && !httpUrl.startsWith("https")) { - httpUrl = "http://" + httpUrl; - } - return new URL(httpUrl); - } - - public static String getDomain(URL url) { - return url.getHost(); - } - - public static String getPath(URL url) { - String path = url.getPath(); - String queryString = url.getQuery(); - - if (TypeUtils.isNotEmpty(queryString)) { - path = path + "?" + queryString; - } - return path; + public static URL getUrl(String httpUrl) throws MalformedURLException { + if (!httpUrl.startsWith("http") && !httpUrl.startsWith("https")) { + httpUrl = "http://" + httpUrl; } + return new URL(httpUrl); + } - public static int getPort(URL url) { - return url.getPort(); - } + public static String getDomain(URL url) { + return url.getHost(); + } - public static String getProtocol(URL url) { - return url.getProtocol(); - } + public static String getPath(URL url) { + String path = url.getPath(); + String queryString = url.getQuery(); - public static boolean isVariableUrl(String url) { - Matcher matcher = pattern.matcher(url); - return matcher.find(); + if (TypeUtils.isNotEmpty(queryString)) { + path = path + "?" + queryString; } - - public static String getVariableUrl(String url) { - Matcher matcher = urlPartitionPattern.matcher(url); - matcher.matches(); - return matcher.group(3); - } - - public static String getVariablePath(String url) { - Matcher matcher = urlPartitionPattern.matcher(url); - matcher.matches(); - String path = matcher.group(6); - if (matcher.group(9) != null) { - path = path + matcher.group(9); - } - return path; - } - - public static String getVariableProtocol(String url) { - Matcher matcher = urlPartitionPattern.matcher(url); - matcher.matches(); - return matcher.group(2); - } - - public static int getVariablePort(String url) { - Matcher matcher = urlPartitionPattern.matcher(url); - matcher.matches(); - return matcher.group(5) != null ? Integer.valueOf(matcher.group(5)) : -1; + return path; + } + + public static int getPort(URL url) { + return url.getPort(); + } + + public static String getProtocol(URL url) { + return url.getProtocol(); + } + + public static boolean isVariableUrl(String url) { + Matcher matcher = pattern.matcher(url); + return matcher.find(); + } + + public static String getVariableUrl(String url) { + Matcher matcher = urlPartitionPattern.matcher(url); + matcher.matches(); + return matcher.group(3); + } + + public static String getVariablePath(String url) { + Matcher matcher = urlPartitionPattern.matcher(url); + matcher.matches(); + String path = matcher.group(6); + if (matcher.group(9) != null) { + path = path + matcher.group(9); } + return path; + } + + public static String getVariableProtocol(String url) { + Matcher matcher = urlPartitionPattern.matcher(url); + matcher.matches(); + return matcher.group(2); + } + + public static int getVariablePort(String url) { + Matcher matcher = urlPartitionPattern.matcher(url); + matcher.matches(); + return matcher.group(5) != null ? Integer.valueOf(matcher.group(5)) : -1; + } } diff --git a/components/fluent-openapi/src/test/java/io/fluent/postman/PostmanParserTest.java b/components/fluent-openapi/src/test/java/io/fluent/postman/PostmanParserTest.java index 0bfc13d..5568330 100644 --- a/components/fluent-openapi/src/test/java/io/fluent/postman/PostmanParserTest.java +++ b/components/fluent-openapi/src/test/java/io/fluent/postman/PostmanParserTest.java @@ -2,19 +2,17 @@ import cn.hutool.core.io.FileUtil; import io.fluent.postman.model.PostmanCollection; +import java.nio.charset.Charset; import org.assertj.core.api.Assertions; import org.junit.jupiter.api.Test; -import java.nio.charset.Charset; - - public class PostmanParserTest { PostmanParser parser = new PostmanParser(); @Test void toPostmanCollectionFromFile() { - String jsonString = FileUtil.readString("openproject-postman.json", Charset.defaultCharset()); - PostmanCollection pc = parser.toPostmanCollection(jsonString); + String jsonString = FileUtil.readString("openproject-postman.json", Charset.defaultCharset()); + PostmanCollection pc = parser.toPostmanCollection(jsonString); Assertions.assertThat(pc.getItem()).isNotNull(); - } -} \ No newline at end of file + } +} diff --git a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/QuickDao.java b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/QuickDao.java index a8ce57c..c9dd265 100644 --- a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/QuickDao.java +++ b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/QuickDao.java @@ -4,21 +4,17 @@ import cn.hutool.db.Db; import cn.hutool.db.Entity; import cn.hutool.setting.Setting; -import io.fluent.quickdao.entity.EntityUtil; -import io.fluent.quickdao.exceptions.DbExecutionFoundException; import io.fluent.quickdao.datasource.DataSourceCreator; import io.fluent.quickdao.datasource.model.DataSourceSetting; -import lombok.extern.slf4j.Slf4j; - -import javax.sql.DataSource; +import io.fluent.quickdao.entity.EntityUtil; +import io.fluent.quickdao.exceptions.DbExecutionFoundException; import java.sql.SQLException; -import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; -import java.util.function.Consumer; -import java.util.function.Function; import java.util.stream.Collectors; +import javax.sql.DataSource; +import lombok.extern.slf4j.Slf4j; @Slf4j public class QuickDao { @@ -26,27 +22,27 @@ public class QuickDao { Db db; DataSource ds; - - public static QuickDao createDao(T dsConfig){ - QuickDao dao = new QuickDao(); - dao.dsConfig = dsConfig; - dao.ds = DataSourceCreator.createDataSource(dsConfig); - dao.db = Db.use(dao.ds); - return dao; + public static QuickDao createDao(T dsConfig) { + QuickDao dao = new QuickDao(); + dao.dsConfig = dsConfig; + dao.ds = DataSourceCreator.createDataSource(dsConfig); + dao.db = Db.use(dao.ds); + return dao; } /** - * Create DAO From Setting files + * Create DAO From Setting files + * * @param settingPath * @return */ - public static QuickDao createDao(String settingPath){ - Setting setting = new Setting(settingPath); - setting.autoLoad(true); + public static QuickDao createDao(String settingPath) { + Setting setting = new Setting(settingPath); + setting.autoLoad(true); return buildDao(setting); } - public static QuickDao createDao(){ + public static QuickDao createDao() { Setting setting = new Setting(); setting.autoLoad(true); return buildDao(setting); @@ -59,82 +55,80 @@ private static QuickDao buildDao(Setting setting) { return dao; } - public Entity queryOne(String query,Object ...parameters){ + public Entity queryOne(String query, Object... parameters) { try { - return this.getDb().queryOne(query,parameters); + return this.getDb().queryOne(query, parameters); } catch (SQLException e) { throw new DbExecutionFoundException(e); } } - public List query(String query,Object ...parameters){ - try { - return this.getDb().query(query,parameters); - } catch (SQLException e) { - log.error("sql query error,error=",e); - return Collections.emptyList(); - } + + public List query(String query, Object... parameters) { + try { + return this.getDb().query(query, parameters); + } catch (SQLException e) { + log.error("sql query error,error=", e); + return Collections.emptyList(); + } } - public List query(String query, Map parameters){ + public List query(String query, Map parameters) { try { - return this.getDb().query(query,parameters); + return this.getDb().query(query, parameters); } catch (SQLException e) { - log.error("sql query error,error=",e); + log.error("sql query error,error=", e); return Collections.emptyList(); } } - public int execute(String query,Object ...parameters){ + + public int execute(String query, Object... parameters) { try { - return this.getDb().execute(query,parameters); + return this.getDb().execute(query, parameters); } catch (SQLException e) { throw new DbExecutionFoundException(e); } } - public void save(T entity,String tableName){ - Entity e = EntityUtil.convertToEntity(entity, tableName); - try { - db.insert(e); - } catch (SQLException ex) { - throw new DbExecutionFoundException(ex); - } + + public void save(T entity, String tableName) { + Entity e = EntityUtil.convertToEntity(entity, tableName); + try { + db.insert(e); + } catch (SQLException ex) { + throw new DbExecutionFoundException(ex); } + } - public void upsert(T entity, String tableName, String...uniqKeys){ - Entity e = EntityUtil.convertToEntity(entity, tableName); - try { - db.upsert(e,uniqKeys); - } catch (SQLException ex) { - throw new DbExecutionFoundException(ex); - } + public void upsert(T entity, String tableName, String... uniqKeys) { + Entity e = EntityUtil.convertToEntity(entity, tableName); + try { + db.upsert(e, uniqKeys); + } catch (SQLException ex) { + throw new DbExecutionFoundException(ex); } + } - public void saveOrUpdate(T entity,String tableName,String...findByKeys){ + public void saveOrUpdate(T entity, String tableName, String... findByKeys) { Entity e = EntityUtil.convertToEntity(entity, tableName); try { - db.insertOrUpdate(e,findByKeys); + db.insertOrUpdate(e, findByKeys); } catch (SQLException ex) { throw new DbExecutionFoundException(ex); } } public Db getDb() { - return db; + return db; + } + /** abstract to : 1. before sql action 2. sql action 3. after sql action */ + public List queryForObjects(String query, Map parameters, Class clazz) { + try { + var queryResult = this.getDb().query(query, parameters); + return queryResult.stream() + .map(entity -> BeanUtil.copyProperties(entity, clazz)) + .collect(Collectors.toList()); + } catch (SQLException e) { + log.error("sql query error,error=", e); + return Collections.emptyList(); } - /** - * abstract to : - * 1. before sql action - * 2. sql action - * 3. after sql action - */ - - public List queryForObjects(String query, Map parameters,Class clazz){ - try { - var queryResult = this.getDb().query(query,parameters); - return queryResult.stream().map(entity -> BeanUtil.copyProperties(entity,clazz)) - .collect(Collectors.toList()); - } catch (SQLException e) { - log.error("sql query error,error=",e); - return Collections.emptyList(); - } } } diff --git a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/annotations/QuickDaoColumn.java b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/annotations/QuickDaoColumn.java index a5dc908..74d7e1d 100644 --- a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/annotations/QuickDaoColumn.java +++ b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/annotations/QuickDaoColumn.java @@ -1,6 +1,5 @@ package io.fluent.quickdao.annotations; - import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -9,6 +8,5 @@ @Target({ElementType.FIELD, ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface QuickDaoColumn { - String name() default ""; - + String name() default ""; } diff --git a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/constants/DefaultConstants.java b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/constants/DefaultConstants.java index 2115263..8ab3d2d 100644 --- a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/constants/DefaultConstants.java +++ b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/constants/DefaultConstants.java @@ -1,6 +1,6 @@ package io.fluent.quickdao.constants; public class DefaultConstants { - public final static String POSTGRESQL="postgresql"; - public final static String DB_GROUP="database"; + public static final String POSTGRESQL = "postgresql"; + public static final String DB_GROUP = "database"; } diff --git a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/datasource/DataSourceCreator.java b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/datasource/DataSourceCreator.java index bc975f6..b8f0469 100644 --- a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/datasource/DataSourceCreator.java +++ b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/datasource/DataSourceCreator.java @@ -1,11 +1,9 @@ package io.fluent.quickdao.datasource; - import cn.hutool.core.util.StrUtil; import cn.hutool.db.ds.DSFactory; import cn.hutool.setting.Setting; import io.fluent.quickdao.datasource.model.DataSourceSetting; - import javax.sql.DataSource; public class DataSourceCreator { @@ -16,13 +14,12 @@ public static DataSource createDataSource(DataSourceSetting dsModel) { return factory.getDataSource(); } - private static String whichDriver(DataSourceSetting setting) { if (StrUtil.isNotEmpty(setting.getDriver())) return setting.getDriver(); return drivers.getDriverByDbType(setting.getDbType()); } - public static DataSource createDateSource(Setting setting){ + public static DataSource createDateSource(Setting setting) { return DSFactory.create(setting).getDataSource(); } } diff --git a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/datasource/DialectAndDrivers.java b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/datasource/DialectAndDrivers.java index 76008f3..8963685 100644 --- a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/datasource/DialectAndDrivers.java +++ b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/datasource/DialectAndDrivers.java @@ -1,56 +1,56 @@ package io.fluent.quickdao.datasource; - import cn.hutool.core.util.ReflectUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.db.dialect.DriverNamePool; import io.fluent.quickdao.exceptions.NoDbDriverFoundException; - import java.lang.reflect.Field; import java.util.Map; import java.util.Set; import java.util.concurrent.ConcurrentHashMap; - public class DialectAndDrivers { - private static Map DIALECT_DRIVER_MAPPING ; - private static String DEFAULT_DB_TYPE="postgresql".toUpperCase(); + private static Map DIALECT_DRIVER_MAPPING; + private static String DEFAULT_DB_TYPE = "postgresql".toUpperCase(); + static { DIALECT_DRIVER_MAPPING = getAllDialectDriverMapping(); } /** * Get All Dialect/DriverMapping + * * @return @Map */ public static Map getAllDialectDriverMapping() { Map fields = ReflectUtil.getFieldMap(DriverNamePool.class); Map result = new ConcurrentHashMap<>(); - fields.forEach((s, field) -> { - try { - result.put(s.replaceAll("DRIVER_",""), - (String) field.get(DriverNamePool.class)); - } catch (IllegalAccessException e) { - throw new RuntimeException(e); - } - }); + fields.forEach( + (s, field) -> { + try { + result.put(s.replaceAll("DRIVER_", ""), (String) field.get(DriverNamePool.class)); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + }); return result; } public String getDriverByDbType(String dbType) { String driver = DIALECT_DRIVER_MAPPING.get(dbType.toUpperCase()); - if(StrUtil.isEmpty(driver)){ - throw new NoDbDriverFoundException("%s is not found,please use driver in %s ".formatted(dbType,getAllDbType())); + if (StrUtil.isEmpty(driver)) { + throw new NoDbDriverFoundException( + "%s is not found,please use driver in %s ".formatted(dbType, getAllDbType())); } return driver; } - public void registerDbDriver(String dbType, String dbDriver){ - DIALECT_DRIVER_MAPPING.put(dbType,dbDriver); + public void registerDbDriver(String dbType, String dbDriver) { + DIALECT_DRIVER_MAPPING.put(dbType, dbDriver); } - public Set getAllDbType(){ + public Set getAllDbType() { return DIALECT_DRIVER_MAPPING.keySet(); } } diff --git a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/datasource/model/DataSourceSetting.java b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/datasource/model/DataSourceSetting.java index 5bf54fc..b4323c7 100644 --- a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/datasource/model/DataSourceSetting.java +++ b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/datasource/model/DataSourceSetting.java @@ -1,14 +1,13 @@ package io.fluent.quickdao.datasource.model; +import static io.fluent.quickdao.constants.DefaultConstants.POSTGRESQL; + import cn.hutool.core.lang.Dict; import cn.hutool.setting.Setting; +import java.util.Map; import lombok.Builder; import lombok.Data; -import java.util.Map; - -import static io.fluent.quickdao.constants.DefaultConstants.POSTGRESQL; - @Data @Builder public class DataSourceSetting extends Dict { @@ -16,8 +15,7 @@ public class DataSourceSetting extends Dict { private String username; private String password; private String driver; - @Builder.Default - private String dbType = POSTGRESQL; + @Builder.Default private String dbType = POSTGRESQL; public Setting toSetting() { Setting setting = Setting.create(); @@ -34,5 +32,4 @@ public Setting toSetting() { } return setting; } - } diff --git a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/datasource/model/TableColumn.java b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/datasource/model/TableColumn.java index 540ca1b..30cd4ef 100644 --- a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/datasource/model/TableColumn.java +++ b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/datasource/model/TableColumn.java @@ -4,11 +4,11 @@ @Data public class TableColumn { - private String columnName; - private String tableName; - private String tableComment; - private String dataType; - private String tableType; - private boolean isPk; - private String comments; + private String columnName; + private String tableName; + private String tableComment; + private String dataType; + private String tableType; + private boolean isPk; + private String comments; } diff --git a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/datasource/model/TableInfoQuery.java b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/datasource/model/TableInfoQuery.java index 4a5b88a..d4ed039 100644 --- a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/datasource/model/TableInfoQuery.java +++ b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/datasource/model/TableInfoQuery.java @@ -1,41 +1,40 @@ package io.fluent.quickdao.datasource.model; -import lombok.Builder; -import lombok.Data; - -import java.beans.ConstructorProperties; import java.util.*; +import lombok.Data; @Data public class TableInfoQuery { - private String tableInfoQuery; - private List paramList = new ArrayList<>(); - private Map parameters = new HashMap<>(); - public TableInfoQuery addParameter(String parameter){ - paramList.add(parameter); - return this; - } - public TableInfoQuery addQueryParameterValue(String parameter,String value){ - parameters.put(parameter, value); - return this; - } + private String tableInfoQuery; + private List paramList = new ArrayList<>(); + private Map parameters = new HashMap<>(); + + public TableInfoQuery addParameter(String parameter) { + paramList.add(parameter); + return this; + } - public static TableInfoQuery postgresqlTableInfoQuery(){ - TableInfoQuery query = new TableInfoQuery(); - query.setTableInfoQuery("SELECT c.table_name,c.column_name,\n" + - "\t\tc.udt_name data_type, t.table_type,\n" + - "\t\tcase when k.constraint_name is null then 0 else 1 end is_pk \n" + - "\tFROM information_schema.tables t join \n" + - "\t\tinformation_schema.columns c \n" + - "\t\t on t.table_name = c.table_name left join \n" + - "\t\tinformation_schema.key_column_usage k\n" + - "\t\t\ton c.table_name = k.table_name\n" + - "\t\t\tand c.column_name = k.column_name\n" + - "\t\t\tand RIGHT(constraint_name, 4) = 'pkey'\n" + - "\tWHERE c.table_schema = @schema\n" + - "\tORDER BY c.table_name, c.ordinal_position;\n"); - query.addParameter("scheme"); - return query; - } + public TableInfoQuery addQueryParameterValue(String parameter, String value) { + parameters.put(parameter, value); + return this; + } + public static TableInfoQuery postgresqlTableInfoQuery() { + TableInfoQuery query = new TableInfoQuery(); + query.setTableInfoQuery( + "SELECT c.table_name,c.column_name,\n" + + "\t\tc.udt_name data_type, t.table_type,\n" + + "\t\tcase when k.constraint_name is null then 0 else 1 end is_pk \n" + + "\tFROM information_schema.tables t join \n" + + "\t\tinformation_schema.columns c \n" + + "\t\t on t.table_name = c.table_name left join \n" + + "\t\tinformation_schema.key_column_usage k\n" + + "\t\t\ton c.table_name = k.table_name\n" + + "\t\t\tand c.column_name = k.column_name\n" + + "\t\t\tand RIGHT(constraint_name, 4) = 'pkey'\n" + + "\tWHERE c.table_schema = @schema\n" + + "\tORDER BY c.table_name, c.ordinal_position;\n"); + query.addParameter("scheme"); + return query; + } } diff --git a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/datasource/model/TableInfoQueryFinder.java b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/datasource/model/TableInfoQueryFinder.java index 3f65538..82de207 100644 --- a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/datasource/model/TableInfoQueryFinder.java +++ b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/datasource/model/TableInfoQueryFinder.java @@ -5,23 +5,22 @@ public class TableInfoQueryFinder { - private Map tableInfoQueries = new HashMap<>(); + private Map tableInfoQueries = new HashMap<>(); - public TableInfoQueryFinder() { - tableInfoQueries.put("postgresql", TableInfoQuery.postgresqlTableInfoQuery()); + public TableInfoQueryFinder() { + tableInfoQueries.put("postgresql", TableInfoQuery.postgresqlTableInfoQuery()); + } - } + public TableInfoQuery getTableInfoQuery(String dbType) { + return tableInfoQueries.get(dbType); + } - public TableInfoQuery getTableInfoQuery(String dbType) { - return tableInfoQueries.get(dbType); - } + public TableInfoQueryFinder register(String dbType, TableInfoQuery query) { + this.tableInfoQueries.put(dbType.toLowerCase(), query); + return this; + } - public TableInfoQueryFinder register(String dbType,TableInfoQuery query){ - this.tableInfoQueries.put(dbType.toLowerCase(),query); - return this; - } - - public TableInfoQuery find(String dbType){ - return this.tableInfoQueries.get(dbType.toLowerCase()); - } + public TableInfoQuery find(String dbType) { + return this.tableInfoQueries.get(dbType.toLowerCase()); + } } diff --git a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/entity/EntityUtil.java b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/entity/EntityUtil.java index 6d1514d..8e1b057 100644 --- a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/entity/EntityUtil.java +++ b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/entity/EntityUtil.java @@ -3,26 +3,25 @@ import cn.hutool.core.util.ReflectUtil; import cn.hutool.db.Entity; import io.fluent.quickdao.annotations.QuickDaoColumn; - import java.lang.reflect.Field; public class EntityUtil { - public static Entity convertToEntity(T entity, String tableName) { - if (entity instanceof Entity) { - ((Entity) entity).setTableName(tableName); - return (Entity) entity; - } - Entity e = Entity.create(tableName); - Field[] fields = ReflectUtil.getFields(entity.getClass()); - for (Field field : fields) { - QuickDaoColumn a = field.getDeclaredAnnotation(QuickDaoColumn.class); - if (a != null) { - e.set(a.name(), ReflectUtil.getFieldValue(entity, field)); - } else { - e.set(field.getName(), ReflectUtil.getFieldValue(entity, field)); - } - } - return e; + public static Entity convertToEntity(T entity, String tableName) { + if (entity instanceof Entity) { + ((Entity) entity).setTableName(tableName); + return (Entity) entity; + } + Entity e = Entity.create(tableName); + Field[] fields = ReflectUtil.getFields(entity.getClass()); + for (Field field : fields) { + QuickDaoColumn a = field.getDeclaredAnnotation(QuickDaoColumn.class); + if (a != null) { + e.set(a.name(), ReflectUtil.getFieldValue(entity, field)); + } else { + e.set(field.getName(), ReflectUtil.getFieldValue(entity, field)); + } } + return e; + } } diff --git a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/exceptions/DbExecutionFoundException.java b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/exceptions/DbExecutionFoundException.java index 3952392..ae8ba67 100644 --- a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/exceptions/DbExecutionFoundException.java +++ b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/exceptions/DbExecutionFoundException.java @@ -1,8 +1,7 @@ package io.fluent.quickdao.exceptions; -public class DbExecutionFoundException extends RuntimeException{ - public DbExecutionFoundException() { - } +public class DbExecutionFoundException extends RuntimeException { + public DbExecutionFoundException() {} public DbExecutionFoundException(String message) { super(message); @@ -16,7 +15,8 @@ public DbExecutionFoundException(Throwable cause) { super(cause); } - public DbExecutionFoundException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + public DbExecutionFoundException( + String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { super(message, cause, enableSuppression, writableStackTrace); } } diff --git a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/exceptions/NoDbDriverFoundException.java b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/exceptions/NoDbDriverFoundException.java index b93a36b..76c59c8 100644 --- a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/exceptions/NoDbDriverFoundException.java +++ b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/exceptions/NoDbDriverFoundException.java @@ -1,8 +1,7 @@ package io.fluent.quickdao.exceptions; -public class NoDbDriverFoundException extends RuntimeException{ - public NoDbDriverFoundException() { - } +public class NoDbDriverFoundException extends RuntimeException { + public NoDbDriverFoundException() {} public NoDbDriverFoundException(String message) { super(message); @@ -16,7 +15,8 @@ public NoDbDriverFoundException(Throwable cause) { super(cause); } - public NoDbDriverFoundException(String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { + public NoDbDriverFoundException( + String message, Throwable cause, boolean enableSuppression, boolean writableStackTrace) { super(message, cause, enableSuppression, writableStackTrace); } } diff --git a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/service/SqlExecuteResponse.java b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/service/SqlExecuteResponse.java index cea49a1..db0d4a3 100644 --- a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/service/SqlExecuteResponse.java +++ b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/service/SqlExecuteResponse.java @@ -7,5 +7,5 @@ @Builder public class SqlExecuteResponse { - private int count; + private int count; } diff --git a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/service/SqlQueryResponse.java b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/service/SqlQueryResponse.java index db2836e..8041680 100644 --- a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/service/SqlQueryResponse.java +++ b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/service/SqlQueryResponse.java @@ -1,15 +1,13 @@ package io.fluent.quickdao.service; import cn.hutool.db.Entity; +import java.util.List; import lombok.Builder; import lombok.Data; -import java.util.ArrayList; -import java.util.List; - @Data @Builder public class SqlQueryResponse { - private List result; + private List result; } diff --git a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/service/SqlRequest.java b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/service/SqlRequest.java index 9a15d5c..d16de0f 100644 --- a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/service/SqlRequest.java +++ b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/service/SqlRequest.java @@ -2,33 +2,32 @@ import cn.hutool.json.JSONUtil; import io.fluent.quickdao.datasource.model.DataSourceSetting; -import lombok.Data; - import java.util.List; import java.util.Map; +import lombok.Data; @Data public class SqlRequest { - private String sql; - private List paramValues; - private Map bindParamValues; - private DataSourceSetting dsConfig; + private String sql; + private List paramValues; + private Map bindParamValues; + private DataSourceSetting dsConfig; - public SqlRequest dsConfig(String configJson){ - DataSourceSetting setting = JSONUtil.toBean(configJson,DataSourceSetting.class); - this.setDsConfig(setting); - return this; - } + public SqlRequest dsConfig(String configJson) { + DataSourceSetting setting = JSONUtil.toBean(configJson, DataSourceSetting.class); + this.setDsConfig(setting); + return this; + } - public SqlRequest bindParameterValues(String parameterValues){ - Map parameters = JSONUtil.toBean(parameterValues,Map.class); - this.setBindParamValues(parameters); - return this; - } + public SqlRequest bindParameterValues(String parameterValues) { + Map parameters = JSONUtil.toBean(parameterValues, Map.class); + this.setBindParamValues(parameters); + return this; + } - public static SqlRequest createRequest(String sql){ - SqlRequest request = new SqlRequest(); - request.setSql(sql); - return request; - } + public static SqlRequest createRequest(String sql) { + SqlRequest request = new SqlRequest(); + request.setSql(sql); + return request; + } } diff --git a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/service/SqlService.java b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/service/SqlService.java index 625f19b..3ec251b 100644 --- a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/service/SqlService.java +++ b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/service/SqlService.java @@ -2,20 +2,19 @@ import cn.hutool.db.Entity; import io.fluent.quickdao.QuickDao; - import java.util.List; public class SqlService { - public SqlExecuteResponse execute(SqlRequest request) { - QuickDao dao = QuickDao.createDao(request.getDsConfig()); - int result = dao.execute(request.getSql(), request.getBindParamValues()); - return SqlExecuteResponse.builder().count(result).build(); - } + public SqlExecuteResponse execute(SqlRequest request) { + QuickDao dao = QuickDao.createDao(request.getDsConfig()); + int result = dao.execute(request.getSql(), request.getBindParamValues()); + return SqlExecuteResponse.builder().count(result).build(); + } - public SqlQueryResponse query(SqlRequest request) { - QuickDao dao = QuickDao.createDao(request.getDsConfig()); - List result = dao.query(request.getSql(), request.getBindParamValues()); - return SqlQueryResponse.builder().result(result).build(); - } + public SqlQueryResponse query(SqlRequest request) { + QuickDao dao = QuickDao.createDao(request.getDsConfig()); + List result = dao.query(request.getSql(), request.getBindParamValues()); + return SqlQueryResponse.builder().result(result).build(); + } } diff --git a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/service/package-info.java b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/service/package-info.java index b722d2b..3a25fce 100644 --- a/components/fluent-quickdao/src/main/java/io/fluent/quickdao/service/package-info.java +++ b/components/fluent-quickdao/src/main/java/io/fluent/quickdao/service/package-info.java @@ -1 +1 @@ -package io.fluent.quickdao.service; \ No newline at end of file +package io.fluent.quickdao.service; diff --git a/components/fluent-quickdao/src/test/java/io/fluent/quickdao/QuickDaoTest.java b/components/fluent-quickdao/src/test/java/io/fluent/quickdao/QuickDaoTest.java index 2334751..5c138ea 100644 --- a/components/fluent-quickdao/src/test/java/io/fluent/quickdao/QuickDaoTest.java +++ b/components/fluent-quickdao/src/test/java/io/fluent/quickdao/QuickDaoTest.java @@ -1,136 +1,130 @@ package io.fluent.quickdao; - -import cn.hutool.core.bean.BeanUtil; -import cn.hutool.core.bean.copier.CopyOptions; import cn.hutool.core.map.MapUtil; import cn.hutool.db.Entity; import cn.hutool.json.JSONUtil; import io.fluent.quickdao.datasource.model.DataSourceSetting; import io.fluent.quickdao.datasource.model.TableColumn; import io.fluent.quickdao.datasource.model.TableInfoQueryFinder; -import io.fluent.quickdao.entity.EntityUtil; import io.fluent.quickdao.service.SqlQueryResponse; import io.fluent.quickdao.service.SqlRequest; import io.fluent.quickdao.service.SqlService; -import org.junit.jupiter.api.Test; - import java.util.Map; - +import org.junit.jupiter.api.Test; public class QuickDaoTest { - DataSourceSetting setting = DataSourceSetting.builder(). - url("jdbc:sqlite:sample.db") -// url("jdbc:postgresql://127.0.0.1:7432/test_hub?currentSchema=demo") -// .driver("org.sqlite.JDBC.Driver") -// .username("postgres").password("changeit") - .build(); - QuickDao dao = QuickDao.createDao(setting); - - @Test - public void testQuery() { - var queryResult = dao.query("select * from hero"); - - for (Entity entity : queryResult) { - System.out.println(entity.keySet()); - System.out.println(entity.values()); - } - } - - @Test - public void testQueryWithParameters() { - var queryResult = dao.query("select * from hero where name=?", "test"); - for (Entity entity : queryResult) { - System.out.println(entity.keySet()); - System.out.println(entity.values()); - } - } - - @Test - public void testQueryWithBindParams() { - Map params = MapUtil.builder("name", (Object) "test2").build(); - var queryResult = dao.query("select * from hero where name=@name", - params); - for (Entity entity : queryResult) { - System.out.println(entity.keySet()); - System.out.println(entity.values()); - } - } - - @Test - public void testInsert() { - Entity e = Entity.create("hero").set("name", "test4").set("secret_name", 100); - dao.saveOrUpdate(e, "hero", "name"); + DataSourceSetting setting = + DataSourceSetting.builder() + .url("jdbc:sqlite:sample.db") + // url("jdbc:postgresql://127.0.0.1:7432/test_hub?currentSchema=demo") + // .driver("org.sqlite.JDBC.Driver") + // .username("postgres").password("changeit") + .build(); + QuickDao dao = QuickDao.createDao(setting); + + @Test + public void testQuery() { + var queryResult = dao.query("select * from hero"); + + for (Entity entity : queryResult) { + System.out.println(entity.keySet()); + System.out.println(entity.values()); } - - @Test - public void testUpsert() { - Entity e = Entity.create("hero").set("name", "test2") - .set("secret_name", "100").set("age", 100); - dao.upsert(e, "hero", "name"); //for upsert error - } - - @Test - public void testSaveOrInsert() { - Entity e = Entity.create("hero").set("name", "test4") - .set("secret_name", "100").set("age", 9000); - - dao.saveOrUpdate(e, "hero", "name", "secret_name"); //for upsert error + } + + @Test + public void testQueryWithParameters() { + var queryResult = dao.query("select * from hero where name=?", "test"); + for (Entity entity : queryResult) { + System.out.println(entity.keySet()); + System.out.println(entity.values()); } - - @Test - public void testSaveOrInsertEntity() { - Entity e = Entity.create("hero").set("name", "test4") - .set("secret_name", "100").set("age", 9000); - - HeroDemoEntity demoEntity = new HeroDemoEntity(); - demoEntity.setName("hero"); - demoEntity.setAge(10); - demoEntity.setSecret_name("secret_name"); - dao.saveOrUpdate(demoEntity, "hero"); - dao.saveOrUpdate(e, "hero", "name", "secret_name"); //for upsert error - } - - @Test - public void testExecute() { - int count = dao.execute("delete from hero where name='test2'"); - System.out.println(count); + } + + @Test + public void testQueryWithBindParams() { + Map params = MapUtil.builder("name", (Object) "test2").build(); + var queryResult = dao.query("select * from hero where name=@name", params); + for (Entity entity : queryResult) { + System.out.println(entity.keySet()); + System.out.println(entity.values()); } - - @Test - public void testDaoService() { - String connectConfig = "{\n" + - " \"url\" :\"jdbc:postgresql://127.0.0.1:7432/test_hub\",\n" + - " \"user\":\"postgres\",\n" + - " \"password\": \"password\"\n" + - "}"; - SqlRequest request = SqlRequest.createRequest("select * from data_sources where name=@name"); - String bindvalue = "{\n" + - "\"name\":\"本地测试环境\"\n" + - " }"; - request.bindParameterValues(bindvalue); - request.dsConfig(connectConfig); - SqlService service = new SqlService(); - SqlQueryResponse response = service.query(request); - System.out.println(JSONUtil.toJsonPrettyStr(response)); - } - - @Test - public void testGetColumnName() { - DataSourceSetting setting = DataSourceSetting.builder(). -// url("jdbc:sqlite:sample.db") - url("jdbc:postgresql://127.0.0.1:5432/qa") - .username("postgres").password("changeit") - .build(); - QuickDao dao = QuickDao.createDao(setting); - TableInfoQueryFinder finder = new TableInfoQueryFinder(); - var tableInfoQuery = finder.find(setting.getDbType()); - tableInfoQuery.addQueryParameterValue("schema", "workspace"); - - var results = dao.queryForObjects(tableInfoQuery.getTableInfoQuery(), - tableInfoQuery.getParameters(), TableColumn.class); - System.out.println(results); - - } - + } + + @Test + public void testInsert() { + Entity e = Entity.create("hero").set("name", "test4").set("secret_name", 100); + dao.saveOrUpdate(e, "hero", "name"); + } + + @Test + public void testUpsert() { + Entity e = Entity.create("hero").set("name", "test2").set("secret_name", "100").set("age", 100); + dao.upsert(e, "hero", "name"); // for upsert error + } + + @Test + public void testSaveOrInsert() { + Entity e = + Entity.create("hero").set("name", "test4").set("secret_name", "100").set("age", 9000); + + dao.saveOrUpdate(e, "hero", "name", "secret_name"); // for upsert error + } + + @Test + public void testSaveOrInsertEntity() { + Entity e = + Entity.create("hero").set("name", "test4").set("secret_name", "100").set("age", 9000); + + HeroDemoEntity demoEntity = new HeroDemoEntity(); + demoEntity.setName("hero"); + demoEntity.setAge(10); + demoEntity.setSecret_name("secret_name"); + dao.saveOrUpdate(demoEntity, "hero"); + dao.saveOrUpdate(e, "hero", "name", "secret_name"); // for upsert error + } + + @Test + public void testExecute() { + int count = dao.execute("delete from hero where name='test2'"); + System.out.println(count); + } + + @Test + public void testDaoService() { + String connectConfig = + "{\n" + + " \"url\" :\"jdbc:postgresql://127.0.0.1:7432/test_hub\",\n" + + " \"user\":\"postgres\",\n" + + " \"password\": \"password\"\n" + + "}"; + SqlRequest request = SqlRequest.createRequest("select * from data_sources where name=@name"); + String bindvalue = "{\n" + "\"name\":\"本地测试环境\"\n" + " }"; + request.bindParameterValues(bindvalue); + request.dsConfig(connectConfig); + SqlService service = new SqlService(); + SqlQueryResponse response = service.query(request); + System.out.println(JSONUtil.toJsonPrettyStr(response)); + } + + @Test + public void testGetColumnName() { + DataSourceSetting setting = + DataSourceSetting.builder() + . + // url("jdbc:sqlite:sample.db") + url("jdbc:postgresql://127.0.0.1:5432/qa") + .username("postgres") + .password("changeit") + .build(); + QuickDao dao = QuickDao.createDao(setting); + TableInfoQueryFinder finder = new TableInfoQueryFinder(); + var tableInfoQuery = finder.find(setting.getDbType()); + tableInfoQuery.addQueryParameterValue("schema", "workspace"); + + var results = + dao.queryForObjects( + tableInfoQuery.getTableInfoQuery(), tableInfoQuery.getParameters(), TableColumn.class); + System.out.println(results); + } } diff --git a/components/fluent-quickdao/src/test/java/io/fluent/quickdao/entity/EntityUtilTest.java b/components/fluent-quickdao/src/test/java/io/fluent/quickdao/entity/EntityUtilTest.java index e421562..48846d4 100644 --- a/components/fluent-quickdao/src/test/java/io/fluent/quickdao/entity/EntityUtilTest.java +++ b/components/fluent-quickdao/src/test/java/io/fluent/quickdao/entity/EntityUtilTest.java @@ -1,13 +1,9 @@ package io.fluent.quickdao.entity; - import org.junit.jupiter.api.Test; class EntityUtilTest { - @Test - public void testEntityUtils(){ - - - } -} \ No newline at end of file + @Test + public void testEntityUtils() {} +} diff --git a/components/fluent-quickdao/src/test/java/io/fluent/quickdao/entity/GithubStarredRepo.java b/components/fluent-quickdao/src/test/java/io/fluent/quickdao/entity/GithubStarredRepo.java index e717e1e..cf7389b 100644 --- a/components/fluent-quickdao/src/test/java/io/fluent/quickdao/entity/GithubStarredRepo.java +++ b/components/fluent-quickdao/src/test/java/io/fluent/quickdao/entity/GithubStarredRepo.java @@ -1,21 +1,19 @@ package io.fluent.quickdao.entity; - import lombok.Data; - @Data public class GithubStarredRepo { - private Long id; + private Long id; - private String name; - private String url; - private String fullName; + private String name; + private String url; + private String fullName; - private String nodeId; - private String description; - private int forkedCount; - private int stargazersCount; + private String nodeId; + private String description; + private int forkedCount; + private int stargazersCount; - private String topics ; + private String topics; } diff --git a/components/fluent-testlibs/pom.xml b/components/fluent-testlibs/pom.xml index 45cae27..a545b9f 100644 --- a/components/fluent-testlibs/pom.xml +++ b/components/fluent-testlibs/pom.xml @@ -18,6 +18,18 @@ 1.41.0 test + + org.quickperf + quick-perf-testng + 1.1.0 + test + + + org.quickperf + quick-perf-junit4 + 1.1.0 + test + io.vavr vavr diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/BooleanConverter.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/BooleanConverter.java index c119ea3..9e02764 100644 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/BooleanConverter.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/BooleanConverter.java @@ -1,17 +1,17 @@ package io.fluent.testlibs.datafactory.supplier.converters; -import java.lang.reflect.Type; - import static java.lang.Boolean.parseBoolean; +import java.lang.reflect.Type; + public class BooleanConverter extends DefaultConverter { - @Override - public Boolean convert(final String value) { - return parseBoolean(value); - } + @Override + public Boolean convert(final String value) { + return parseBoolean(value); + } - @Override - public Type getType() { - return Boolean.TYPE; - } + @Override + public Type getType() { + return Boolean.TYPE; + } } diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/DefaultConverter.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/DefaultConverter.java index ff6fc13..53588d4 100644 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/DefaultConverter.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/DefaultConverter.java @@ -3,15 +3,15 @@ import java.lang.reflect.Type; public abstract class DefaultConverter implements IConverter { - private final Type type; + private final Type type; - @SafeVarargs - protected DefaultConverter(final T... values) { - this.type = values.getClass().getComponentType(); - } + @SafeVarargs + protected DefaultConverter(final T... values) { + this.type = values.getClass().getComponentType(); + } - @Override - public Type getType() { - return type; - } + @Override + public Type getType() { + return type; + } } diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/DoubleConverter.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/DoubleConverter.java index aed3f65..4e530d1 100644 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/DoubleConverter.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/DoubleConverter.java @@ -1,22 +1,22 @@ package io.fluent.testlibs.datafactory.supplier.converters; -import io.vavr.control.Try; - -import java.lang.reflect.Type; - import static cn.hutool.core.util.NumberUtil.parseNumber; import static java.lang.String.format; +import io.vavr.control.Try; +import java.lang.reflect.Type; + public class DoubleConverter extends DefaultConverter { - @Override - public Double convert(final String value) { - return Try.of(() -> parseNumber(value)) - .map(Number::doubleValue) - .getOrElseThrow(ex -> new IllegalArgumentException(format("Cannot parse %s to double", value), ex)); - } + @Override + public Double convert(final String value) { + return Try.of(() -> parseNumber(value)) + .map(Number::doubleValue) + .getOrElseThrow( + ex -> new IllegalArgumentException(format("Cannot parse %s to double", value), ex)); + } - @Override - public Type getType() { - return Double.TYPE; - } + @Override + public Type getType() { + return Double.TYPE; + } } diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/IConverter.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/IConverter.java index 293d6c1..8cc5d53 100644 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/IConverter.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/IConverter.java @@ -3,11 +3,11 @@ import java.lang.reflect.Type; public interface IConverter { - T convert(String value); + T convert(String value); - Type getType(); + Type getType(); - default T convert(final String value, final String format) { - return convert(value); - } + default T convert(final String value, final String format) { + return convert(value); + } } diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/IntegerConverter.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/IntegerConverter.java index a00b444..6285cac 100644 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/IntegerConverter.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/IntegerConverter.java @@ -1,17 +1,17 @@ package io.fluent.testlibs.datafactory.supplier.converters; -import java.lang.reflect.Type; - import static java.lang.Integer.parseInt; +import java.lang.reflect.Type; + public class IntegerConverter extends DefaultConverter { - @Override - public Integer convert(final String value) { - return parseInt(value); - } + @Override + public Integer convert(final String value) { + return parseInt(value); + } - @Override - public Type getType() { - return Integer.TYPE; - } + @Override + public Type getType() { + return Integer.TYPE; + } } diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/LocalDateConverter.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/LocalDateConverter.java index fc6719e..ad11bc4 100644 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/LocalDateConverter.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/LocalDateConverter.java @@ -1,21 +1,22 @@ package io.fluent.testlibs.datafactory.supplier.converters; -import java.time.LocalDate; - import static java.time.LocalDate.parse; import static java.time.format.DateTimeFormatter.ofPattern; import static java.util.Optional.ofNullable; +import java.time.LocalDate; + public class LocalDateConverter extends DefaultConverter { - private static final String DEFAULT_FORMAT = "yyyy-MM-dd"; + private static final String DEFAULT_FORMAT = "yyyy-MM-dd"; - @Override - public LocalDate convert(final String value) { - return convert(value, DEFAULT_FORMAT); - } + @Override + public LocalDate convert(final String value) { + return convert(value, DEFAULT_FORMAT); + } - @Override - public LocalDate convert(final String value, final String format) { - return parse(value, ofPattern(ofNullable(format).filter(f -> !f.isEmpty()).orElse(DEFAULT_FORMAT))); - } + @Override + public LocalDate convert(final String value, final String format) { + return parse( + value, ofPattern(ofNullable(format).filter(f -> !f.isEmpty()).orElse(DEFAULT_FORMAT))); + } } diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/LocalDateTimeConverter.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/LocalDateTimeConverter.java index 14c5eba..a4805cb 100644 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/LocalDateTimeConverter.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/LocalDateTimeConverter.java @@ -1,21 +1,22 @@ package io.fluent.testlibs.datafactory.supplier.converters; -import java.time.LocalDateTime; - import static java.time.LocalDateTime.parse; import static java.time.format.DateTimeFormatter.ofPattern; import static java.util.Optional.ofNullable; +import java.time.LocalDateTime; + public class LocalDateTimeConverter extends DefaultConverter { - public static final String DEFAULT_FORMAT = "yyyy-MM-dd HH:mm:ss"; + public static final String DEFAULT_FORMAT = "yyyy-MM-dd HH:mm:ss"; - @Override - public LocalDateTime convert(final String value) { - return convert(value, DEFAULT_FORMAT); - } + @Override + public LocalDateTime convert(final String value) { + return convert(value, DEFAULT_FORMAT); + } - @Override - public LocalDateTime convert(final String value, final String format) { - return parse(value, ofPattern(ofNullable(format).filter(f -> !f.isEmpty()).orElse(DEFAULT_FORMAT))); - } + @Override + public LocalDateTime convert(final String value, final String format) { + return parse( + value, ofPattern(ofNullable(format).filter(f -> !f.isEmpty()).orElse(DEFAULT_FORMAT))); + } } diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/StringConverter.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/StringConverter.java index d95d9de..e83d844 100644 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/StringConverter.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/converters/StringConverter.java @@ -1,8 +1,8 @@ package io.fluent.testlibs.datafactory.supplier.converters; public class StringConverter extends DefaultConverter { - @Override - public String convert(final String value) { - return value; - } + @Override + public String convert(final String value) { + return value; + } } diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/core/DataProviderTransformer.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/core/DataProviderTransformer.java index 4b9617e..46c0c7a 100755 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/core/DataProviderTransformer.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/core/DataProviderTransformer.java @@ -1,85 +1,79 @@ package io.fluent.testlibs.datafactory.supplier.core; +import static io.fluent.testlibs.datafactory.supplier.utils.ReflectionUtils.getDataSupplierClass; +import static java.util.Objects.nonNull; import io.fluent.testlibs.datafactory.supplier.model.DataSupplierMetaData; import io.fluent.testlibs.datafactory.supplier.utils.ReflectionUtils; -import org.testng.*; -import org.testng.annotations.*; -import org.testng.internal.annotations.IDataProvidable; - import java.lang.reflect.Constructor; import java.lang.reflect.Method; import java.util.Iterator; +import org.testng.*; +import org.testng.annotations.*; +import org.testng.internal.annotations.IDataProvidable; -import static io.fluent.testlibs.datafactory.supplier.utils.ReflectionUtils.getDataSupplierClass; -import static java.util.Objects.nonNull; - -/** - * Core listener which transforms custom DataSupplier format to common TestNG DataProvider. - */ +/** Core listener which transforms custom DataSupplier format to common TestNG DataProvider. */ public class DataProviderTransformer implements IAnnotationTransformer { - @DataProvider - public Iterator supplySeqData(final ITestContext context, final ITestNGMethod testMethod) { - return getMetaData(context, testMethod).getTestData().iterator(); - } + @DataProvider + public Iterator supplySeqData( + final ITestContext context, final ITestNGMethod testMethod) { + return getMetaData(context, testMethod).getTestData().iterator(); + } - @DataProvider(parallel = true) - public Iterator supplyParallelData(final ITestContext context, final ITestNGMethod testMethod) { - return getMetaData(context, testMethod).getTestData().iterator(); - } + @DataProvider(parallel = true) + public Iterator supplyParallelData( + final ITestContext context, final ITestNGMethod testMethod) { + return getMetaData(context, testMethod).getTestData().iterator(); + } - @DataProvider(propagateFailureAsTestFailure = true) - public Iterator supplySeqDataWithErrorPropagation( - final ITestContext context, - final ITestNGMethod testMethod - ) { - return getMetaData(context, testMethod).getTestData().iterator(); - } + @DataProvider(propagateFailureAsTestFailure = true) + public Iterator supplySeqDataWithErrorPropagation( + final ITestContext context, final ITestNGMethod testMethod) { + return getMetaData(context, testMethod).getTestData().iterator(); + } - @DataProvider(parallel = true, propagateFailureAsTestFailure = true) - public Iterator supplyParallelDataWithErrorPropagation( - final ITestContext context, - final ITestNGMethod testMethod - ) { - return getMetaData(context, testMethod).getTestData().iterator(); - } + @DataProvider(parallel = true, propagateFailureAsTestFailure = true) + public Iterator supplyParallelDataWithErrorPropagation( + final ITestContext context, final ITestNGMethod testMethod) { + return getMetaData(context, testMethod).getTestData().iterator(); + } - @SuppressWarnings("unchecked") - @Override - public void transform( - final ITestAnnotation annotation, - final Class testClass, - final Constructor testConstructor, - final Method testMethod - ) { - assignCustomDataSupplier(annotation, testMethod, testClass); - } + @SuppressWarnings("unchecked") + @Override + public void transform( + final ITestAnnotation annotation, + final Class testClass, + final Constructor testConstructor, + final Method testMethod) { + assignCustomDataSupplier(annotation, testMethod, testClass); + } - @Override - public void transform(final IFactoryAnnotation annotation, final Method testMethod) { - assignCustomDataSupplier(annotation, testMethod, null); - } + @Override + public void transform(final IFactoryAnnotation annotation, final Method testMethod) { + assignCustomDataSupplier(annotation, testMethod, null); + } - private DataSupplierMetaData getMetaData(final ITestContext context, final ITestNGMethod testMethod) { - return new DataSupplierMetaData(context, testMethod); - } + private DataSupplierMetaData getMetaData( + final ITestContext context, final ITestNGMethod testMethod) { + return new DataSupplierMetaData(context, testMethod); + } - @SuppressWarnings("FinalLocalVariable") - private void assignCustomDataSupplier( - final IDataProvidable annotation, - final Method testMethod, - final Class testClass - ) { - var dataSupplierClass = getDataSupplierClass(annotation, testClass, testMethod); - var dataSupplierAnnotation = ReflectionUtils.getDataSupplierAnnotation(dataSupplierClass, annotation.getDataProvider()); + @SuppressWarnings("FinalLocalVariable") + private void assignCustomDataSupplier( + final IDataProvidable annotation, final Method testMethod, final Class testClass) { + var dataSupplierClass = getDataSupplierClass(annotation, testClass, testMethod); + var dataSupplierAnnotation = + ReflectionUtils.getDataSupplierAnnotation(dataSupplierClass, annotation.getDataProvider()); - if (!annotation.getDataProvider().isEmpty() && nonNull(dataSupplierAnnotation)) { - annotation.setDataProviderClass(getClass()); - var propagationSuffix = dataSupplierAnnotation.propagateTestFailure() ? "WithErrorPropagation" : ""; - var dataProviderName = - (dataSupplierAnnotation.runInParallel() ? "supplyParallelData" : "supplySeqData") + propagationSuffix; - annotation.setDataProvider(dataProviderName); - } + if (!annotation.getDataProvider().isEmpty() && nonNull(dataSupplierAnnotation)) { + annotation.setDataProviderClass(getClass()); + var propagationSuffix = + dataSupplierAnnotation.propagateTestFailure() ? "WithErrorPropagation" : ""; + var dataProviderName = + (dataSupplierAnnotation.runInParallel() ? "supplyParallelData" : "supplySeqData") + + propagationSuffix; + annotation.setDataProvider(dataProviderName); } + } } diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/core/DataSupplier.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/core/DataSupplier.java index 9f29691..2f1e92f 100644 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/core/DataSupplier.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/core/DataSupplier.java @@ -5,22 +5,20 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -/** - * Key annotation which replaces common DataProvider. - */ +/** Key annotation which replaces common DataProvider. */ @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.METHOD, ElementType.TYPE}) public @interface DataSupplier { - String name() default ""; + String name() default ""; - boolean transpose() default false; + boolean transpose() default false; - boolean flatMap() default false; + boolean flatMap() default false; - boolean runInParallel() default false; + boolean runInParallel() default false; - int[] indices() default {}; + int[] indices() default {}; - boolean propagateTestFailure() default false; + boolean propagateTestFailure() default false; } diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/core/DataSupplierAspect.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/core/DataSupplierAspect.java index 159d847..3c3dd2b 100644 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/core/DataSupplierAspect.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/core/DataSupplierAspect.java @@ -1,8 +1,13 @@ package io.fluent.testlibs.datafactory.supplier.core; +import static io.vavr.API.*; import io.fluent.testlibs.datafactory.supplier.model.DataSupplierMetaData; import io.fluent.testlibs.datafactory.supplier.utils.ServiceLoaderUtils; +import java.lang.reflect.Constructor; +import java.lang.reflect.Method; +import java.util.List; +import java.util.function.Consumer; import one.util.streamex.StreamEx; import org.aspectj.lang.JoinPoint; import org.aspectj.lang.ProceedingJoinPoint; @@ -14,85 +19,109 @@ import org.testng.ITestNGMethod; import org.testng.annotations.*; -import java.lang.reflect.Constructor; -import java.lang.reflect.Method; -import java.util.List; -import java.util.function.Consumer; - -import static io.vavr.API.*; - -/** - * Key aspect for DataSupplier interception. - */ +/** Key aspect for DataSupplier interception. */ @Aspect public class DataSupplierAspect { - private static final List DATA_SUPPLIERS = - ServiceLoaderUtils.load(DataSupplierInterceptor.class, DataSupplierAspect.class.getClassLoader()); - private static final List ANNOTATION_TRANSFORMERS = - ServiceLoaderUtils.load(IAnnotationTransformerInterceptor.class, DataSupplierAspect.class.getClassLoader()); + private static final List DATA_SUPPLIERS = + ServiceLoaderUtils.load( + DataSupplierInterceptor.class, DataSupplierAspect.class.getClassLoader()); + private static final List ANNOTATION_TRANSFORMERS = + ServiceLoaderUtils.load( + IAnnotationTransformerInterceptor.class, DataSupplierAspect.class.getClassLoader()); - @Before("execution(@org.testng.annotations.DataProvider * io.github.sskorol.core.DataProviderTransformer.*(..))") - public void beforeDataProviderCall(final JoinPoint joinPoint) { - DATA_SUPPLIERS.forEach(ds -> ds.beforeDataPreparation((ITestContext) joinPoint.getArgs()[0], - (ITestNGMethod) joinPoint.getArgs()[1])); - } + @Before( + "execution(@org.testng.annotations.DataProvider * io.github.sskorol.core.DataProviderTransformer.*(..))") + public void beforeDataProviderCall(final JoinPoint joinPoint) { + DATA_SUPPLIERS.forEach( + ds -> + ds.beforeDataPreparation( + (ITestContext) joinPoint.getArgs()[0], (ITestNGMethod) joinPoint.getArgs()[1])); + } - @After("execution(@org.testng.annotations.DataProvider * io.github.sskorol.core.DataProviderTransformer.*(..))") - public void afterDataProviderCall(final JoinPoint joinPoint) { - DATA_SUPPLIERS.forEach(ds -> ds.afterDataPreparation((ITestContext) joinPoint.getArgs()[0], - (ITestNGMethod) joinPoint.getArgs()[1])); - } + @After( + "execution(@org.testng.annotations.DataProvider * io.github.sskorol.core.DataProviderTransformer.*(..))") + public void afterDataProviderCall(final JoinPoint joinPoint) { + DATA_SUPPLIERS.forEach( + ds -> + ds.afterDataPreparation( + (ITestContext) joinPoint.getArgs()[0], (ITestNGMethod) joinPoint.getArgs()[1])); + } - @Around("execution(* io.github.sskorol.core.DataProviderTransformer.getMetaData(..))") - public DataSupplierMetaData onDataPreparation(final ProceedingJoinPoint joinPoint) throws Throwable { - final DataSupplierMetaData metaData = (DataSupplierMetaData) joinPoint.proceed(joinPoint.getArgs()); - DATA_SUPPLIERS.forEach(ds -> ds.onDataPreparation(metaData)); - return metaData; - } + @Around("execution(* io.github.sskorol.core.DataProviderTransformer.getMetaData(..))") + public DataSupplierMetaData onDataPreparation(final ProceedingJoinPoint joinPoint) + throws Throwable { + final DataSupplierMetaData metaData = + (DataSupplierMetaData) joinPoint.proceed(joinPoint.getArgs()); + DATA_SUPPLIERS.forEach(ds -> ds.onDataPreparation(metaData)); + return metaData; + } - @SuppressWarnings("unchecked") - @Before("execution(* io.github.sskorol.core.DataProviderTransformer.transform(..))") - public void beforeTransformationCall(final JoinPoint joinPoint) { - final Object[] args = joinPoint.getArgs(); + @SuppressWarnings("unchecked") + @Before("execution(* io.github.sskorol.core.DataProviderTransformer.transform(..))") + public void beforeTransformationCall(final JoinPoint joinPoint) { + final Object[] args = joinPoint.getArgs(); - Match(args[0]).of( - Case($(ITestAnnotation.class::isInstance), arg -> - run(() -> callTransformer(at -> at.transform( - (ITestAnnotation) arg, - (Class) args[1], (Constructor) args[2], - (Method) args[3])) - ) - ), - Case($(IFactoryAnnotation.class::isInstance), arg -> - run(() -> callTransformer(at -> at.transform((IFactoryAnnotation) arg, (Method) args[1])))), - Case($(IConfigurationAnnotation.class::isInstance), arg -> - run(() -> callTransformer(at -> at.transform( - (IConfigurationAnnotation) arg, - (Class) args[1], (Constructor) args[2], - (Method) args[3])) - ) - ), - Case($(IDataProviderAnnotation.class::isInstance), arg -> - run(() -> callTransformer(at -> at.transform( - (IDataProviderAnnotation) arg, - (Method) args[1])) - ) - ), - Case($(IListenersAnnotation.class::isInstance), arg -> - run(() -> callTransformer(at -> at.transform((IListenersAnnotation) arg, (Class) args[1])))) - ); - } + Match(args[0]) + .of( + Case( + $(ITestAnnotation.class::isInstance), + arg -> + run( + () -> + callTransformer( + at -> + at.transform( + (ITestAnnotation) arg, + (Class) args[1], + (Constructor) args[2], + (Method) args[3])))), + Case( + $(IFactoryAnnotation.class::isInstance), + arg -> + run( + () -> + callTransformer( + at -> at.transform((IFactoryAnnotation) arg, (Method) args[1])))), + Case( + $(IConfigurationAnnotation.class::isInstance), + arg -> + run( + () -> + callTransformer( + at -> + at.transform( + (IConfigurationAnnotation) arg, + (Class) args[1], + (Constructor) args[2], + (Method) args[3])))), + Case( + $(IDataProviderAnnotation.class::isInstance), + arg -> + run( + () -> + callTransformer( + at -> + at.transform( + (IDataProviderAnnotation) arg, (Method) args[1])))), + Case( + $(IListenersAnnotation.class::isInstance), + arg -> + run( + () -> + callTransformer( + at -> at.transform((IListenersAnnotation) arg, (Class) args[1]))))); + } - public static List getInterceptors() { - return DATA_SUPPLIERS; - } + public static List getInterceptors() { + return DATA_SUPPLIERS; + } - public static List getTransformers() { - return ANNOTATION_TRANSFORMERS; - } + public static List getTransformers() { + return ANNOTATION_TRANSFORMERS; + } - private static void callTransformer(final Consumer condition) { - StreamEx.of(ANNOTATION_TRANSFORMERS).forEach(condition); - } + private static void callTransformer(final Consumer condition) { + StreamEx.of(ANNOTATION_TRANSFORMERS).forEach(condition); + } } diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/core/DataSupplierInterceptor.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/core/DataSupplierInterceptor.java index f2dfc73..d13167a 100755 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/core/DataSupplierInterceptor.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/core/DataSupplierInterceptor.java @@ -1,30 +1,30 @@ package io.fluent.testlibs.datafactory.supplier.core; import io.fluent.testlibs.datafactory.supplier.model.DataSupplierMetaData; -import org.testng.ITestContext; -import org.testng.ITestNGMethod; - import java.util.Collection; import java.util.Collections; +import org.testng.ITestContext; +import org.testng.ITestNGMethod; /** - * A listener which allows retrieving useful meta-data. Should be implemented on client side, and linked via SPI. + * A listener which allows retrieving useful meta-data. Should be implemented on client side, and + * linked via SPI. */ public interface DataSupplierInterceptor { - default void beforeDataPreparation(final ITestContext context, final ITestNGMethod method) { - // not implemented - } + default void beforeDataPreparation(final ITestContext context, final ITestNGMethod method) { + // not implemented + } - default void afterDataPreparation(final ITestContext context, final ITestNGMethod method) { - // not implemented - } + default void afterDataPreparation(final ITestContext context, final ITestNGMethod method) { + // not implemented + } - default void onDataPreparation(final DataSupplierMetaData metaData) { - // not implemented - } + default void onDataPreparation(final DataSupplierMetaData metaData) { + // not implemented + } - default Collection getMetaData() { - return Collections.emptyList(); - } + default Collection getMetaData() { + return Collections.emptyList(); + } } diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/core/IAnnotationTransformerInterceptor.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/core/IAnnotationTransformerInterceptor.java index b0c9aa6..53f65f8 100644 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/core/IAnnotationTransformerInterceptor.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/core/IAnnotationTransformerInterceptor.java @@ -1,43 +1,40 @@ package io.fluent.testlibs.datafactory.supplier.core; -import org.testng.annotations.*; - import java.lang.reflect.Constructor; import java.lang.reflect.Method; +import org.testng.annotations.*; /** - * A listener which allows intercepting IAnnotationTransformer events. - * Should be implemented on client side, and linked via SPI. + * A listener which allows intercepting IAnnotationTransformer events. Should be implemented on + * client side, and linked via SPI. */ public interface IAnnotationTransformerInterceptor { - default void transform( - final ITestAnnotation annotation, - final Class testClass, - final Constructor testConstructor, - final Method testMethod - ) { - // not implemented - } - - default void transform(final IFactoryAnnotation annotation, final Method testMethod) { - // not implemented - } - - default void transform( - final IConfigurationAnnotation annotation, - final Class testClass, - final Constructor testConstructor, - final Method testMethod - ) { - // not implemented - } - - default void transform(final IDataProviderAnnotation annotation, final Method method) { - // not implemented - } - - default void transform(final IListenersAnnotation annotation, final Class testClass) { - // not implemented - } + default void transform( + final ITestAnnotation annotation, + final Class testClass, + final Constructor testConstructor, + final Method testMethod) { + // not implemented + } + + default void transform(final IFactoryAnnotation annotation, final Method testMethod) { + // not implemented + } + + default void transform( + final IConfigurationAnnotation annotation, + final Class testClass, + final Constructor testConstructor, + final Method testMethod) { + // not implemented + } + + default void transform(final IDataProviderAnnotation annotation, final Method method) { + // not implemented + } + + default void transform(final IListenersAnnotation annotation, final Class testClass) { + // not implemented + } } diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/Column.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/Column.java index 34c383c..f2efcc5 100644 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/Column.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/Column.java @@ -1,9 +1,6 @@ package io.fluent.testlibs.datafactory.supplier.data; - - import io.fluent.testlibs.datafactory.supplier.converters.StringConverter; - import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -12,9 +9,9 @@ @Target(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME) public @interface Column { - String name(); + String name(); - String format() default ""; + String format() default ""; - Class converter() default StringConverter.class; + Class converter() default StringConverter.class; } diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/CsvReader.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/CsvReader.java index cb69f0a..28f3446 100644 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/CsvReader.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/CsvReader.java @@ -1,50 +1,48 @@ package io.fluent.testlibs.datafactory.supplier.data; +import static java.lang.String.format; +import static org.apache.commons.csv.CSVFormat.Builder.create; +import static org.apache.commons.csv.CSVParser.parse; +import static org.joor.Reflect.onClass; + import io.fluent.testlibs.datafactory.supplier.utils.ReflectionUtils; +import java.io.IOException; +import java.nio.charset.StandardCharsets; import lombok.AllArgsConstructor; import lombok.Getter; import lombok.val; import one.util.streamex.StreamEx; -import org.apache.commons.csv.CSVFormat; - -import java.io.IOException; -import java.nio.charset.StandardCharsets; - -import static java.lang.String.format; -import static org.apache.commons.csv.CSVFormat.Builder.create; -import static org.apache.commons.csv.CSVParser.parse; -import static org.joor.Reflect.onClass; @AllArgsConstructor public class CsvReader implements DataReader { - @Getter - private final Class entityClass; - @Getter - private final String path; + @Getter private final Class entityClass; + @Getter private final String path; - public CsvReader(final Class entityClass) { - this(entityClass, ""); - } + public CsvReader(final Class entityClass) { + this(entityClass, ""); + } - @Override - public StreamEx read() { - try (val csvParser = parse( + @Override + public StreamEx read() { + try (val csvParser = + parse( getUrl(), StandardCharsets.UTF_8, - create().setHeader().setSkipHeaderRecord(true).setIgnoreHeaderCase(true).setTrim(true).build() - )) { - val entityFields = StreamEx.of(entityClass.getDeclaredFields()) - .map(ReflectionUtils::getFieldName) - .toList(); - return StreamEx.of(csvParser.getRecords()) - .map(csvRecord -> StreamEx.of(entityFields).map(csvRecord::get).toArray()) - .map(args -> onClass(entityClass).create(args).get()); - } catch (IOException ex) { - throw new IllegalArgumentException( - format("Unable to read CSV data to %s. Check provided path.", entityClass), - ex - ); - } + create() + .setHeader() + .setSkipHeaderRecord(true) + .setIgnoreHeaderCase(true) + .setTrim(true) + .build())) { + val entityFields = + StreamEx.of(entityClass.getDeclaredFields()).map(ReflectionUtils::getFieldName).toList(); + return StreamEx.of(csvParser.getRecords()) + .map(csvRecord -> StreamEx.of(entityFields).map(csvRecord::get).toArray()) + .map(args -> onClass(entityClass).create(args).get()); + } catch (IOException ex) { + throw new IllegalArgumentException( + format("Unable to read CSV data to %s. Check provided path.", entityClass), ex); } + } } diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/DataReader.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/DataReader.java index 11810ec..23e63e9 100644 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/DataReader.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/DataReader.java @@ -1,22 +1,20 @@ package io.fluent.testlibs.datafactory.supplier.data; -import one.util.streamex.StreamEx; +import static io.fluent.testlibs.datafactory.supplier.utils.ReflectionUtils.getSourcePath; import java.io.IOException; import java.net.URL; - -import static io.fluent.testlibs.datafactory.supplier.utils.ReflectionUtils.getSourcePath; - +import one.util.streamex.StreamEx; public interface DataReader { - StreamEx read(); + StreamEx read(); - Class getEntityClass(); + Class getEntityClass(); - String getPath(); + String getPath(); - default URL getUrl() throws IOException { - return getPath().isEmpty() ? getSourcePath(getEntityClass()) : getSourcePath(getPath()); - } + default URL getUrl() throws IOException { + return getPath().isEmpty() ? getSourcePath(getEntityClass()) : getSourcePath(getPath()); + } } diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/FieldName.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/FieldName.java index bfa9a5e..cafc29b 100644 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/FieldName.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/FieldName.java @@ -6,11 +6,12 @@ import java.lang.annotation.Target; /** - * Use this annotation to specify CSV field's name. Just to avoid breaking Java fields name convention. + * Use this annotation to specify CSV field's name. Just to avoid breaking Java fields name + * convention. */ @Target(ElementType.FIELD) @Retention(RetentionPolicy.RUNTIME) public @interface FieldName { - String value(); + String value(); } diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/JsonReader.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/JsonReader.java index e3bb78b..584c822 100644 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/JsonReader.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/JsonReader.java @@ -1,43 +1,44 @@ package io.fluent.testlibs.datafactory.supplier.data; +import static com.google.gson.JsonParser.parseReader; +import static io.vavr.API.*; +import static java.lang.String.format; + import com.google.gson.Gson; import com.google.gson.JsonElement; import io.fluent.testlibs.datafactory.supplier.utils.ReflectionUtils; -import lombok.AllArgsConstructor; -import lombok.Getter; -import one.util.streamex.StreamEx; - import java.io.IOException; import java.io.InputStreamReader; import java.nio.charset.StandardCharsets; - -import static com.google.gson.JsonParser.parseReader; -import static io.vavr.API.*; -import static java.lang.String.format; +import lombok.AllArgsConstructor; +import lombok.Getter; +import one.util.streamex.StreamEx; @AllArgsConstructor public class JsonReader implements DataReader { - @Getter - private final Class entityClass; - @Getter - private final String path; + @Getter private final Class entityClass; + @Getter private final String path; - public JsonReader(final Class entityClass) { - this(entityClass, ""); - } + public JsonReader(final Class entityClass) { + this(entityClass, ""); + } - public StreamEx read() { - var gson = new Gson(); - try (var streamReader = new InputStreamReader(getUrl().openStream(), StandardCharsets.UTF_8); - var jsonReader = new com.google.gson.stream.JsonReader(streamReader)) { - return Match(parseReader(jsonReader)).of( - Case($(JsonElement::isJsonArray), j -> StreamEx.of(gson.fromJson(j, ReflectionUtils.castToArray(entityClass)))), - Case($(), j -> StreamEx.of(gson.fromJson(j, ReflectionUtils.castToObject(entityClass)))) - ); - } catch (IOException ex) { - throw new IllegalArgumentException( - format("Unable to read JSON data to %s. Check provided path.", entityClass), ex); - } + public StreamEx read() { + var gson = new Gson(); + try (var streamReader = new InputStreamReader(getUrl().openStream(), StandardCharsets.UTF_8); + var jsonReader = new com.google.gson.stream.JsonReader(streamReader)) { + return Match(parseReader(jsonReader)) + .of( + Case( + $(JsonElement::isJsonArray), + j -> StreamEx.of(gson.fromJson(j, ReflectionUtils.castToArray(entityClass)))), + Case( + $(), + j -> StreamEx.of(gson.fromJson(j, ReflectionUtils.castToObject(entityClass))))); + } catch (IOException ex) { + throw new IllegalArgumentException( + format("Unable to read JSON data to %s. Check provided path.", entityClass), ex); } + } } diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/Sheet.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/Sheet.java index 237729b..b2287d6 100644 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/Sheet.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/Sheet.java @@ -5,12 +5,10 @@ import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -/** - * Use this annotation to provide Excel sheet name. If none is specified hte first one is used. - */ +/** Use this annotation to provide Excel sheet name. If none is specified hte first one is used. */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface Sheet { - String name(); + String name(); } diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/Source.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/Source.java index 7284141..c51b569 100644 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/Source.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/Source.java @@ -6,12 +6,12 @@ import java.lang.annotation.Target; /** - * Use this annotation to provide CSV / JSON source path. Note that local path should be relative to resources folder. - * As an alternative you can provide a URL. + * Use this annotation to provide CSV / JSON source path. Note that local path should be relative to + * resources folder. As an alternative you can provide a URL. */ @Target(ElementType.TYPE) @Retention(RetentionPolicy.RUNTIME) public @interface Source { - String path(); + String path(); } diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/TestDataReader.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/TestDataReader.java index 6d0992e..a231307 100644 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/TestDataReader.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/TestDataReader.java @@ -1,57 +1,58 @@ package io.fluent.testlibs.datafactory.supplier.data; -import lombok.AllArgsConstructor; -import one.util.streamex.StreamEx; +import static org.joor.Reflect.onClass; import java.util.Objects; - -import static org.joor.Reflect.onClass; +import lombok.AllArgsConstructor; +import one.util.streamex.StreamEx; /** - * Generic structure for reading test data in JSON, CSV and YAML formats. Each format has it's own implementation, - * which should be passed to {@link #use(Class)} method. + * Generic structure for reading test data in JSON, CSV and YAML formats. Each format has it's own + * implementation, which should be passed to {@link #use(Class)} method. + * *

{@code
  * use(CsvReader.class).withTarget(User.class).withSource("users.csv").read();
  * use(YamlReader.class).withTarget(TravisConfiguration.class).read();
  * use(JsonReader.class).withTarget(Animal.class).withSource("http://animals.json").read();
  * }
- * Please note that {@link io.github.sskorol.data.TestDataReader.DataBuilder#withSource(String)} is optional. But if - * it's skipped, you have to use {@link Source} annotation to define source path. + * + * Please note that {@link io.github.sskorol.data.TestDataReader.DataBuilder#withSource(String)} is + * optional. But if it's skipped, you have to use {@link Source} annotation to define source path. * * @param {@link DataReader} implementation class. */ @AllArgsConstructor public class TestDataReader> { - private final Class dataReaderClass; + private final Class dataReaderClass; - public static > TestDataReader use(final Class dataReaderClass) { - return new TestDataReader<>(dataReaderClass); - } + public static > TestDataReader use(final Class dataReaderClass) { + return new TestDataReader<>(dataReaderClass); + } - public DataBuilder withTarget(final Class entityClass) { - return new DataBuilder<>(dataReaderClass, entityClass); - } + public DataBuilder withTarget(final Class entityClass) { + return new DataBuilder<>(dataReaderClass, entityClass); + } - public static class DataBuilder { + public static class DataBuilder { - private final Class dataReaderClass; - private final Class entityClass; - private String path; + private final Class dataReaderClass; + private final Class entityClass; + private String path; - public DataBuilder(final Class dataReaderClass, final Class entityClass) { - this.dataReaderClass = dataReaderClass; - this.entityClass = entityClass; - } + public DataBuilder(final Class dataReaderClass, final Class entityClass) { + this.dataReaderClass = dataReaderClass; + this.entityClass = entityClass; + } - public DataBuilder withSource(final String path) { - this.path = path; - return this; - } + public DataBuilder withSource(final String path) { + this.path = path; + return this; + } - public StreamEx read() { - var args = StreamEx.of(entityClass, path).filter(Objects::nonNull).toArray(); - return onClass(dataReaderClass).create(args).call("read").get(); - } + public StreamEx read() { + var args = StreamEx.of(entityClass, path).filter(Objects::nonNull).toArray(); + return onClass(dataReaderClass).create(args).call("read").get(); } + } } diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/XlsxCellMapper.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/XlsxCellMapper.java index 9a21f9d..14a5643 100644 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/XlsxCellMapper.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/XlsxCellMapper.java @@ -1,83 +1,88 @@ package io.fluent.testlibs.datafactory.supplier.data; -import io.fluent.testlibs.datafactory.supplier.converters.IConverter; -import one.util.streamex.StreamEx; -import org.apache.poi.ss.usermodel.DataFormatter; -import org.apache.poi.ss.usermodel.Row; +import static java.lang.String.format; +import static java.util.Optional.ofNullable; +import static org.apache.poi.ss.usermodel.Row.MissingCellPolicy.RETURN_BLANK_AS_NULL; +import static org.joor.Reflect.on; +import static org.joor.Reflect.onClass; +import io.fluent.testlibs.datafactory.supplier.converters.IConverter; import java.lang.reflect.Field; import java.lang.reflect.Type; import java.util.List; import java.util.Map; import java.util.Optional; - -import static java.lang.String.format; -import static java.util.Optional.ofNullable; -import static org.apache.poi.ss.usermodel.Row.MissingCellPolicy.RETURN_BLANK_AS_NULL; -import static org.joor.Reflect.on; -import static org.joor.Reflect.onClass; +import one.util.streamex.StreamEx; +import org.apache.poi.ss.usermodel.DataFormatter; +import org.apache.poi.ss.usermodel.Row; public class XlsxCellMapper { - private final int index; - private final Field field; - private final IConverter converter; - private final DataFormatter formatter; - private final List> defaultIConverters; + private final int index; + private final Field field; + private final IConverter converter; + private final DataFormatter formatter; + private final List> defaultIConverters; - private T convertedValue; + private T convertedValue; - public XlsxCellMapper( - final Field field, - final Map headers, - final List> defaultIConverters - ) { - this.field = field; - this.defaultIConverters = defaultIConverters; - this.index = getColumn() + public XlsxCellMapper( + final Field field, + final Map headers, + final List> defaultIConverters) { + this.field = field; + this.defaultIConverters = defaultIConverters; + this.index = + getColumn() .map(Column::name) .filter(headers::containsKey) .map(headers::get) - .orElseThrow(() -> new IllegalArgumentException(format("Column %s not found", field.getName()))); - this.converter = findMatchingConverter(); - this.formatter = new DataFormatter(); - } + .orElseThrow( + () -> new IllegalArgumentException(format("Column %s not found", field.getName()))); + this.converter = findMatchingConverter(); + this.formatter = new DataFormatter(); + } - public XlsxCellMapper parse(final Row row) { - var cellValue = ofNullable(row.getCell(index, RETURN_BLANK_AS_NULL)) + public XlsxCellMapper parse(final Row row) { + var cellValue = + ofNullable(row.getCell(index, RETURN_BLANK_AS_NULL)) .map(cell -> formatter.formatCellValue(cell).trim()) .orElse(""); - this.convertedValue = converter.convert(cellValue, getColumn().map(Column::format).orElse("")); - return this; - } + this.convertedValue = converter.convert(cellValue, getColumn().map(Column::format).orElse("")); + return this; + } - public void assignValue(final R instance) { - ofNullable(convertedValue) - .ifPresent(value -> on(instance).set(getFieldName(), value)); - } + public void assignValue(final R instance) { + ofNullable(convertedValue).ifPresent(value -> on(instance).set(getFieldName(), value)); + } - private String getFieldName() { - return field.getName(); - } + private String getFieldName() { + return field.getName(); + } - private Type getFieldType() { - return field.getType(); - } + private Type getFieldType() { + return field.getType(); + } - private Optional getColumn() { - return ofNullable(field.getDeclaredAnnotation(Column.class)); - } + private Optional getColumn() { + return ofNullable(field.getDeclaredAnnotation(Column.class)); + } - @SuppressWarnings("unchecked") - private IConverter findMatchingConverter() { - return getColumn() - .map(Column::converter) - .map(converterClass -> (IConverter) onClass(converterClass).create().get()) - .filter(converterInstance -> converterInstance.getType().equals(getFieldType())) - .orElseGet(() -> StreamEx.of(defaultIConverters) - .findFirst(converterInstance -> converterInstance.getType().equals(getFieldType())) - .orElseThrow(() -> new IllegalStateException(format( - "There's no matching converter found for %s field of type %s", getFieldName(), getFieldType())) - ) - ); - } + @SuppressWarnings("unchecked") + private IConverter findMatchingConverter() { + return getColumn() + .map(Column::converter) + .map(converterClass -> (IConverter) onClass(converterClass).create().get()) + .filter(converterInstance -> converterInstance.getType().equals(getFieldType())) + .orElseGet( + () -> + StreamEx.of(defaultIConverters) + .findFirst( + converterInstance -> converterInstance.getType().equals(getFieldType())) + .orElseThrow( + () -> + new IllegalStateException( + format( + "There's no matching converter found for %s field of type %s", + getFieldName(), getFieldType())))); + } } diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/XlsxReader.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/XlsxReader.java index b361db1..f6f7820 100644 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/XlsxReader.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/XlsxReader.java @@ -1,86 +1,88 @@ package io.fluent.testlibs.datafactory.supplier.data; +import static java.lang.String.format; +import static java.util.Optional.ofNullable; +import static org.joor.Reflect.onClass; + import io.fluent.testlibs.datafactory.supplier.converters.*; import io.fluent.testlibs.datafactory.supplier.converters.IConverter; +import java.util.*; import lombok.Getter; import one.util.streamex.StreamEx; import org.apache.poi.ss.usermodel.*; -import java.util.*; - -import static java.lang.String.format; -import static java.util.Optional.ofNullable; -import static org.joor.Reflect.onClass; - public class XlsxReader implements DataReader { - @Getter - private final Class entityClass; - @Getter - private final String path; - private final List> defaultIConverters; - - public XlsxReader(final Class entityClass, final String path) { - this.entityClass = entityClass; - this.path = path; - this.defaultIConverters = defaultConverters(); + @Getter private final Class entityClass; + @Getter private final String path; + private final List> defaultIConverters; + + public XlsxReader(final Class entityClass, final String path) { + this.entityClass = entityClass; + this.path = path; + this.defaultIConverters = defaultConverters(); + } + + public XlsxReader(final Class entityClass) { + this(entityClass, ""); + } + + @SuppressWarnings("unchecked") + public static List> defaultConverters() { + return StreamEx.of( + BooleanConverter.class, + StringConverter.class, + IntegerConverter.class, + DoubleConverter.class, + LocalDateConverter.class, + LocalDateTimeConverter.class) + .map(cls -> (IConverter) onClass(cls).create().get()) + .toList(); + } + + public StreamEx read() { + try (var workbook = WorkbookFactory.create(getUrl().openStream())) { + var formatter = new DataFormatter(); + var startIndex = 0; + var skip = 1; + + var sheet = + ofNullable(entityClass.getDeclaredAnnotation(Sheet.class)) + .map(annotation -> workbook.getSheet(annotation.name())) + .orElse(workbook.getSheetAt(startIndex)); + + var headers = + StreamEx.of(sheet.getRow(startIndex).cellIterator()) + .toMap(cell -> formatter.formatCellValue(cell).trim(), Cell::getColumnIndex); + + var cellMappers = + StreamEx.of(entityClass.getDeclaredFields()) + .map(field -> new XlsxCellMapper<>(field, headers, defaultIConverters)) + .toList(); + + return StreamEx.of(sheet.iterator()) + .skip(skip) + .map(row -> StreamEx.of(cellMappers).map(cellMapper -> cellMapper.parse(row)).toList()) + .map(this::initEntity); + } catch (Exception ex) { + throw new IllegalArgumentException( + format("Unable to read XLSX data to %s.", entityClass), ex); } + } - public XlsxReader(final Class entityClass) { - this(entityClass, ""); - } - - @SuppressWarnings("unchecked") - public static List> defaultConverters() { - return StreamEx.of( - BooleanConverter.class, - StringConverter.class, - IntegerConverter.class, - DoubleConverter.class, - LocalDateConverter.class, - LocalDateTimeConverter.class - ) - .map(cls -> (IConverter) onClass(cls).create().get()) - .toList(); - } - - public StreamEx read() { - try (var workbook = WorkbookFactory.create(getUrl().openStream())) { - var formatter = new DataFormatter(); - var startIndex = 0; - var skip = 1; - - var sheet = ofNullable(entityClass.getDeclaredAnnotation(Sheet.class)) - .map(annotation -> workbook.getSheet(annotation.name())) - .orElse(workbook.getSheetAt(startIndex)); - - var headers = StreamEx.of(sheet.getRow(startIndex).cellIterator()) - .toMap(cell -> formatter.formatCellValue(cell).trim(), Cell::getColumnIndex); - - var cellMappers = StreamEx.of(entityClass.getDeclaredFields()) - .map(field -> new XlsxCellMapper<>(field, headers, defaultIConverters)) - .toList(); - - return StreamEx.of(sheet.iterator()) - .skip(skip) - .map(row -> StreamEx.of(cellMappers).map(cellMapper -> cellMapper.parse(row)).toList()) - .map(this::initEntity); - } catch (Exception ex) { - throw new IllegalArgumentException(format("Unable to read XLSX data to %s.", entityClass), ex); - } - } - - @SuppressWarnings("unchecked") - public T initEntity(final List> mappers) { - var hasDefaultConstructor = StreamEx.of(entityClass.getDeclaredConstructors()) + @SuppressWarnings("unchecked") + public T initEntity(final List> mappers) { + var hasDefaultConstructor = + StreamEx.of(entityClass.getDeclaredConstructors()) .anyMatch(constructor -> constructor.getParameterCount() == 0); - if (!hasDefaultConstructor) { - throw new IllegalStateException(format("%s must have default constructor.", entityClass.getSimpleName())); - } + if (!hasDefaultConstructor) { + throw new IllegalStateException( + format("%s must have default constructor.", entityClass.getSimpleName())); + } - var entity = (T) onClass(entityClass).create().get(); - StreamEx.of(mappers).forEach(mapper -> mapper.assignValue(entity)); + var entity = (T) onClass(entityClass).create().get(); + StreamEx.of(mappers).forEach(mapper -> mapper.assignValue(entity)); - return entity; - } + return entity; + } } diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/YamlReader.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/YamlReader.java index 8f4059e..64596dd 100644 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/YamlReader.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/data/YamlReader.java @@ -1,37 +1,35 @@ package io.fluent.testlibs.datafactory.supplier.data; +import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES; +import static java.lang.String.format; + import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.dataformat.yaml.YAMLFactory; import lombok.AllArgsConstructor; import lombok.Getter; import one.util.streamex.StreamEx; -import static com.fasterxml.jackson.databind.DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES; -import static java.lang.String.format; - @AllArgsConstructor public class YamlReader implements DataReader { - @Getter - private final Class entityClass; - @Getter - private final String path; + @Getter private final Class entityClass; + @Getter private final String path; - public YamlReader(final Class entityClass) { - this(entityClass, ""); - } + public YamlReader(final Class entityClass) { + this(entityClass, ""); + } - public StreamEx read() { - try { - var yamlFactory = new YAMLFactory(); - return StreamEx.of( - new ObjectMapper(yamlFactory) - .configure(FAIL_ON_UNKNOWN_PROPERTIES, false) - .readValues(yamlFactory.createParser(getUrl()), entityClass) - .readAll() - ); - } catch (Exception ex) { - throw new IllegalArgumentException(format("Unable to read YAML data to %s.", entityClass), ex); - } + public StreamEx read() { + try { + var yamlFactory = new YAMLFactory(); + return StreamEx.of( + new ObjectMapper(yamlFactory) + .configure(FAIL_ON_UNKNOWN_PROPERTIES, false) + .readValues(yamlFactory.createParser(getUrl()), entityClass) + .readAll()); + } catch (Exception ex) { + throw new IllegalArgumentException( + format("Unable to read YAML data to %s.", entityClass), ex); } + } } diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/model/DataSupplierMetaData.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/model/DataSupplierMetaData.java index e4ed066..c54b719 100755 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/model/DataSupplierMetaData.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/model/DataSupplierMetaData.java @@ -1,75 +1,73 @@ package io.fluent.testlibs.datafactory.supplier.model; +import static io.fluent.testlibs.datafactory.supplier.utils.ReflectionUtils.invokeDataSupplier; +import static io.fluent.testlibs.datafactory.supplier.utils.ReflectionUtils.streamOf; +import static java.util.Collections.singletonList; +import static java.util.Optional.ofNullable; +import io.fluent.testlibs.datafactory.supplier.core.DataSupplier; import io.fluent.testlibs.datafactory.supplier.utils.ReflectionUtils; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Objects; import lombok.Getter; import one.util.streamex.EntryStream; import one.util.streamex.IntStreamEx; import org.testng.ITestContext; import org.testng.ITestNGMethod; -import java.util.Collection; -import java.util.List; -import java.util.Map; -import java.util.Objects; -import io.fluent.testlibs.datafactory.supplier.core.DataSupplier; - -import static io.fluent.testlibs.datafactory.supplier.utils.ReflectionUtils.invokeDataSupplier; -import static io.fluent.testlibs.datafactory.supplier.utils.ReflectionUtils.streamOf; -import static java.util.Collections.singletonList; -import static java.util.Optional.ofNullable; - -/** - * Base container for DataSupplier meta data. - */ +/** Base container for DataSupplier meta data. */ public class DataSupplierMetaData { - @Getter - private final List testData; - private final boolean transpose; - private final boolean flatMap; - private final int[] indices; - @Getter - private final TestNGMethod testNGMethod; - - public DataSupplierMetaData(final ITestContext context, final ITestNGMethod testMethod) { - this.testNGMethod = new TestNGMethod(context, testMethod); - this.transpose = testNGMethod.getDataSupplierArg(DataSupplier::transpose, false); - this.flatMap = testNGMethod.getDataSupplierArg(DataSupplier::flatMap, false); - this.indices = testNGMethod.getDataSupplierArg(DataSupplier::indices, new int[0]); - this.testData = transform(); - } + @Getter private final List testData; + private final boolean transpose; + private final boolean flatMap; + private final int[] indices; + @Getter private final TestNGMethod testNGMethod; - private List transform() { - var returnValue = obtainReturnValue(); - var data = streamOf(returnValue).toList(); - var indicesList = indicesList(data.size()); - var wrappedReturnValue = EntryStream.of(data).filterKeys(indicesList::contains).values(); + public DataSupplierMetaData(final ITestContext context, final ITestNGMethod testMethod) { + this.testNGMethod = new TestNGMethod(context, testMethod); + this.transpose = testNGMethod.getDataSupplierArg(DataSupplier::transpose, false); + this.flatMap = testNGMethod.getDataSupplierArg(DataSupplier::flatMap, false); + this.indices = testNGMethod.getDataSupplierArg(DataSupplier::indices, new int[0]); + this.testData = transform(); + } - if (transpose) { - if (returnValue instanceof Collection || returnValue instanceof Map) { - return singletonList(flatMap ? wrappedReturnValue.toArray() : new Object[]{returnValue}); - } - return singletonList( - flatMap - ? wrappedReturnValue.filter(Objects::nonNull).flatMap(ReflectionUtils::streamOf).toArray() - : wrappedReturnValue.toArray() - ); - } + private List transform() { + var returnValue = obtainReturnValue(); + var data = streamOf(returnValue).toList(); + var indicesList = indicesList(data.size()); + var wrappedReturnValue = EntryStream.of(data).filterKeys(indicesList::contains).values(); - return wrappedReturnValue.map(ob -> flatMap ? streamOf(ob).toArray() : new Object[]{ob}).toList(); + if (transpose) { + if (returnValue instanceof Collection || returnValue instanceof Map) { + return singletonList(flatMap ? wrappedReturnValue.toArray() : new Object[] {returnValue}); + } + return singletonList( + flatMap + ? wrappedReturnValue + .filter(Objects::nonNull) + .flatMap(ReflectionUtils::streamOf) + .toArray() + : wrappedReturnValue.toArray()); } - private Object obtainReturnValue() { - return invokeDataSupplier(testNGMethod.getDataSupplierMetaData()); - } + return wrappedReturnValue + .map(ob -> flatMap ? streamOf(ob).toArray() : new Object[] {ob}) + .toList(); + } - private List indicesList(final int collectionSize) { - return ofNullable(indices) - .filter(indicesArray -> indicesArray.length > 0) - .map(IntStreamEx::of) - .orElseGet(() -> IntStreamEx.range(0, collectionSize)) - .boxed() - .toList(); - } + private Object obtainReturnValue() { + return invokeDataSupplier(testNGMethod.getDataSupplierMetaData()); + } + + private List indicesList(final int collectionSize) { + return ofNullable(indices) + .filter(indicesArray -> indicesArray.length > 0) + .map(IntStreamEx::of) + .orElseGet(() -> IntStreamEx.range(0, collectionSize)) + .boxed() + .toList(); + } } diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/model/TestNGMethod.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/model/TestNGMethod.java index 7e61df3..6d5d374 100644 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/model/TestNGMethod.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/model/TestNGMethod.java @@ -1,47 +1,51 @@ package io.fluent.testlibs.datafactory.supplier.model; +import static io.fluent.testlibs.datafactory.supplier.utils.ReflectionUtils.findDataSupplier; +import static io.vavr.API.*; +import static java.util.Arrays.stream; +import static java.util.Optional.ofNullable; + import io.fluent.testlibs.datafactory.supplier.core.DataSupplier; import io.vavr.Tuple; import io.vavr.Tuple2; -import org.testng.ITestContext; -import org.testng.ITestNGMethod; - import java.lang.reflect.Method; import java.util.function.Function; +import org.testng.ITestContext; +import org.testng.ITestNGMethod; -import static io.fluent.testlibs.datafactory.supplier.utils.ReflectionUtils.findDataSupplier; -import static io.vavr.API.*; -import static java.util.Arrays.stream; -import static java.util.Optional.ofNullable; - -/** - * Internal entity required for storing TestNG meta data retrieved from listeners. - */ +/** Internal entity required for storing TestNG meta data retrieved from listeners. */ public class TestNGMethod { - private final ITestNGMethod testMethod; - private final Method dataSupplierMethod; - private final ITestContext context; - private final DataSupplier dataSupplier; - - public TestNGMethod(final ITestContext context, final ITestNGMethod testMethod) { - this.context = context; - this.testMethod = testMethod; - this.dataSupplierMethod = findDataSupplier(testMethod); - this.dataSupplier = dataSupplierMethod.getDeclaredAnnotation(DataSupplier.class); - } - - public T getDataSupplierArg(final Function mapper, final T other) { - return ofNullable(dataSupplier).map(mapper).orElse(other); - } - - public Tuple2 getDataSupplierMetaData() { - return Tuple.of(dataSupplierMethod, stream(dataSupplierMethod.getParameterTypes()) - .map(t -> Match((Class) t).of( - Case($(ITestContext.class), () -> context), - Case($(Method.class), () -> testMethod.getConstructorOrMethod().getMethod()), - Case($(ITestNGMethod.class), () -> testMethod), - Case($(), () -> null))) + private final ITestNGMethod testMethod; + private final Method dataSupplierMethod; + private final ITestContext context; + private final DataSupplier dataSupplier; + + public TestNGMethod(final ITestContext context, final ITestNGMethod testMethod) { + this.context = context; + this.testMethod = testMethod; + this.dataSupplierMethod = findDataSupplier(testMethod); + this.dataSupplier = dataSupplierMethod.getDeclaredAnnotation(DataSupplier.class); + } + + public T getDataSupplierArg(final Function mapper, final T other) { + return ofNullable(dataSupplier).map(mapper).orElse(other); + } + + public Tuple2 getDataSupplierMetaData() { + return Tuple.of( + dataSupplierMethod, + stream(dataSupplierMethod.getParameterTypes()) + .map( + t -> + Match((Class) t) + .of( + Case($(ITestContext.class), () -> context), + Case( + $(Method.class), + () -> testMethod.getConstructorOrMethod().getMethod()), + Case($(ITestNGMethod.class), () -> testMethod), + Case($(), () -> null))) .toArray()); - } + } } diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/model/TypeMappings.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/model/TypeMappings.java index 5b0080e..b0dcd81 100644 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/model/TypeMappings.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/model/TypeMappings.java @@ -1,40 +1,36 @@ package io.fluent.testlibs.datafactory.supplier.model; import io.vavr.Tuple; -import lombok.AllArgsConstructor; -import one.util.streamex.*; - import java.util.AbstractMap; import java.util.Collection; import java.util.Map; import java.util.function.Function; import java.util.stream.Stream; +import lombok.AllArgsConstructor; +import one.util.streamex.*; -/** - * Internal structure for handling type transformations. - */ +/** Internal structure for handling type transformations. */ @AllArgsConstructor public enum TypeMappings { + COLLECTION(Collection.class, d -> StreamEx.of((Collection) d)), + MAP(Map.class, d -> EntryStream.of((Map) d).mapKeyValue(AbstractMap.SimpleEntry::new)), + ENTRY(Map.Entry.class, d -> StreamEx.of(((Map.Entry) d).getKey(), ((Map.Entry) d).getValue())), + OBJECT_ARRAY(Object[].class, d -> StreamEx.of((Object[]) d)), + DOUBLE_ARRAY(double[].class, d -> DoubleStreamEx.of((double[]) d).boxed()), + INT_ARRAY(int[].class, d -> IntStreamEx.of((int[]) d).boxed()), + LONG_ARRAY(long[].class, d -> LongStreamEx.of((long[]) d).boxed()), + STREAM(Stream.class, d -> StreamEx.of((Stream) d)), + TUPLE(Tuple.class, d -> StreamEx.of(((Tuple) d).toSeq().toJavaArray())); - COLLECTION(Collection.class, d -> StreamEx.of((Collection) d)), - MAP(Map.class, d -> EntryStream.of((Map) d).mapKeyValue(AbstractMap.SimpleEntry::new)), - ENTRY(Map.Entry.class, d -> StreamEx.of(((Map.Entry) d).getKey(), ((Map.Entry) d).getValue())), - OBJECT_ARRAY(Object[].class, d -> StreamEx.of((Object[]) d)), - DOUBLE_ARRAY(double[].class, d -> DoubleStreamEx.of((double[]) d).boxed()), - INT_ARRAY(int[].class, d -> IntStreamEx.of((int[]) d).boxed()), - LONG_ARRAY(long[].class, d -> LongStreamEx.of((long[]) d).boxed()), - STREAM(Stream.class, d -> StreamEx.of((Stream) d)), - TUPLE(Tuple.class, d -> StreamEx.of(((Tuple) d).toSeq().toJavaArray())); - - private final Class typeClass; - private final Function> mapper; + private final Class typeClass; + private final Function> mapper; - public boolean isInstanceOf(final Object ob) { - return ob != null && typeClass.isAssignableFrom(ob.getClass()); - } + public boolean isInstanceOf(final Object ob) { + return ob != null && typeClass.isAssignableFrom(ob.getClass()); + } - @SuppressWarnings("unchecked") - public StreamEx streamOf(final T ob) { - return (StreamEx) mapper.apply(ob); - } + @SuppressWarnings("unchecked") + public StreamEx streamOf(final T ob) { + return (StreamEx) mapper.apply(ob); + } } diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/utils/ReflectionUtils.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/utils/ReflectionUtils.java index ed10681..5f4cd80 100644 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/utils/ReflectionUtils.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/utils/ReflectionUtils.java @@ -1,5 +1,10 @@ package io.fluent.testlibs.datafactory.supplier.utils; +import static java.lang.ClassLoader.getSystemResource; +import static java.util.Objects.isNull; +import static java.util.Objects.nonNull; +import static java.util.Optional.ofNullable; +import static org.joor.Reflect.onClass; import io.fluent.testlibs.datafactory.supplier.core.DataSupplier; import io.fluent.testlibs.datafactory.supplier.data.FieldName; @@ -8,15 +13,6 @@ import io.vavr.Tuple; import io.vavr.Tuple2; import io.vavr.control.Try; -import lombok.experimental.UtilityClass; - -import one.util.streamex.StreamEx; -import org.reflections.Reflections; -import org.testng.ITestNGMethod; -import org.testng.annotations.Factory; -import org.testng.annotations.Test; -import org.testng.internal.annotations.IDataProvidable; - import java.io.IOException; import java.lang.reflect.Array; import java.lang.reflect.Field; @@ -25,160 +21,169 @@ import java.util.Objects; import java.util.function.Function; import java.util.function.Predicate; +import lombok.experimental.UtilityClass; +import one.util.streamex.StreamEx; +import org.reflections.Reflections; +import org.testng.ITestNGMethod; +import org.testng.annotations.Factory; +import org.testng.annotations.Test; +import org.testng.internal.annotations.IDataProvidable; -import static java.lang.ClassLoader.getSystemResource; -import static java.util.Objects.isNull; -import static java.util.Objects.nonNull; -import static java.util.Optional.ofNullable; -import static org.joor.Reflect.onClass; - -/** - * An utility class for internal DataSupplier management. - */ +/** An utility class for internal DataSupplier management. */ @SuppressWarnings("FinalLocalVariable") @UtilityClass public class ReflectionUtils { - @SuppressWarnings("unchecked") - public static Class getDataSupplierClass( - final IDataProvidable annotation, - final Class testClass, - final Method testMethod - ) { - return ofNullable(annotation.getDataProviderClass()) - .map(Class.class::cast) - .orElseGet(() -> findParentDataSupplierClass(testMethod, testClass)); - } - - public static Method getDataSupplierMethod(final Class targetClass, final String targetMethodName) { - var methodMetaData = StreamEx.of(targetClass.getMethods()) + @SuppressWarnings("unchecked") + public static Class getDataSupplierClass( + final IDataProvidable annotation, final Class testClass, final Method testMethod) { + return ofNullable(annotation.getDataProviderClass()) + .map(Class.class::cast) + .orElseGet(() -> findParentDataSupplierClass(testMethod, testClass)); + } + + public static Method getDataSupplierMethod( + final Class targetClass, final String targetMethodName) { + var methodMetaData = + StreamEx.of(targetClass.getMethods()) .map(method -> Tuple.of(method, method.getDeclaredAnnotation(DataSupplier.class))) .filter(hasDataSupplierMethod(targetMethodName)) .map(metaData -> Tuple.of(metaData._1.getName(), metaData._1.getParameterTypes())) .findFirst() .orElseGet(() -> Tuple.of(targetMethodName, new Class[0])); - return Try.of(() -> targetClass.getMethod(methodMetaData._1, methodMetaData._2)).get(); - } - - public static DataSupplier getDataSupplierAnnotation(final Class targetClass, final String targetMethodName) { - return Try.of(() -> getDataSupplierMethod(targetClass, targetMethodName)) - .map(method -> method.getDeclaredAnnotation(DataSupplier.class)) - .filter(Objects::nonNull) - .getOrElse((DataSupplier) null); - } - - public static Object invokeDataSupplier(final Tuple2 methodMetaData) { - return onClass(methodMetaData._1.getDeclaringClass()) - .create() - .call(methodMetaData._1.getName(), methodMetaData._2) - .get(); - } - - public static Method findDataSupplier(final ITestNGMethod testMethod) { - var annotationMetaData = testMethod.isTest() - ? getTestAnnotationMetaData(testMethod) - : getFactoryAnnotationMetaData(testMethod); - return getDataSupplierMethod(annotationMetaData._1, annotationMetaData._2); - } - - @SuppressWarnings("unchecked") - public static Class castToArray(final Class entityClass) { - return (Class) (entityClass.isArray() ? entityClass : Array.newInstance(entityClass, 1).getClass()); - } - - @SuppressWarnings("unchecked") - public static Class castToObject(final Class entityClass) { - return (Class) (entityClass.isArray() ? entityClass.getComponentType() : entityClass); - } - - public static String getFieldName(final Field field) { - var fieldAnnotation = field.getDeclaredAnnotation(FieldName.class); - return isNull(fieldAnnotation) ? field.getName() : fieldAnnotation.value(); - } - - public static URL getSourcePath(final Class entity) throws IOException { - return getSourcePath( - ofNullable(entity.getDeclaredAnnotation(Source.class)) - .map(Source::path) - .orElse("") - ); - } - - public static URL getSourcePath(final String path) throws IOException { - return ofNullable(Try.of(() -> new URL(path)).getOrElseGet(ex -> getSystemResource(path))) - .orElseThrow(() -> new IOException("Unable to access resource specified by " + path + " path")); - } - - public static StreamEx streamOf(final T data) { - if (isNull(data)) { - throw new IllegalArgumentException("Nothing to return from data supplier. Test will be skipped."); - } - - return StreamEx.of(TypeMappings.values()) - .findFirst(type -> type.isInstanceOf(data)) - .map(type -> type.streamOf(data)) - .orElseGet(() -> StreamEx.of(data)); - } - - @SuppressWarnings("unchecked") - private static Tuple2, String> getTestAnnotationMetaData(final ITestNGMethod testMethod) { - var declaringClass = testMethod.getConstructorOrMethod().getDeclaringClass(); - var parentClass = findParentDataSupplierClass(testMethod.getConstructorOrMethod().getMethod(), declaringClass); - var testAnnotation = ofNullable( - testMethod.getConstructorOrMethod() - .getMethod() - .getDeclaredAnnotation(Test.class) - ).orElseGet(() -> declaringClass.getDeclaredAnnotation(Test.class)); - var dataSupplierClass = ofNullable(testAnnotation) + return Try.of(() -> targetClass.getMethod(methodMetaData._1, methodMetaData._2)).get(); + } + + public static DataSupplier getDataSupplierAnnotation( + final Class targetClass, final String targetMethodName) { + return Try.of(() -> getDataSupplierMethod(targetClass, targetMethodName)) + .map(method -> method.getDeclaredAnnotation(DataSupplier.class)) + .filter(Objects::nonNull) + .getOrElse((DataSupplier) null); + } + + public static Object invokeDataSupplier(final Tuple2 methodMetaData) { + return onClass(methodMetaData._1.getDeclaringClass()) + .create() + .call(methodMetaData._1.getName(), methodMetaData._2) + .get(); + } + + public static Method findDataSupplier(final ITestNGMethod testMethod) { + var annotationMetaData = + testMethod.isTest() + ? getTestAnnotationMetaData(testMethod) + : getFactoryAnnotationMetaData(testMethod); + return getDataSupplierMethod(annotationMetaData._1, annotationMetaData._2); + } + + @SuppressWarnings("unchecked") + public static Class castToArray(final Class entityClass) { + return (Class) + (entityClass.isArray() ? entityClass : Array.newInstance(entityClass, 1).getClass()); + } + + @SuppressWarnings("unchecked") + public static Class castToObject(final Class entityClass) { + return (Class) (entityClass.isArray() ? entityClass.getComponentType() : entityClass); + } + + public static String getFieldName(final Field field) { + var fieldAnnotation = field.getDeclaredAnnotation(FieldName.class); + return isNull(fieldAnnotation) ? field.getName() : fieldAnnotation.value(); + } + + public static URL getSourcePath(final Class entity) throws IOException { + return getSourcePath( + ofNullable(entity.getDeclaredAnnotation(Source.class)).map(Source::path).orElse("")); + } + + public static URL getSourcePath(final String path) throws IOException { + return ofNullable(Try.of(() -> new URL(path)).getOrElseGet(ex -> getSystemResource(path))) + .orElseThrow( + () -> new IOException("Unable to access resource specified by " + path + " path")); + } + + public static StreamEx streamOf(final T data) { + if (isNull(data)) { + throw new IllegalArgumentException( + "Nothing to return from data supplier. Test will be skipped."); + } + + return StreamEx.of(TypeMappings.values()) + .findFirst(type -> type.isInstanceOf(data)) + .map(type -> type.streamOf(data)) + .orElseGet(() -> StreamEx.of(data)); + } + + @SuppressWarnings("unchecked") + private static Tuple2, String> getTestAnnotationMetaData( + final ITestNGMethod testMethod) { + var declaringClass = testMethod.getConstructorOrMethod().getDeclaringClass(); + var parentClass = + findParentDataSupplierClass( + testMethod.getConstructorOrMethod().getMethod(), declaringClass); + var testAnnotation = + ofNullable( + testMethod.getConstructorOrMethod().getMethod().getDeclaredAnnotation(Test.class)) + .orElseGet(() -> declaringClass.getDeclaredAnnotation(Test.class)); + var dataSupplierClass = + ofNullable(testAnnotation) .map(Test::dataProviderClass) .filter(dp -> dp != Object.class) .orElse((Class) parentClass); - return Tuple.of( - dataSupplierClass, - ofNullable(testAnnotation).map(Test::dataProvider).orElse("") - ); - } + return Tuple.of( + dataSupplierClass, ofNullable(testAnnotation).map(Test::dataProvider).orElse("")); + } - @SuppressWarnings("unchecked") - private static Tuple2, String> getFactoryAnnotationMetaData(final ITestNGMethod testMethod) { - var constructor = testMethod.getConstructorOrMethod().getConstructor(); - var method = testMethod.getConstructorOrMethod().getMethod(); + @SuppressWarnings("unchecked") + private static Tuple2, String> getFactoryAnnotationMetaData( + final ITestNGMethod testMethod) { + var constructor = testMethod.getConstructorOrMethod().getConstructor(); + var method = testMethod.getConstructorOrMethod().getMethod(); - var factoryAnnotation = nonNull(method) - ? ofNullable(method.getDeclaredAnnotation(Factory.class)) - : ofNullable(constructor.getDeclaredAnnotation(Factory.class)); + var factoryAnnotation = + nonNull(method) + ? ofNullable(method.getDeclaredAnnotation(Factory.class)) + : ofNullable(constructor.getDeclaredAnnotation(Factory.class)); - var dataProviderClass = factoryAnnotation + var dataProviderClass = + factoryAnnotation .map(fa -> (Class) fa.dataProviderClass()) .filter(cl -> cl != Object.class) .orElseGet(() -> testMethod.getConstructorOrMethod().getDeclaringClass()); - var dataProviderMethod = factoryAnnotation.map(Factory::dataProvider).orElse(""); + var dataProviderMethod = factoryAnnotation.map(Factory::dataProvider).orElse(""); - return Tuple.of(dataProviderClass, dataProviderMethod); - } + return Tuple.of(dataProviderClass, dataProviderMethod); + } - @SuppressWarnings("unchecked") - private static Class findParentDataSupplierClass(final Method testMethod, final Class testClass) { - return (Class) ofNullable(testMethod) + @SuppressWarnings("unchecked") + private static Class findParentDataSupplierClass( + final Method testMethod, final Class testClass) { + return (Class) + ofNullable(testMethod) .map(m -> Tuple.of(m, new Reflections(m.getDeclaringClass().getPackage().getName()))) .map(findParentDataSupplierClass()) .orElse(testClass); - } + } - private static Function, Class> findParentDataSupplierClass() { - return t -> StreamEx.of(t._2.getSubTypesOf(t._1.getDeclaringClass())) + private static Function, Class> findParentDataSupplierClass() { + return t -> + StreamEx.of(t._2.getSubTypesOf(t._1.getDeclaringClass())) .findFirst(c -> c.isAnnotationPresent(Test.class)) .map(c -> c.getDeclaredAnnotation(Test.class)) .map(a -> (Class) a.dataProviderClass()) .orElse(t._1.getDeclaringClass()); - } - - private static Predicate> hasDataSupplierMethod(final String targetMethodName) { - return metaData -> nonNull(metaData._2) && ( - metaData._2.name().equals(targetMethodName) || metaData._1.getName().equals(targetMethodName) - ); - } + } + + private static Predicate> hasDataSupplierMethod( + final String targetMethodName) { + return metaData -> + nonNull(metaData._2) + && (metaData._2.name().equals(targetMethodName) + || metaData._1.getName().equals(targetMethodName)); + } } diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/utils/ServiceLoaderUtils.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/utils/ServiceLoaderUtils.java index 6232803..bd5d479 100755 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/utils/ServiceLoaderUtils.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/datafactory/supplier/utils/ServiceLoaderUtils.java @@ -1,22 +1,19 @@ package io.fluent.testlibs.datafactory.supplier.utils; -import io.vavr.control.Try; -import lombok.experimental.UtilityClass; -import one.util.streamex.StreamEx; +import static java.util.Collections.emptyList; +import io.vavr.control.Try; import java.util.List; import java.util.ServiceLoader; +import lombok.experimental.UtilityClass; +import one.util.streamex.StreamEx; -import static java.util.Collections.emptyList; - -/** - * SPI management internals for dynamic listeners' implementation loading. - */ +/** SPI management internals for dynamic listeners' implementation loading. */ @UtilityClass public class ServiceLoaderUtils { - public static List load(final Class type, final ClassLoader classLoader) { - return Try.of(() -> StreamEx.of(ServiceLoader.load(type, classLoader).iterator()).toList()) - .getOrElseGet(ex -> emptyList()); - } + public static List load(final Class type, final ClassLoader classLoader) { + return Try.of(() -> StreamEx.of(ServiceLoader.load(type, classLoader).iterator()).toList()) + .getOrElseGet(ex -> emptyList()); + } } diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/package-info.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/package-info.java index f39b2c8..fa3b428 100644 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/package-info.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/package-info.java @@ -1 +1 @@ -package io.fluent.testlibs; \ No newline at end of file +package io.fluent.testlibs; diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/random/IdCardGenerator.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/random/IdCardGenerator.java index 8b518cd..89fa912 100644 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/random/IdCardGenerator.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/random/IdCardGenerator.java @@ -1,3630 +1,3627 @@ package io.fluent.testlibs.random; import com.google.common.collect.Maps; - import java.util.Collection; import java.util.Iterator; import java.util.Map; -/** - * 身份证自动生成工具 - */ +/** 身份证自动生成工具 */ public class IdCardGenerator { - public static final Map areaCode = Maps.newConcurrentMap(); - - static { - IdCardGenerator.areaCode.put("北京市", 110000); - IdCardGenerator.areaCode.put("市辖区", 110100); - IdCardGenerator.areaCode.put("东城区", 110101); - IdCardGenerator.areaCode.put("西城区", 110102); - IdCardGenerator.areaCode.put("崇文区", 110103); - IdCardGenerator.areaCode.put("宣武区", 110104); - IdCardGenerator.areaCode.put("朝阳区", 110105); - IdCardGenerator.areaCode.put("丰台区", 110106); - IdCardGenerator.areaCode.put("石景山区", 110107); - IdCardGenerator.areaCode.put("海淀区", 110108); - IdCardGenerator.areaCode.put("门头沟区", 110109); - IdCardGenerator.areaCode.put("房山区", 110111); - IdCardGenerator.areaCode.put("通州区", 110112); - IdCardGenerator.areaCode.put("顺义区", 110113); - IdCardGenerator.areaCode.put("昌平区", 110114); - IdCardGenerator.areaCode.put("大兴区", 110115); - IdCardGenerator.areaCode.put("怀柔区", 110116); - IdCardGenerator.areaCode.put("平谷区", 110117); - IdCardGenerator.areaCode.put("县", 110200); - IdCardGenerator.areaCode.put("密云县", 110228); - IdCardGenerator.areaCode.put("延庆县", 110229); - IdCardGenerator.areaCode.put("天津市", 120000); - IdCardGenerator.areaCode.put("市辖区", 120100); - IdCardGenerator.areaCode.put("和平区", 120101); - IdCardGenerator.areaCode.put("河东区", 120102); - IdCardGenerator.areaCode.put("河西区", 120103); - IdCardGenerator.areaCode.put("南开区", 120104); - IdCardGenerator.areaCode.put("河北区", 120105); - IdCardGenerator.areaCode.put("红桥区", 120106); - IdCardGenerator.areaCode.put("东丽区", 120110); - IdCardGenerator.areaCode.put("西青区", 120111); - IdCardGenerator.areaCode.put("津南区", 120112); - IdCardGenerator.areaCode.put("北辰区", 120113); - IdCardGenerator.areaCode.put("武清区", 120114); - IdCardGenerator.areaCode.put("宝坻区", 120115); - IdCardGenerator.areaCode.put("县", 120200); - IdCardGenerator.areaCode.put("宁河县", 120221); - IdCardGenerator.areaCode.put("静海县", 120223); - IdCardGenerator.areaCode.put("蓟 县", 120225); - IdCardGenerator.areaCode.put("河北省", 130000); - IdCardGenerator.areaCode.put("石家庄市", 130100); - IdCardGenerator.areaCode.put("市辖区", 130101); - IdCardGenerator.areaCode.put("长安区", 130102); - IdCardGenerator.areaCode.put("桥东区", 130103); - IdCardGenerator.areaCode.put("桥西区", 130104); - IdCardGenerator.areaCode.put("新华区", 130105); - IdCardGenerator.areaCode.put("井陉矿区", 130107); - IdCardGenerator.areaCode.put("裕华区", 130108); - IdCardGenerator.areaCode.put("井陉县", 130121); - IdCardGenerator.areaCode.put("正定县", 130123); - IdCardGenerator.areaCode.put("栾城县", 130124); - IdCardGenerator.areaCode.put("行唐县", 130125); - IdCardGenerator.areaCode.put("灵寿县", 130126); - IdCardGenerator.areaCode.put("高邑县", 130127); - IdCardGenerator.areaCode.put("深泽县", 130128); - IdCardGenerator.areaCode.put("赞皇县", 130129); - IdCardGenerator.areaCode.put("无极县", 130130); - IdCardGenerator.areaCode.put("平山县", 130131); - IdCardGenerator.areaCode.put("元氏县", 130132); - IdCardGenerator.areaCode.put("赵 县", 130133); - IdCardGenerator.areaCode.put("辛集市", 130181); - IdCardGenerator.areaCode.put("藁城市", 130182); - IdCardGenerator.areaCode.put("晋州市", 130183); - IdCardGenerator.areaCode.put("新乐市", 130184); - IdCardGenerator.areaCode.put("鹿泉市", 130185); - IdCardGenerator.areaCode.put("唐山市", 130200); - IdCardGenerator.areaCode.put("市辖区", 130201); - IdCardGenerator.areaCode.put("路南区", 130202); - IdCardGenerator.areaCode.put("路北区", 130203); - IdCardGenerator.areaCode.put("古冶区", 130204); - IdCardGenerator.areaCode.put("开平区", 130205); - IdCardGenerator.areaCode.put("丰南区", 130207); - IdCardGenerator.areaCode.put("丰润区", 130208); - IdCardGenerator.areaCode.put("滦 县", 130223); - IdCardGenerator.areaCode.put("滦南县", 130224); - IdCardGenerator.areaCode.put("乐亭县", 130225); - IdCardGenerator.areaCode.put("迁西县", 130227); - IdCardGenerator.areaCode.put("玉田县", 130229); - IdCardGenerator.areaCode.put("唐海县", 130230); - IdCardGenerator.areaCode.put("遵化市", 130281); - IdCardGenerator.areaCode.put("迁安市", 130283); - IdCardGenerator.areaCode.put("秦皇岛市", 130300); - IdCardGenerator.areaCode.put("市辖区", 130301); - IdCardGenerator.areaCode.put("海港区", 130302); - IdCardGenerator.areaCode.put("山海关区", 130303); - IdCardGenerator.areaCode.put("北戴河区", 130304); - IdCardGenerator.areaCode.put("青龙满族自治县", 130321); - IdCardGenerator.areaCode.put("昌黎县", 130322); - IdCardGenerator.areaCode.put("抚宁县", 130323); - IdCardGenerator.areaCode.put("卢龙县", 130324); - IdCardGenerator.areaCode.put("邯郸市", 130400); - IdCardGenerator.areaCode.put("市辖区", 130401); - IdCardGenerator.areaCode.put("邯山区", 130402); - IdCardGenerator.areaCode.put("丛台区", 130403); - IdCardGenerator.areaCode.put("复兴区", 130404); - IdCardGenerator.areaCode.put("峰峰矿区", 130406); - IdCardGenerator.areaCode.put("邯郸县", 130421); - IdCardGenerator.areaCode.put("临漳县", 130423); - IdCardGenerator.areaCode.put("成安县", 130424); - IdCardGenerator.areaCode.put("大名县", 130425); - IdCardGenerator.areaCode.put("涉 县", 130426); - IdCardGenerator.areaCode.put("磁 县", 130427); - IdCardGenerator.areaCode.put("肥乡县", 130428); - IdCardGenerator.areaCode.put("永年县", 130429); - IdCardGenerator.areaCode.put("邱 县", 130430); - IdCardGenerator.areaCode.put("鸡泽县", 130431); - IdCardGenerator.areaCode.put("广平县", 130432); - IdCardGenerator.areaCode.put("馆陶县", 130433); - IdCardGenerator.areaCode.put("魏 县", 130434); - IdCardGenerator.areaCode.put("曲周县", 130435); - IdCardGenerator.areaCode.put("武安市", 130481); - IdCardGenerator.areaCode.put("邢台市", 130500); - IdCardGenerator.areaCode.put("市辖区", 130501); - IdCardGenerator.areaCode.put("桥东区", 130502); - IdCardGenerator.areaCode.put("桥西区", 130503); - IdCardGenerator.areaCode.put("邢台县", 130521); - IdCardGenerator.areaCode.put("临城县", 130522); - IdCardGenerator.areaCode.put("内丘县", 130523); - IdCardGenerator.areaCode.put("柏乡县", 130524); - IdCardGenerator.areaCode.put("隆尧县", 130525); - IdCardGenerator.areaCode.put("任 县", 130526); - IdCardGenerator.areaCode.put("南和县", 130527); - IdCardGenerator.areaCode.put("宁晋县", 130528); - IdCardGenerator.areaCode.put("巨鹿县", 130529); - IdCardGenerator.areaCode.put("新河县", 130530); - IdCardGenerator.areaCode.put("广宗县", 130531); - IdCardGenerator.areaCode.put("平乡县", 130532); - IdCardGenerator.areaCode.put("威 县", 130533); - IdCardGenerator.areaCode.put("清河县", 130534); - IdCardGenerator.areaCode.put("临西县", 130535); - IdCardGenerator.areaCode.put("南宫市", 130581); - IdCardGenerator.areaCode.put("沙河市", 130582); - IdCardGenerator.areaCode.put("保定市", 130600); - IdCardGenerator.areaCode.put("市辖区", 130601); - IdCardGenerator.areaCode.put("新市区", 130602); - IdCardGenerator.areaCode.put("北市区", 130603); - IdCardGenerator.areaCode.put("南市区", 130604); - IdCardGenerator.areaCode.put("满城县", 130621); - IdCardGenerator.areaCode.put("清苑县", 130622); - IdCardGenerator.areaCode.put("涞水县", 130623); - IdCardGenerator.areaCode.put("阜平县", 130624); - IdCardGenerator.areaCode.put("徐水县", 130625); - IdCardGenerator.areaCode.put("定兴县", 130626); - IdCardGenerator.areaCode.put("唐 县", 130627); - IdCardGenerator.areaCode.put("高阳县", 130628); - IdCardGenerator.areaCode.put("容城县", 130629); - IdCardGenerator.areaCode.put("涞源县", 130630); - IdCardGenerator.areaCode.put("望都县", 130631); - IdCardGenerator.areaCode.put("安新县", 130632); - IdCardGenerator.areaCode.put("易 县", 130633); - IdCardGenerator.areaCode.put("曲阳县", 130634); - IdCardGenerator.areaCode.put("蠡 县", 130635); - IdCardGenerator.areaCode.put("顺平县", 130636); - IdCardGenerator.areaCode.put("博野县", 130637); - IdCardGenerator.areaCode.put("雄 县", 130638); - IdCardGenerator.areaCode.put("涿州市", 130681); - IdCardGenerator.areaCode.put("定州市", 130682); - IdCardGenerator.areaCode.put("安国市", 130683); - IdCardGenerator.areaCode.put("高碑店市", 130684); - IdCardGenerator.areaCode.put("张家口市", 130700); - IdCardGenerator.areaCode.put("市辖区", 130701); - IdCardGenerator.areaCode.put("桥东区", 130702); - IdCardGenerator.areaCode.put("桥西区", 130703); - IdCardGenerator.areaCode.put("宣化区", 130705); - IdCardGenerator.areaCode.put("下花园区", 130706); - IdCardGenerator.areaCode.put("宣化县", 130721); - IdCardGenerator.areaCode.put("张北县", 130722); - IdCardGenerator.areaCode.put("康保县", 130723); - IdCardGenerator.areaCode.put("沽源县", 130724); - IdCardGenerator.areaCode.put("尚义县", 130725); - IdCardGenerator.areaCode.put("蔚 县", 130726); - IdCardGenerator.areaCode.put("阳原县", 130727); - IdCardGenerator.areaCode.put("怀安县", 130728); - IdCardGenerator.areaCode.put("万全县", 130729); - IdCardGenerator.areaCode.put("怀来县", 130730); - IdCardGenerator.areaCode.put("涿鹿县", 130731); - IdCardGenerator.areaCode.put("赤城县", 130732); - IdCardGenerator.areaCode.put("崇礼县", 130733); - IdCardGenerator.areaCode.put("承德市", 130800); - IdCardGenerator.areaCode.put("市辖区", 130801); - IdCardGenerator.areaCode.put("双桥区", 130802); - IdCardGenerator.areaCode.put("双滦区", 130803); - IdCardGenerator.areaCode.put("鹰手营子矿区", 130804); - IdCardGenerator.areaCode.put("承德县", 130821); - IdCardGenerator.areaCode.put("兴隆县", 130822); - IdCardGenerator.areaCode.put("平泉县", 130823); - IdCardGenerator.areaCode.put("滦平县", 130824); - IdCardGenerator.areaCode.put("隆化县", 130825); - IdCardGenerator.areaCode.put("丰宁满族自治县", 130826); - IdCardGenerator.areaCode.put("宽城满族自治县", 130827); - IdCardGenerator.areaCode.put("围场满族蒙古族自治县", 130828); - IdCardGenerator.areaCode.put("沧州市", 130900); - IdCardGenerator.areaCode.put("市辖区", 130901); - IdCardGenerator.areaCode.put("新华区", 130902); - IdCardGenerator.areaCode.put("运河区", 130903); - IdCardGenerator.areaCode.put("沧 县", 130921); - IdCardGenerator.areaCode.put("青 县", 130922); - IdCardGenerator.areaCode.put("东光县", 130923); - IdCardGenerator.areaCode.put("海兴县", 130924); - IdCardGenerator.areaCode.put("盐山县", 130925); - IdCardGenerator.areaCode.put("肃宁县", 130926); - IdCardGenerator.areaCode.put("南皮县", 130927); - IdCardGenerator.areaCode.put("吴桥县", 130928); - IdCardGenerator.areaCode.put("献 县", 130929); - IdCardGenerator.areaCode.put("孟村回族自治县", 130930); - IdCardGenerator.areaCode.put("泊头市", 130981); - IdCardGenerator.areaCode.put("任丘市", 130982); - IdCardGenerator.areaCode.put("黄骅市", 130983); - IdCardGenerator.areaCode.put("河间市", 130984); - IdCardGenerator.areaCode.put("廊坊市", 131000); - IdCardGenerator.areaCode.put("市辖区", 131001); - IdCardGenerator.areaCode.put("安次区", 131002); - IdCardGenerator.areaCode.put("广阳区", 131003); - IdCardGenerator.areaCode.put("固安县", 131022); - IdCardGenerator.areaCode.put("永清县", 131023); - IdCardGenerator.areaCode.put("香河县", 131024); - IdCardGenerator.areaCode.put("大城县", 131025); - IdCardGenerator.areaCode.put("文安县", 131026); - IdCardGenerator.areaCode.put("大厂回族自治县", 131028); - IdCardGenerator.areaCode.put("霸州市", 131081); - IdCardGenerator.areaCode.put("三河市", 131082); - IdCardGenerator.areaCode.put("衡水市", 131100); - IdCardGenerator.areaCode.put("市辖区", 131101); - IdCardGenerator.areaCode.put("桃城区", 131102); - IdCardGenerator.areaCode.put("枣强县", 131121); - IdCardGenerator.areaCode.put("武邑县", 131122); - IdCardGenerator.areaCode.put("武强县", 131123); - IdCardGenerator.areaCode.put("饶阳县", 131124); - IdCardGenerator.areaCode.put("安平县", 131125); - IdCardGenerator.areaCode.put("故城县", 131126); - IdCardGenerator.areaCode.put("景 县", 131127); - IdCardGenerator.areaCode.put("阜城县", 131128); - IdCardGenerator.areaCode.put("冀州市", 131181); - IdCardGenerator.areaCode.put("深州市", 131182); - IdCardGenerator.areaCode.put("山西省", 140000); - IdCardGenerator.areaCode.put("太原市", 140100); - IdCardGenerator.areaCode.put("市辖区", 140101); - IdCardGenerator.areaCode.put("小店区", 140105); - IdCardGenerator.areaCode.put("迎泽区", 140106); - IdCardGenerator.areaCode.put("杏花岭区", 140107); - IdCardGenerator.areaCode.put("尖草坪区", 140108); - IdCardGenerator.areaCode.put("万柏林区", 140109); - IdCardGenerator.areaCode.put("晋源区", 140110); - IdCardGenerator.areaCode.put("清徐县", 140121); - IdCardGenerator.areaCode.put("阳曲县", 140122); - IdCardGenerator.areaCode.put("娄烦县", 140123); - IdCardGenerator.areaCode.put("古交市", 140181); - IdCardGenerator.areaCode.put("大同市", 140200); - IdCardGenerator.areaCode.put("市辖区", 140201); - IdCardGenerator.areaCode.put("城 区", 140202); - IdCardGenerator.areaCode.put("矿 区", 140203); - IdCardGenerator.areaCode.put("南郊区", 140211); - IdCardGenerator.areaCode.put("新荣区", 140212); - IdCardGenerator.areaCode.put("阳高县", 140221); - IdCardGenerator.areaCode.put("天镇县", 140222); - IdCardGenerator.areaCode.put("广灵县", 140223); - IdCardGenerator.areaCode.put("灵丘县", 140224); - IdCardGenerator.areaCode.put("浑源县", 140225); - IdCardGenerator.areaCode.put("左云县", 140226); - IdCardGenerator.areaCode.put("大同县", 140227); - IdCardGenerator.areaCode.put("阳泉市", 140300); - IdCardGenerator.areaCode.put("市辖区", 140301); - IdCardGenerator.areaCode.put("城 区", 140302); - IdCardGenerator.areaCode.put("矿 区", 140303); - IdCardGenerator.areaCode.put("郊 区", 140311); - IdCardGenerator.areaCode.put("平定县", 140321); - IdCardGenerator.areaCode.put("盂 县", 140322); - IdCardGenerator.areaCode.put("长治市", 140400); - IdCardGenerator.areaCode.put("市辖区", 140401); - IdCardGenerator.areaCode.put("城 区", 140402); - IdCardGenerator.areaCode.put("郊 区", 140411); - IdCardGenerator.areaCode.put("长治县", 140421); - IdCardGenerator.areaCode.put("襄垣县", 140423); - IdCardGenerator.areaCode.put("屯留县", 140424); - IdCardGenerator.areaCode.put("平顺县", 140425); - IdCardGenerator.areaCode.put("黎城县", 140426); - IdCardGenerator.areaCode.put("壶关县", 140427); - IdCardGenerator.areaCode.put("长子县", 140428); - IdCardGenerator.areaCode.put("武乡县", 140429); - IdCardGenerator.areaCode.put("沁 县", 140430); - IdCardGenerator.areaCode.put("沁源县", 140431); - IdCardGenerator.areaCode.put("潞城市", 140481); - IdCardGenerator.areaCode.put("晋城市", 140500); - IdCardGenerator.areaCode.put("市辖区", 140501); - IdCardGenerator.areaCode.put("城 区", 140502); - IdCardGenerator.areaCode.put("沁水县", 140521); - IdCardGenerator.areaCode.put("阳城县", 140522); - IdCardGenerator.areaCode.put("陵川县", 140524); - IdCardGenerator.areaCode.put("泽州县", 140525); - IdCardGenerator.areaCode.put("高平市", 140581); - IdCardGenerator.areaCode.put("朔州市", 140600); - IdCardGenerator.areaCode.put("市辖区", 140601); - IdCardGenerator.areaCode.put("朔城区", 140602); - IdCardGenerator.areaCode.put("平鲁区", 140603); - IdCardGenerator.areaCode.put("山阴县", 140621); - IdCardGenerator.areaCode.put("应 县", 140622); - IdCardGenerator.areaCode.put("右玉县", 140623); - IdCardGenerator.areaCode.put("怀仁县", 140624); - IdCardGenerator.areaCode.put("晋中市", 140700); - IdCardGenerator.areaCode.put("市辖区", 140701); - IdCardGenerator.areaCode.put("榆次区", 140702); - IdCardGenerator.areaCode.put("榆社县", 140721); - IdCardGenerator.areaCode.put("左权县", 140722); - IdCardGenerator.areaCode.put("和顺县", 140723); - IdCardGenerator.areaCode.put("昔阳县", 140724); - IdCardGenerator.areaCode.put("寿阳县", 140725); - IdCardGenerator.areaCode.put("太谷县", 140726); - IdCardGenerator.areaCode.put("祁 县", 140727); - IdCardGenerator.areaCode.put("平遥县", 140728); - IdCardGenerator.areaCode.put("灵石县", 140729); - IdCardGenerator.areaCode.put("介休市", 140781); - IdCardGenerator.areaCode.put("运城市", 140800); - IdCardGenerator.areaCode.put("市辖区", 140801); - IdCardGenerator.areaCode.put("盐湖区", 140802); - IdCardGenerator.areaCode.put("临猗县", 140821); - IdCardGenerator.areaCode.put("万荣县", 140822); - IdCardGenerator.areaCode.put("闻喜县", 140823); - IdCardGenerator.areaCode.put("稷山县", 140824); - IdCardGenerator.areaCode.put("新绛县", 140825); - IdCardGenerator.areaCode.put("绛 县", 140826); - IdCardGenerator.areaCode.put("垣曲县", 140827); - IdCardGenerator.areaCode.put("夏 县", 140828); - IdCardGenerator.areaCode.put("平陆县", 140829); - IdCardGenerator.areaCode.put("芮城县", 140830); - IdCardGenerator.areaCode.put("永济市", 140881); - IdCardGenerator.areaCode.put("河津市", 140882); - IdCardGenerator.areaCode.put("忻州市", 140900); - IdCardGenerator.areaCode.put("市辖区", 140901); - IdCardGenerator.areaCode.put("忻府区", 140902); - IdCardGenerator.areaCode.put("定襄县", 140921); - IdCardGenerator.areaCode.put("五台县", 140922); - IdCardGenerator.areaCode.put("代 县", 140923); - IdCardGenerator.areaCode.put("繁峙县", 140924); - IdCardGenerator.areaCode.put("宁武县", 140925); - IdCardGenerator.areaCode.put("静乐县", 140926); - IdCardGenerator.areaCode.put("神池县", 140927); - IdCardGenerator.areaCode.put("五寨县", 140928); - IdCardGenerator.areaCode.put("岢岚县", 140929); - IdCardGenerator.areaCode.put("河曲县", 140930); - IdCardGenerator.areaCode.put("保德县", 140931); - IdCardGenerator.areaCode.put("偏关县", 140932); - IdCardGenerator.areaCode.put("原平市", 140981); - IdCardGenerator.areaCode.put("临汾市", 141000); - IdCardGenerator.areaCode.put("市辖区", 141001); - IdCardGenerator.areaCode.put("尧都区", 141002); - IdCardGenerator.areaCode.put("曲沃县", 141021); - IdCardGenerator.areaCode.put("翼城县", 141022); - IdCardGenerator.areaCode.put("襄汾县", 141023); - IdCardGenerator.areaCode.put("洪洞县", 141024); - IdCardGenerator.areaCode.put("古 县", 141025); - IdCardGenerator.areaCode.put("安泽县", 141026); - IdCardGenerator.areaCode.put("浮山县", 141027); - IdCardGenerator.areaCode.put("吉 县", 141028); - IdCardGenerator.areaCode.put("乡宁县", 141029); - IdCardGenerator.areaCode.put("大宁县", 141030); - IdCardGenerator.areaCode.put("隰 县", 141031); - IdCardGenerator.areaCode.put("永和县", 141032); - IdCardGenerator.areaCode.put("蒲 县", 141033); - IdCardGenerator.areaCode.put("汾西县", 141034); - IdCardGenerator.areaCode.put("侯马市", 141081); - IdCardGenerator.areaCode.put("霍州市", 141082); - IdCardGenerator.areaCode.put("吕梁市", 141100); - IdCardGenerator.areaCode.put("市辖区", 141101); - IdCardGenerator.areaCode.put("离石区", 141102); - IdCardGenerator.areaCode.put("文水县", 141121); - IdCardGenerator.areaCode.put("交城县", 141122); - IdCardGenerator.areaCode.put("兴 县", 141123); - IdCardGenerator.areaCode.put("临 县", 141124); - IdCardGenerator.areaCode.put("柳林县", 141125); - IdCardGenerator.areaCode.put("石楼县", 141126); - IdCardGenerator.areaCode.put("岚 县", 141127); - IdCardGenerator.areaCode.put("方山县", 141128); - IdCardGenerator.areaCode.put("中阳县", 141129); - IdCardGenerator.areaCode.put("交口县", 141130); - IdCardGenerator.areaCode.put("孝义市", 141181); - IdCardGenerator.areaCode.put("汾阳市", 141182); - IdCardGenerator.areaCode.put("内蒙古自治区", 150000); - IdCardGenerator.areaCode.put("呼和浩特市", 150100); - IdCardGenerator.areaCode.put("市辖区", 150101); - IdCardGenerator.areaCode.put("新城区", 150102); - IdCardGenerator.areaCode.put("回民区", 150103); - IdCardGenerator.areaCode.put("玉泉区", 150104); - IdCardGenerator.areaCode.put("赛罕区", 150105); - IdCardGenerator.areaCode.put("土默特左旗", 150121); - IdCardGenerator.areaCode.put("托克托县", 150122); - IdCardGenerator.areaCode.put("和林格尔县", 150123); - IdCardGenerator.areaCode.put("清水河县", 150124); - IdCardGenerator.areaCode.put("武川县", 150125); - IdCardGenerator.areaCode.put("包头市", 150200); - IdCardGenerator.areaCode.put("市辖区", 150201); - IdCardGenerator.areaCode.put("东河区", 150202); - IdCardGenerator.areaCode.put("昆都仑区", 150203); - IdCardGenerator.areaCode.put("青山区", 150204); - IdCardGenerator.areaCode.put("石拐区", 150205); - IdCardGenerator.areaCode.put("白云鄂博矿区", 150206); - IdCardGenerator.areaCode.put("九原区", 150207); - IdCardGenerator.areaCode.put("土默特右旗", 150221); - IdCardGenerator.areaCode.put("固阳县", 150222); - IdCardGenerator.areaCode.put("达尔罕茂明安联合旗", 150223); - IdCardGenerator.areaCode.put("乌海市", 150300); - IdCardGenerator.areaCode.put("市辖区", 150301); - IdCardGenerator.areaCode.put("海勃湾区", 150302); - IdCardGenerator.areaCode.put("海南区", 150303); - IdCardGenerator.areaCode.put("乌达区", 150304); - IdCardGenerator.areaCode.put("赤峰市", 150400); - IdCardGenerator.areaCode.put("市辖区", 150401); - IdCardGenerator.areaCode.put("红山区", 150402); - IdCardGenerator.areaCode.put("元宝山区", 150403); - IdCardGenerator.areaCode.put("松山区", 150404); - IdCardGenerator.areaCode.put("阿鲁科尔沁旗", 150421); - IdCardGenerator.areaCode.put("巴林左旗", 150422); - IdCardGenerator.areaCode.put("巴林右旗", 150423); - IdCardGenerator.areaCode.put("林西县", 150424); - IdCardGenerator.areaCode.put("克什克腾旗", 150425); - IdCardGenerator.areaCode.put("翁牛特旗", 150426); - IdCardGenerator.areaCode.put("喀喇沁旗", 150428); - IdCardGenerator.areaCode.put("宁城县", 150429); - IdCardGenerator.areaCode.put("敖汉旗", 150430); - IdCardGenerator.areaCode.put("通辽市", 150500); - IdCardGenerator.areaCode.put("市辖区", 150501); - IdCardGenerator.areaCode.put("科尔沁区", 150502); - IdCardGenerator.areaCode.put("科尔沁左翼中旗", 150521); - IdCardGenerator.areaCode.put("科尔沁左翼后旗", 150522); - IdCardGenerator.areaCode.put("开鲁县", 150523); - IdCardGenerator.areaCode.put("库伦旗", 150524); - IdCardGenerator.areaCode.put("奈曼旗", 150525); - IdCardGenerator.areaCode.put("扎鲁特旗", 150526); - IdCardGenerator.areaCode.put("霍林郭勒市", 150581); - IdCardGenerator.areaCode.put("鄂尔多斯市", 150600); - IdCardGenerator.areaCode.put("市辖区", 150601); - IdCardGenerator.areaCode.put(" 东胜区", 150602); - IdCardGenerator.areaCode.put("达拉特旗", 150621); - IdCardGenerator.areaCode.put("准格尔旗", 150622); - IdCardGenerator.areaCode.put("鄂托克前旗", 150623); - IdCardGenerator.areaCode.put("鄂托克旗", 150624); - IdCardGenerator.areaCode.put("杭锦旗", 150625); - IdCardGenerator.areaCode.put("乌审旗", 150626); - IdCardGenerator.areaCode.put("伊金霍洛旗", 150627); - IdCardGenerator.areaCode.put("呼伦贝尔市", 150700); - IdCardGenerator.areaCode.put("市辖区", 150701); - IdCardGenerator.areaCode.put("海拉尔区", 150702); - IdCardGenerator.areaCode.put("阿荣旗", 150721); - IdCardGenerator.areaCode.put("莫力达瓦达斡尔族自治旗", 150722); - IdCardGenerator.areaCode.put("鄂伦春自治旗", 150723); - IdCardGenerator.areaCode.put("鄂温克族自治旗", 150724); - IdCardGenerator.areaCode.put("陈巴尔虎旗", 150725); - IdCardGenerator.areaCode.put("新巴尔虎左旗", 150726); - IdCardGenerator.areaCode.put("新巴尔虎右旗", 150727); - IdCardGenerator.areaCode.put("满洲里市", 150781); - IdCardGenerator.areaCode.put("牙克石市", 150782); - IdCardGenerator.areaCode.put("扎兰屯市", 150783); - IdCardGenerator.areaCode.put("额尔古纳市", 150784); - IdCardGenerator.areaCode.put("根河市", 150785); - IdCardGenerator.areaCode.put("巴彦淖尔市", 150800); - IdCardGenerator.areaCode.put("市辖区", 150801); - IdCardGenerator.areaCode.put("临河区", 150802); - IdCardGenerator.areaCode.put("五原县", 150821); - IdCardGenerator.areaCode.put("磴口县", 150822); - IdCardGenerator.areaCode.put("乌拉特前旗", 150823); - IdCardGenerator.areaCode.put("乌拉特中旗", 150824); - IdCardGenerator.areaCode.put("乌拉特后旗", 150825); - IdCardGenerator.areaCode.put("杭锦后旗", 150826); - IdCardGenerator.areaCode.put("乌兰察布市", 150900); - IdCardGenerator.areaCode.put("市辖区", 150901); - IdCardGenerator.areaCode.put("集宁区", 150902); - IdCardGenerator.areaCode.put("卓资县", 150921); - IdCardGenerator.areaCode.put("化德县", 150922); - IdCardGenerator.areaCode.put("商都县", 150923); - IdCardGenerator.areaCode.put("兴和县", 150924); - IdCardGenerator.areaCode.put("凉城县", 150925); - IdCardGenerator.areaCode.put("察哈尔右翼前旗", 150926); - IdCardGenerator.areaCode.put("察哈尔右翼中旗", 150927); - IdCardGenerator.areaCode.put("察哈尔右翼后旗", 150928); - IdCardGenerator.areaCode.put("四子王旗", 150929); - IdCardGenerator.areaCode.put("丰镇市", 150981); - IdCardGenerator.areaCode.put("兴安盟", 152200); - IdCardGenerator.areaCode.put("乌兰浩特市", 152201); - IdCardGenerator.areaCode.put("阿尔山市", 152202); - IdCardGenerator.areaCode.put("科尔沁右翼前旗", 152221); - IdCardGenerator.areaCode.put("科尔沁右翼中旗", 152222); - IdCardGenerator.areaCode.put("扎赉特旗", 152223); - IdCardGenerator.areaCode.put("突泉县", 152224); - IdCardGenerator.areaCode.put("锡林郭勒盟", 152500); - IdCardGenerator.areaCode.put("二连浩特市", 152501); - IdCardGenerator.areaCode.put("锡林浩特市", 152502); - IdCardGenerator.areaCode.put("阿巴嘎旗", 152522); - IdCardGenerator.areaCode.put("苏尼特左旗", 152523); - IdCardGenerator.areaCode.put("苏尼特右旗", 152524); - IdCardGenerator.areaCode.put("东乌珠穆沁旗", 152525); - IdCardGenerator.areaCode.put("西乌珠穆沁旗", 152526); - IdCardGenerator.areaCode.put("太仆寺旗", 152527); - IdCardGenerator.areaCode.put("镶黄旗", 152528); - IdCardGenerator.areaCode.put("正镶白旗", 152529); - IdCardGenerator.areaCode.put("正蓝旗", 152530); - IdCardGenerator.areaCode.put("多伦县", 152531); - IdCardGenerator.areaCode.put("阿拉善盟", 152900); - IdCardGenerator.areaCode.put("阿拉善左旗", 152921); - IdCardGenerator.areaCode.put("阿拉善右旗", 152922); - IdCardGenerator.areaCode.put("额济纳旗", 152923); - IdCardGenerator.areaCode.put("辽宁省", 210000); - IdCardGenerator.areaCode.put("沈阳市", 210100); - IdCardGenerator.areaCode.put("市辖区", 210101); - IdCardGenerator.areaCode.put("和平区", 210102); - IdCardGenerator.areaCode.put("沈河区", 210103); - IdCardGenerator.areaCode.put("大东区", 210104); - IdCardGenerator.areaCode.put("皇姑区", 210105); - IdCardGenerator.areaCode.put("铁西区", 210106); - IdCardGenerator.areaCode.put("苏家屯区", 210111); - IdCardGenerator.areaCode.put("东陵区", 210112); - IdCardGenerator.areaCode.put("沈北新区", 210113); - IdCardGenerator.areaCode.put("于洪区", 210114); - IdCardGenerator.areaCode.put("辽中县", 210122); - IdCardGenerator.areaCode.put("康平县", 210123); - IdCardGenerator.areaCode.put("法库县", 210124); - IdCardGenerator.areaCode.put("新民市", 210181); - IdCardGenerator.areaCode.put("大连市", 210200); - IdCardGenerator.areaCode.put("市辖区", 210201); - IdCardGenerator.areaCode.put("中山区", 210202); - IdCardGenerator.areaCode.put("西岗区", 210203); - IdCardGenerator.areaCode.put("沙河口区", 210204); - IdCardGenerator.areaCode.put("甘井子区", 210211); - IdCardGenerator.areaCode.put("旅顺口区", 210212); - IdCardGenerator.areaCode.put("金州区", 210213); - IdCardGenerator.areaCode.put("长海县", 210224); - IdCardGenerator.areaCode.put("瓦房店市", 210281); - IdCardGenerator.areaCode.put("普兰店市", 210282); - IdCardGenerator.areaCode.put("庄河市", 210283); - IdCardGenerator.areaCode.put("鞍山市", 210300); - IdCardGenerator.areaCode.put("市辖区", 210301); - IdCardGenerator.areaCode.put("铁东区", 210302); - IdCardGenerator.areaCode.put("铁西区", 210303); - IdCardGenerator.areaCode.put("立山区", 210304); - IdCardGenerator.areaCode.put("千山区", 210311); - IdCardGenerator.areaCode.put("台安县", 210321); - IdCardGenerator.areaCode.put("岫岩满族自治县", 210323); - IdCardGenerator.areaCode.put("海城市", 210381); - IdCardGenerator.areaCode.put("抚顺市", 210400); - IdCardGenerator.areaCode.put("市辖区", 210401); - IdCardGenerator.areaCode.put("新抚区", 210402); - IdCardGenerator.areaCode.put("东洲区", 210403); - IdCardGenerator.areaCode.put("望花区", 210404); - IdCardGenerator.areaCode.put("顺城区", 210411); - IdCardGenerator.areaCode.put("抚顺县", 210421); - IdCardGenerator.areaCode.put("新宾满族自治县", 210422); - IdCardGenerator.areaCode.put("清原满族自治县", 210423); - IdCardGenerator.areaCode.put("本溪市", 210500); - IdCardGenerator.areaCode.put("市辖区", 210501); - IdCardGenerator.areaCode.put("平山区", 210502); - IdCardGenerator.areaCode.put("溪湖区", 210503); - IdCardGenerator.areaCode.put("明山区", 210504); - IdCardGenerator.areaCode.put("南芬区", 210505); - IdCardGenerator.areaCode.put("本溪满族自治县", 210521); - IdCardGenerator.areaCode.put("桓仁满族自治县", 210522); - IdCardGenerator.areaCode.put("丹东市", 210600); - IdCardGenerator.areaCode.put("市辖区", 210601); - IdCardGenerator.areaCode.put("元宝区", 210602); - IdCardGenerator.areaCode.put("振兴区", 210603); - IdCardGenerator.areaCode.put("振安区", 210604); - IdCardGenerator.areaCode.put("宽甸满族自治县", 210624); - IdCardGenerator.areaCode.put("东港市", 210681); - IdCardGenerator.areaCode.put("凤城市", 210682); - IdCardGenerator.areaCode.put("锦州市", 210700); - IdCardGenerator.areaCode.put("市辖区", 210701); - IdCardGenerator.areaCode.put("古塔区", 210702); - IdCardGenerator.areaCode.put("凌河区", 210703); - IdCardGenerator.areaCode.put("太和区", 210711); - IdCardGenerator.areaCode.put("黑山县", 210726); - IdCardGenerator.areaCode.put("义 县", 210727); - IdCardGenerator.areaCode.put("凌海市", 210781); - IdCardGenerator.areaCode.put("北镇市", 210782); - IdCardGenerator.areaCode.put("营口市", 210800); - IdCardGenerator.areaCode.put("市辖区", 210801); - IdCardGenerator.areaCode.put("站前区", 210802); - IdCardGenerator.areaCode.put("西市区", 210803); - IdCardGenerator.areaCode.put("鲅鱼圈区", 210804); - IdCardGenerator.areaCode.put("老边区", 210811); - IdCardGenerator.areaCode.put("盖州市", 210881); - IdCardGenerator.areaCode.put("大石桥市", 210882); - IdCardGenerator.areaCode.put("阜新市", 210900); - IdCardGenerator.areaCode.put("市辖区", 210901); - IdCardGenerator.areaCode.put("海州区", 210902); - IdCardGenerator.areaCode.put("新邱区", 210903); - IdCardGenerator.areaCode.put("太平区", 210904); - IdCardGenerator.areaCode.put("清河门区", 210905); - IdCardGenerator.areaCode.put("细河区", 210911); - IdCardGenerator.areaCode.put("阜新蒙古族自治县", 210921); - IdCardGenerator.areaCode.put("彰武县", 210922); - IdCardGenerator.areaCode.put("辽阳市", 211000); - IdCardGenerator.areaCode.put("市辖区", 211001); - IdCardGenerator.areaCode.put("白塔区", 211002); - IdCardGenerator.areaCode.put("文圣区", 211003); - IdCardGenerator.areaCode.put("宏伟区", 211004); - IdCardGenerator.areaCode.put("弓长岭区", 211005); - IdCardGenerator.areaCode.put("太子河区", 211011); - IdCardGenerator.areaCode.put("辽阳县", 211021); - IdCardGenerator.areaCode.put("灯塔市", 211081); - IdCardGenerator.areaCode.put("盘锦市", 211100); - IdCardGenerator.areaCode.put("市辖区", 211101); - IdCardGenerator.areaCode.put("双台子区", 211102); - IdCardGenerator.areaCode.put("兴隆台区", 211103); - IdCardGenerator.areaCode.put("大洼县", 211121); - IdCardGenerator.areaCode.put("盘山县", 211122); - IdCardGenerator.areaCode.put("铁岭市", 211200); - IdCardGenerator.areaCode.put("市辖区", 211201); - IdCardGenerator.areaCode.put("银州区", 211202); - IdCardGenerator.areaCode.put("清河区", 211204); - IdCardGenerator.areaCode.put("铁岭县", 211221); - IdCardGenerator.areaCode.put("西丰县", 211223); - IdCardGenerator.areaCode.put("昌图县", 211224); - IdCardGenerator.areaCode.put("调兵山市", 211281); - IdCardGenerator.areaCode.put("开原市", 211282); - IdCardGenerator.areaCode.put("朝阳市", 211300); - IdCardGenerator.areaCode.put("市辖区", 211301); - IdCardGenerator.areaCode.put("双塔区", 211302); - IdCardGenerator.areaCode.put("龙城区", 211303); - IdCardGenerator.areaCode.put("朝阳县", 211321); - IdCardGenerator.areaCode.put("建平县", 211322); - IdCardGenerator.areaCode.put("喀喇沁左翼蒙古族自治县", 211324); - IdCardGenerator.areaCode.put("北票市", 211381); - IdCardGenerator.areaCode.put("凌源市", 211382); - IdCardGenerator.areaCode.put("葫芦岛市", 211400); - IdCardGenerator.areaCode.put("市辖区", 211401); - IdCardGenerator.areaCode.put("连山区", 211402); - IdCardGenerator.areaCode.put("龙港区", 211403); - IdCardGenerator.areaCode.put("南票区", 211404); - IdCardGenerator.areaCode.put("绥中县", 211421); - IdCardGenerator.areaCode.put("建昌县", 211422); - IdCardGenerator.areaCode.put("兴城市", 211481); - IdCardGenerator.areaCode.put("吉林省", 220000); - IdCardGenerator.areaCode.put("长春市", 220100); - IdCardGenerator.areaCode.put("市辖区", 220101); - IdCardGenerator.areaCode.put("南关区", 220102); - IdCardGenerator.areaCode.put("宽城区", 220103); - IdCardGenerator.areaCode.put("朝阳区", 220104); - IdCardGenerator.areaCode.put("二道区", 220105); - IdCardGenerator.areaCode.put("绿园区", 220106); - IdCardGenerator.areaCode.put("双阳区", 220112); - IdCardGenerator.areaCode.put("农安县", 220122); - IdCardGenerator.areaCode.put("九台市", 220181); - IdCardGenerator.areaCode.put("榆树市", 220182); - IdCardGenerator.areaCode.put("德惠市", 220183); - IdCardGenerator.areaCode.put("吉林市", 220200); - IdCardGenerator.areaCode.put("市辖区", 220201); - IdCardGenerator.areaCode.put("昌邑区", 220202); - IdCardGenerator.areaCode.put("龙潭区", 220203); - IdCardGenerator.areaCode.put("船营区", 220204); - IdCardGenerator.areaCode.put("丰满区", 220211); - IdCardGenerator.areaCode.put("永吉县", 220221); - IdCardGenerator.areaCode.put("蛟河市", 220281); - IdCardGenerator.areaCode.put("桦甸市", 220282); - IdCardGenerator.areaCode.put("舒兰市", 220283); - IdCardGenerator.areaCode.put("磐石市", 220284); - IdCardGenerator.areaCode.put("四平市", 220300); - IdCardGenerator.areaCode.put("市辖区", 220301); - IdCardGenerator.areaCode.put("铁西区", 220302); - IdCardGenerator.areaCode.put("铁东区", 220303); - IdCardGenerator.areaCode.put("梨树县", 220322); - IdCardGenerator.areaCode.put("伊通满族自治县", 220323); - IdCardGenerator.areaCode.put("公主岭市", 220381); - IdCardGenerator.areaCode.put("双辽市", 220382); - IdCardGenerator.areaCode.put("辽源市", 220400); - IdCardGenerator.areaCode.put("市辖区", 220401); - IdCardGenerator.areaCode.put("龙山区", 220402); - IdCardGenerator.areaCode.put("西安区", 220403); - IdCardGenerator.areaCode.put("东丰县", 220421); - IdCardGenerator.areaCode.put("东辽县", 220422); - IdCardGenerator.areaCode.put("通化市", 220500); - IdCardGenerator.areaCode.put("市辖区", 220501); - IdCardGenerator.areaCode.put("东昌区", 220502); - IdCardGenerator.areaCode.put("二道江区", 220503); - IdCardGenerator.areaCode.put("通化县", 220521); - IdCardGenerator.areaCode.put("辉南县", 220523); - IdCardGenerator.areaCode.put("柳河县", 220524); - IdCardGenerator.areaCode.put("梅河口市", 220581); - IdCardGenerator.areaCode.put("集安市", 220582); - IdCardGenerator.areaCode.put("白山市", 220600); - IdCardGenerator.areaCode.put("市辖区", 220601); - IdCardGenerator.areaCode.put("八道江区", 220602); - IdCardGenerator.areaCode.put(" 江源区", 220605); - IdCardGenerator.areaCode.put("抚松县", 220621); - IdCardGenerator.areaCode.put("靖宇县", 220622); - IdCardGenerator.areaCode.put("长白朝鲜族自治县", 220623); - IdCardGenerator.areaCode.put("临江市", 220681); - IdCardGenerator.areaCode.put("松原市", 220700); - IdCardGenerator.areaCode.put("市辖区", 220701); - IdCardGenerator.areaCode.put("宁江区", 220702); - IdCardGenerator.areaCode.put("前郭尔罗斯蒙古族自治县", 220721); - IdCardGenerator.areaCode.put("长岭县", 220722); - IdCardGenerator.areaCode.put("乾安县", 220723); - IdCardGenerator.areaCode.put("扶余县", 220724); - IdCardGenerator.areaCode.put("白城市", 220800); - IdCardGenerator.areaCode.put("市辖区", 220801); - IdCardGenerator.areaCode.put("洮北区", 220802); - IdCardGenerator.areaCode.put("镇赉县", 220821); - IdCardGenerator.areaCode.put("通榆县", 220822); - IdCardGenerator.areaCode.put("洮南市", 220881); - IdCardGenerator.areaCode.put("大安市", 220882); - IdCardGenerator.areaCode.put("延边朝鲜族自治州", 222400); - IdCardGenerator.areaCode.put("延吉市", 222401); - IdCardGenerator.areaCode.put("图们市", 222402); - IdCardGenerator.areaCode.put("敦化市", 222403); - IdCardGenerator.areaCode.put("珲春市", 222404); - IdCardGenerator.areaCode.put("龙井市", 222405); - IdCardGenerator.areaCode.put("和龙市", 222406); - IdCardGenerator.areaCode.put("汪清县", 222424); - IdCardGenerator.areaCode.put("安图县", 222426); - IdCardGenerator.areaCode.put("黑龙江省", 230000); - IdCardGenerator.areaCode.put("哈尔滨市", 230100); - IdCardGenerator.areaCode.put("市辖区", 230101); - IdCardGenerator.areaCode.put("道里区", 230102); - IdCardGenerator.areaCode.put("南岗区", 230103); - IdCardGenerator.areaCode.put("道外区", 230104); - IdCardGenerator.areaCode.put("平房区", 230108); - IdCardGenerator.areaCode.put("松北区", 230109); - IdCardGenerator.areaCode.put("香坊区", 230110); - IdCardGenerator.areaCode.put("呼兰区", 230111); - IdCardGenerator.areaCode.put("依兰县", 230123); - IdCardGenerator.areaCode.put("方正县", 230124); - IdCardGenerator.areaCode.put("宾 县", 230125); - IdCardGenerator.areaCode.put("巴彦县", 230126); - IdCardGenerator.areaCode.put("木兰县", 230127); - IdCardGenerator.areaCode.put("通河县", 230128); - IdCardGenerator.areaCode.put("延寿县", 230129); - IdCardGenerator.areaCode.put("双城市", 230182); - IdCardGenerator.areaCode.put("尚志市", 230183); - IdCardGenerator.areaCode.put("五常市", 230184); - IdCardGenerator.areaCode.put("齐齐哈尔市", 230200); - IdCardGenerator.areaCode.put("市辖区", 230201); - IdCardGenerator.areaCode.put("龙沙区", 230202); - IdCardGenerator.areaCode.put("建华区", 230203); - IdCardGenerator.areaCode.put("铁锋区", 230204); - IdCardGenerator.areaCode.put("昂昂溪区", 230205); - IdCardGenerator.areaCode.put("富拉尔基区", 230206); - IdCardGenerator.areaCode.put("碾子山区", 230207); - IdCardGenerator.areaCode.put("梅里斯达斡尔族区", 230208); - IdCardGenerator.areaCode.put("龙江县", 230221); - IdCardGenerator.areaCode.put("依安县", 230223); - IdCardGenerator.areaCode.put("泰来县", 230224); - IdCardGenerator.areaCode.put("甘南县", 230225); - IdCardGenerator.areaCode.put("富裕县", 230227); - IdCardGenerator.areaCode.put("克山县", 230229); - IdCardGenerator.areaCode.put("克东县", 230230); - IdCardGenerator.areaCode.put("拜泉县", 230231); - IdCardGenerator.areaCode.put("讷河市", 230281); - IdCardGenerator.areaCode.put("鸡西市", 230300); - IdCardGenerator.areaCode.put("市辖区", 230301); - IdCardGenerator.areaCode.put("鸡冠区", 230302); - IdCardGenerator.areaCode.put("恒山区", 230303); - IdCardGenerator.areaCode.put("滴道区", 230304); - IdCardGenerator.areaCode.put("梨树区", 230305); - IdCardGenerator.areaCode.put("城子河区", 230306); - IdCardGenerator.areaCode.put("麻山区", 230307); - IdCardGenerator.areaCode.put("鸡东县", 230321); - IdCardGenerator.areaCode.put("虎林市", 230381); - IdCardGenerator.areaCode.put("密山市", 230382); - IdCardGenerator.areaCode.put("鹤岗市", 230400); - IdCardGenerator.areaCode.put("市辖区", 230401); - IdCardGenerator.areaCode.put("向阳区", 230402); - IdCardGenerator.areaCode.put("工农区", 230403); - IdCardGenerator.areaCode.put("南山区", 230404); - IdCardGenerator.areaCode.put("兴安区", 230405); - IdCardGenerator.areaCode.put("东山区", 230406); - IdCardGenerator.areaCode.put("兴山区", 230407); - IdCardGenerator.areaCode.put("萝北县", 230421); - IdCardGenerator.areaCode.put("绥滨县", 230422); - IdCardGenerator.areaCode.put("双鸭山市", 230500); - IdCardGenerator.areaCode.put("市辖区", 230501); - IdCardGenerator.areaCode.put("尖山区", 230502); - IdCardGenerator.areaCode.put("岭东区", 230503); - IdCardGenerator.areaCode.put("四方台区", 230505); - IdCardGenerator.areaCode.put("宝山区", 230506); - IdCardGenerator.areaCode.put("集贤县", 230521); - IdCardGenerator.areaCode.put("友谊县", 230522); - IdCardGenerator.areaCode.put("宝清县", 230523); - IdCardGenerator.areaCode.put("饶河县", 230524); - IdCardGenerator.areaCode.put("大庆市", 230600); - IdCardGenerator.areaCode.put("市辖区", 230601); - IdCardGenerator.areaCode.put("萨尔图区", 230602); - IdCardGenerator.areaCode.put("龙凤区", 230603); - IdCardGenerator.areaCode.put("让胡路区", 230604); - IdCardGenerator.areaCode.put("红岗区", 230605); - IdCardGenerator.areaCode.put("大同区", 230606); - IdCardGenerator.areaCode.put("肇州县", 230621); - IdCardGenerator.areaCode.put("肇源县", 230622); - IdCardGenerator.areaCode.put("林甸县", 230623); - IdCardGenerator.areaCode.put("杜尔伯特蒙古族自治县", 230624); - IdCardGenerator.areaCode.put("伊春市", 230700); - IdCardGenerator.areaCode.put("市辖区", 230701); - IdCardGenerator.areaCode.put("伊春区", 230702); - IdCardGenerator.areaCode.put("南岔区", 230703); - IdCardGenerator.areaCode.put("友好区", 230704); - IdCardGenerator.areaCode.put("西林区", 230705); - IdCardGenerator.areaCode.put("翠峦区", 230706); - IdCardGenerator.areaCode.put("新青区", 230707); - IdCardGenerator.areaCode.put("美溪区", 230708); - IdCardGenerator.areaCode.put("金山屯区", 230709); - IdCardGenerator.areaCode.put("五营区", 230710); - IdCardGenerator.areaCode.put("乌马河区", 230711); - IdCardGenerator.areaCode.put("汤旺河区", 230712); - IdCardGenerator.areaCode.put("带岭区", 230713); - IdCardGenerator.areaCode.put("乌伊岭区", 230714); - IdCardGenerator.areaCode.put("红星区", 230715); - IdCardGenerator.areaCode.put("上甘岭区", 230716); - IdCardGenerator.areaCode.put("嘉荫县", 230722); - IdCardGenerator.areaCode.put("铁力市", 230781); - IdCardGenerator.areaCode.put("佳木斯市", 230800); - IdCardGenerator.areaCode.put("市辖区", 230801); - IdCardGenerator.areaCode.put("向阳区", 230803); - IdCardGenerator.areaCode.put("前进区", 230804); - IdCardGenerator.areaCode.put("东风区", 230805); - IdCardGenerator.areaCode.put("郊 区", 230811); - IdCardGenerator.areaCode.put("桦南县", 230822); - IdCardGenerator.areaCode.put("桦川县", 230826); - IdCardGenerator.areaCode.put("汤原县", 230828); - IdCardGenerator.areaCode.put("抚远县", 230833); - IdCardGenerator.areaCode.put("同江市", 230881); - IdCardGenerator.areaCode.put("富锦市", 230882); - IdCardGenerator.areaCode.put("七台河市", 230900); - IdCardGenerator.areaCode.put("市辖区", 230901); - IdCardGenerator.areaCode.put("新兴区", 230902); - IdCardGenerator.areaCode.put("桃山区", 230903); - IdCardGenerator.areaCode.put("茄子河区", 230904); - IdCardGenerator.areaCode.put("勃利县", 230921); - IdCardGenerator.areaCode.put("牡丹江市", 231000); - IdCardGenerator.areaCode.put("市辖区", 231001); - IdCardGenerator.areaCode.put("东安区", 231002); - IdCardGenerator.areaCode.put("阳明区", 231003); - IdCardGenerator.areaCode.put("爱民区", 231004); - IdCardGenerator.areaCode.put("西安区", 231005); - IdCardGenerator.areaCode.put("东宁县", 231024); - IdCardGenerator.areaCode.put("林口县", 231025); - IdCardGenerator.areaCode.put("绥芬河市", 231081); - IdCardGenerator.areaCode.put("海林市", 231083); - IdCardGenerator.areaCode.put("宁安市", 231084); - IdCardGenerator.areaCode.put("穆棱市", 231085); - IdCardGenerator.areaCode.put("黑河市", 231100); - IdCardGenerator.areaCode.put("市辖区", 231101); - IdCardGenerator.areaCode.put("爱辉区", 231102); - IdCardGenerator.areaCode.put("嫩江县", 231121); - IdCardGenerator.areaCode.put("逊克县", 231123); - IdCardGenerator.areaCode.put("孙吴县", 231124); - IdCardGenerator.areaCode.put("北安市", 231181); - IdCardGenerator.areaCode.put("五大连池市", 231182); - IdCardGenerator.areaCode.put("绥化市", 231200); - IdCardGenerator.areaCode.put("市辖区", 231201); - IdCardGenerator.areaCode.put("北林区", 231202); - IdCardGenerator.areaCode.put("望奎县", 231221); - IdCardGenerator.areaCode.put("兰西县", 231222); - IdCardGenerator.areaCode.put("青冈县", 231223); - IdCardGenerator.areaCode.put("庆安县", 231224); - IdCardGenerator.areaCode.put("明水县", 231225); - IdCardGenerator.areaCode.put("绥棱县", 231226); - IdCardGenerator.areaCode.put("安达市", 231281); - IdCardGenerator.areaCode.put("肇东市", 231282); - IdCardGenerator.areaCode.put("海伦市", 231283); - IdCardGenerator.areaCode.put("大兴安岭地区", 232700); - IdCardGenerator.areaCode.put("呼玛县", 232721); - IdCardGenerator.areaCode.put("塔河县", 232722); - IdCardGenerator.areaCode.put("漠河县", 232723); - IdCardGenerator.areaCode.put("上海市", 310000); - IdCardGenerator.areaCode.put("市辖区", 310100); - IdCardGenerator.areaCode.put("黄浦区", 310101); - IdCardGenerator.areaCode.put("卢湾区", 310103); - IdCardGenerator.areaCode.put("徐汇区", 310104); - IdCardGenerator.areaCode.put("长宁区", 310105); - IdCardGenerator.areaCode.put("静安区", 310106); - IdCardGenerator.areaCode.put("普陀区", 310107); - IdCardGenerator.areaCode.put("闸北区", 310108); - IdCardGenerator.areaCode.put("虹口区", 310109); - IdCardGenerator.areaCode.put("杨浦区", 310110); - IdCardGenerator.areaCode.put("闵行区", 310112); - IdCardGenerator.areaCode.put("宝山区", 310113); - IdCardGenerator.areaCode.put("嘉定区", 310114); - IdCardGenerator.areaCode.put("浦东新区 (*)", 310115); - IdCardGenerator.areaCode.put("金山区", 310116); - IdCardGenerator.areaCode.put("松江区", 310117); - IdCardGenerator.areaCode.put("青浦区", 310118); - IdCardGenerator.areaCode.put("奉贤区", 310120); - IdCardGenerator.areaCode.put("县", 310200); - IdCardGenerator.areaCode.put("崇明县", 310230); - IdCardGenerator.areaCode.put("江苏省", 320000); - IdCardGenerator.areaCode.put("南京市", 320100); - IdCardGenerator.areaCode.put("市辖区", 320101); - IdCardGenerator.areaCode.put("玄武区", 320102); - IdCardGenerator.areaCode.put("白下区", 320103); - IdCardGenerator.areaCode.put("秦淮区", 320104); - IdCardGenerator.areaCode.put("建邺区", 320105); - IdCardGenerator.areaCode.put("鼓楼区", 320106); - IdCardGenerator.areaCode.put("下关区", 320107); - IdCardGenerator.areaCode.put("浦口区", 320111); - IdCardGenerator.areaCode.put("栖霞区", 320113); - IdCardGenerator.areaCode.put("雨花台区", 320114); - IdCardGenerator.areaCode.put("江宁区", 320115); - IdCardGenerator.areaCode.put("六合区", 320116); - IdCardGenerator.areaCode.put("溧水县", 320124); - IdCardGenerator.areaCode.put("高淳县", 320125); - IdCardGenerator.areaCode.put("无锡市", 320200); - IdCardGenerator.areaCode.put("市辖区", 320201); - IdCardGenerator.areaCode.put("崇安区", 320202); - IdCardGenerator.areaCode.put("南长区", 320203); - IdCardGenerator.areaCode.put("北塘区", 320204); - IdCardGenerator.areaCode.put("锡山区", 320205); - IdCardGenerator.areaCode.put("惠山区", 320206); - IdCardGenerator.areaCode.put("滨湖区", 320211); - IdCardGenerator.areaCode.put("江阴市", 320281); - IdCardGenerator.areaCode.put("宜兴市", 320282); - IdCardGenerator.areaCode.put("徐州市", 320300); - IdCardGenerator.areaCode.put("市辖区", 320301); - IdCardGenerator.areaCode.put("鼓楼区", 320302); - IdCardGenerator.areaCode.put("云龙区", 320303); - IdCardGenerator.areaCode.put("九里区", 320304); - IdCardGenerator.areaCode.put("贾汪区", 320305); - IdCardGenerator.areaCode.put("泉山区", 320311); - IdCardGenerator.areaCode.put("丰 县", 320321); - IdCardGenerator.areaCode.put("沛 县", 320322); - IdCardGenerator.areaCode.put("铜山县", 320323); - IdCardGenerator.areaCode.put("睢宁县", 320324); - IdCardGenerator.areaCode.put("新沂市", 320381); - IdCardGenerator.areaCode.put("邳州市", 320382); - IdCardGenerator.areaCode.put("常州市", 320400); - IdCardGenerator.areaCode.put("市辖区", 320401); - IdCardGenerator.areaCode.put("天宁区", 320402); - IdCardGenerator.areaCode.put("钟楼区", 320404); - IdCardGenerator.areaCode.put("戚墅堰区", 320405); - IdCardGenerator.areaCode.put("新北区", 320411); - IdCardGenerator.areaCode.put("武进区", 320412); - IdCardGenerator.areaCode.put("溧阳市", 320481); - IdCardGenerator.areaCode.put("金坛市", 320482); - IdCardGenerator.areaCode.put("苏州市", 320500); - IdCardGenerator.areaCode.put("市辖区", 320501); - IdCardGenerator.areaCode.put("沧浪区", 320502); - IdCardGenerator.areaCode.put("平江区", 320503); - IdCardGenerator.areaCode.put("金阊区", 320504); - IdCardGenerator.areaCode.put("虎丘区", 320505); - IdCardGenerator.areaCode.put("吴中区", 320506); - IdCardGenerator.areaCode.put("相城区", 320507); - IdCardGenerator.areaCode.put("常熟市", 320581); - IdCardGenerator.areaCode.put("张家港市", 320582); - IdCardGenerator.areaCode.put("昆山市", 320583); - IdCardGenerator.areaCode.put("吴江市", 320584); - IdCardGenerator.areaCode.put("太仓市", 320585); - IdCardGenerator.areaCode.put("南通市", 320600); - IdCardGenerator.areaCode.put("市辖区", 320601); - IdCardGenerator.areaCode.put("崇川区", 320602); - IdCardGenerator.areaCode.put("港闸区", 320611); - IdCardGenerator.areaCode.put("海安县", 320621); - IdCardGenerator.areaCode.put("如东县", 320623); - IdCardGenerator.areaCode.put("启东市", 320681); - IdCardGenerator.areaCode.put("如皋市", 320682); - IdCardGenerator.areaCode.put("海门市", 320684); - IdCardGenerator.areaCode.put("连云港市", 320700); - IdCardGenerator.areaCode.put("市辖区", 320701); - IdCardGenerator.areaCode.put("连云区", 320703); - IdCardGenerator.areaCode.put("新浦区", 320705); - IdCardGenerator.areaCode.put("海州区", 320706); - IdCardGenerator.areaCode.put("赣榆县", 320721); - IdCardGenerator.areaCode.put("东海县", 320722); - IdCardGenerator.areaCode.put("灌云县", 320723); - IdCardGenerator.areaCode.put("灌南县", 320724); - IdCardGenerator.areaCode.put("淮安市", 320800); - IdCardGenerator.areaCode.put("市辖区", 320801); - IdCardGenerator.areaCode.put("清河区", 320802); - IdCardGenerator.areaCode.put("楚州区", 320803); - IdCardGenerator.areaCode.put("淮阴区", 320804); - IdCardGenerator.areaCode.put("清浦区", 320811); - IdCardGenerator.areaCode.put("涟水县", 320826); - IdCardGenerator.areaCode.put("洪泽县", 320829); - IdCardGenerator.areaCode.put("盱眙县", 320830); - IdCardGenerator.areaCode.put("金湖县", 320831); - IdCardGenerator.areaCode.put("盐城市", 320900); - IdCardGenerator.areaCode.put("市辖区", 320901); - IdCardGenerator.areaCode.put("亭湖区", 320902); - IdCardGenerator.areaCode.put("盐都区", 320903); - IdCardGenerator.areaCode.put("响水县", 320921); - IdCardGenerator.areaCode.put("滨海县", 320922); - IdCardGenerator.areaCode.put("阜宁县", 320923); - IdCardGenerator.areaCode.put("射阳县", 320924); - IdCardGenerator.areaCode.put("建湖县", 320925); - IdCardGenerator.areaCode.put("东台市", 320981); - IdCardGenerator.areaCode.put("大丰市", 320982); - IdCardGenerator.areaCode.put("扬州市", 321000); - IdCardGenerator.areaCode.put("市辖区", 321001); - IdCardGenerator.areaCode.put("广陵区", 321002); - IdCardGenerator.areaCode.put("邗江区", 321003); - IdCardGenerator.areaCode.put("维扬区", 321011); - IdCardGenerator.areaCode.put("宝应县", 321023); - IdCardGenerator.areaCode.put("仪征市", 321081); - IdCardGenerator.areaCode.put("高邮市", 321084); - IdCardGenerator.areaCode.put("江都市", 321088); - IdCardGenerator.areaCode.put("镇江市", 321100); - IdCardGenerator.areaCode.put("市辖区", 321101); - IdCardGenerator.areaCode.put("京口区", 321102); - IdCardGenerator.areaCode.put("润州区", 321111); - IdCardGenerator.areaCode.put("丹徒区", 321112); - IdCardGenerator.areaCode.put("丹阳市", 321181); - IdCardGenerator.areaCode.put("扬中市", 321182); - IdCardGenerator.areaCode.put("句容市", 321183); - IdCardGenerator.areaCode.put("泰州市", 321200); - IdCardGenerator.areaCode.put("市辖区", 321201); - IdCardGenerator.areaCode.put("海陵区", 321202); - IdCardGenerator.areaCode.put("高港区", 321203); - IdCardGenerator.areaCode.put("兴化市", 321281); - IdCardGenerator.areaCode.put("靖江市", 321282); - IdCardGenerator.areaCode.put("泰兴市", 321283); - IdCardGenerator.areaCode.put("姜堰市", 321284); - IdCardGenerator.areaCode.put("宿迁市", 321300); - IdCardGenerator.areaCode.put("市辖区", 321301); - IdCardGenerator.areaCode.put("宿城区", 321302); - IdCardGenerator.areaCode.put("宿豫区", 321311); - IdCardGenerator.areaCode.put("沭阳县", 321322); - IdCardGenerator.areaCode.put("泗阳县", 321323); - IdCardGenerator.areaCode.put("泗洪县", 321324); - IdCardGenerator.areaCode.put("浙江省", 330000); - IdCardGenerator.areaCode.put("杭州市", 330100); - IdCardGenerator.areaCode.put("市辖区", 330101); - IdCardGenerator.areaCode.put("上城区", 330102); - IdCardGenerator.areaCode.put("下城区", 330103); - IdCardGenerator.areaCode.put("江干区", 330104); - IdCardGenerator.areaCode.put("拱墅区", 330105); - IdCardGenerator.areaCode.put("西湖区", 330106); - IdCardGenerator.areaCode.put("滨江区", 330108); - IdCardGenerator.areaCode.put("萧山区", 330109); - IdCardGenerator.areaCode.put("余杭区", 330110); - IdCardGenerator.areaCode.put("桐庐县", 330122); - IdCardGenerator.areaCode.put("淳安县", 330127); - IdCardGenerator.areaCode.put("建德市", 330182); - IdCardGenerator.areaCode.put("富阳市", 330183); - IdCardGenerator.areaCode.put("临安市", 330185); - IdCardGenerator.areaCode.put("宁波市", 330200); - IdCardGenerator.areaCode.put("市辖区", 330201); - IdCardGenerator.areaCode.put("海曙区", 330203); - IdCardGenerator.areaCode.put("江东区", 330204); - IdCardGenerator.areaCode.put("江北区", 330205); - IdCardGenerator.areaCode.put("北仑区", 330206); - IdCardGenerator.areaCode.put("镇海区", 330211); - IdCardGenerator.areaCode.put("鄞州区", 330212); - IdCardGenerator.areaCode.put("象山县", 330225); - IdCardGenerator.areaCode.put("宁海县", 330226); - IdCardGenerator.areaCode.put("余姚市", 330281); - IdCardGenerator.areaCode.put("慈溪市", 330282); - IdCardGenerator.areaCode.put("奉化市", 330283); - IdCardGenerator.areaCode.put("温州市", 330300); - IdCardGenerator.areaCode.put("市辖区", 330301); - IdCardGenerator.areaCode.put("鹿城区", 330302); - IdCardGenerator.areaCode.put("龙湾区", 330303); - IdCardGenerator.areaCode.put("瓯海区", 330304); - IdCardGenerator.areaCode.put("洞头县", 330322); - IdCardGenerator.areaCode.put("永嘉县", 330324); - IdCardGenerator.areaCode.put("平阳县", 330326); - IdCardGenerator.areaCode.put("苍南县", 330327); - IdCardGenerator.areaCode.put("文成县", 330328); - IdCardGenerator.areaCode.put("泰顺县", 330329); - IdCardGenerator.areaCode.put("瑞安市", 330381); - IdCardGenerator.areaCode.put("乐清市", 330382); - IdCardGenerator.areaCode.put("嘉兴市", 330400); - IdCardGenerator.areaCode.put("市辖区", 330401); - IdCardGenerator.areaCode.put("南湖区", 330402); - IdCardGenerator.areaCode.put("秀洲区", 330411); - IdCardGenerator.areaCode.put("嘉善县", 330421); - IdCardGenerator.areaCode.put("海盐县", 330424); - IdCardGenerator.areaCode.put("海宁市", 330481); - IdCardGenerator.areaCode.put("平湖市", 330482); - IdCardGenerator.areaCode.put("桐乡市", 330483); - IdCardGenerator.areaCode.put("湖州市", 330500); - IdCardGenerator.areaCode.put("市辖区", 330501); - IdCardGenerator.areaCode.put("吴兴区", 330502); - IdCardGenerator.areaCode.put("南浔区", 330503); - IdCardGenerator.areaCode.put("德清县", 330521); - IdCardGenerator.areaCode.put("长兴县", 330522); - IdCardGenerator.areaCode.put("安吉县", 330523); - IdCardGenerator.areaCode.put("绍兴市", 330600); - IdCardGenerator.areaCode.put("市辖区", 330601); - IdCardGenerator.areaCode.put("越城区", 330602); - IdCardGenerator.areaCode.put("绍兴县", 330621); - IdCardGenerator.areaCode.put("新昌县", 330624); - IdCardGenerator.areaCode.put("诸暨市", 330681); - IdCardGenerator.areaCode.put("上虞市", 330682); - IdCardGenerator.areaCode.put("嵊州市", 330683); - IdCardGenerator.areaCode.put("金华市", 330700); - IdCardGenerator.areaCode.put("市辖区", 330701); - IdCardGenerator.areaCode.put("婺城区", 330702); - IdCardGenerator.areaCode.put("金东区", 330703); - IdCardGenerator.areaCode.put("武义县", 330723); - IdCardGenerator.areaCode.put("浦江县", 330726); - IdCardGenerator.areaCode.put("磐安县", 330727); - IdCardGenerator.areaCode.put("兰溪市", 330781); - IdCardGenerator.areaCode.put("义乌市", 330782); - IdCardGenerator.areaCode.put("东阳市", 330783); - IdCardGenerator.areaCode.put("永康市", 330784); - IdCardGenerator.areaCode.put("衢州市", 330800); - IdCardGenerator.areaCode.put("市辖区", 330801); - IdCardGenerator.areaCode.put("柯城区", 330802); - IdCardGenerator.areaCode.put("衢江区", 330803); - IdCardGenerator.areaCode.put("常山县", 330822); - IdCardGenerator.areaCode.put("开化县", 330824); - IdCardGenerator.areaCode.put("龙游县", 330825); - IdCardGenerator.areaCode.put("江山市", 330881); - IdCardGenerator.areaCode.put("舟山市", 330900); - IdCardGenerator.areaCode.put("市辖区", 330901); - IdCardGenerator.areaCode.put("定海区", 330902); - IdCardGenerator.areaCode.put("普陀区", 330903); - IdCardGenerator.areaCode.put("岱山县", 330921); - IdCardGenerator.areaCode.put("嵊泗县", 330922); - IdCardGenerator.areaCode.put("台州市", 331000); - IdCardGenerator.areaCode.put("市辖区", 331001); - IdCardGenerator.areaCode.put("椒江区", 331002); - IdCardGenerator.areaCode.put("黄岩区", 331003); - IdCardGenerator.areaCode.put("路桥区", 331004); - IdCardGenerator.areaCode.put("玉环县", 331021); - IdCardGenerator.areaCode.put("三门县", 331022); - IdCardGenerator.areaCode.put("天台县", 331023); - IdCardGenerator.areaCode.put("仙居县", 331024); - IdCardGenerator.areaCode.put("温岭市", 331081); - IdCardGenerator.areaCode.put("临海市", 331082); - IdCardGenerator.areaCode.put("丽水市", 331100); - IdCardGenerator.areaCode.put("市辖区", 331101); - IdCardGenerator.areaCode.put("莲都区", 331102); - IdCardGenerator.areaCode.put("青田县", 331121); - IdCardGenerator.areaCode.put("缙云县", 331122); - IdCardGenerator.areaCode.put("遂昌县", 331123); - IdCardGenerator.areaCode.put("松阳县", 331124); - IdCardGenerator.areaCode.put("云和县", 331125); - IdCardGenerator.areaCode.put("庆元县", 331126); - IdCardGenerator.areaCode.put("景宁畲族自治县", 331127); - IdCardGenerator.areaCode.put("龙泉市", 331181); - IdCardGenerator.areaCode.put("安徽省", 340000); - IdCardGenerator.areaCode.put("合肥市", 340100); - IdCardGenerator.areaCode.put("市辖区", 340101); - IdCardGenerator.areaCode.put("瑶海区", 340102); - IdCardGenerator.areaCode.put("庐阳区", 340103); - IdCardGenerator.areaCode.put("蜀山区", 340104); - IdCardGenerator.areaCode.put("包河区", 340111); - IdCardGenerator.areaCode.put("长丰县", 340121); - IdCardGenerator.areaCode.put("肥东县", 340122); - IdCardGenerator.areaCode.put("肥西县", 340123); - IdCardGenerator.areaCode.put("芜湖市", 340200); - IdCardGenerator.areaCode.put("市辖区", 340201); - IdCardGenerator.areaCode.put("镜湖区", 340202); - IdCardGenerator.areaCode.put("弋江区", 340203); - IdCardGenerator.areaCode.put("鸠江区", 340207); - IdCardGenerator.areaCode.put("三山区", 340208); - IdCardGenerator.areaCode.put("芜湖县", 340221); - IdCardGenerator.areaCode.put("繁昌县", 340222); - IdCardGenerator.areaCode.put("南陵县", 340223); - IdCardGenerator.areaCode.put("蚌埠市", 340300); - IdCardGenerator.areaCode.put("市辖区", 340301); - IdCardGenerator.areaCode.put("龙子湖区", 340302); - IdCardGenerator.areaCode.put("蚌山区", 340303); - IdCardGenerator.areaCode.put("禹会区", 340304); - IdCardGenerator.areaCode.put("淮上区", 340311); - IdCardGenerator.areaCode.put("怀远县", 340321); - IdCardGenerator.areaCode.put("五河县", 340322); - IdCardGenerator.areaCode.put("固镇县", 340323); - IdCardGenerator.areaCode.put("淮南市", 340400); - IdCardGenerator.areaCode.put("市辖区", 340401); - IdCardGenerator.areaCode.put("大通区", 340402); - IdCardGenerator.areaCode.put("田家庵区", 340403); - IdCardGenerator.areaCode.put("谢家集区", 340404); - IdCardGenerator.areaCode.put("八公山区", 340405); - IdCardGenerator.areaCode.put("潘集区", 340406); - IdCardGenerator.areaCode.put("凤台县", 340421); - IdCardGenerator.areaCode.put("马鞍山市", 340500); - IdCardGenerator.areaCode.put("市辖区", 340501); - IdCardGenerator.areaCode.put("金家庄区", 340502); - IdCardGenerator.areaCode.put("花山区", 340503); - IdCardGenerator.areaCode.put("雨山区", 340504); - IdCardGenerator.areaCode.put("当涂县", 340521); - IdCardGenerator.areaCode.put("淮北市", 340600); - IdCardGenerator.areaCode.put("市辖区", 340601); - IdCardGenerator.areaCode.put("杜集区", 340602); - IdCardGenerator.areaCode.put("相山区", 340603); - IdCardGenerator.areaCode.put("烈山区", 340604); - IdCardGenerator.areaCode.put("濉溪县", 340621); - IdCardGenerator.areaCode.put("铜陵市", 340700); - IdCardGenerator.areaCode.put("市辖区", 340701); - IdCardGenerator.areaCode.put("铜官山区", 340702); - IdCardGenerator.areaCode.put("狮子山区", 340703); - IdCardGenerator.areaCode.put("郊 区", 340711); - IdCardGenerator.areaCode.put("铜陵县", 340721); - IdCardGenerator.areaCode.put("安庆市", 340800); - IdCardGenerator.areaCode.put("市辖区", 340801); - IdCardGenerator.areaCode.put("迎江区", 340802); - IdCardGenerator.areaCode.put("大观区", 340803); - IdCardGenerator.areaCode.put("宜秀区", 340811); - IdCardGenerator.areaCode.put("怀宁县", 340822); - IdCardGenerator.areaCode.put("枞阳县", 340823); - IdCardGenerator.areaCode.put("潜山县", 340824); - IdCardGenerator.areaCode.put("太湖县", 340825); - IdCardGenerator.areaCode.put("宿松县", 340826); - IdCardGenerator.areaCode.put("望江县", 340827); - IdCardGenerator.areaCode.put("岳西县", 340828); - IdCardGenerator.areaCode.put("桐城市", 340881); - IdCardGenerator.areaCode.put("黄山市", 341000); - IdCardGenerator.areaCode.put("市辖区", 341001); - IdCardGenerator.areaCode.put("屯溪区", 341002); - IdCardGenerator.areaCode.put("黄山区", 341003); - IdCardGenerator.areaCode.put("徽州区", 341004); - IdCardGenerator.areaCode.put("歙 县", 341021); - IdCardGenerator.areaCode.put("休宁县", 341022); - IdCardGenerator.areaCode.put("黟 县", 341023); - IdCardGenerator.areaCode.put("祁门县", 341024); - IdCardGenerator.areaCode.put("滁州市", 341100); - IdCardGenerator.areaCode.put("市辖区", 341101); - IdCardGenerator.areaCode.put("琅琊区", 341102); - IdCardGenerator.areaCode.put("南谯区", 341103); - IdCardGenerator.areaCode.put("来安县", 341122); - IdCardGenerator.areaCode.put("全椒县", 341124); - IdCardGenerator.areaCode.put("定远县", 341125); - IdCardGenerator.areaCode.put("凤阳县", 341126); - IdCardGenerator.areaCode.put("天长市", 341181); - IdCardGenerator.areaCode.put("明光市", 341182); - IdCardGenerator.areaCode.put("阜阳市", 341200); - IdCardGenerator.areaCode.put("市辖区", 341201); - IdCardGenerator.areaCode.put("颍州区", 341202); - IdCardGenerator.areaCode.put("颍东区", 341203); - IdCardGenerator.areaCode.put("颍泉区", 341204); - IdCardGenerator.areaCode.put("临泉县", 341221); - IdCardGenerator.areaCode.put("太和县", 341222); - IdCardGenerator.areaCode.put("阜南县", 341225); - IdCardGenerator.areaCode.put("颍上县", 341226); - IdCardGenerator.areaCode.put("界首市", 341282); - IdCardGenerator.areaCode.put("宿州市", 341300); - IdCardGenerator.areaCode.put("市辖区", 341301); - IdCardGenerator.areaCode.put("埇桥区", 341302); - IdCardGenerator.areaCode.put("砀山县", 341321); - IdCardGenerator.areaCode.put("萧 县", 341322); - IdCardGenerator.areaCode.put("灵璧县", 341323); - IdCardGenerator.areaCode.put("泗 县", 341324); - IdCardGenerator.areaCode.put("巢湖市", 341400); - IdCardGenerator.areaCode.put("市辖区", 341401); - IdCardGenerator.areaCode.put("居巢区", 341402); - IdCardGenerator.areaCode.put("庐江县", 341421); - IdCardGenerator.areaCode.put("无为县", 341422); - IdCardGenerator.areaCode.put("含山县", 341423); - IdCardGenerator.areaCode.put("和 县", 341424); - IdCardGenerator.areaCode.put("六安市", 341500); - IdCardGenerator.areaCode.put("市辖区", 341501); - IdCardGenerator.areaCode.put("金安区", 341502); - IdCardGenerator.areaCode.put("裕安区", 341503); - IdCardGenerator.areaCode.put("寿 县", 341521); - IdCardGenerator.areaCode.put("霍邱县", 341522); - IdCardGenerator.areaCode.put("舒城县", 341523); - IdCardGenerator.areaCode.put("金寨县", 341524); - IdCardGenerator.areaCode.put("霍山县", 341525); - IdCardGenerator.areaCode.put("亳州市", 341600); - IdCardGenerator.areaCode.put("市辖区", 341601); - IdCardGenerator.areaCode.put("谯城区", 341602); - IdCardGenerator.areaCode.put("涡阳县", 341621); - IdCardGenerator.areaCode.put("蒙城县", 341622); - IdCardGenerator.areaCode.put("利辛县", 341623); - IdCardGenerator.areaCode.put("池州市", 341700); - IdCardGenerator.areaCode.put("市辖区", 341701); - IdCardGenerator.areaCode.put("贵池区", 341702); - IdCardGenerator.areaCode.put("东至县", 341721); - IdCardGenerator.areaCode.put("石台县", 341722); - IdCardGenerator.areaCode.put("青阳县", 341723); - IdCardGenerator.areaCode.put("宣城市", 341800); - IdCardGenerator.areaCode.put("市辖区", 341801); - IdCardGenerator.areaCode.put("宣州区", 341802); - IdCardGenerator.areaCode.put("郎溪县", 341821); - IdCardGenerator.areaCode.put("广德县", 341822); - IdCardGenerator.areaCode.put("泾 县", 341823); - IdCardGenerator.areaCode.put("绩溪县", 341824); - IdCardGenerator.areaCode.put("旌德县", 341825); - IdCardGenerator.areaCode.put("宁国市", 341881); - IdCardGenerator.areaCode.put("福建省", 350000); - IdCardGenerator.areaCode.put("福州市", 350100); - IdCardGenerator.areaCode.put("市辖区", 350101); - IdCardGenerator.areaCode.put("鼓楼区", 350102); - IdCardGenerator.areaCode.put("台江区", 350103); - IdCardGenerator.areaCode.put("仓山区", 350104); - IdCardGenerator.areaCode.put("马尾区", 350105); - IdCardGenerator.areaCode.put("晋安区", 350111); - IdCardGenerator.areaCode.put("闽侯县", 350121); - IdCardGenerator.areaCode.put("连江县", 350122); - IdCardGenerator.areaCode.put("罗源县", 350123); - IdCardGenerator.areaCode.put("闽清县", 350124); - IdCardGenerator.areaCode.put("永泰县", 350125); - IdCardGenerator.areaCode.put("平潭县", 350128); - IdCardGenerator.areaCode.put("福清市", 350181); - IdCardGenerator.areaCode.put("长乐市", 350182); - IdCardGenerator.areaCode.put("厦门市", 350200); - IdCardGenerator.areaCode.put("市辖区", 350201); - IdCardGenerator.areaCode.put("思明区", 350203); - IdCardGenerator.areaCode.put("海沧区", 350205); - IdCardGenerator.areaCode.put("湖里区", 350206); - IdCardGenerator.areaCode.put("集美区", 350211); - IdCardGenerator.areaCode.put("同安区", 350212); - IdCardGenerator.areaCode.put("翔安区", 350213); - IdCardGenerator.areaCode.put("莆田市", 350300); - IdCardGenerator.areaCode.put("市辖区", 350301); - IdCardGenerator.areaCode.put("城厢区", 350302); - IdCardGenerator.areaCode.put("涵江区", 350303); - IdCardGenerator.areaCode.put("荔城区", 350304); - IdCardGenerator.areaCode.put("秀屿区", 350305); - IdCardGenerator.areaCode.put("仙游县", 350322); - IdCardGenerator.areaCode.put("三明市", 350400); - IdCardGenerator.areaCode.put("市辖区", 350401); - IdCardGenerator.areaCode.put("梅列区", 350402); - IdCardGenerator.areaCode.put("三元区", 350403); - IdCardGenerator.areaCode.put("明溪县", 350421); - IdCardGenerator.areaCode.put("清流县", 350423); - IdCardGenerator.areaCode.put("宁化县", 350424); - IdCardGenerator.areaCode.put("大田县", 350425); - IdCardGenerator.areaCode.put("尤溪县", 350426); - IdCardGenerator.areaCode.put("沙 县", 350427); - IdCardGenerator.areaCode.put("将乐县", 350428); - IdCardGenerator.areaCode.put("泰宁县", 350429); - IdCardGenerator.areaCode.put("建宁县", 350430); - IdCardGenerator.areaCode.put("永安市", 350481); - IdCardGenerator.areaCode.put("泉州市", 350500); - IdCardGenerator.areaCode.put("市辖区", 350501); - IdCardGenerator.areaCode.put("鲤城区", 350502); - IdCardGenerator.areaCode.put("丰泽区", 350503); - IdCardGenerator.areaCode.put("洛江区", 350504); - IdCardGenerator.areaCode.put("泉港区", 350505); - IdCardGenerator.areaCode.put("惠安县", 350521); - IdCardGenerator.areaCode.put("安溪县", 350524); - IdCardGenerator.areaCode.put("永春县", 350525); - IdCardGenerator.areaCode.put("德化县", 350526); - IdCardGenerator.areaCode.put("金门县", 350527); - IdCardGenerator.areaCode.put("石狮市", 350581); - IdCardGenerator.areaCode.put("晋江市", 350582); - IdCardGenerator.areaCode.put("南安市", 350583); - IdCardGenerator.areaCode.put("漳州市", 350600); - IdCardGenerator.areaCode.put("市辖区", 350601); - IdCardGenerator.areaCode.put("芗城区", 350602); - IdCardGenerator.areaCode.put("龙文区", 350603); - IdCardGenerator.areaCode.put("云霄县", 350622); - IdCardGenerator.areaCode.put("漳浦县", 350623); - IdCardGenerator.areaCode.put("诏安县", 350624); - IdCardGenerator.areaCode.put("长泰县", 350625); - IdCardGenerator.areaCode.put("东山县", 350626); - IdCardGenerator.areaCode.put("南靖县", 350627); - IdCardGenerator.areaCode.put("平和县", 350628); - IdCardGenerator.areaCode.put("华安县", 350629); - IdCardGenerator.areaCode.put("龙海市", 350681); - IdCardGenerator.areaCode.put("南平市", 350700); - IdCardGenerator.areaCode.put("市辖区", 350701); - IdCardGenerator.areaCode.put("延平区", 350702); - IdCardGenerator.areaCode.put("顺昌县", 350721); - IdCardGenerator.areaCode.put("浦城县", 350722); - IdCardGenerator.areaCode.put("光泽县", 350723); - IdCardGenerator.areaCode.put("松溪县", 350724); - IdCardGenerator.areaCode.put("政和县", 350725); - IdCardGenerator.areaCode.put("邵武市", 350781); - IdCardGenerator.areaCode.put("武夷山市", 350782); - IdCardGenerator.areaCode.put("建瓯市", 350783); - IdCardGenerator.areaCode.put("建阳市", 350784); - IdCardGenerator.areaCode.put("龙岩市", 350800); - IdCardGenerator.areaCode.put("市辖区", 350801); - IdCardGenerator.areaCode.put("新罗区", 350802); - IdCardGenerator.areaCode.put("长汀县", 350821); - IdCardGenerator.areaCode.put("永定县", 350822); - IdCardGenerator.areaCode.put("上杭县", 350823); - IdCardGenerator.areaCode.put("武平县", 350824); - IdCardGenerator.areaCode.put("连城县", 350825); - IdCardGenerator.areaCode.put("漳平市", 350881); - IdCardGenerator.areaCode.put("宁德市", 350900); - IdCardGenerator.areaCode.put("市辖区", 350901); - IdCardGenerator.areaCode.put("蕉城区", 350902); - IdCardGenerator.areaCode.put("霞浦县", 350921); - IdCardGenerator.areaCode.put("古田县", 350922); - IdCardGenerator.areaCode.put("屏南县", 350923); - IdCardGenerator.areaCode.put("寿宁县", 350924); - IdCardGenerator.areaCode.put("周宁县", 350925); - IdCardGenerator.areaCode.put("柘荣县", 350926); - IdCardGenerator.areaCode.put("福安市", 350981); - IdCardGenerator.areaCode.put("福鼎市", 350982); - IdCardGenerator.areaCode.put("江西省", 360000); - IdCardGenerator.areaCode.put("南昌市", 360100); - IdCardGenerator.areaCode.put("市辖区", 360101); - IdCardGenerator.areaCode.put("东湖区", 360102); - IdCardGenerator.areaCode.put("西湖区", 360103); - IdCardGenerator.areaCode.put("青云谱区", 360104); - IdCardGenerator.areaCode.put("湾里区", 360105); - IdCardGenerator.areaCode.put("青山湖区", 360111); - IdCardGenerator.areaCode.put("南昌县", 360121); - IdCardGenerator.areaCode.put("新建县", 360122); - IdCardGenerator.areaCode.put("安义县", 360123); - IdCardGenerator.areaCode.put("进贤县", 360124); - IdCardGenerator.areaCode.put("景德镇市", 360200); - IdCardGenerator.areaCode.put("市辖区", 360201); - IdCardGenerator.areaCode.put("昌江区", 360202); - IdCardGenerator.areaCode.put("珠山区", 360203); - IdCardGenerator.areaCode.put("浮梁县", 360222); - IdCardGenerator.areaCode.put("乐平市", 360281); - IdCardGenerator.areaCode.put("萍乡市", 360300); - IdCardGenerator.areaCode.put("市辖区", 360301); - IdCardGenerator.areaCode.put("安源区", 360302); - IdCardGenerator.areaCode.put("湘东区", 360313); - IdCardGenerator.areaCode.put("莲花县", 360321); - IdCardGenerator.areaCode.put("上栗县", 360322); - IdCardGenerator.areaCode.put("芦溪县", 360323); - IdCardGenerator.areaCode.put("九江市", 360400); - IdCardGenerator.areaCode.put("市辖区", 360401); - IdCardGenerator.areaCode.put("庐山区", 360402); - IdCardGenerator.areaCode.put("浔阳区", 360403); - IdCardGenerator.areaCode.put("九江县", 360421); - IdCardGenerator.areaCode.put("武宁县", 360423); - IdCardGenerator.areaCode.put("修水县", 360424); - IdCardGenerator.areaCode.put("永修县", 360425); - IdCardGenerator.areaCode.put("德安县", 360426); - IdCardGenerator.areaCode.put("星子县", 360427); - IdCardGenerator.areaCode.put("都昌县", 360428); - IdCardGenerator.areaCode.put("湖口县", 360429); - IdCardGenerator.areaCode.put("彭泽县", 360430); - IdCardGenerator.areaCode.put("瑞昌市", 360481); - IdCardGenerator.areaCode.put("新余市", 360500); - IdCardGenerator.areaCode.put("市辖区", 360501); - IdCardGenerator.areaCode.put("渝水区", 360502); - IdCardGenerator.areaCode.put("分宜县", 360521); - IdCardGenerator.areaCode.put("鹰潭市", 360600); - IdCardGenerator.areaCode.put("市辖区", 360601); - IdCardGenerator.areaCode.put("月湖区", 360602); - IdCardGenerator.areaCode.put("余江县", 360622); - IdCardGenerator.areaCode.put("贵溪市", 360681); - IdCardGenerator.areaCode.put("赣州市", 360700); - IdCardGenerator.areaCode.put("市辖区", 360701); - IdCardGenerator.areaCode.put("章贡区", 360702); - IdCardGenerator.areaCode.put("赣 县", 360721); - IdCardGenerator.areaCode.put("信丰县", 360722); - IdCardGenerator.areaCode.put("大余县", 360723); - IdCardGenerator.areaCode.put("上犹县", 360724); - IdCardGenerator.areaCode.put("崇义县", 360725); - IdCardGenerator.areaCode.put("安远县", 360726); - IdCardGenerator.areaCode.put("龙南县", 360727); - IdCardGenerator.areaCode.put("定南县", 360728); - IdCardGenerator.areaCode.put("全南县", 360729); - IdCardGenerator.areaCode.put("宁都县", 360730); - IdCardGenerator.areaCode.put("于都县", 360731); - IdCardGenerator.areaCode.put("兴国县", 360732); - IdCardGenerator.areaCode.put("会昌县", 360733); - IdCardGenerator.areaCode.put("寻乌县", 360734); - IdCardGenerator.areaCode.put("石城县", 360735); - IdCardGenerator.areaCode.put("瑞金市", 360781); - IdCardGenerator.areaCode.put("南康市", 360782); - IdCardGenerator.areaCode.put("吉安市", 360800); - IdCardGenerator.areaCode.put("市辖区", 360801); - IdCardGenerator.areaCode.put("吉州区", 360802); - IdCardGenerator.areaCode.put("青原区", 360803); - IdCardGenerator.areaCode.put("吉安县", 360821); - IdCardGenerator.areaCode.put("吉水县", 360822); - IdCardGenerator.areaCode.put("峡江县", 360823); - IdCardGenerator.areaCode.put("新干县", 360824); - IdCardGenerator.areaCode.put("永丰县", 360825); - IdCardGenerator.areaCode.put("泰和县", 360826); - IdCardGenerator.areaCode.put("遂川县", 360827); - IdCardGenerator.areaCode.put("万安县", 360828); - IdCardGenerator.areaCode.put("安福县", 360829); - IdCardGenerator.areaCode.put("永新县", 360830); - IdCardGenerator.areaCode.put("井冈山市", 360881); - IdCardGenerator.areaCode.put("宜春市", 360900); - IdCardGenerator.areaCode.put("市辖区", 360901); - IdCardGenerator.areaCode.put("袁州区", 360902); - IdCardGenerator.areaCode.put("奉新县", 360921); - IdCardGenerator.areaCode.put("万载县", 360922); - IdCardGenerator.areaCode.put("上高县", 360923); - IdCardGenerator.areaCode.put("宜丰县", 360924); - IdCardGenerator.areaCode.put("靖安县", 360925); - IdCardGenerator.areaCode.put("铜鼓县", 360926); - IdCardGenerator.areaCode.put("丰城市", 360981); - IdCardGenerator.areaCode.put("樟树市", 360982); - IdCardGenerator.areaCode.put("高安市", 360983); - IdCardGenerator.areaCode.put("抚州市", 361000); - IdCardGenerator.areaCode.put("市辖区", 361001); - IdCardGenerator.areaCode.put("临川区", 361002); - IdCardGenerator.areaCode.put("南城县", 361021); - IdCardGenerator.areaCode.put("黎川县", 361022); - IdCardGenerator.areaCode.put("南丰县", 361023); - IdCardGenerator.areaCode.put("崇仁县", 361024); - IdCardGenerator.areaCode.put("乐安县", 361025); - IdCardGenerator.areaCode.put("宜黄县", 361026); - IdCardGenerator.areaCode.put("金溪县", 361027); - IdCardGenerator.areaCode.put("资溪县", 361028); - IdCardGenerator.areaCode.put("东乡县", 361029); - IdCardGenerator.areaCode.put("广昌县", 361030); - IdCardGenerator.areaCode.put("上饶市", 361100); - IdCardGenerator.areaCode.put("市辖区", 361101); - IdCardGenerator.areaCode.put("信州区", 361102); - IdCardGenerator.areaCode.put("上饶县", 361121); - IdCardGenerator.areaCode.put("广丰县", 361122); - IdCardGenerator.areaCode.put("玉山县", 361123); - IdCardGenerator.areaCode.put("铅山县", 361124); - IdCardGenerator.areaCode.put("横峰县", 361125); - IdCardGenerator.areaCode.put("弋阳县", 361126); - IdCardGenerator.areaCode.put("余干县", 361127); - IdCardGenerator.areaCode.put("鄱阳县", 361128); - IdCardGenerator.areaCode.put("万年县", 361129); - IdCardGenerator.areaCode.put("婺源县", 361130); - IdCardGenerator.areaCode.put("德兴市", 361181); - IdCardGenerator.areaCode.put("山东省", 370000); - IdCardGenerator.areaCode.put("济南市", 370100); - IdCardGenerator.areaCode.put("市辖区", 370101); - IdCardGenerator.areaCode.put("历下区", 370102); - IdCardGenerator.areaCode.put("市中区", 370103); - IdCardGenerator.areaCode.put("槐荫区", 370104); - IdCardGenerator.areaCode.put("天桥区", 370105); - IdCardGenerator.areaCode.put("历城区", 370112); - IdCardGenerator.areaCode.put("长清区", 370113); - IdCardGenerator.areaCode.put("平阴县", 370124); - IdCardGenerator.areaCode.put("济阳县", 370125); - IdCardGenerator.areaCode.put("商河县", 370126); - IdCardGenerator.areaCode.put("章丘市", 370181); - IdCardGenerator.areaCode.put("青岛市", 370200); - IdCardGenerator.areaCode.put("市辖区", 370201); - IdCardGenerator.areaCode.put("市南区", 370202); - IdCardGenerator.areaCode.put("市北区", 370203); - IdCardGenerator.areaCode.put("四方区", 370205); - IdCardGenerator.areaCode.put("黄岛区", 370211); - IdCardGenerator.areaCode.put("崂山区", 370212); - IdCardGenerator.areaCode.put("李沧区", 370213); - IdCardGenerator.areaCode.put("城阳区", 370214); - IdCardGenerator.areaCode.put("胶州市", 370281); - IdCardGenerator.areaCode.put("即墨市", 370282); - IdCardGenerator.areaCode.put("平度市", 370283); - IdCardGenerator.areaCode.put("胶南市", 370284); - IdCardGenerator.areaCode.put("莱西市", 370285); - IdCardGenerator.areaCode.put("淄博市", 370300); - IdCardGenerator.areaCode.put("市辖区", 370301); - IdCardGenerator.areaCode.put("淄川区", 370302); - IdCardGenerator.areaCode.put("张店区", 370303); - IdCardGenerator.areaCode.put("博山区", 370304); - IdCardGenerator.areaCode.put("临淄区", 370305); - IdCardGenerator.areaCode.put("周村区", 370306); - IdCardGenerator.areaCode.put("桓台县", 370321); - IdCardGenerator.areaCode.put("高青县", 370322); - IdCardGenerator.areaCode.put("沂源县", 370323); - IdCardGenerator.areaCode.put("枣庄市", 370400); - IdCardGenerator.areaCode.put("市辖区", 370401); - IdCardGenerator.areaCode.put("市中区", 370402); - IdCardGenerator.areaCode.put("薛城区", 370403); - IdCardGenerator.areaCode.put("峄城区", 370404); - IdCardGenerator.areaCode.put("台儿庄区", 370405); - IdCardGenerator.areaCode.put("山亭区", 370406); - IdCardGenerator.areaCode.put("滕州市", 370481); - IdCardGenerator.areaCode.put("东营市", 370500); - IdCardGenerator.areaCode.put("市辖区", 370501); - IdCardGenerator.areaCode.put("东营区", 370502); - IdCardGenerator.areaCode.put("河口区", 370503); - IdCardGenerator.areaCode.put("垦利县", 370521); - IdCardGenerator.areaCode.put("利津县", 370522); - IdCardGenerator.areaCode.put("广饶县", 370523); - IdCardGenerator.areaCode.put("烟台市", 370600); - IdCardGenerator.areaCode.put("市辖区", 370601); - IdCardGenerator.areaCode.put("芝罘区", 370602); - IdCardGenerator.areaCode.put("福山区", 370611); - IdCardGenerator.areaCode.put("牟平区", 370612); - IdCardGenerator.areaCode.put("莱山区", 370613); - IdCardGenerator.areaCode.put("长岛县", 370634); - IdCardGenerator.areaCode.put("龙口市", 370681); - IdCardGenerator.areaCode.put("莱阳市", 370682); - IdCardGenerator.areaCode.put("莱州市", 370683); - IdCardGenerator.areaCode.put("蓬莱市", 370684); - IdCardGenerator.areaCode.put("招远市", 370685); - IdCardGenerator.areaCode.put("栖霞市", 370686); - IdCardGenerator.areaCode.put("海阳市", 370687); - IdCardGenerator.areaCode.put("潍坊市", 370700); - IdCardGenerator.areaCode.put("市辖区", 370701); - IdCardGenerator.areaCode.put("潍城区", 370702); - IdCardGenerator.areaCode.put("寒亭区", 370703); - IdCardGenerator.areaCode.put("坊子区", 370704); - IdCardGenerator.areaCode.put("奎文区", 370705); - IdCardGenerator.areaCode.put("临朐县", 370724); - IdCardGenerator.areaCode.put("昌乐县", 370725); - IdCardGenerator.areaCode.put("青州市", 370781); - IdCardGenerator.areaCode.put("诸城市", 370782); - IdCardGenerator.areaCode.put("寿光市", 370783); - IdCardGenerator.areaCode.put("安丘市", 370784); - IdCardGenerator.areaCode.put("高密市", 370785); - IdCardGenerator.areaCode.put("昌邑市", 370786); - IdCardGenerator.areaCode.put("济宁市", 370800); - IdCardGenerator.areaCode.put("市辖区", 370801); - IdCardGenerator.areaCode.put("市中区", 370802); - IdCardGenerator.areaCode.put("任城区", 370811); - IdCardGenerator.areaCode.put("微山县", 370826); - IdCardGenerator.areaCode.put("鱼台县", 370827); - IdCardGenerator.areaCode.put("金乡县", 370828); - IdCardGenerator.areaCode.put("嘉祥县", 370829); - IdCardGenerator.areaCode.put("汶上县", 370830); - IdCardGenerator.areaCode.put("泗水县", 370831); - IdCardGenerator.areaCode.put("梁山县", 370832); - IdCardGenerator.areaCode.put("曲阜市", 370881); - IdCardGenerator.areaCode.put("兖州市", 370882); - IdCardGenerator.areaCode.put("邹城市", 370883); - IdCardGenerator.areaCode.put("泰安市", 370900); - IdCardGenerator.areaCode.put("市辖区", 370901); - IdCardGenerator.areaCode.put("泰山区", 370902); - IdCardGenerator.areaCode.put("岱岳区", 370911); - IdCardGenerator.areaCode.put("宁阳县", 370921); - IdCardGenerator.areaCode.put("东平县", 370923); - IdCardGenerator.areaCode.put("新泰市", 370982); - IdCardGenerator.areaCode.put("肥城市", 370983); - IdCardGenerator.areaCode.put("威海市", 371000); - IdCardGenerator.areaCode.put("市辖区", 371001); - IdCardGenerator.areaCode.put("环翠区", 371002); - IdCardGenerator.areaCode.put("文登市", 371081); - IdCardGenerator.areaCode.put("荣成市", 371082); - IdCardGenerator.areaCode.put("乳山市", 371083); - IdCardGenerator.areaCode.put("日照市", 371100); - IdCardGenerator.areaCode.put("市辖区", 371101); - IdCardGenerator.areaCode.put("东港区", 371102); - IdCardGenerator.areaCode.put("岚山区", 371103); - IdCardGenerator.areaCode.put("五莲县", 371121); - IdCardGenerator.areaCode.put("莒 县", 371122); - IdCardGenerator.areaCode.put("莱芜市", 371200); - IdCardGenerator.areaCode.put("市辖区", 371201); - IdCardGenerator.areaCode.put("莱城区", 371202); - IdCardGenerator.areaCode.put("钢城区", 371203); - IdCardGenerator.areaCode.put("临沂市", 371300); - IdCardGenerator.areaCode.put("市辖区", 371301); - IdCardGenerator.areaCode.put("兰山区", 371302); - IdCardGenerator.areaCode.put("罗庄区", 371311); - IdCardGenerator.areaCode.put("河东区", 371312); - IdCardGenerator.areaCode.put("沂南县", 371321); - IdCardGenerator.areaCode.put("郯城县", 371322); - IdCardGenerator.areaCode.put("沂水县", 371323); - IdCardGenerator.areaCode.put("苍山县", 371324); - IdCardGenerator.areaCode.put("费 县", 371325); - IdCardGenerator.areaCode.put("平邑县", 371326); - IdCardGenerator.areaCode.put("莒南县", 371327); - IdCardGenerator.areaCode.put("蒙阴县", 371328); - IdCardGenerator.areaCode.put("临沭县", 371329); - IdCardGenerator.areaCode.put("德州市", 371400); - IdCardGenerator.areaCode.put("市辖区", 371401); - IdCardGenerator.areaCode.put("德城区", 371402); - IdCardGenerator.areaCode.put("陵 县", 371421); - IdCardGenerator.areaCode.put("宁津县", 371422); - IdCardGenerator.areaCode.put("庆云县", 371423); - IdCardGenerator.areaCode.put("临邑县", 371424); - IdCardGenerator.areaCode.put("齐河县", 371425); - IdCardGenerator.areaCode.put("平原县", 371426); - IdCardGenerator.areaCode.put("夏津县", 371427); - IdCardGenerator.areaCode.put("武城县", 371428); - IdCardGenerator.areaCode.put("乐陵市", 371481); - IdCardGenerator.areaCode.put("禹城市", 371482); - IdCardGenerator.areaCode.put("聊城市", 371500); - IdCardGenerator.areaCode.put("市辖区", 371501); - IdCardGenerator.areaCode.put("东昌府区", 371502); - IdCardGenerator.areaCode.put("阳谷县", 371521); - IdCardGenerator.areaCode.put("莘 县", 371522); - IdCardGenerator.areaCode.put("茌平县", 371523); - IdCardGenerator.areaCode.put("东阿县", 371524); - IdCardGenerator.areaCode.put("冠 县", 371525); - IdCardGenerator.areaCode.put("高唐县", 371526); - IdCardGenerator.areaCode.put("临清市", 371581); - IdCardGenerator.areaCode.put("滨州市", 371600); - IdCardGenerator.areaCode.put("市辖区", 371601); - IdCardGenerator.areaCode.put("滨城区", 371602); - IdCardGenerator.areaCode.put("惠民县", 371621); - IdCardGenerator.areaCode.put("阳信县", 371622); - IdCardGenerator.areaCode.put("无棣县", 371623); - IdCardGenerator.areaCode.put("沾化县", 371624); - IdCardGenerator.areaCode.put("博兴县", 371625); - IdCardGenerator.areaCode.put("邹平县", 371626); - IdCardGenerator.areaCode.put("菏泽市", 371700); - IdCardGenerator.areaCode.put("市辖区", 371701); - IdCardGenerator.areaCode.put("牡丹区", 371702); - IdCardGenerator.areaCode.put("曹 县", 371721); - IdCardGenerator.areaCode.put("单 县", 371722); - IdCardGenerator.areaCode.put("成武县", 371723); - IdCardGenerator.areaCode.put("巨野县", 371724); - IdCardGenerator.areaCode.put("郓城县", 371725); - IdCardGenerator.areaCode.put("鄄城县", 371726); - IdCardGenerator.areaCode.put("定陶县", 371727); - IdCardGenerator.areaCode.put("东明县", 371728); - IdCardGenerator.areaCode.put("河南省", 410000); - IdCardGenerator.areaCode.put("郑州市", 410100); - IdCardGenerator.areaCode.put("市辖区", 410101); - IdCardGenerator.areaCode.put("中原区", 410102); - IdCardGenerator.areaCode.put("二七区", 410103); - IdCardGenerator.areaCode.put("管城回族区", 410104); - IdCardGenerator.areaCode.put("金水区", 410105); - IdCardGenerator.areaCode.put("上街区", 410106); - IdCardGenerator.areaCode.put("惠济区", 410108); - IdCardGenerator.areaCode.put("中牟县", 410122); - IdCardGenerator.areaCode.put("巩义市", 410181); - IdCardGenerator.areaCode.put("荥阳市", 410182); - IdCardGenerator.areaCode.put("新密市", 410183); - IdCardGenerator.areaCode.put("新郑市", 410184); - IdCardGenerator.areaCode.put("登封市", 410185); - IdCardGenerator.areaCode.put("开封市", 410200); - IdCardGenerator.areaCode.put("市辖区", 410201); - IdCardGenerator.areaCode.put("龙亭区", 410202); - IdCardGenerator.areaCode.put("顺河回族区", 410203); - IdCardGenerator.areaCode.put("鼓楼区", 410204); - IdCardGenerator.areaCode.put("禹王台区", 410205); - IdCardGenerator.areaCode.put("金明区", 410211); - IdCardGenerator.areaCode.put("杞 县", 410221); - IdCardGenerator.areaCode.put("通许县", 410222); - IdCardGenerator.areaCode.put("尉氏县", 410223); - IdCardGenerator.areaCode.put("开封县", 410224); - IdCardGenerator.areaCode.put("兰考县", 410225); - IdCardGenerator.areaCode.put("洛阳市", 410300); - IdCardGenerator.areaCode.put("市辖区", 410301); - IdCardGenerator.areaCode.put("老城区", 410302); - IdCardGenerator.areaCode.put("西工区", 410303); - IdCardGenerator.areaCode.put("瀍河回族区", 410304); - IdCardGenerator.areaCode.put("涧西区", 410305); - IdCardGenerator.areaCode.put("吉利区", 410306); - IdCardGenerator.areaCode.put("洛龙区", 410311); - IdCardGenerator.areaCode.put("孟津县", 410322); - IdCardGenerator.areaCode.put("新安县", 410323); - IdCardGenerator.areaCode.put("栾川县", 410324); - IdCardGenerator.areaCode.put("嵩 县", 410325); - IdCardGenerator.areaCode.put("汝阳县", 410326); - IdCardGenerator.areaCode.put("宜阳县", 410327); - IdCardGenerator.areaCode.put("洛宁县", 410328); - IdCardGenerator.areaCode.put("伊川县", 410329); - IdCardGenerator.areaCode.put("偃师市", 410381); - IdCardGenerator.areaCode.put("平顶山市", 410400); - IdCardGenerator.areaCode.put("市辖区", 410401); - IdCardGenerator.areaCode.put("新华区", 410402); - IdCardGenerator.areaCode.put("卫东区", 410403); - IdCardGenerator.areaCode.put("石龙区", 410404); - IdCardGenerator.areaCode.put("湛河区", 410411); - IdCardGenerator.areaCode.put("宝丰县", 410421); - IdCardGenerator.areaCode.put("叶 县", 410422); - IdCardGenerator.areaCode.put("鲁山县", 410423); - IdCardGenerator.areaCode.put("郏 县", 410425); - IdCardGenerator.areaCode.put("舞钢市", 410481); - IdCardGenerator.areaCode.put("汝州市", 410482); - IdCardGenerator.areaCode.put("安阳市", 410500); - IdCardGenerator.areaCode.put("市辖区", 410501); - IdCardGenerator.areaCode.put("文峰区", 410502); - IdCardGenerator.areaCode.put("北关区", 410503); - IdCardGenerator.areaCode.put("殷都区", 410505); - IdCardGenerator.areaCode.put("龙安区", 410506); - IdCardGenerator.areaCode.put("安阳县", 410522); - IdCardGenerator.areaCode.put("汤阴县", 410523); - IdCardGenerator.areaCode.put("滑 县", 410526); - IdCardGenerator.areaCode.put("内黄县", 410527); - IdCardGenerator.areaCode.put("林州市", 410581); - IdCardGenerator.areaCode.put("鹤壁市", 410600); - IdCardGenerator.areaCode.put("市辖区", 410601); - IdCardGenerator.areaCode.put("鹤山区", 410602); - IdCardGenerator.areaCode.put("山城区", 410603); - IdCardGenerator.areaCode.put("淇滨区", 410611); - IdCardGenerator.areaCode.put("浚 县", 410621); - IdCardGenerator.areaCode.put("淇 县", 410622); - IdCardGenerator.areaCode.put("新乡市", 410700); - IdCardGenerator.areaCode.put("市辖区", 410701); - IdCardGenerator.areaCode.put("红旗区", 410702); - IdCardGenerator.areaCode.put("卫滨区", 410703); - IdCardGenerator.areaCode.put("凤泉区", 410704); - IdCardGenerator.areaCode.put("牧野区", 410711); - IdCardGenerator.areaCode.put("新乡县", 410721); - IdCardGenerator.areaCode.put("获嘉县", 410724); - IdCardGenerator.areaCode.put("原阳县", 410725); - IdCardGenerator.areaCode.put("延津县", 410726); - IdCardGenerator.areaCode.put("封丘县", 410727); - IdCardGenerator.areaCode.put("长垣县", 410728); - IdCardGenerator.areaCode.put("卫辉市", 410781); - IdCardGenerator.areaCode.put("辉县市", 410782); - IdCardGenerator.areaCode.put("焦作市", 410800); - IdCardGenerator.areaCode.put("市辖区", 410801); - IdCardGenerator.areaCode.put("解放区", 410802); - IdCardGenerator.areaCode.put("中站区", 410803); - IdCardGenerator.areaCode.put("马村区", 410804); - IdCardGenerator.areaCode.put("山阳区", 410811); - IdCardGenerator.areaCode.put("修武县", 410821); - IdCardGenerator.areaCode.put("博爱县", 410822); - IdCardGenerator.areaCode.put("武陟县", 410823); - IdCardGenerator.areaCode.put("温 县", 410825); - IdCardGenerator.areaCode.put("沁阳市", 410882); - IdCardGenerator.areaCode.put("孟州市", 410883); - IdCardGenerator.areaCode.put("濮阳市", 410900); - IdCardGenerator.areaCode.put("市辖区", 410901); - IdCardGenerator.areaCode.put("华龙区", 410902); - IdCardGenerator.areaCode.put("清丰县", 410922); - IdCardGenerator.areaCode.put("南乐县", 410923); - IdCardGenerator.areaCode.put("范 县", 410926); - IdCardGenerator.areaCode.put("台前县", 410927); - IdCardGenerator.areaCode.put("濮阳县", 410928); - IdCardGenerator.areaCode.put("许昌市", 411000); - IdCardGenerator.areaCode.put("市辖区", 411001); - IdCardGenerator.areaCode.put("魏都区", 411002); - IdCardGenerator.areaCode.put("许昌县", 411023); - IdCardGenerator.areaCode.put("鄢陵县", 411024); - IdCardGenerator.areaCode.put("襄城县", 411025); - IdCardGenerator.areaCode.put("禹州市", 411081); - IdCardGenerator.areaCode.put("长葛市", 411082); - IdCardGenerator.areaCode.put("漯河市", 411100); - IdCardGenerator.areaCode.put("市辖区", 411101); - IdCardGenerator.areaCode.put("源汇区", 411102); - IdCardGenerator.areaCode.put("郾城区", 411103); - IdCardGenerator.areaCode.put("召陵区", 411104); - IdCardGenerator.areaCode.put("舞阳县", 411121); - IdCardGenerator.areaCode.put("临颍县", 411122); - IdCardGenerator.areaCode.put("三门峡市", 411200); - IdCardGenerator.areaCode.put("市辖区", 411201); - IdCardGenerator.areaCode.put("湖滨区", 411202); - IdCardGenerator.areaCode.put("渑池县", 411221); - IdCardGenerator.areaCode.put("陕 县", 411222); - IdCardGenerator.areaCode.put("卢氏县", 411224); - IdCardGenerator.areaCode.put("义马市", 411281); - IdCardGenerator.areaCode.put("灵宝市", 411282); - IdCardGenerator.areaCode.put("南阳市", 411300); - IdCardGenerator.areaCode.put("市辖区", 411301); - IdCardGenerator.areaCode.put("宛城区", 411302); - IdCardGenerator.areaCode.put("卧龙区", 411303); - IdCardGenerator.areaCode.put("南召县", 411321); - IdCardGenerator.areaCode.put("方城县", 411322); - IdCardGenerator.areaCode.put("西峡县", 411323); - IdCardGenerator.areaCode.put("镇平县", 411324); - IdCardGenerator.areaCode.put("内乡县", 411325); - IdCardGenerator.areaCode.put("淅川县", 411326); - IdCardGenerator.areaCode.put("社旗县", 411327); - IdCardGenerator.areaCode.put("唐河县", 411328); - IdCardGenerator.areaCode.put("新野县", 411329); - IdCardGenerator.areaCode.put("桐柏县", 411330); - IdCardGenerator.areaCode.put("邓州市", 411381); - IdCardGenerator.areaCode.put("商丘市", 411400); - IdCardGenerator.areaCode.put("市辖区", 411401); - IdCardGenerator.areaCode.put("梁园区", 411402); - IdCardGenerator.areaCode.put("睢阳区", 411403); - IdCardGenerator.areaCode.put("民权县", 411421); - IdCardGenerator.areaCode.put("睢 县", 411422); - IdCardGenerator.areaCode.put("宁陵县", 411423); - IdCardGenerator.areaCode.put("柘城县", 411424); - IdCardGenerator.areaCode.put("虞城县", 411425); - IdCardGenerator.areaCode.put("夏邑县", 411426); - IdCardGenerator.areaCode.put("永城市", 411481); - IdCardGenerator.areaCode.put("信阳市", 411500); - IdCardGenerator.areaCode.put("市辖区", 411501); - IdCardGenerator.areaCode.put("浉河区", 411502); - IdCardGenerator.areaCode.put("平桥区", 411503); - IdCardGenerator.areaCode.put("罗山县", 411521); - IdCardGenerator.areaCode.put("光山县", 411522); - IdCardGenerator.areaCode.put("新 县", 411523); - IdCardGenerator.areaCode.put("商城县", 411524); - IdCardGenerator.areaCode.put("固始县", 411525); - IdCardGenerator.areaCode.put("潢川县", 411526); - IdCardGenerator.areaCode.put("淮滨县", 411527); - IdCardGenerator.areaCode.put("息 县", 411528); - IdCardGenerator.areaCode.put("周口市", 411600); - IdCardGenerator.areaCode.put("市辖区", 411601); - IdCardGenerator.areaCode.put("川汇区", 411602); - IdCardGenerator.areaCode.put("扶沟县", 411621); - IdCardGenerator.areaCode.put("西华县", 411622); - IdCardGenerator.areaCode.put("商水县", 411623); - IdCardGenerator.areaCode.put("沈丘县", 411624); - IdCardGenerator.areaCode.put("郸城县", 411625); - IdCardGenerator.areaCode.put("淮阳县", 411626); - IdCardGenerator.areaCode.put("太康县", 411627); - IdCardGenerator.areaCode.put("鹿邑县", 411628); - IdCardGenerator.areaCode.put("项城市", 411681); - IdCardGenerator.areaCode.put("驻马店市", 411700); - IdCardGenerator.areaCode.put("市辖区", 411701); - IdCardGenerator.areaCode.put("驿城区", 411702); - IdCardGenerator.areaCode.put("西平县", 411721); - IdCardGenerator.areaCode.put("上蔡县", 411722); - IdCardGenerator.areaCode.put("平舆县", 411723); - IdCardGenerator.areaCode.put("正阳县", 411724); - IdCardGenerator.areaCode.put("确山县", 411725); - IdCardGenerator.areaCode.put("泌阳县", 411726); - IdCardGenerator.areaCode.put("汝南县", 411727); - IdCardGenerator.areaCode.put("遂平县", 411728); - IdCardGenerator.areaCode.put("新蔡县", 411729); - IdCardGenerator.areaCode.put("济源市", 419001); - IdCardGenerator.areaCode.put("湖北省", 420000); - IdCardGenerator.areaCode.put("武汉市", 420100); - IdCardGenerator.areaCode.put("市辖区", 420101); - IdCardGenerator.areaCode.put("江岸区", 420102); - IdCardGenerator.areaCode.put("江汉区", 420103); - IdCardGenerator.areaCode.put("硚口区", 420104); - IdCardGenerator.areaCode.put("汉阳区", 420105); - IdCardGenerator.areaCode.put("武昌区", 420106); - IdCardGenerator.areaCode.put("青山区", 420107); - IdCardGenerator.areaCode.put("洪山区", 420111); - IdCardGenerator.areaCode.put("东西湖区", 420112); - IdCardGenerator.areaCode.put("汉南区", 420113); - IdCardGenerator.areaCode.put("蔡甸区", 420114); - IdCardGenerator.areaCode.put("江夏区", 420115); - IdCardGenerator.areaCode.put("黄陂区", 420116); - IdCardGenerator.areaCode.put("新洲区", 420117); - IdCardGenerator.areaCode.put("黄石市", 420200); - IdCardGenerator.areaCode.put("市辖区", 420201); - IdCardGenerator.areaCode.put("黄石港区", 420202); - IdCardGenerator.areaCode.put("西塞山区", 420203); - IdCardGenerator.areaCode.put("下陆区", 420204); - IdCardGenerator.areaCode.put("铁山区", 420205); - IdCardGenerator.areaCode.put("阳新县", 420222); - IdCardGenerator.areaCode.put("大冶市", 420281); - IdCardGenerator.areaCode.put("十堰市", 420300); - IdCardGenerator.areaCode.put("市辖区", 420301); - IdCardGenerator.areaCode.put("茅箭区", 420302); - IdCardGenerator.areaCode.put("张湾区", 420303); - IdCardGenerator.areaCode.put("郧 县", 420321); - IdCardGenerator.areaCode.put("郧西县", 420322); - IdCardGenerator.areaCode.put("竹山县", 420323); - IdCardGenerator.areaCode.put("竹溪县", 420324); - IdCardGenerator.areaCode.put("房 县", 420325); - IdCardGenerator.areaCode.put("丹江口市", 420381); - IdCardGenerator.areaCode.put("宜昌市", 420500); - IdCardGenerator.areaCode.put("市辖区", 420501); - IdCardGenerator.areaCode.put("西陵区", 420502); - IdCardGenerator.areaCode.put("伍家岗区", 420503); - IdCardGenerator.areaCode.put("点军区", 420504); - IdCardGenerator.areaCode.put("猇亭区", 420505); - IdCardGenerator.areaCode.put("夷陵区", 420506); - IdCardGenerator.areaCode.put("远安县", 420525); - IdCardGenerator.areaCode.put("兴山县", 420526); - IdCardGenerator.areaCode.put("秭归县", 420527); - IdCardGenerator.areaCode.put("长阳土家族自治县", 420528); - IdCardGenerator.areaCode.put("五峰土家族自治县", 420529); - IdCardGenerator.areaCode.put("宜都市", 420581); - IdCardGenerator.areaCode.put("当阳市", 420582); - IdCardGenerator.areaCode.put("枝江市", 420583); - IdCardGenerator.areaCode.put("襄樊市", 420600); - IdCardGenerator.areaCode.put("市辖区", 420601); - IdCardGenerator.areaCode.put("襄城区", 420602); - IdCardGenerator.areaCode.put("樊城区", 420606); - IdCardGenerator.areaCode.put("襄阳区", 420607); - IdCardGenerator.areaCode.put("南漳县", 420624); - IdCardGenerator.areaCode.put("谷城县", 420625); - IdCardGenerator.areaCode.put("保康县", 420626); - IdCardGenerator.areaCode.put("老河口市", 420682); - IdCardGenerator.areaCode.put("枣阳市", 420683); - IdCardGenerator.areaCode.put("宜城市", 420684); - IdCardGenerator.areaCode.put("鄂州市", 420700); - IdCardGenerator.areaCode.put("市辖区", 420701); - IdCardGenerator.areaCode.put("梁子湖区", 420702); - IdCardGenerator.areaCode.put("华容区", 420703); - IdCardGenerator.areaCode.put("鄂城区", 420704); - IdCardGenerator.areaCode.put("荆门市", 420800); - IdCardGenerator.areaCode.put("市辖区", 420801); - IdCardGenerator.areaCode.put("东宝区", 420802); - IdCardGenerator.areaCode.put("掇刀区", 420804); - IdCardGenerator.areaCode.put("京山县", 420821); - IdCardGenerator.areaCode.put("沙洋县", 420822); - IdCardGenerator.areaCode.put("钟祥市", 420881); - IdCardGenerator.areaCode.put("孝感市", 420900); - IdCardGenerator.areaCode.put("市辖区", 420901); - IdCardGenerator.areaCode.put("孝南区", 420902); - IdCardGenerator.areaCode.put("孝昌县", 420921); - IdCardGenerator.areaCode.put("大悟县", 420922); - IdCardGenerator.areaCode.put("云梦县", 420923); - IdCardGenerator.areaCode.put("应城市", 420981); - IdCardGenerator.areaCode.put("安陆市", 420982); - IdCardGenerator.areaCode.put("汉川市", 420984); - IdCardGenerator.areaCode.put("荆州市", 421000); - IdCardGenerator.areaCode.put("市辖区", 421001); - IdCardGenerator.areaCode.put("沙市区", 421002); - IdCardGenerator.areaCode.put("荆州区", 421003); - IdCardGenerator.areaCode.put("公安县", 421022); - IdCardGenerator.areaCode.put("监利县", 421023); - IdCardGenerator.areaCode.put("江陵县", 421024); - IdCardGenerator.areaCode.put("石首市", 421081); - IdCardGenerator.areaCode.put("洪湖市", 421083); - IdCardGenerator.areaCode.put("松滋市", 421087); - IdCardGenerator.areaCode.put("黄冈市", 421100); - IdCardGenerator.areaCode.put("市辖区", 421101); - IdCardGenerator.areaCode.put("黄州区", 421102); - IdCardGenerator.areaCode.put("团风县", 421121); - IdCardGenerator.areaCode.put("红安县", 421122); - IdCardGenerator.areaCode.put("罗田县", 421123); - IdCardGenerator.areaCode.put("英山县", 421124); - IdCardGenerator.areaCode.put("浠水县", 421125); - IdCardGenerator.areaCode.put("蕲春县", 421126); - IdCardGenerator.areaCode.put("黄梅县", 421127); - IdCardGenerator.areaCode.put("麻城市", 421181); - IdCardGenerator.areaCode.put("武穴市", 421182); - IdCardGenerator.areaCode.put("咸宁市", 421200); - IdCardGenerator.areaCode.put("市辖区", 421201); - IdCardGenerator.areaCode.put("咸安区", 421202); - IdCardGenerator.areaCode.put("嘉鱼县", 421221); - IdCardGenerator.areaCode.put("通城县", 421222); - IdCardGenerator.areaCode.put("崇阳县", 421223); - IdCardGenerator.areaCode.put("通山县", 421224); - IdCardGenerator.areaCode.put("赤壁市", 421281); - IdCardGenerator.areaCode.put("随州市", 421300); - IdCardGenerator.areaCode.put("市辖区", 421301); - IdCardGenerator.areaCode.put("曾都区 (*)", 421303); - IdCardGenerator.areaCode.put("广水市", 421381); - IdCardGenerator.areaCode.put("恩施土家族苗族自治州", 422800); - IdCardGenerator.areaCode.put("恩施市", 422801); - IdCardGenerator.areaCode.put("利川市", 422802); - IdCardGenerator.areaCode.put("建始县", 422822); - IdCardGenerator.areaCode.put("巴东县", 422823); - IdCardGenerator.areaCode.put("宣恩县", 422825); - IdCardGenerator.areaCode.put("咸丰县", 422826); - IdCardGenerator.areaCode.put("来凤县", 422827); - IdCardGenerator.areaCode.put("鹤峰县", 422828); - IdCardGenerator.areaCode.put("省直辖县级行政区划", 429000); - IdCardGenerator.areaCode.put("仙桃市", 429004); - IdCardGenerator.areaCode.put("潜江市", 429005); - IdCardGenerator.areaCode.put("天门市", 429006); - IdCardGenerator.areaCode.put("神农架林区", 429021); - IdCardGenerator.areaCode.put("湖南省", 430000); - IdCardGenerator.areaCode.put("长沙市", 430100); - IdCardGenerator.areaCode.put("市辖区", 430101); - IdCardGenerator.areaCode.put("芙蓉区", 430102); - IdCardGenerator.areaCode.put("天心区", 430103); - IdCardGenerator.areaCode.put("岳麓区", 430104); - IdCardGenerator.areaCode.put("开福区", 430105); - IdCardGenerator.areaCode.put("雨花区", 430111); - IdCardGenerator.areaCode.put("长沙县", 430121); - IdCardGenerator.areaCode.put("望城县", 430122); - IdCardGenerator.areaCode.put("宁乡县", 430124); - IdCardGenerator.areaCode.put("浏阳市", 430181); - IdCardGenerator.areaCode.put("株洲市", 430200); - IdCardGenerator.areaCode.put("市辖区", 430201); - IdCardGenerator.areaCode.put("荷塘区", 430202); - IdCardGenerator.areaCode.put("芦淞区", 430203); - IdCardGenerator.areaCode.put("石峰区", 430204); - IdCardGenerator.areaCode.put("天元区", 430211); - IdCardGenerator.areaCode.put("株洲县", 430221); - IdCardGenerator.areaCode.put("攸 县", 430223); - IdCardGenerator.areaCode.put("茶陵县", 430224); - IdCardGenerator.areaCode.put("炎陵县", 430225); - IdCardGenerator.areaCode.put("醴陵市", 430281); - IdCardGenerator.areaCode.put("湘潭市", 430300); - IdCardGenerator.areaCode.put("市辖区", 430301); - IdCardGenerator.areaCode.put("雨湖区", 430302); - IdCardGenerator.areaCode.put("岳塘区", 430304); - IdCardGenerator.areaCode.put("湘潭县", 430321); - IdCardGenerator.areaCode.put("湘乡市", 430381); - IdCardGenerator.areaCode.put("韶山市", 430382); - IdCardGenerator.areaCode.put("衡阳市", 430400); - IdCardGenerator.areaCode.put("市辖区", 430401); - IdCardGenerator.areaCode.put("珠晖区", 430405); - IdCardGenerator.areaCode.put("雁峰区", 430406); - IdCardGenerator.areaCode.put("石鼓区", 430407); - IdCardGenerator.areaCode.put("蒸湘区", 430408); - IdCardGenerator.areaCode.put("南岳区", 430412); - IdCardGenerator.areaCode.put("衡阳县", 430421); - IdCardGenerator.areaCode.put("衡南县", 430422); - IdCardGenerator.areaCode.put("衡山县", 430423); - IdCardGenerator.areaCode.put("衡东县", 430424); - IdCardGenerator.areaCode.put("祁东县", 430426); - IdCardGenerator.areaCode.put("耒阳市", 430481); - IdCardGenerator.areaCode.put("常宁市", 430482); - IdCardGenerator.areaCode.put("邵阳市", 430500); - IdCardGenerator.areaCode.put("市辖区", 430501); - IdCardGenerator.areaCode.put("双清区", 430502); - IdCardGenerator.areaCode.put("大祥区", 430503); - IdCardGenerator.areaCode.put("北塔区", 430511); - IdCardGenerator.areaCode.put("邵东县", 430521); - IdCardGenerator.areaCode.put("新邵县", 430522); - IdCardGenerator.areaCode.put("邵阳县", 430523); - IdCardGenerator.areaCode.put("隆回县", 430524); - IdCardGenerator.areaCode.put("洞口县", 430525); - IdCardGenerator.areaCode.put("绥宁县", 430527); - IdCardGenerator.areaCode.put("新宁县", 430528); - IdCardGenerator.areaCode.put("城步苗族自治县", 430529); - IdCardGenerator.areaCode.put("武冈市", 430581); - IdCardGenerator.areaCode.put("岳阳市", 430600); - IdCardGenerator.areaCode.put("市辖区", 430601); - IdCardGenerator.areaCode.put("岳阳楼区", 430602); - IdCardGenerator.areaCode.put("云溪区", 430603); - IdCardGenerator.areaCode.put("君山区", 430611); - IdCardGenerator.areaCode.put("岳阳县", 430621); - IdCardGenerator.areaCode.put("华容县", 430623); - IdCardGenerator.areaCode.put("湘阴县", 430624); - IdCardGenerator.areaCode.put("平江县", 430626); - IdCardGenerator.areaCode.put("汨罗市", 430681); - IdCardGenerator.areaCode.put("临湘市", 430682); - IdCardGenerator.areaCode.put("常德市", 430700); - IdCardGenerator.areaCode.put("市辖区", 430701); - IdCardGenerator.areaCode.put("武陵区", 430702); - IdCardGenerator.areaCode.put("鼎城区", 430703); - IdCardGenerator.areaCode.put("安乡县", 430721); - IdCardGenerator.areaCode.put("汉寿县", 430722); - IdCardGenerator.areaCode.put("澧 县", 430723); - IdCardGenerator.areaCode.put("临澧县", 430724); - IdCardGenerator.areaCode.put("桃源县", 430725); - IdCardGenerator.areaCode.put("石门县", 430726); - IdCardGenerator.areaCode.put("津市市", 430781); - IdCardGenerator.areaCode.put("张家界市", 430800); - IdCardGenerator.areaCode.put("市辖区", 430801); - IdCardGenerator.areaCode.put("永定区", 430802); - IdCardGenerator.areaCode.put("武陵源区", 430811); - IdCardGenerator.areaCode.put("慈利县", 430821); - IdCardGenerator.areaCode.put("桑植县", 430822); - IdCardGenerator.areaCode.put("益阳市", 430900); - IdCardGenerator.areaCode.put("市辖区", 430901); - IdCardGenerator.areaCode.put("资阳区", 430902); - IdCardGenerator.areaCode.put("赫山区", 430903); - IdCardGenerator.areaCode.put("南 县", 430921); - IdCardGenerator.areaCode.put("桃江县", 430922); - IdCardGenerator.areaCode.put("安化县", 430923); - IdCardGenerator.areaCode.put("沅江市", 430981); - IdCardGenerator.areaCode.put("郴州市", 431000); - IdCardGenerator.areaCode.put("市辖区", 431001); - IdCardGenerator.areaCode.put("北湖区", 431002); - IdCardGenerator.areaCode.put("苏仙区", 431003); - IdCardGenerator.areaCode.put("桂阳县", 431021); - IdCardGenerator.areaCode.put("宜章县", 431022); - IdCardGenerator.areaCode.put("永兴县", 431023); - IdCardGenerator.areaCode.put("嘉禾县", 431024); - IdCardGenerator.areaCode.put("临武县", 431025); - IdCardGenerator.areaCode.put("汝城县", 431026); - IdCardGenerator.areaCode.put("桂东县", 431027); - IdCardGenerator.areaCode.put("安仁县", 431028); - IdCardGenerator.areaCode.put("资兴市", 431081); - IdCardGenerator.areaCode.put("永州市", 431100); - IdCardGenerator.areaCode.put("市辖区", 431101); - IdCardGenerator.areaCode.put("零陵区", 431102); - IdCardGenerator.areaCode.put("冷水滩区", 431103); - IdCardGenerator.areaCode.put("祁阳县", 431121); - IdCardGenerator.areaCode.put("东安县", 431122); - IdCardGenerator.areaCode.put("双牌县", 431123); - IdCardGenerator.areaCode.put("道 县", 431124); - IdCardGenerator.areaCode.put("江永县", 431125); - IdCardGenerator.areaCode.put("宁远县", 431126); - IdCardGenerator.areaCode.put("蓝山县", 431127); - IdCardGenerator.areaCode.put("新田县", 431128); - IdCardGenerator.areaCode.put("江华瑶族自治县", 431129); - IdCardGenerator.areaCode.put("怀化市", 431200); - IdCardGenerator.areaCode.put("市辖区", 431201); - IdCardGenerator.areaCode.put("鹤城区", 431202); - IdCardGenerator.areaCode.put("中方县", 431221); - IdCardGenerator.areaCode.put("沅陵县", 431222); - IdCardGenerator.areaCode.put("辰溪县", 431223); - IdCardGenerator.areaCode.put("溆浦县", 431224); - IdCardGenerator.areaCode.put("会同县", 431225); - IdCardGenerator.areaCode.put("麻阳苗族自治县", 431226); - IdCardGenerator.areaCode.put("新晃侗族自治县", 431227); - IdCardGenerator.areaCode.put("芷江侗族自治县", 431228); - IdCardGenerator.areaCode.put("靖州苗族侗族自治县", 431229); - IdCardGenerator.areaCode.put("通道侗族自治县", 431230); - IdCardGenerator.areaCode.put("洪江市", 431281); - IdCardGenerator.areaCode.put("娄底市", 431300); - IdCardGenerator.areaCode.put("市辖区", 431301); - IdCardGenerator.areaCode.put("娄星区", 431302); - IdCardGenerator.areaCode.put("双峰县", 431321); - IdCardGenerator.areaCode.put("新化县", 431322); - IdCardGenerator.areaCode.put("冷水江市", 431381); - IdCardGenerator.areaCode.put("涟源市", 431382); - IdCardGenerator.areaCode.put("湘西土家族苗族自治州", 433100); - IdCardGenerator.areaCode.put("吉首市", 433101); - IdCardGenerator.areaCode.put("泸溪县", 433122); - IdCardGenerator.areaCode.put("凤凰县", 433123); - IdCardGenerator.areaCode.put("花垣县", 433124); - IdCardGenerator.areaCode.put("保靖县", 433125); - IdCardGenerator.areaCode.put("古丈县", 433126); - IdCardGenerator.areaCode.put("永顺县", 433127); - IdCardGenerator.areaCode.put("龙山县", 433130); - IdCardGenerator.areaCode.put("广东省", 440000); - IdCardGenerator.areaCode.put("广州市", 440100); - IdCardGenerator.areaCode.put("市辖区", 440101); - IdCardGenerator.areaCode.put("荔湾区", 440103); - IdCardGenerator.areaCode.put("越秀区", 440104); - IdCardGenerator.areaCode.put("海珠区", 440105); - IdCardGenerator.areaCode.put("天河区", 440106); - IdCardGenerator.areaCode.put("白云区", 440111); - IdCardGenerator.areaCode.put("黄埔区", 440112); - IdCardGenerator.areaCode.put("番禺区", 440113); - IdCardGenerator.areaCode.put("花都区", 440114); - IdCardGenerator.areaCode.put("南沙区", 440115); - IdCardGenerator.areaCode.put("萝岗区", 440116); - IdCardGenerator.areaCode.put("增城市", 440183); - IdCardGenerator.areaCode.put("从化市", 440184); - IdCardGenerator.areaCode.put("韶关市", 440200); - IdCardGenerator.areaCode.put("市辖区", 440201); - IdCardGenerator.areaCode.put("武江区", 440203); - IdCardGenerator.areaCode.put("浈江区", 440204); - IdCardGenerator.areaCode.put("曲江区", 440205); - IdCardGenerator.areaCode.put("始兴县", 440222); - IdCardGenerator.areaCode.put("仁化县", 440224); - IdCardGenerator.areaCode.put("翁源县", 440229); - IdCardGenerator.areaCode.put("乳源瑶族自治县", 440232); - IdCardGenerator.areaCode.put("新丰县", 440233); - IdCardGenerator.areaCode.put("乐昌市", 440281); - IdCardGenerator.areaCode.put("南雄市", 440282); - IdCardGenerator.areaCode.put("深圳市", 440300); - IdCardGenerator.areaCode.put("市辖区", 440301); - IdCardGenerator.areaCode.put("罗湖区", 440303); - IdCardGenerator.areaCode.put("福田区", 440304); - IdCardGenerator.areaCode.put("南山区", 440305); - IdCardGenerator.areaCode.put("宝安区", 440306); - IdCardGenerator.areaCode.put("龙岗区", 440307); - IdCardGenerator.areaCode.put("盐田区", 440308); - IdCardGenerator.areaCode.put("珠海市", 440400); - IdCardGenerator.areaCode.put("市辖区", 440401); - IdCardGenerator.areaCode.put("香洲区", 440402); - IdCardGenerator.areaCode.put("斗门区", 440403); - IdCardGenerator.areaCode.put("金湾区", 440404); - IdCardGenerator.areaCode.put("汕头市", 440500); - IdCardGenerator.areaCode.put("市辖区", 440501); - IdCardGenerator.areaCode.put("龙湖区", 440507); - IdCardGenerator.areaCode.put("金平区", 440511); - IdCardGenerator.areaCode.put("濠江区", 440512); - IdCardGenerator.areaCode.put("潮阳区", 440513); - IdCardGenerator.areaCode.put("潮南区", 440514); - IdCardGenerator.areaCode.put("澄海区", 440515); - IdCardGenerator.areaCode.put("南澳县", 440523); - IdCardGenerator.areaCode.put("佛山市", 440600); - IdCardGenerator.areaCode.put("市辖区", 440601); - IdCardGenerator.areaCode.put("禅城区", 440604); - IdCardGenerator.areaCode.put("南海区", 440605); - IdCardGenerator.areaCode.put("顺德区", 440606); - IdCardGenerator.areaCode.put("三水区", 440607); - IdCardGenerator.areaCode.put("高明区", 440608); - IdCardGenerator.areaCode.put("江门市", 440700); - IdCardGenerator.areaCode.put("市辖区", 440701); - IdCardGenerator.areaCode.put("蓬江区", 440703); - IdCardGenerator.areaCode.put("江海区", 440704); - IdCardGenerator.areaCode.put("新会区", 440705); - IdCardGenerator.areaCode.put("台山市", 440781); - IdCardGenerator.areaCode.put("开平市", 440783); - IdCardGenerator.areaCode.put("鹤山市", 440784); - IdCardGenerator.areaCode.put("恩平市", 440785); - IdCardGenerator.areaCode.put("湛江市", 440800); - IdCardGenerator.areaCode.put("市辖区", 440801); - IdCardGenerator.areaCode.put("赤坎区", 440802); - IdCardGenerator.areaCode.put("霞山区", 440803); - IdCardGenerator.areaCode.put("坡头区", 440804); - IdCardGenerator.areaCode.put("麻章区", 440811); - IdCardGenerator.areaCode.put("遂溪县", 440823); - IdCardGenerator.areaCode.put("徐闻县", 440825); - IdCardGenerator.areaCode.put("廉江市", 440881); - IdCardGenerator.areaCode.put("雷州市", 440882); - IdCardGenerator.areaCode.put("吴川市", 440883); - IdCardGenerator.areaCode.put("茂名市", 440900); - IdCardGenerator.areaCode.put("市辖区", 440901); - IdCardGenerator.areaCode.put("茂南区", 440902); - IdCardGenerator.areaCode.put("茂港区", 440903); - IdCardGenerator.areaCode.put("电白县", 440923); - IdCardGenerator.areaCode.put("高州市", 440981); - IdCardGenerator.areaCode.put("化州市", 440982); - IdCardGenerator.areaCode.put("信宜市", 440983); - IdCardGenerator.areaCode.put("肇庆市", 441200); - IdCardGenerator.areaCode.put("市辖区", 441201); - IdCardGenerator.areaCode.put("端州区", 441202); - IdCardGenerator.areaCode.put("鼎湖区", 441203); - IdCardGenerator.areaCode.put("广宁县", 441223); - IdCardGenerator.areaCode.put("怀集县", 441224); - IdCardGenerator.areaCode.put("封开县", 441225); - IdCardGenerator.areaCode.put("德庆县", 441226); - IdCardGenerator.areaCode.put("高要市", 441283); - IdCardGenerator.areaCode.put("四会市", 441284); - IdCardGenerator.areaCode.put("惠州市", 441300); - IdCardGenerator.areaCode.put("市辖区", 441301); - IdCardGenerator.areaCode.put("惠城区", 441302); - IdCardGenerator.areaCode.put("惠阳区", 441303); - IdCardGenerator.areaCode.put("博罗县", 441322); - IdCardGenerator.areaCode.put("惠东县", 441323); - IdCardGenerator.areaCode.put("龙门县", 441324); - IdCardGenerator.areaCode.put("梅州市", 441400); - IdCardGenerator.areaCode.put("市辖区", 441401); - IdCardGenerator.areaCode.put("梅江区", 441402); - IdCardGenerator.areaCode.put("梅 县", 441421); - IdCardGenerator.areaCode.put("大埔县", 441422); - IdCardGenerator.areaCode.put("丰顺县", 441423); - IdCardGenerator.areaCode.put("五华县", 441424); - IdCardGenerator.areaCode.put("平远县", 441426); - IdCardGenerator.areaCode.put("蕉岭县", 441427); - IdCardGenerator.areaCode.put("兴宁市", 441481); - IdCardGenerator.areaCode.put("汕尾市", 441500); - IdCardGenerator.areaCode.put("市辖区", 441501); - IdCardGenerator.areaCode.put("城 区", 441502); - IdCardGenerator.areaCode.put("海丰县", 441521); - IdCardGenerator.areaCode.put("陆河县", 441523); - IdCardGenerator.areaCode.put("陆丰市", 441581); - IdCardGenerator.areaCode.put("河源市", 441600); - IdCardGenerator.areaCode.put("市辖区", 441601); - IdCardGenerator.areaCode.put("源城区", 441602); - IdCardGenerator.areaCode.put("紫金县", 441621); - IdCardGenerator.areaCode.put("龙川县", 441622); - IdCardGenerator.areaCode.put("连平县", 441623); - IdCardGenerator.areaCode.put("和平县", 441624); - IdCardGenerator.areaCode.put("东源县", 441625); - IdCardGenerator.areaCode.put("阳江市", 441700); - IdCardGenerator.areaCode.put("市辖区", 441701); - IdCardGenerator.areaCode.put("江城区", 441702); - IdCardGenerator.areaCode.put("阳西县", 441721); - IdCardGenerator.areaCode.put("阳东县", 441723); - IdCardGenerator.areaCode.put("阳春市", 441781); - IdCardGenerator.areaCode.put("清远市", 441800); - IdCardGenerator.areaCode.put("市辖区", 441801); - IdCardGenerator.areaCode.put("清城区", 441802); - IdCardGenerator.areaCode.put("佛冈县", 441821); - IdCardGenerator.areaCode.put("阳山县", 441823); - IdCardGenerator.areaCode.put("连山壮族瑶族自治县", 441825); - IdCardGenerator.areaCode.put("连南瑶族自治县", 441826); - IdCardGenerator.areaCode.put("清新县", 441827); - IdCardGenerator.areaCode.put("英德市", 441881); - IdCardGenerator.areaCode.put("连州市", 441882); - IdCardGenerator.areaCode.put("东莞市", 441900); - IdCardGenerator.areaCode.put("中山市", 442000); - IdCardGenerator.areaCode.put("潮州市", 445100); - IdCardGenerator.areaCode.put("市辖区", 445101); - IdCardGenerator.areaCode.put("湘桥区", 445102); - IdCardGenerator.areaCode.put("潮安县", 445121); - IdCardGenerator.areaCode.put("饶平县", 445122); - IdCardGenerator.areaCode.put("揭阳市", 445200); - IdCardGenerator.areaCode.put("市辖区", 445201); - IdCardGenerator.areaCode.put("榕城区", 445202); - IdCardGenerator.areaCode.put("揭东县", 445221); - IdCardGenerator.areaCode.put("揭西县", 445222); - IdCardGenerator.areaCode.put("惠来县", 445224); - IdCardGenerator.areaCode.put("普宁市", 445281); - IdCardGenerator.areaCode.put("云浮市", 445300); - IdCardGenerator.areaCode.put("市辖区", 445301); - IdCardGenerator.areaCode.put("云城区", 445302); - IdCardGenerator.areaCode.put("新兴县", 445321); - IdCardGenerator.areaCode.put("郁南县", 445322); - IdCardGenerator.areaCode.put("云安县", 445323); - IdCardGenerator.areaCode.put("罗定市", 445381); - IdCardGenerator.areaCode.put("广西壮族自治区", 450000); - IdCardGenerator.areaCode.put("南宁市", 450100); - IdCardGenerator.areaCode.put("市辖区", 450101); - IdCardGenerator.areaCode.put("兴宁区", 450102); - IdCardGenerator.areaCode.put("青秀区", 450103); - IdCardGenerator.areaCode.put("江南区", 450105); - IdCardGenerator.areaCode.put("西乡塘区", 450107); - IdCardGenerator.areaCode.put("良庆区", 450108); - IdCardGenerator.areaCode.put("邕宁区", 450109); - IdCardGenerator.areaCode.put("武鸣县", 450122); - IdCardGenerator.areaCode.put("隆安县", 450123); - IdCardGenerator.areaCode.put("马山县", 450124); - IdCardGenerator.areaCode.put("上林县", 450125); - IdCardGenerator.areaCode.put("宾阳县", 450126); - IdCardGenerator.areaCode.put("横 县", 450127); - IdCardGenerator.areaCode.put("柳州市", 450200); - IdCardGenerator.areaCode.put("市辖区", 450201); - IdCardGenerator.areaCode.put("城中区", 450202); - IdCardGenerator.areaCode.put("鱼峰区", 450203); - IdCardGenerator.areaCode.put("柳南区", 450204); - IdCardGenerator.areaCode.put("柳北区", 450205); - IdCardGenerator.areaCode.put("柳江县", 450221); - IdCardGenerator.areaCode.put("柳城县", 450222); - IdCardGenerator.areaCode.put("鹿寨县", 450223); - IdCardGenerator.areaCode.put("融安县", 450224); - IdCardGenerator.areaCode.put("融水苗族自治县", 450225); - IdCardGenerator.areaCode.put("三江侗族自治县", 450226); - IdCardGenerator.areaCode.put("桂林市", 450300); - IdCardGenerator.areaCode.put("市辖区", 450301); - IdCardGenerator.areaCode.put("秀峰区", 450302); - IdCardGenerator.areaCode.put("叠彩区", 450303); - IdCardGenerator.areaCode.put("象山区", 450304); - IdCardGenerator.areaCode.put("七星区", 450305); - IdCardGenerator.areaCode.put("雁山区", 450311); - IdCardGenerator.areaCode.put("阳朔县", 450321); - IdCardGenerator.areaCode.put("临桂县", 450322); - IdCardGenerator.areaCode.put("灵川县", 450323); - IdCardGenerator.areaCode.put("全州县", 450324); - IdCardGenerator.areaCode.put("兴安县", 450325); - IdCardGenerator.areaCode.put("永福县", 450326); - IdCardGenerator.areaCode.put("灌阳县", 450327); - IdCardGenerator.areaCode.put("龙胜各族自治县", 450328); - IdCardGenerator.areaCode.put("资源县", 450329); - IdCardGenerator.areaCode.put("平乐县", 450330); - IdCardGenerator.areaCode.put("荔蒲县", 450331); - IdCardGenerator.areaCode.put("恭城瑶族自治县", 450332); - IdCardGenerator.areaCode.put("梧州市", 450400); - IdCardGenerator.areaCode.put("市辖区", 450401); - IdCardGenerator.areaCode.put("万秀区", 450403); - IdCardGenerator.areaCode.put("蝶山区", 450404); - IdCardGenerator.areaCode.put("长洲区", 450405); - IdCardGenerator.areaCode.put("苍梧县", 450421); - IdCardGenerator.areaCode.put("藤 县", 450422); - IdCardGenerator.areaCode.put("蒙山县", 450423); - IdCardGenerator.areaCode.put("岑溪市", 450481); - IdCardGenerator.areaCode.put("北海市", 450500); - IdCardGenerator.areaCode.put("市辖区", 450501); - IdCardGenerator.areaCode.put("海城区", 450502); - IdCardGenerator.areaCode.put("银海区", 450503); - IdCardGenerator.areaCode.put("铁山港区", 450512); - IdCardGenerator.areaCode.put("合浦县", 450521); - IdCardGenerator.areaCode.put("防城港市", 450600); - IdCardGenerator.areaCode.put("市辖区", 450601); - IdCardGenerator.areaCode.put("港口区", 450602); - IdCardGenerator.areaCode.put("防城区", 450603); - IdCardGenerator.areaCode.put("上思县", 450621); - IdCardGenerator.areaCode.put("东兴市", 450681); - IdCardGenerator.areaCode.put("钦州市", 450700); - IdCardGenerator.areaCode.put("市辖区", 450701); - IdCardGenerator.areaCode.put("钦南区", 450702); - IdCardGenerator.areaCode.put("钦北区", 450703); - IdCardGenerator.areaCode.put("灵山县", 450721); - IdCardGenerator.areaCode.put("浦北县", 450722); - IdCardGenerator.areaCode.put("贵港市", 450800); - IdCardGenerator.areaCode.put("市辖区", 450801); - IdCardGenerator.areaCode.put("港北区", 450802); - IdCardGenerator.areaCode.put("港南区", 450803); - IdCardGenerator.areaCode.put("覃塘区", 450804); - IdCardGenerator.areaCode.put("平南县", 450821); - IdCardGenerator.areaCode.put("桂平市", 450881); - IdCardGenerator.areaCode.put("玉林市", 450900); - IdCardGenerator.areaCode.put("市辖区", 450901); - IdCardGenerator.areaCode.put("玉州区", 450902); - IdCardGenerator.areaCode.put("容 县", 450921); - IdCardGenerator.areaCode.put("陆川县", 450922); - IdCardGenerator.areaCode.put("博白县", 450923); - IdCardGenerator.areaCode.put("兴业县", 450924); - IdCardGenerator.areaCode.put("北流市", 450981); - IdCardGenerator.areaCode.put("百色市", 451000); - IdCardGenerator.areaCode.put("市辖区", 451001); - IdCardGenerator.areaCode.put("右江区", 451002); - IdCardGenerator.areaCode.put("田阳县", 451021); - IdCardGenerator.areaCode.put("田东县", 451022); - IdCardGenerator.areaCode.put("平果县", 451023); - IdCardGenerator.areaCode.put("德保县", 451024); - IdCardGenerator.areaCode.put("靖西县", 451025); - IdCardGenerator.areaCode.put("那坡县", 451026); - IdCardGenerator.areaCode.put("凌云县", 451027); - IdCardGenerator.areaCode.put("乐业县", 451028); - IdCardGenerator.areaCode.put("田林县", 451029); - IdCardGenerator.areaCode.put("西林县", 451030); - IdCardGenerator.areaCode.put("隆林各族自治县", 451031); - IdCardGenerator.areaCode.put("贺州市", 451100); - IdCardGenerator.areaCode.put("市辖区", 451101); - IdCardGenerator.areaCode.put("八步区", 451102); - IdCardGenerator.areaCode.put("昭平县", 451121); - IdCardGenerator.areaCode.put("钟山县", 451122); - IdCardGenerator.areaCode.put("富川瑶族自治县", 451123); - IdCardGenerator.areaCode.put("河池市", 451200); - IdCardGenerator.areaCode.put("市辖区", 451201); - IdCardGenerator.areaCode.put("金城江区", 451202); - IdCardGenerator.areaCode.put("南丹县", 451221); - IdCardGenerator.areaCode.put("天峨县", 451222); - IdCardGenerator.areaCode.put("凤山县", 451223); - IdCardGenerator.areaCode.put("东兰县", 451224); - IdCardGenerator.areaCode.put("罗城仫佬族自治县", 451225); - IdCardGenerator.areaCode.put("环江毛南族自治县", 451226); - IdCardGenerator.areaCode.put("巴马瑶族自治县", 451227); - IdCardGenerator.areaCode.put("都安瑶族自治县", 451228); - IdCardGenerator.areaCode.put("大化瑶族自治县", 451229); - IdCardGenerator.areaCode.put("宜州市", 451281); - IdCardGenerator.areaCode.put("来宾市", 451300); - IdCardGenerator.areaCode.put("市辖区", 451301); - IdCardGenerator.areaCode.put("兴宾区", 451302); - IdCardGenerator.areaCode.put("忻城县", 451321); - IdCardGenerator.areaCode.put("象州县", 451322); - IdCardGenerator.areaCode.put("武宣县", 451323); - IdCardGenerator.areaCode.put("金秀瑶族自治县", 451324); - IdCardGenerator.areaCode.put("合山市", 451381); - IdCardGenerator.areaCode.put("崇左市", 451400); - IdCardGenerator.areaCode.put("市辖区", 451401); - IdCardGenerator.areaCode.put("江洲区", 451402); - IdCardGenerator.areaCode.put("扶绥县", 451421); - IdCardGenerator.areaCode.put("宁明县", 451422); - IdCardGenerator.areaCode.put("龙州县", 451423); - IdCardGenerator.areaCode.put("大新县", 451424); - IdCardGenerator.areaCode.put("天等县", 451425); - IdCardGenerator.areaCode.put("凭祥市", 451481); - IdCardGenerator.areaCode.put("海南省", 460000); - IdCardGenerator.areaCode.put("海口市", 460100); - IdCardGenerator.areaCode.put("市辖区", 460101); - IdCardGenerator.areaCode.put("秀英区", 460105); - IdCardGenerator.areaCode.put("龙华区", 460106); - IdCardGenerator.areaCode.put("琼山区", 460107); - IdCardGenerator.areaCode.put("美兰区", 460108); - IdCardGenerator.areaCode.put("三亚市", 460200); - IdCardGenerator.areaCode.put("市辖区", 460201); - IdCardGenerator.areaCode.put("省直辖县级行政区划", 469000); - IdCardGenerator.areaCode.put("五指山市", 469001); - IdCardGenerator.areaCode.put("琼海市", 469002); - IdCardGenerator.areaCode.put("儋州市", 469003); - IdCardGenerator.areaCode.put("文昌市", 469005); - IdCardGenerator.areaCode.put("万宁市", 469006); - IdCardGenerator.areaCode.put("东方市", 469007); - IdCardGenerator.areaCode.put("定安县", 469021); - IdCardGenerator.areaCode.put("屯昌县", 469022); - IdCardGenerator.areaCode.put("澄迈县", 469023); - IdCardGenerator.areaCode.put("临高县", 469024); - IdCardGenerator.areaCode.put("白沙黎族自治县", 469025); - IdCardGenerator.areaCode.put("昌江黎族自治县", 469026); - IdCardGenerator.areaCode.put("乐东黎族自治县", 469027); - IdCardGenerator.areaCode.put("陵水黎族自治县", 469028); - IdCardGenerator.areaCode.put("保亭黎族苗族自治县", 469029); - IdCardGenerator.areaCode.put("琼中黎族苗族自治县", 469030); - IdCardGenerator.areaCode.put("西沙群岛", 469031); - IdCardGenerator.areaCode.put("南沙群岛", 469032); - IdCardGenerator.areaCode.put("中沙群岛的岛礁及其海域", 469033); - IdCardGenerator.areaCode.put("重庆市", 500000); - IdCardGenerator.areaCode.put("市辖区", 500100); - IdCardGenerator.areaCode.put("万州区", 500101); - IdCardGenerator.areaCode.put("涪陵区", 500102); - IdCardGenerator.areaCode.put("渝中区", 500103); - IdCardGenerator.areaCode.put("大渡口区", 500104); - IdCardGenerator.areaCode.put("江北区", 500105); - IdCardGenerator.areaCode.put("沙坪坝区", 500106); - IdCardGenerator.areaCode.put("九龙坡区", 500107); - IdCardGenerator.areaCode.put("南岸区", 500108); - IdCardGenerator.areaCode.put("北碚区", 500109); - IdCardGenerator.areaCode.put("万盛区", 500110); - IdCardGenerator.areaCode.put("双桥区", 500111); - IdCardGenerator.areaCode.put("渝北区", 500112); - IdCardGenerator.areaCode.put("巴南区", 500113); - IdCardGenerator.areaCode.put("黔江区", 500114); - IdCardGenerator.areaCode.put("长寿区", 500115); - IdCardGenerator.areaCode.put("江津区", 500116); - IdCardGenerator.areaCode.put("合川区", 500117); - IdCardGenerator.areaCode.put("永川区", 500118); - IdCardGenerator.areaCode.put("南川区", 500119); - IdCardGenerator.areaCode.put("县", 500200); - IdCardGenerator.areaCode.put("綦江县", 500222); - IdCardGenerator.areaCode.put("潼南县", 500223); - IdCardGenerator.areaCode.put("铜梁县", 500224); - IdCardGenerator.areaCode.put("大足县", 500225); - IdCardGenerator.areaCode.put("荣昌县", 500226); - IdCardGenerator.areaCode.put("璧山县", 500227); - IdCardGenerator.areaCode.put("梁平县", 500228); - IdCardGenerator.areaCode.put("城口县", 500229); - IdCardGenerator.areaCode.put("丰都县", 500230); - IdCardGenerator.areaCode.put("垫江县", 500231); - IdCardGenerator.areaCode.put("武隆县", 500232); - IdCardGenerator.areaCode.put("忠 县", 500233); - IdCardGenerator.areaCode.put("开 县", 500234); - IdCardGenerator.areaCode.put("云阳县", 500235); - IdCardGenerator.areaCode.put("奉节县", 500236); - IdCardGenerator.areaCode.put("巫山县", 500237); - IdCardGenerator.areaCode.put("巫溪县", 500238); - IdCardGenerator.areaCode.put("石柱土家族自治县", 500240); - IdCardGenerator.areaCode.put("秀山土家族苗族自治县", 500241); - IdCardGenerator.areaCode.put("酉阳土家族苗族自治县", 500242); - IdCardGenerator.areaCode.put("彭水苗族土家族自治县", 500243); - IdCardGenerator.areaCode.put("四川省", 510000); - IdCardGenerator.areaCode.put("成都市", 510100); - IdCardGenerator.areaCode.put("市辖区", 510101); - IdCardGenerator.areaCode.put("锦江区", 510104); - IdCardGenerator.areaCode.put("青羊区", 510105); - IdCardGenerator.areaCode.put("金牛区", 510106); - IdCardGenerator.areaCode.put("武侯区", 510107); - IdCardGenerator.areaCode.put("成华区", 510108); - IdCardGenerator.areaCode.put("龙泉驿区", 510112); - IdCardGenerator.areaCode.put("青白江区", 510113); - IdCardGenerator.areaCode.put("新都区", 510114); - IdCardGenerator.areaCode.put("温江区", 510115); - IdCardGenerator.areaCode.put("金堂县", 510121); - IdCardGenerator.areaCode.put("双流县", 510122); - IdCardGenerator.areaCode.put("郫 县", 510124); - IdCardGenerator.areaCode.put("大邑县", 510129); - IdCardGenerator.areaCode.put("蒲江县", 510131); - IdCardGenerator.areaCode.put("新津县", 510132); - IdCardGenerator.areaCode.put("都江堰市", 510181); - IdCardGenerator.areaCode.put("彭州市", 510182); - IdCardGenerator.areaCode.put("邛崃市", 510183); - IdCardGenerator.areaCode.put("崇州市", 510184); - IdCardGenerator.areaCode.put("自贡市", 510300); - IdCardGenerator.areaCode.put("市辖区", 510301); - IdCardGenerator.areaCode.put("自流井区", 510302); - IdCardGenerator.areaCode.put("贡井区", 510303); - IdCardGenerator.areaCode.put("大安区", 510304); - IdCardGenerator.areaCode.put("沿滩区", 510311); - IdCardGenerator.areaCode.put("荣 县", 510321); - IdCardGenerator.areaCode.put("富顺县", 510322); - IdCardGenerator.areaCode.put("攀枝花市", 510400); - IdCardGenerator.areaCode.put("市辖区", 510401); - IdCardGenerator.areaCode.put("东 区", 510402); - IdCardGenerator.areaCode.put("西 区", 510403); - IdCardGenerator.areaCode.put("仁和区", 510411); - IdCardGenerator.areaCode.put("米易县", 510421); - IdCardGenerator.areaCode.put("盐边县", 510422); - IdCardGenerator.areaCode.put("泸州市", 510500); - IdCardGenerator.areaCode.put("市辖区", 510501); - IdCardGenerator.areaCode.put("江阳区", 510502); - IdCardGenerator.areaCode.put("纳溪区", 510503); - IdCardGenerator.areaCode.put("龙马潭区", 510504); - IdCardGenerator.areaCode.put("泸 县", 510521); - IdCardGenerator.areaCode.put("合江县", 510522); - IdCardGenerator.areaCode.put("叙永县", 510524); - IdCardGenerator.areaCode.put("古蔺县", 510525); - IdCardGenerator.areaCode.put("德阳市", 510600); - IdCardGenerator.areaCode.put("市辖区", 510601); - IdCardGenerator.areaCode.put("旌阳区", 510603); - IdCardGenerator.areaCode.put("中江县", 510623); - IdCardGenerator.areaCode.put("罗江县", 510626); - IdCardGenerator.areaCode.put("广汉市", 510681); - IdCardGenerator.areaCode.put("什邡市", 510682); - IdCardGenerator.areaCode.put("绵竹市", 510683); - IdCardGenerator.areaCode.put("绵阳市", 510700); - IdCardGenerator.areaCode.put("市辖区", 510701); - IdCardGenerator.areaCode.put("涪城区", 510703); - IdCardGenerator.areaCode.put("游仙区", 510704); - IdCardGenerator.areaCode.put("三台县", 510722); - IdCardGenerator.areaCode.put("盐亭县", 510723); - IdCardGenerator.areaCode.put("安 县", 510724); - IdCardGenerator.areaCode.put("梓潼县", 510725); - IdCardGenerator.areaCode.put("北川羌族自治县", 510726); - IdCardGenerator.areaCode.put("平武县", 510727); - IdCardGenerator.areaCode.put("江油市", 510781); - IdCardGenerator.areaCode.put("广元市", 510800); - IdCardGenerator.areaCode.put("市辖区", 510801); - IdCardGenerator.areaCode.put("利州区", 510802); - IdCardGenerator.areaCode.put("元坝区", 510811); - IdCardGenerator.areaCode.put("朝天区", 510812); - IdCardGenerator.areaCode.put("旺苍县", 510821); - IdCardGenerator.areaCode.put("青川县", 510822); - IdCardGenerator.areaCode.put("剑阁县", 510823); - IdCardGenerator.areaCode.put("苍溪县", 510824); - IdCardGenerator.areaCode.put("遂宁市", 510900); - IdCardGenerator.areaCode.put("市辖区", 510901); - IdCardGenerator.areaCode.put("船山区", 510903); - IdCardGenerator.areaCode.put("安居区", 510904); - IdCardGenerator.areaCode.put("蓬溪县", 510921); - IdCardGenerator.areaCode.put("射洪县", 510922); - IdCardGenerator.areaCode.put("大英县", 510923); - IdCardGenerator.areaCode.put("内江市", 511000); - IdCardGenerator.areaCode.put("市辖区", 511001); - IdCardGenerator.areaCode.put("市中区", 511002); - IdCardGenerator.areaCode.put("东兴区", 511011); - IdCardGenerator.areaCode.put("威远县", 511024); - IdCardGenerator.areaCode.put("资中县", 511025); - IdCardGenerator.areaCode.put("隆昌县", 511028); - IdCardGenerator.areaCode.put("乐山市", 511100); - IdCardGenerator.areaCode.put("市辖区", 511101); - IdCardGenerator.areaCode.put("市中区", 511102); - IdCardGenerator.areaCode.put("沙湾区", 511111); - IdCardGenerator.areaCode.put("五通桥区", 511112); - IdCardGenerator.areaCode.put("金口河区", 511113); - IdCardGenerator.areaCode.put("犍为县", 511123); - IdCardGenerator.areaCode.put("井研县", 511124); - IdCardGenerator.areaCode.put("夹江县", 511126); - IdCardGenerator.areaCode.put("沐川县", 511129); - IdCardGenerator.areaCode.put("峨边彝族自治县", 511132); - IdCardGenerator.areaCode.put("马边彝族自治县", 511133); - IdCardGenerator.areaCode.put("峨眉山市", 511181); - IdCardGenerator.areaCode.put("南充市", 511300); - IdCardGenerator.areaCode.put("市辖区", 511301); - IdCardGenerator.areaCode.put("顺庆区", 511302); - IdCardGenerator.areaCode.put("高坪区", 511303); - IdCardGenerator.areaCode.put("嘉陵区", 511304); - IdCardGenerator.areaCode.put("南部县", 511321); - IdCardGenerator.areaCode.put("营山县", 511322); - IdCardGenerator.areaCode.put("蓬安县", 511323); - IdCardGenerator.areaCode.put("仪陇县", 511324); - IdCardGenerator.areaCode.put("西充县", 511325); - IdCardGenerator.areaCode.put("阆中市", 511381); - IdCardGenerator.areaCode.put("眉山市", 511400); - IdCardGenerator.areaCode.put("市辖区", 511401); - IdCardGenerator.areaCode.put("东坡区", 511402); - IdCardGenerator.areaCode.put("仁寿县", 511421); - IdCardGenerator.areaCode.put("彭山县", 511422); - IdCardGenerator.areaCode.put("洪雅县", 511423); - IdCardGenerator.areaCode.put("丹棱县", 511424); - IdCardGenerator.areaCode.put("青神县", 511425); - IdCardGenerator.areaCode.put("宜宾市", 511500); - IdCardGenerator.areaCode.put("市辖区", 511501); - IdCardGenerator.areaCode.put("翠屏区", 511502); - IdCardGenerator.areaCode.put("宜宾县", 511521); - IdCardGenerator.areaCode.put("南溪县", 511522); - IdCardGenerator.areaCode.put("江安县", 511523); - IdCardGenerator.areaCode.put("长宁县", 511524); - IdCardGenerator.areaCode.put("高 县", 511525); - IdCardGenerator.areaCode.put("珙 县", 511526); - IdCardGenerator.areaCode.put("筠连县", 511527); - IdCardGenerator.areaCode.put("兴文县", 511528); - IdCardGenerator.areaCode.put("屏山县", 511529); - IdCardGenerator.areaCode.put("广安市", 511600); - IdCardGenerator.areaCode.put("市辖区", 511601); - IdCardGenerator.areaCode.put("广安区", 511602); - IdCardGenerator.areaCode.put("岳池县", 511621); - IdCardGenerator.areaCode.put("武胜县", 511622); - IdCardGenerator.areaCode.put("邻水县", 511623); - IdCardGenerator.areaCode.put("华蓥市", 511681); - IdCardGenerator.areaCode.put("达州市", 511700); - IdCardGenerator.areaCode.put("市辖区", 511701); - IdCardGenerator.areaCode.put("通川区", 511702); - IdCardGenerator.areaCode.put("达 县", 511721); - IdCardGenerator.areaCode.put("宣汉县", 511722); - IdCardGenerator.areaCode.put("开江县", 511723); - IdCardGenerator.areaCode.put("大竹县", 511724); - IdCardGenerator.areaCode.put("渠 县", 511725); - IdCardGenerator.areaCode.put("万源市", 511781); - IdCardGenerator.areaCode.put("雅安市", 511800); - IdCardGenerator.areaCode.put("市辖区", 511801); - IdCardGenerator.areaCode.put("雨城区", 511802); - IdCardGenerator.areaCode.put("名山县", 511821); - IdCardGenerator.areaCode.put("荥经县", 511822); - IdCardGenerator.areaCode.put("汉源县", 511823); - IdCardGenerator.areaCode.put("石棉县", 511824); - IdCardGenerator.areaCode.put("天全县", 511825); - IdCardGenerator.areaCode.put("芦山县", 511826); - IdCardGenerator.areaCode.put("宝兴县", 511827); - IdCardGenerator.areaCode.put("巴中市", 511900); - IdCardGenerator.areaCode.put("市辖区", 511901); - IdCardGenerator.areaCode.put("巴州区", 511902); - IdCardGenerator.areaCode.put("通江县", 511921); - IdCardGenerator.areaCode.put("南江县", 511922); - IdCardGenerator.areaCode.put("平昌县", 511923); - IdCardGenerator.areaCode.put("资阳市", 512000); - IdCardGenerator.areaCode.put("市辖区", 512001); - IdCardGenerator.areaCode.put("雁江区", 512002); - IdCardGenerator.areaCode.put("安岳县", 512021); - IdCardGenerator.areaCode.put("乐至县", 512022); - IdCardGenerator.areaCode.put("简阳市", 512081); - IdCardGenerator.areaCode.put("阿坝藏族羌族自治州", 513200); - IdCardGenerator.areaCode.put("汶川县", 513221); - IdCardGenerator.areaCode.put("理 县", 513222); - IdCardGenerator.areaCode.put("茂 县", 513223); - IdCardGenerator.areaCode.put("松潘县", 513224); - IdCardGenerator.areaCode.put("九寨沟县", 513225); - IdCardGenerator.areaCode.put("金川县", 513226); - IdCardGenerator.areaCode.put("小金县", 513227); - IdCardGenerator.areaCode.put("黑水县", 513228); - IdCardGenerator.areaCode.put("马尔康县", 513229); - IdCardGenerator.areaCode.put("壤塘县", 513230); - IdCardGenerator.areaCode.put("阿坝县", 513231); - IdCardGenerator.areaCode.put("若尔盖县", 513232); - IdCardGenerator.areaCode.put("红原县", 513233); - IdCardGenerator.areaCode.put("甘孜藏族自治州", 513300); - IdCardGenerator.areaCode.put("康定县", 513321); - IdCardGenerator.areaCode.put("泸定县", 513322); - IdCardGenerator.areaCode.put("丹巴县", 513323); - IdCardGenerator.areaCode.put("九龙县", 513324); - IdCardGenerator.areaCode.put("雅江县", 513325); - IdCardGenerator.areaCode.put("道孚县", 513326); - IdCardGenerator.areaCode.put("炉霍县", 513327); - IdCardGenerator.areaCode.put("甘孜县", 513328); - IdCardGenerator.areaCode.put("新龙县", 513329); - IdCardGenerator.areaCode.put("德格县", 513330); - IdCardGenerator.areaCode.put("白玉县", 513331); - IdCardGenerator.areaCode.put("石渠县", 513332); - IdCardGenerator.areaCode.put("色达县", 513333); - IdCardGenerator.areaCode.put("理塘县", 513334); - IdCardGenerator.areaCode.put("巴塘县", 513335); - IdCardGenerator.areaCode.put("乡城县", 513336); - IdCardGenerator.areaCode.put("稻城县", 513337); - IdCardGenerator.areaCode.put("得荣县", 513338); - IdCardGenerator.areaCode.put("凉山彝族自治州", 513400); - IdCardGenerator.areaCode.put("西昌市", 513401); - IdCardGenerator.areaCode.put("木里藏族自治县", 513422); - IdCardGenerator.areaCode.put("盐源县", 513423); - IdCardGenerator.areaCode.put("德昌县", 513424); - IdCardGenerator.areaCode.put("会理县", 513425); - IdCardGenerator.areaCode.put("会东县", 513426); - IdCardGenerator.areaCode.put("宁南县", 513427); - IdCardGenerator.areaCode.put("普格县", 513428); - IdCardGenerator.areaCode.put("布拖县", 513429); - IdCardGenerator.areaCode.put("金阳县", 513430); - IdCardGenerator.areaCode.put("昭觉县", 513431); - IdCardGenerator.areaCode.put("喜德县", 513432); - IdCardGenerator.areaCode.put("冕宁县", 513433); - IdCardGenerator.areaCode.put("越西县", 513434); - IdCardGenerator.areaCode.put("甘洛县", 513435); - IdCardGenerator.areaCode.put("美姑县", 513436); - IdCardGenerator.areaCode.put("雷波县", 513437); - IdCardGenerator.areaCode.put("贵州省", 520000); - IdCardGenerator.areaCode.put("贵阳市", 520100); - IdCardGenerator.areaCode.put("市辖区", 520101); - IdCardGenerator.areaCode.put("南明区", 520102); - IdCardGenerator.areaCode.put("云岩区", 520103); - IdCardGenerator.areaCode.put("花溪区", 520111); - IdCardGenerator.areaCode.put("乌当区", 520112); - IdCardGenerator.areaCode.put("白云区", 520113); - IdCardGenerator.areaCode.put("小河区", 520114); - IdCardGenerator.areaCode.put("开阳县", 520121); - IdCardGenerator.areaCode.put("息烽县", 520122); - IdCardGenerator.areaCode.put("修文县", 520123); - IdCardGenerator.areaCode.put("清镇市", 520181); - IdCardGenerator.areaCode.put("六盘水市", 520200); - IdCardGenerator.areaCode.put("钟山区", 520201); - IdCardGenerator.areaCode.put("六枝特区", 520203); - IdCardGenerator.areaCode.put("水城县", 520221); - IdCardGenerator.areaCode.put("盘 县", 520222); - IdCardGenerator.areaCode.put("遵义市", 520300); - IdCardGenerator.areaCode.put("市辖区", 520301); - IdCardGenerator.areaCode.put("红花岗区", 520302); - IdCardGenerator.areaCode.put("汇川区", 520303); - IdCardGenerator.areaCode.put("遵义县", 520321); - IdCardGenerator.areaCode.put("桐梓县", 520322); - IdCardGenerator.areaCode.put("绥阳县", 520323); - IdCardGenerator.areaCode.put("正安县", 520324); - IdCardGenerator.areaCode.put("道真仡佬族苗族自治县", 520325); - IdCardGenerator.areaCode.put("务川仡佬族苗族自治县", 520326); - IdCardGenerator.areaCode.put("凤冈县", 520327); - IdCardGenerator.areaCode.put("湄潭县", 520328); - IdCardGenerator.areaCode.put("余庆县", 520329); - IdCardGenerator.areaCode.put("习水县", 520330); - IdCardGenerator.areaCode.put("赤水市", 520381); - IdCardGenerator.areaCode.put("仁怀市", 520382); - IdCardGenerator.areaCode.put("安顺市", 520400); - IdCardGenerator.areaCode.put("市辖区", 520401); - IdCardGenerator.areaCode.put("西秀区", 520402); - IdCardGenerator.areaCode.put("平坝县", 520421); - IdCardGenerator.areaCode.put("普定县", 520422); - IdCardGenerator.areaCode.put("镇宁布依族苗族自治县", 520423); - IdCardGenerator.areaCode.put("关岭布依族苗族自治县", 520424); - IdCardGenerator.areaCode.put("紫云苗族布依族自治县", 520425); - IdCardGenerator.areaCode.put("铜仁地区", 522200); - IdCardGenerator.areaCode.put("铜仁市", 522201); - IdCardGenerator.areaCode.put("江口县", 522222); - IdCardGenerator.areaCode.put("玉屏侗族自治县", 522223); - IdCardGenerator.areaCode.put("石阡县", 522224); - IdCardGenerator.areaCode.put("思南县", 522225); - IdCardGenerator.areaCode.put("印江土家族苗族自治县", 522226); - IdCardGenerator.areaCode.put("德江县", 522227); - IdCardGenerator.areaCode.put("沿河土家族自治县", 522228); - IdCardGenerator.areaCode.put("松桃苗族自治县", 522229); - IdCardGenerator.areaCode.put("万山特区", 522230); - IdCardGenerator.areaCode.put("黔西南布依族苗族自治州", 522300); - IdCardGenerator.areaCode.put("兴义市", 522301); - IdCardGenerator.areaCode.put("兴仁县", 522322); - IdCardGenerator.areaCode.put("普安县", 522323); - IdCardGenerator.areaCode.put("晴隆县", 522324); - IdCardGenerator.areaCode.put("贞丰县", 522325); - IdCardGenerator.areaCode.put("望谟县", 522326); - IdCardGenerator.areaCode.put("册亨县", 522327); - IdCardGenerator.areaCode.put("安龙县", 522328); - IdCardGenerator.areaCode.put("毕节地区", 522400); - IdCardGenerator.areaCode.put("毕节市", 522401); - IdCardGenerator.areaCode.put("大方县", 522422); - IdCardGenerator.areaCode.put("黔西县", 522423); - IdCardGenerator.areaCode.put("金沙县", 522424); - IdCardGenerator.areaCode.put("织金县", 522425); - IdCardGenerator.areaCode.put("纳雍县", 522426); - IdCardGenerator.areaCode.put("威宁彝族回族苗族自治县", 522427); - IdCardGenerator.areaCode.put("赫章县", 522428); - IdCardGenerator.areaCode.put("黔东南苗族侗族自治州", 522600); - IdCardGenerator.areaCode.put("凯里市", 522601); - IdCardGenerator.areaCode.put("黄平县", 522622); - IdCardGenerator.areaCode.put("施秉县", 522623); - IdCardGenerator.areaCode.put("三穗县", 522624); - IdCardGenerator.areaCode.put("镇远县", 522625); - IdCardGenerator.areaCode.put("岑巩县", 522626); - IdCardGenerator.areaCode.put("天柱县", 522627); - IdCardGenerator.areaCode.put("锦屏县", 522628); - IdCardGenerator.areaCode.put("剑河县", 522629); - IdCardGenerator.areaCode.put("台江县", 522630); - IdCardGenerator.areaCode.put("黎平县", 522631); - IdCardGenerator.areaCode.put("榕江县", 522632); - IdCardGenerator.areaCode.put("从江县", 522633); - IdCardGenerator.areaCode.put("雷山县", 522634); - IdCardGenerator.areaCode.put("麻江县", 522635); - IdCardGenerator.areaCode.put("丹寨县", 522636); - IdCardGenerator.areaCode.put("黔南布依族苗族自治州", 522700); - IdCardGenerator.areaCode.put("都匀市", 522701); - IdCardGenerator.areaCode.put("福泉市", 522702); - IdCardGenerator.areaCode.put("荔波县", 522722); - IdCardGenerator.areaCode.put("贵定县", 522723); - IdCardGenerator.areaCode.put("瓮安县", 522725); - IdCardGenerator.areaCode.put("独山县", 522726); - IdCardGenerator.areaCode.put("平塘县", 522727); - IdCardGenerator.areaCode.put("罗甸县", 522728); - IdCardGenerator.areaCode.put("长顺县", 522729); - IdCardGenerator.areaCode.put("龙里县", 522730); - IdCardGenerator.areaCode.put("惠水县", 522731); - IdCardGenerator.areaCode.put("三都水族自治县", 522732); - IdCardGenerator.areaCode.put("云南省", 530000); - IdCardGenerator.areaCode.put("昆明市", 530100); - IdCardGenerator.areaCode.put("市辖区", 530101); - IdCardGenerator.areaCode.put("五华区", 530102); - IdCardGenerator.areaCode.put("盘龙区", 530103); - IdCardGenerator.areaCode.put("官渡区", 530111); - IdCardGenerator.areaCode.put("西山区", 530112); - IdCardGenerator.areaCode.put("东川区", 530113); - IdCardGenerator.areaCode.put("呈贡县", 530121); - IdCardGenerator.areaCode.put("晋宁县", 530122); - IdCardGenerator.areaCode.put("富民县", 530124); - IdCardGenerator.areaCode.put("宜良县", 530125); - IdCardGenerator.areaCode.put("石林彝族自治县", 530126); - IdCardGenerator.areaCode.put("嵩明县", 530127); - IdCardGenerator.areaCode.put("禄劝彝族苗族自治县", 530128); - IdCardGenerator.areaCode.put("寻甸回族彝族自治县", 530129); - IdCardGenerator.areaCode.put("安宁市", 530181); - IdCardGenerator.areaCode.put("曲靖市", 530300); - IdCardGenerator.areaCode.put("市辖区", 530301); - IdCardGenerator.areaCode.put("麒麟区", 530302); - IdCardGenerator.areaCode.put("马龙县", 530321); - IdCardGenerator.areaCode.put("陆良县", 530322); - IdCardGenerator.areaCode.put("师宗县", 530323); - IdCardGenerator.areaCode.put("罗平县", 530324); - IdCardGenerator.areaCode.put("富源县", 530325); - IdCardGenerator.areaCode.put("会泽县", 530326); - IdCardGenerator.areaCode.put("沾益县", 530328); - IdCardGenerator.areaCode.put("宣威市", 530381); - IdCardGenerator.areaCode.put("玉溪市", 530400); - IdCardGenerator.areaCode.put("市辖区", 530401); - IdCardGenerator.areaCode.put("红塔区", 530402); - IdCardGenerator.areaCode.put("江川县", 530421); - IdCardGenerator.areaCode.put("澄江县", 530422); - IdCardGenerator.areaCode.put("通海县", 530423); - IdCardGenerator.areaCode.put("华宁县", 530424); - IdCardGenerator.areaCode.put("易门县", 530425); - IdCardGenerator.areaCode.put("峨山彝族自治县", 530426); - IdCardGenerator.areaCode.put("新平彝族傣族自治县", 530427); - IdCardGenerator.areaCode.put("元江哈尼族彝族傣族自治县", 530428); - IdCardGenerator.areaCode.put("保山市", 530500); - IdCardGenerator.areaCode.put("市辖区", 530501); - IdCardGenerator.areaCode.put("隆阳区", 530502); - IdCardGenerator.areaCode.put("施甸县", 530521); - IdCardGenerator.areaCode.put("腾冲县", 530522); - IdCardGenerator.areaCode.put("龙陵县", 530523); - IdCardGenerator.areaCode.put("昌宁县", 530524); - IdCardGenerator.areaCode.put("昭通市", 530600); - IdCardGenerator.areaCode.put("市辖区", 530601); - IdCardGenerator.areaCode.put("昭阳区", 530602); - IdCardGenerator.areaCode.put("鲁甸县", 530621); - IdCardGenerator.areaCode.put("巧家县", 530622); - IdCardGenerator.areaCode.put("盐津县", 530623); - IdCardGenerator.areaCode.put("大关县", 530624); - IdCardGenerator.areaCode.put("永善县", 530625); - IdCardGenerator.areaCode.put("绥江县", 530626); - IdCardGenerator.areaCode.put("镇雄县", 530627); - IdCardGenerator.areaCode.put("彝良县", 530628); - IdCardGenerator.areaCode.put("威信县", 530629); - IdCardGenerator.areaCode.put("水富县", 530630); - IdCardGenerator.areaCode.put("丽江市", 530700); - IdCardGenerator.areaCode.put("市辖区", 530701); - IdCardGenerator.areaCode.put("古城区", 530702); - IdCardGenerator.areaCode.put("玉龙纳西族自治县", 530721); - IdCardGenerator.areaCode.put("永胜县", 530722); - IdCardGenerator.areaCode.put("华坪县", 530723); - IdCardGenerator.areaCode.put("宁蒗彝族自治县", 530724); - IdCardGenerator.areaCode.put("普洱市", 530800); - IdCardGenerator.areaCode.put("市辖区", 530801); - IdCardGenerator.areaCode.put("思茅区", 530802); - IdCardGenerator.areaCode.put("宁洱哈尼族彝族自治县", 530821); - IdCardGenerator.areaCode.put("墨江哈尼族自治县", 530822); - IdCardGenerator.areaCode.put("景东彝族自治县", 530823); - IdCardGenerator.areaCode.put("景谷傣族彝族自治县", 530824); - IdCardGenerator.areaCode.put("镇沅彝族哈尼族拉祜族自治县", 530825); - IdCardGenerator.areaCode.put("江城哈尼族彝族自治县", 530826); - IdCardGenerator.areaCode.put("孟连傣族拉祜族佤族自治县", 530827); - IdCardGenerator.areaCode.put("澜沧拉祜族自治县", 530828); - IdCardGenerator.areaCode.put("西盟佤族自治县", 530829); - IdCardGenerator.areaCode.put("临沧市", 530900); - IdCardGenerator.areaCode.put("市辖区", 530901); - IdCardGenerator.areaCode.put("临翔区", 530902); - IdCardGenerator.areaCode.put("凤庆县", 530921); - IdCardGenerator.areaCode.put("云 县", 530922); - IdCardGenerator.areaCode.put("永德县", 530923); - IdCardGenerator.areaCode.put("镇康县", 530924); - IdCardGenerator.areaCode.put("双江拉祜族佤族布朗族傣族自治县", 530925); - IdCardGenerator.areaCode.put("耿马傣族佤族自治县", 530926); - IdCardGenerator.areaCode.put("沧源佤族自治县", 530927); - IdCardGenerator.areaCode.put("楚雄彝族自治州", 532300); - IdCardGenerator.areaCode.put("楚雄市", 532301); - IdCardGenerator.areaCode.put("双柏县", 532322); - IdCardGenerator.areaCode.put("牟定县", 532323); - IdCardGenerator.areaCode.put("南华县", 532324); - IdCardGenerator.areaCode.put("姚安县", 532325); - IdCardGenerator.areaCode.put("大姚县", 532326); - IdCardGenerator.areaCode.put("永仁县", 532327); - IdCardGenerator.areaCode.put("元谋县", 532328); - IdCardGenerator.areaCode.put("武定县", 532329); - IdCardGenerator.areaCode.put("禄丰县", 532331); - IdCardGenerator.areaCode.put("红河哈尼族彝族自治州", 532500); - IdCardGenerator.areaCode.put("个旧市", 532501); - IdCardGenerator.areaCode.put("开远市", 532502); - IdCardGenerator.areaCode.put("蒙自县", 532522); - IdCardGenerator.areaCode.put("屏边苗族自治县", 532523); - IdCardGenerator.areaCode.put("建水县", 532524); - IdCardGenerator.areaCode.put("石屏县", 532525); - IdCardGenerator.areaCode.put("弥勒县", 532526); - IdCardGenerator.areaCode.put("泸西县", 532527); - IdCardGenerator.areaCode.put("元阳县", 532528); - IdCardGenerator.areaCode.put("红河县", 532529); - IdCardGenerator.areaCode.put("金平苗族瑶族傣族自治县", 532530); - IdCardGenerator.areaCode.put("绿春县", 532531); - IdCardGenerator.areaCode.put("河口瑶族自治县", 532532); - IdCardGenerator.areaCode.put("文山壮族苗族自治州", 532600); - IdCardGenerator.areaCode.put("文山县", 532621); - IdCardGenerator.areaCode.put("砚山县", 532622); - IdCardGenerator.areaCode.put("西畴县", 532623); - IdCardGenerator.areaCode.put("麻栗坡县", 532624); - IdCardGenerator.areaCode.put("马关县", 532625); - IdCardGenerator.areaCode.put("丘北县", 532626); - IdCardGenerator.areaCode.put("广南县", 532627); - IdCardGenerator.areaCode.put("富宁县", 532628); - IdCardGenerator.areaCode.put("西双版纳傣族自治州", 532800); - IdCardGenerator.areaCode.put("景洪市", 532801); - IdCardGenerator.areaCode.put("勐海县", 532822); - IdCardGenerator.areaCode.put("勐腊县", 532823); - IdCardGenerator.areaCode.put("大理白族自治州", 532900); - IdCardGenerator.areaCode.put("大理市", 532901); - IdCardGenerator.areaCode.put("漾濞彝族自治县", 532922); - IdCardGenerator.areaCode.put("祥云县", 532923); - IdCardGenerator.areaCode.put("宾川县", 532924); - IdCardGenerator.areaCode.put("弥渡县", 532925); - IdCardGenerator.areaCode.put("南涧彝族自治县", 532926); - IdCardGenerator.areaCode.put("巍山彝族回族自治县", 532927); - IdCardGenerator.areaCode.put("永平县", 532928); - IdCardGenerator.areaCode.put("云龙县", 532929); - IdCardGenerator.areaCode.put("洱源县", 532930); - IdCardGenerator.areaCode.put("剑川县", 532931); - IdCardGenerator.areaCode.put("鹤庆县", 532932); - IdCardGenerator.areaCode.put("德宏傣族景颇族自治州", 533100); - IdCardGenerator.areaCode.put("瑞丽市", 533102); - IdCardGenerator.areaCode.put("潞西市", 533103); - IdCardGenerator.areaCode.put("梁河县", 533122); - IdCardGenerator.areaCode.put("盈江县", 533123); - IdCardGenerator.areaCode.put("陇川县", 533124); - IdCardGenerator.areaCode.put("怒江傈僳族自治州", 533300); - IdCardGenerator.areaCode.put("泸水县", 533321); - IdCardGenerator.areaCode.put("福贡县", 533323); - IdCardGenerator.areaCode.put("贡山独龙族怒族自治县", 533324); - IdCardGenerator.areaCode.put("兰坪白族普米族自治县", 533325); - IdCardGenerator.areaCode.put("迪庆藏族自治州", 533400); - IdCardGenerator.areaCode.put("香格里拉县", 533421); - IdCardGenerator.areaCode.put("德钦县", 533422); - IdCardGenerator.areaCode.put("维西傈僳族自治县", 533423); - IdCardGenerator.areaCode.put("西藏自治区", 540000); - IdCardGenerator.areaCode.put("拉萨市", 540100); - IdCardGenerator.areaCode.put("市辖区", 540101); - IdCardGenerator.areaCode.put("城关区", 540102); - IdCardGenerator.areaCode.put("林周县", 540121); - IdCardGenerator.areaCode.put("当雄县", 540122); - IdCardGenerator.areaCode.put("尼木县", 540123); - IdCardGenerator.areaCode.put("曲水县", 540124); - IdCardGenerator.areaCode.put("堆龙德庆县", 540125); - IdCardGenerator.areaCode.put("达孜县", 540126); - IdCardGenerator.areaCode.put("墨竹工卡县", 540127); - IdCardGenerator.areaCode.put("昌都地区", 542100); - IdCardGenerator.areaCode.put("昌都县", 542121); - IdCardGenerator.areaCode.put("江达县", 542122); - IdCardGenerator.areaCode.put("贡觉县", 542123); - IdCardGenerator.areaCode.put("类乌齐县", 542124); - IdCardGenerator.areaCode.put("丁青县", 542125); - IdCardGenerator.areaCode.put("察雅县", 542126); - IdCardGenerator.areaCode.put("八宿县", 542127); - IdCardGenerator.areaCode.put("左贡县", 542128); - IdCardGenerator.areaCode.put("芒康县", 542129); - IdCardGenerator.areaCode.put("洛隆县", 542132); - IdCardGenerator.areaCode.put("边坝县", 542133); - IdCardGenerator.areaCode.put("山南地区", 542200); - IdCardGenerator.areaCode.put("乃东县", 542221); - IdCardGenerator.areaCode.put("扎囊县", 542222); - IdCardGenerator.areaCode.put("贡嘎县", 542223); - IdCardGenerator.areaCode.put("桑日县", 542224); - IdCardGenerator.areaCode.put("琼结县", 542225); - IdCardGenerator.areaCode.put("曲松县", 542226); - IdCardGenerator.areaCode.put("措美县", 542227); - IdCardGenerator.areaCode.put("洛扎县", 542228); - IdCardGenerator.areaCode.put("加查县", 542229); - IdCardGenerator.areaCode.put("隆子县", 542231); - IdCardGenerator.areaCode.put("错那县", 542232); - IdCardGenerator.areaCode.put("浪卡子县", 542233); - IdCardGenerator.areaCode.put("日喀则地区", 542300); - IdCardGenerator.areaCode.put("日喀则市", 542301); - IdCardGenerator.areaCode.put("南木林县", 542322); - IdCardGenerator.areaCode.put("江孜县", 542323); - IdCardGenerator.areaCode.put("定日县", 542324); - IdCardGenerator.areaCode.put("萨迦县", 542325); - IdCardGenerator.areaCode.put("拉孜县", 542326); - IdCardGenerator.areaCode.put("昂仁县", 542327); - IdCardGenerator.areaCode.put("谢通门县", 542328); - IdCardGenerator.areaCode.put("白朗县", 542329); - IdCardGenerator.areaCode.put("仁布县", 542330); - IdCardGenerator.areaCode.put("康马县", 542331); - IdCardGenerator.areaCode.put("定结县", 542332); - IdCardGenerator.areaCode.put("仲巴县", 542333); - IdCardGenerator.areaCode.put("亚东县", 542334); - IdCardGenerator.areaCode.put("吉隆县", 542335); - IdCardGenerator.areaCode.put("聂拉木县", 542336); - IdCardGenerator.areaCode.put("萨嘎县", 542337); - IdCardGenerator.areaCode.put("岗巴县", 542338); - IdCardGenerator.areaCode.put("那曲地区", 542400); - IdCardGenerator.areaCode.put("那曲县", 542421); - IdCardGenerator.areaCode.put("嘉黎县", 542422); - IdCardGenerator.areaCode.put("比如县", 542423); - IdCardGenerator.areaCode.put("聂荣县", 542424); - IdCardGenerator.areaCode.put("安多县", 542425); - IdCardGenerator.areaCode.put("申扎县", 542426); - IdCardGenerator.areaCode.put("索 县", 542427); - IdCardGenerator.areaCode.put("班戈县", 542428); - IdCardGenerator.areaCode.put("巴青县", 542429); - IdCardGenerator.areaCode.put("尼玛县", 542430); - IdCardGenerator.areaCode.put("阿里地区", 542500); - IdCardGenerator.areaCode.put("普兰县", 542521); - IdCardGenerator.areaCode.put("札达县", 542522); - IdCardGenerator.areaCode.put("噶尔县", 542523); - IdCardGenerator.areaCode.put("日土县", 542524); - IdCardGenerator.areaCode.put("革吉县", 542525); - IdCardGenerator.areaCode.put("改则县", 542526); - IdCardGenerator.areaCode.put("措勤县", 542527); - IdCardGenerator.areaCode.put("林芝地区", 542600); - IdCardGenerator.areaCode.put("林芝县", 542621); - IdCardGenerator.areaCode.put("工布江达县", 542622); - IdCardGenerator.areaCode.put("米林县", 542623); - IdCardGenerator.areaCode.put("墨脱县", 542624); - IdCardGenerator.areaCode.put("波密县", 542625); - IdCardGenerator.areaCode.put("察隅县", 542626); - IdCardGenerator.areaCode.put("朗 县", 542627); - IdCardGenerator.areaCode.put("陕西省", 610000); - IdCardGenerator.areaCode.put("西安市", 610100); - IdCardGenerator.areaCode.put("市辖区", 610101); - IdCardGenerator.areaCode.put("新城区", 610102); - IdCardGenerator.areaCode.put("碑林区", 610103); - IdCardGenerator.areaCode.put("莲湖区", 610104); - IdCardGenerator.areaCode.put("灞桥区", 610111); - IdCardGenerator.areaCode.put("未央区", 610112); - IdCardGenerator.areaCode.put("雁塔区", 610113); - IdCardGenerator.areaCode.put("阎良区", 610114); - IdCardGenerator.areaCode.put("临潼区", 610115); - IdCardGenerator.areaCode.put("长安区", 610116); - IdCardGenerator.areaCode.put("蓝田县", 610122); - IdCardGenerator.areaCode.put("周至县", 610124); - IdCardGenerator.areaCode.put("户 县", 610125); - IdCardGenerator.areaCode.put("高陵县", 610126); - IdCardGenerator.areaCode.put("铜川市", 610200); - IdCardGenerator.areaCode.put("市辖区", 610201); - IdCardGenerator.areaCode.put("王益区", 610202); - IdCardGenerator.areaCode.put("印台区", 610203); - IdCardGenerator.areaCode.put("耀州区", 610204); - IdCardGenerator.areaCode.put("宜君县", 610222); - IdCardGenerator.areaCode.put("宝鸡市", 610300); - IdCardGenerator.areaCode.put("市辖区", 610301); - IdCardGenerator.areaCode.put("渭滨区", 610302); - IdCardGenerator.areaCode.put("金台区", 610303); - IdCardGenerator.areaCode.put("陈仓区", 610304); - IdCardGenerator.areaCode.put("凤翔县", 610322); - IdCardGenerator.areaCode.put("岐山县", 610323); - IdCardGenerator.areaCode.put("扶风县", 610324); - IdCardGenerator.areaCode.put("眉 县", 610326); - IdCardGenerator.areaCode.put("陇 县", 610327); - IdCardGenerator.areaCode.put("千阳县", 610328); - IdCardGenerator.areaCode.put("麟游县", 610329); - IdCardGenerator.areaCode.put("凤 县", 610330); - IdCardGenerator.areaCode.put("太白县", 610331); - IdCardGenerator.areaCode.put("咸阳市", 610400); - IdCardGenerator.areaCode.put("市辖区", 610401); - IdCardGenerator.areaCode.put("秦都区", 610402); - IdCardGenerator.areaCode.put("杨陵区", 610403); - IdCardGenerator.areaCode.put("渭城区", 610404); - IdCardGenerator.areaCode.put("三原县", 610422); - IdCardGenerator.areaCode.put("泾阳县", 610423); - IdCardGenerator.areaCode.put("乾 县", 610424); - IdCardGenerator.areaCode.put("礼泉县", 610425); - IdCardGenerator.areaCode.put("永寿县", 610426); - IdCardGenerator.areaCode.put("彬 县", 610427); - IdCardGenerator.areaCode.put("长武县", 610428); - IdCardGenerator.areaCode.put("旬邑县", 610429); - IdCardGenerator.areaCode.put("淳化县", 610430); - IdCardGenerator.areaCode.put("武功县", 610431); - IdCardGenerator.areaCode.put("兴平市", 610481); - IdCardGenerator.areaCode.put("渭南市", 610500); - IdCardGenerator.areaCode.put("市辖区", 610501); - IdCardGenerator.areaCode.put("临渭区", 610502); - IdCardGenerator.areaCode.put("华 县", 610521); - IdCardGenerator.areaCode.put("潼关县", 610522); - IdCardGenerator.areaCode.put("大荔县", 610523); - IdCardGenerator.areaCode.put("合阳县", 610524); - IdCardGenerator.areaCode.put("澄城县", 610525); - IdCardGenerator.areaCode.put("蒲城县", 610526); - IdCardGenerator.areaCode.put("白水县", 610527); - IdCardGenerator.areaCode.put("富平县", 610528); - IdCardGenerator.areaCode.put("韩城市", 610581); - IdCardGenerator.areaCode.put("华阴市", 610582); - IdCardGenerator.areaCode.put("延安市", 610600); - IdCardGenerator.areaCode.put("市辖区", 610601); - IdCardGenerator.areaCode.put("宝塔区", 610602); - IdCardGenerator.areaCode.put("延长县", 610621); - IdCardGenerator.areaCode.put("延川县", 610622); - IdCardGenerator.areaCode.put("子长县", 610623); - IdCardGenerator.areaCode.put("安塞县", 610624); - IdCardGenerator.areaCode.put("志丹县", 610625); - IdCardGenerator.areaCode.put("吴起县", 610626); - IdCardGenerator.areaCode.put("甘泉县", 610627); - IdCardGenerator.areaCode.put("富 县", 610628); - IdCardGenerator.areaCode.put("洛川县", 610629); - IdCardGenerator.areaCode.put("宜川县", 610630); - IdCardGenerator.areaCode.put("黄龙县", 610631); - IdCardGenerator.areaCode.put("黄陵县", 610632); - IdCardGenerator.areaCode.put("汉中市", 610700); - IdCardGenerator.areaCode.put("市辖区", 610701); - IdCardGenerator.areaCode.put("汉台区", 610702); - IdCardGenerator.areaCode.put("南郑县", 610721); - IdCardGenerator.areaCode.put("城固县", 610722); - IdCardGenerator.areaCode.put("洋 县", 610723); - IdCardGenerator.areaCode.put("西乡县", 610724); - IdCardGenerator.areaCode.put("勉 县", 610725); - IdCardGenerator.areaCode.put("宁强县", 610726); - IdCardGenerator.areaCode.put("略阳县", 610727); - IdCardGenerator.areaCode.put("镇巴县", 610728); - IdCardGenerator.areaCode.put("留坝县", 610729); - IdCardGenerator.areaCode.put("佛坪县", 610730); - IdCardGenerator.areaCode.put("榆林市", 610800); - IdCardGenerator.areaCode.put("市辖区", 610801); - IdCardGenerator.areaCode.put("榆阳区", 610802); - IdCardGenerator.areaCode.put("神木县", 610821); - IdCardGenerator.areaCode.put("府谷县", 610822); - IdCardGenerator.areaCode.put("横山县", 610823); - IdCardGenerator.areaCode.put("靖边县", 610824); - IdCardGenerator.areaCode.put("定边县", 610825); - IdCardGenerator.areaCode.put("绥德县", 610826); - IdCardGenerator.areaCode.put("米脂县", 610827); - IdCardGenerator.areaCode.put("佳 县", 610828); - IdCardGenerator.areaCode.put("吴堡县", 610829); - IdCardGenerator.areaCode.put("清涧县", 610830); - IdCardGenerator.areaCode.put("子洲县", 610831); - IdCardGenerator.areaCode.put("安康市", 610900); - IdCardGenerator.areaCode.put("市辖区", 610901); - IdCardGenerator.areaCode.put("汉滨区", 610902); - IdCardGenerator.areaCode.put("汉阴县", 610921); - IdCardGenerator.areaCode.put("石泉县", 610922); - IdCardGenerator.areaCode.put("宁陕县", 610923); - IdCardGenerator.areaCode.put("紫阳县", 610924); - IdCardGenerator.areaCode.put("岚皋县", 610925); - IdCardGenerator.areaCode.put("平利县", 610926); - IdCardGenerator.areaCode.put("镇坪县", 610927); - IdCardGenerator.areaCode.put("旬阳县", 610928); - IdCardGenerator.areaCode.put("白河县", 610929); - IdCardGenerator.areaCode.put("商洛市", 611000); - IdCardGenerator.areaCode.put("市辖区", 611001); - IdCardGenerator.areaCode.put("商州区", 611002); - IdCardGenerator.areaCode.put("洛南县", 611021); - IdCardGenerator.areaCode.put("丹凤县", 611022); - IdCardGenerator.areaCode.put("商南县", 611023); - IdCardGenerator.areaCode.put("山阳县", 611024); - IdCardGenerator.areaCode.put("镇安县", 611025); - IdCardGenerator.areaCode.put("柞水县", 611026); - IdCardGenerator.areaCode.put("甘肃省", 620000); - IdCardGenerator.areaCode.put("兰州市", 620100); - IdCardGenerator.areaCode.put("市辖区", 620101); - IdCardGenerator.areaCode.put("城关区", 620102); - IdCardGenerator.areaCode.put("七里河区", 620103); - IdCardGenerator.areaCode.put("西固区", 620104); - IdCardGenerator.areaCode.put("安宁区", 620105); - IdCardGenerator.areaCode.put("红古区", 620111); - IdCardGenerator.areaCode.put("永登县", 620121); - IdCardGenerator.areaCode.put("皋兰县", 620122); - IdCardGenerator.areaCode.put("榆中县", 620123); - IdCardGenerator.areaCode.put("嘉峪关市", 620200); - IdCardGenerator.areaCode.put("市辖区", 620201); - IdCardGenerator.areaCode.put("金昌市", 620300); - IdCardGenerator.areaCode.put("市辖区", 620301); - IdCardGenerator.areaCode.put("金川区", 620302); - IdCardGenerator.areaCode.put("永昌县", 620321); - IdCardGenerator.areaCode.put("白银市", 620400); - IdCardGenerator.areaCode.put("市辖区", 620401); - IdCardGenerator.areaCode.put("白银区", 620402); - IdCardGenerator.areaCode.put("平川区", 620403); - IdCardGenerator.areaCode.put("靖远县", 620421); - IdCardGenerator.areaCode.put("会宁县", 620422); - IdCardGenerator.areaCode.put("景泰县", 620423); - IdCardGenerator.areaCode.put("天水市", 620500); - IdCardGenerator.areaCode.put("市辖区", 620501); - IdCardGenerator.areaCode.put("秦州区", 620502); - IdCardGenerator.areaCode.put("麦积区", 620503); - IdCardGenerator.areaCode.put("清水县", 620521); - IdCardGenerator.areaCode.put("秦安县", 620522); - IdCardGenerator.areaCode.put("甘谷县", 620523); - IdCardGenerator.areaCode.put("武山县", 620524); - IdCardGenerator.areaCode.put("张家川回族自治县", 620525); - IdCardGenerator.areaCode.put("武威市", 620600); - IdCardGenerator.areaCode.put("市辖区", 620601); - IdCardGenerator.areaCode.put("凉州区", 620602); - IdCardGenerator.areaCode.put("民勤县", 620621); - IdCardGenerator.areaCode.put("古浪县", 620622); - IdCardGenerator.areaCode.put("天祝藏族自治县", 620623); - IdCardGenerator.areaCode.put("张掖市", 620700); - IdCardGenerator.areaCode.put("市辖区", 620701); - IdCardGenerator.areaCode.put("甘州区", 620702); - IdCardGenerator.areaCode.put("肃南裕固族自治县", 620721); - IdCardGenerator.areaCode.put("民乐县", 620722); - IdCardGenerator.areaCode.put("临泽县", 620723); - IdCardGenerator.areaCode.put("高台县", 620724); - IdCardGenerator.areaCode.put("山丹县", 620725); - IdCardGenerator.areaCode.put("平凉市", 620800); - IdCardGenerator.areaCode.put("市辖区", 620801); - IdCardGenerator.areaCode.put("崆峒区", 620802); - IdCardGenerator.areaCode.put("泾川县", 620821); - IdCardGenerator.areaCode.put("灵台县", 620822); - IdCardGenerator.areaCode.put("崇信县", 620823); - IdCardGenerator.areaCode.put("华亭县", 620824); - IdCardGenerator.areaCode.put("庄浪县", 620825); - IdCardGenerator.areaCode.put("静宁县", 620826); - IdCardGenerator.areaCode.put("酒泉市", 620900); - IdCardGenerator.areaCode.put("市辖区", 620901); - IdCardGenerator.areaCode.put("肃州区", 620902); - IdCardGenerator.areaCode.put("金塔县", 620921); - IdCardGenerator.areaCode.put("瓜州县", 620922); - IdCardGenerator.areaCode.put("肃北蒙古族自治县", 620923); - IdCardGenerator.areaCode.put("阿克塞哈萨克族自治县", 620924); - IdCardGenerator.areaCode.put("玉门市", 620981); - IdCardGenerator.areaCode.put("敦煌市", 620982); - IdCardGenerator.areaCode.put("庆阳市", 621000); - IdCardGenerator.areaCode.put("市辖区", 621001); - IdCardGenerator.areaCode.put("西峰区", 621002); - IdCardGenerator.areaCode.put("庆城县", 621021); - IdCardGenerator.areaCode.put("环 县", 621022); - IdCardGenerator.areaCode.put("华池县", 621023); - IdCardGenerator.areaCode.put("合水县", 621024); - IdCardGenerator.areaCode.put("正宁县", 621025); - IdCardGenerator.areaCode.put("宁 县", 621026); - IdCardGenerator.areaCode.put("镇原县", 621027); - IdCardGenerator.areaCode.put("定西市", 621100); - IdCardGenerator.areaCode.put("市辖区", 621101); - IdCardGenerator.areaCode.put("安定区", 621102); - IdCardGenerator.areaCode.put("通渭县", 621121); - IdCardGenerator.areaCode.put("陇西县", 621122); - IdCardGenerator.areaCode.put("渭源县", 621123); - IdCardGenerator.areaCode.put("临洮县", 621124); - IdCardGenerator.areaCode.put("漳 县", 621125); - IdCardGenerator.areaCode.put("岷 县", 621126); - IdCardGenerator.areaCode.put("陇南市", 621200); - IdCardGenerator.areaCode.put("市辖区", 621201); - IdCardGenerator.areaCode.put("武都区", 621202); - IdCardGenerator.areaCode.put("成 县", 621221); - IdCardGenerator.areaCode.put("文 县", 621222); - IdCardGenerator.areaCode.put("宕昌县", 621223); - IdCardGenerator.areaCode.put("康 县", 621224); - IdCardGenerator.areaCode.put("西和县", 621225); - IdCardGenerator.areaCode.put("礼 县", 621226); - IdCardGenerator.areaCode.put("徽 县", 621227); - IdCardGenerator.areaCode.put("两当县", 621228); - IdCardGenerator.areaCode.put("临夏回族自治州", 622900); - IdCardGenerator.areaCode.put("临夏市", 622901); - IdCardGenerator.areaCode.put("临夏县", 622921); - IdCardGenerator.areaCode.put("康乐县", 622922); - IdCardGenerator.areaCode.put("永靖县", 622923); - IdCardGenerator.areaCode.put("广河县", 622924); - IdCardGenerator.areaCode.put("和政县", 622925); - IdCardGenerator.areaCode.put("东乡族自治县", 622926); - IdCardGenerator.areaCode.put("积石山保安族东乡族撒拉族自治县", 622927); - IdCardGenerator.areaCode.put("甘南藏族自治州", 623000); - IdCardGenerator.areaCode.put("合作市", 623001); - IdCardGenerator.areaCode.put("临潭县", 623021); - IdCardGenerator.areaCode.put("卓尼县", 623022); - IdCardGenerator.areaCode.put("舟曲县", 623023); - IdCardGenerator.areaCode.put("迭部县", 623024); - IdCardGenerator.areaCode.put("玛曲县", 623025); - IdCardGenerator.areaCode.put("碌曲县", 623026); - IdCardGenerator.areaCode.put("夏河县", 623027); - IdCardGenerator.areaCode.put("青海省", 630000); - IdCardGenerator.areaCode.put("西宁市", 630100); - IdCardGenerator.areaCode.put("市辖区", 630101); - IdCardGenerator.areaCode.put("城东区", 630102); - IdCardGenerator.areaCode.put("城中区", 630103); - IdCardGenerator.areaCode.put("城西区", 630104); - IdCardGenerator.areaCode.put("城北区", 630105); - IdCardGenerator.areaCode.put("大通回族土族自治县", 630121); - IdCardGenerator.areaCode.put("湟中县", 630122); - IdCardGenerator.areaCode.put("湟源县", 630123); - IdCardGenerator.areaCode.put("海东地区", 632100); - IdCardGenerator.areaCode.put("平安县", 632121); - IdCardGenerator.areaCode.put("民和回族土族自治县", 632122); - IdCardGenerator.areaCode.put("乐都县", 632123); - IdCardGenerator.areaCode.put("互助土族自治县", 632126); - IdCardGenerator.areaCode.put("化隆回族自治县", 632127); - IdCardGenerator.areaCode.put("循化撒拉族自治县", 632128); - IdCardGenerator.areaCode.put("海北藏族自治州", 632200); - IdCardGenerator.areaCode.put("门源回族自治县", 632221); - IdCardGenerator.areaCode.put("祁连县", 632222); - IdCardGenerator.areaCode.put("海晏县", 632223); - IdCardGenerator.areaCode.put("刚察县", 632224); - IdCardGenerator.areaCode.put("黄南藏族自治州", 632300); - IdCardGenerator.areaCode.put("同仁县", 632321); - IdCardGenerator.areaCode.put("尖扎县", 632322); - IdCardGenerator.areaCode.put("泽库县", 632323); - IdCardGenerator.areaCode.put("河南蒙古族自治县", 632324); - IdCardGenerator.areaCode.put("海南藏族自治州", 632500); - IdCardGenerator.areaCode.put("共和县", 632521); - IdCardGenerator.areaCode.put("同德县", 632522); - IdCardGenerator.areaCode.put("贵德县", 632523); - IdCardGenerator.areaCode.put("兴海县", 632524); - IdCardGenerator.areaCode.put("贵南县", 632525); - IdCardGenerator.areaCode.put("果洛藏族自治州", 632600); - IdCardGenerator.areaCode.put("玛沁县", 632621); - IdCardGenerator.areaCode.put("班玛县", 632622); - IdCardGenerator.areaCode.put("甘德县", 632623); - IdCardGenerator.areaCode.put("达日县", 632624); - IdCardGenerator.areaCode.put("久治县", 632625); - IdCardGenerator.areaCode.put("玛多县", 632626); - IdCardGenerator.areaCode.put("玉树藏族自治州", 632700); - IdCardGenerator.areaCode.put("玉树县", 632721); - IdCardGenerator.areaCode.put("杂多县", 632722); - IdCardGenerator.areaCode.put("称多县", 632723); - IdCardGenerator.areaCode.put("治多县", 632724); - IdCardGenerator.areaCode.put("囊谦县", 632725); - IdCardGenerator.areaCode.put("曲麻莱县", 632726); - IdCardGenerator.areaCode.put("海西蒙古族藏族自治州", 632800); - IdCardGenerator.areaCode.put("格尔木市", 632801); - IdCardGenerator.areaCode.put("德令哈市", 632802); - IdCardGenerator.areaCode.put("乌兰县", 632821); - IdCardGenerator.areaCode.put("都兰县", 632822); - IdCardGenerator.areaCode.put("天峻县", 632823); - IdCardGenerator.areaCode.put("宁夏回族自治区", 640000); - IdCardGenerator.areaCode.put("银川市", 640100); - IdCardGenerator.areaCode.put("市辖区", 640101); - IdCardGenerator.areaCode.put("兴庆区", 640104); - IdCardGenerator.areaCode.put("西夏区", 640105); - IdCardGenerator.areaCode.put("金凤区", 640106); - IdCardGenerator.areaCode.put("永宁县", 640121); - IdCardGenerator.areaCode.put("贺兰县", 640122); - IdCardGenerator.areaCode.put("灵武市", 640181); - IdCardGenerator.areaCode.put("石嘴山市", 640200); - IdCardGenerator.areaCode.put("市辖区", 640201); - IdCardGenerator.areaCode.put("大武口区", 640202); - IdCardGenerator.areaCode.put("惠农区", 640205); - IdCardGenerator.areaCode.put("平罗县", 640221); - IdCardGenerator.areaCode.put("吴忠市", 640300); - IdCardGenerator.areaCode.put("市辖区", 640301); - IdCardGenerator.areaCode.put("利通区", 640302); - IdCardGenerator.areaCode.put("红寺堡区 (*)", 640303); - IdCardGenerator.areaCode.put("盐池县", 640323); - IdCardGenerator.areaCode.put("同心县", 640324); - IdCardGenerator.areaCode.put("青铜峡市", 640381); - IdCardGenerator.areaCode.put("固原市", 640400); - IdCardGenerator.areaCode.put("市辖区", 640401); - IdCardGenerator.areaCode.put("原州区", 640402); - IdCardGenerator.areaCode.put("西吉县", 640422); - IdCardGenerator.areaCode.put("隆德县", 640423); - IdCardGenerator.areaCode.put("泾源县", 640424); - IdCardGenerator.areaCode.put("彭阳县", 640425); - IdCardGenerator.areaCode.put("中卫市", 640500); - IdCardGenerator.areaCode.put("市辖区", 640501); - IdCardGenerator.areaCode.put("沙坡头区", 640502); - IdCardGenerator.areaCode.put("中宁县", 640521); - IdCardGenerator.areaCode.put("海原县", 640522); - IdCardGenerator.areaCode.put("新疆维吾尔自治区", 650000); - IdCardGenerator.areaCode.put("乌鲁木齐市", 650100); - IdCardGenerator.areaCode.put("市辖区", 650101); - IdCardGenerator.areaCode.put("天山区", 650102); - IdCardGenerator.areaCode.put("沙依巴克区", 650103); - IdCardGenerator.areaCode.put("新市区", 650104); - IdCardGenerator.areaCode.put("水磨沟区", 650105); - IdCardGenerator.areaCode.put("头屯河区", 650106); - IdCardGenerator.areaCode.put("达坂城区", 650107); - IdCardGenerator.areaCode.put("米东区", 650109); - IdCardGenerator.areaCode.put("乌鲁木齐县", 650121); - IdCardGenerator.areaCode.put("克拉玛依市", 650200); - IdCardGenerator.areaCode.put("市辖区", 650201); - IdCardGenerator.areaCode.put("独山子区", 650202); - IdCardGenerator.areaCode.put("克拉玛依区", 650203); - IdCardGenerator.areaCode.put("白碱滩区", 650204); - IdCardGenerator.areaCode.put("乌尔禾区", 650205); - IdCardGenerator.areaCode.put("吐鲁番地区", 652100); - IdCardGenerator.areaCode.put("吐鲁番市", 652101); - IdCardGenerator.areaCode.put("鄯善县", 652122); - IdCardGenerator.areaCode.put("托克逊县", 652123); - IdCardGenerator.areaCode.put("哈密地区", 652200); - IdCardGenerator.areaCode.put("哈密市", 652201); - IdCardGenerator.areaCode.put("巴里坤哈萨克自治县", 652222); - IdCardGenerator.areaCode.put("伊吾县", 652223); - IdCardGenerator.areaCode.put("昌吉回族自治州", 652300); - IdCardGenerator.areaCode.put("昌吉市", 652301); - IdCardGenerator.areaCode.put("阜康市", 652302); - IdCardGenerator.areaCode.put("呼图壁县", 652323); - IdCardGenerator.areaCode.put("玛纳斯县", 652324); - IdCardGenerator.areaCode.put("奇台县", 652325); - IdCardGenerator.areaCode.put("吉木萨尔县", 652327); - IdCardGenerator.areaCode.put("木垒哈萨克自治县", 652328); - IdCardGenerator.areaCode.put("博尔塔拉蒙古自治州", 652700); - IdCardGenerator.areaCode.put("博乐市", 652701); - IdCardGenerator.areaCode.put("精河县", 652722); - IdCardGenerator.areaCode.put("温泉县", 652723); - IdCardGenerator.areaCode.put("巴音郭楞蒙古自治州", 652800); - IdCardGenerator.areaCode.put("库尔勒市", 652801); - IdCardGenerator.areaCode.put("轮台县", 652822); - IdCardGenerator.areaCode.put("尉犁县", 652823); - IdCardGenerator.areaCode.put("若羌县", 652824); - IdCardGenerator.areaCode.put("且末县", 652825); - IdCardGenerator.areaCode.put("焉耆回族自治县", 652826); - IdCardGenerator.areaCode.put("和静县", 652827); - IdCardGenerator.areaCode.put("和硕县", 652828); - IdCardGenerator.areaCode.put("博湖县", 652829); - IdCardGenerator.areaCode.put("阿克苏地区", 652900); - IdCardGenerator.areaCode.put("阿克苏市", 652901); - IdCardGenerator.areaCode.put("温宿县", 652922); - IdCardGenerator.areaCode.put("库车县", 652923); - IdCardGenerator.areaCode.put("沙雅县", 652924); - IdCardGenerator.areaCode.put("新和县", 652925); - IdCardGenerator.areaCode.put("拜城县", 652926); - IdCardGenerator.areaCode.put("乌什县", 652927); - IdCardGenerator.areaCode.put("阿瓦提县", 652928); - IdCardGenerator.areaCode.put("柯坪县", 652929); - IdCardGenerator.areaCode.put("克孜勒苏柯尔克孜自治州", 653000); - IdCardGenerator.areaCode.put("阿图什市", 653001); - IdCardGenerator.areaCode.put("阿克陶县", 653022); - IdCardGenerator.areaCode.put("阿合奇县", 653023); - IdCardGenerator.areaCode.put("乌恰县", 653024); - IdCardGenerator.areaCode.put("喀什地区", 653100); - IdCardGenerator.areaCode.put("喀什市", 653101); - IdCardGenerator.areaCode.put("疏附县", 653121); - IdCardGenerator.areaCode.put("疏勒县", 653122); - IdCardGenerator.areaCode.put("英吉沙县", 653123); - IdCardGenerator.areaCode.put("泽普县", 653124); - IdCardGenerator.areaCode.put("莎车县", 653125); - IdCardGenerator.areaCode.put("叶城县", 653126); - IdCardGenerator.areaCode.put("麦盖提县", 653127); - IdCardGenerator.areaCode.put("岳普湖县", 653128); - IdCardGenerator.areaCode.put("伽师县", 653129); - IdCardGenerator.areaCode.put("巴楚县", 653130); - IdCardGenerator.areaCode.put("塔什库尔干塔吉克自治县", 653131); - IdCardGenerator.areaCode.put("和田地区", 653200); - IdCardGenerator.areaCode.put("和田市", 653201); - IdCardGenerator.areaCode.put("和田县", 653221); - IdCardGenerator.areaCode.put("墨玉县", 653222); - IdCardGenerator.areaCode.put("皮山县", 653223); - IdCardGenerator.areaCode.put("洛浦县", 653224); - IdCardGenerator.areaCode.put("策勒县", 653225); - IdCardGenerator.areaCode.put("于田县", 653226); - IdCardGenerator.areaCode.put("民丰县", 653227); - IdCardGenerator.areaCode.put("伊犁哈萨克自治州", 654000); - IdCardGenerator.areaCode.put("伊宁市", 654002); - IdCardGenerator.areaCode.put("奎屯市", 654003); - IdCardGenerator.areaCode.put("伊宁县", 654021); - IdCardGenerator.areaCode.put("察布查尔锡伯自治县", 654022); - IdCardGenerator.areaCode.put("霍城县", 654023); - IdCardGenerator.areaCode.put("巩留县", 654024); - IdCardGenerator.areaCode.put("新源县", 654025); - IdCardGenerator.areaCode.put("昭苏县", 654026); - IdCardGenerator.areaCode.put("特克斯县", 654027); - IdCardGenerator.areaCode.put("尼勒克县", 654028); - IdCardGenerator.areaCode.put("塔城地区", 654200); - IdCardGenerator.areaCode.put("塔城市", 654201); - IdCardGenerator.areaCode.put("乌苏市", 654202); - IdCardGenerator.areaCode.put("额敏县", 654221); - IdCardGenerator.areaCode.put("沙湾县", 654223); - IdCardGenerator.areaCode.put("托里县", 654224); - IdCardGenerator.areaCode.put("裕民县", 654225); - IdCardGenerator.areaCode.put("和布克赛尔蒙古自治县", 654226); - IdCardGenerator.areaCode.put("阿勒泰地区", 654300); - IdCardGenerator.areaCode.put("阿勒泰市", 654301); - IdCardGenerator.areaCode.put("布尔津县", 654321); - IdCardGenerator.areaCode.put("富蕴县", 654322); - IdCardGenerator.areaCode.put("福海县", 654323); - IdCardGenerator.areaCode.put("哈巴河县", 654324); - IdCardGenerator.areaCode.put("青河县", 654325); - IdCardGenerator.areaCode.put("吉木乃县", 654326); - IdCardGenerator.areaCode.put("自治区直辖县级行政区划", 659000); - IdCardGenerator.areaCode.put("石河子市", 659001); - IdCardGenerator.areaCode.put("阿拉尔市", 659002); - IdCardGenerator.areaCode.put("图木舒克市", 659003); - IdCardGenerator.areaCode.put("五家渠市", 659004); - IdCardGenerator.areaCode.put("台湾省", 710000); - IdCardGenerator.areaCode.put("香港特别行政区", 810000); - IdCardGenerator.areaCode.put("澳门特别行政区", 820000); - } + public static final Map areaCode = Maps.newConcurrentMap(); - public IdCardGenerator() { - } + static { + IdCardGenerator.areaCode.put("北京市", 110000); + IdCardGenerator.areaCode.put("市辖区", 110100); + IdCardGenerator.areaCode.put("东城区", 110101); + IdCardGenerator.areaCode.put("西城区", 110102); + IdCardGenerator.areaCode.put("崇文区", 110103); + IdCardGenerator.areaCode.put("宣武区", 110104); + IdCardGenerator.areaCode.put("朝阳区", 110105); + IdCardGenerator.areaCode.put("丰台区", 110106); + IdCardGenerator.areaCode.put("石景山区", 110107); + IdCardGenerator.areaCode.put("海淀区", 110108); + IdCardGenerator.areaCode.put("门头沟区", 110109); + IdCardGenerator.areaCode.put("房山区", 110111); + IdCardGenerator.areaCode.put("通州区", 110112); + IdCardGenerator.areaCode.put("顺义区", 110113); + IdCardGenerator.areaCode.put("昌平区", 110114); + IdCardGenerator.areaCode.put("大兴区", 110115); + IdCardGenerator.areaCode.put("怀柔区", 110116); + IdCardGenerator.areaCode.put("平谷区", 110117); + IdCardGenerator.areaCode.put("县", 110200); + IdCardGenerator.areaCode.put("密云县", 110228); + IdCardGenerator.areaCode.put("延庆县", 110229); + IdCardGenerator.areaCode.put("天津市", 120000); + IdCardGenerator.areaCode.put("市辖区", 120100); + IdCardGenerator.areaCode.put("和平区", 120101); + IdCardGenerator.areaCode.put("河东区", 120102); + IdCardGenerator.areaCode.put("河西区", 120103); + IdCardGenerator.areaCode.put("南开区", 120104); + IdCardGenerator.areaCode.put("河北区", 120105); + IdCardGenerator.areaCode.put("红桥区", 120106); + IdCardGenerator.areaCode.put("东丽区", 120110); + IdCardGenerator.areaCode.put("西青区", 120111); + IdCardGenerator.areaCode.put("津南区", 120112); + IdCardGenerator.areaCode.put("北辰区", 120113); + IdCardGenerator.areaCode.put("武清区", 120114); + IdCardGenerator.areaCode.put("宝坻区", 120115); + IdCardGenerator.areaCode.put("县", 120200); + IdCardGenerator.areaCode.put("宁河县", 120221); + IdCardGenerator.areaCode.put("静海县", 120223); + IdCardGenerator.areaCode.put("蓟 县", 120225); + IdCardGenerator.areaCode.put("河北省", 130000); + IdCardGenerator.areaCode.put("石家庄市", 130100); + IdCardGenerator.areaCode.put("市辖区", 130101); + IdCardGenerator.areaCode.put("长安区", 130102); + IdCardGenerator.areaCode.put("桥东区", 130103); + IdCardGenerator.areaCode.put("桥西区", 130104); + IdCardGenerator.areaCode.put("新华区", 130105); + IdCardGenerator.areaCode.put("井陉矿区", 130107); + IdCardGenerator.areaCode.put("裕华区", 130108); + IdCardGenerator.areaCode.put("井陉县", 130121); + IdCardGenerator.areaCode.put("正定县", 130123); + IdCardGenerator.areaCode.put("栾城县", 130124); + IdCardGenerator.areaCode.put("行唐县", 130125); + IdCardGenerator.areaCode.put("灵寿县", 130126); + IdCardGenerator.areaCode.put("高邑县", 130127); + IdCardGenerator.areaCode.put("深泽县", 130128); + IdCardGenerator.areaCode.put("赞皇县", 130129); + IdCardGenerator.areaCode.put("无极县", 130130); + IdCardGenerator.areaCode.put("平山县", 130131); + IdCardGenerator.areaCode.put("元氏县", 130132); + IdCardGenerator.areaCode.put("赵 县", 130133); + IdCardGenerator.areaCode.put("辛集市", 130181); + IdCardGenerator.areaCode.put("藁城市", 130182); + IdCardGenerator.areaCode.put("晋州市", 130183); + IdCardGenerator.areaCode.put("新乐市", 130184); + IdCardGenerator.areaCode.put("鹿泉市", 130185); + IdCardGenerator.areaCode.put("唐山市", 130200); + IdCardGenerator.areaCode.put("市辖区", 130201); + IdCardGenerator.areaCode.put("路南区", 130202); + IdCardGenerator.areaCode.put("路北区", 130203); + IdCardGenerator.areaCode.put("古冶区", 130204); + IdCardGenerator.areaCode.put("开平区", 130205); + IdCardGenerator.areaCode.put("丰南区", 130207); + IdCardGenerator.areaCode.put("丰润区", 130208); + IdCardGenerator.areaCode.put("滦 县", 130223); + IdCardGenerator.areaCode.put("滦南县", 130224); + IdCardGenerator.areaCode.put("乐亭县", 130225); + IdCardGenerator.areaCode.put("迁西县", 130227); + IdCardGenerator.areaCode.put("玉田县", 130229); + IdCardGenerator.areaCode.put("唐海县", 130230); + IdCardGenerator.areaCode.put("遵化市", 130281); + IdCardGenerator.areaCode.put("迁安市", 130283); + IdCardGenerator.areaCode.put("秦皇岛市", 130300); + IdCardGenerator.areaCode.put("市辖区", 130301); + IdCardGenerator.areaCode.put("海港区", 130302); + IdCardGenerator.areaCode.put("山海关区", 130303); + IdCardGenerator.areaCode.put("北戴河区", 130304); + IdCardGenerator.areaCode.put("青龙满族自治县", 130321); + IdCardGenerator.areaCode.put("昌黎县", 130322); + IdCardGenerator.areaCode.put("抚宁县", 130323); + IdCardGenerator.areaCode.put("卢龙县", 130324); + IdCardGenerator.areaCode.put("邯郸市", 130400); + IdCardGenerator.areaCode.put("市辖区", 130401); + IdCardGenerator.areaCode.put("邯山区", 130402); + IdCardGenerator.areaCode.put("丛台区", 130403); + IdCardGenerator.areaCode.put("复兴区", 130404); + IdCardGenerator.areaCode.put("峰峰矿区", 130406); + IdCardGenerator.areaCode.put("邯郸县", 130421); + IdCardGenerator.areaCode.put("临漳县", 130423); + IdCardGenerator.areaCode.put("成安县", 130424); + IdCardGenerator.areaCode.put("大名县", 130425); + IdCardGenerator.areaCode.put("涉 县", 130426); + IdCardGenerator.areaCode.put("磁 县", 130427); + IdCardGenerator.areaCode.put("肥乡县", 130428); + IdCardGenerator.areaCode.put("永年县", 130429); + IdCardGenerator.areaCode.put("邱 县", 130430); + IdCardGenerator.areaCode.put("鸡泽县", 130431); + IdCardGenerator.areaCode.put("广平县", 130432); + IdCardGenerator.areaCode.put("馆陶县", 130433); + IdCardGenerator.areaCode.put("魏 县", 130434); + IdCardGenerator.areaCode.put("曲周县", 130435); + IdCardGenerator.areaCode.put("武安市", 130481); + IdCardGenerator.areaCode.put("邢台市", 130500); + IdCardGenerator.areaCode.put("市辖区", 130501); + IdCardGenerator.areaCode.put("桥东区", 130502); + IdCardGenerator.areaCode.put("桥西区", 130503); + IdCardGenerator.areaCode.put("邢台县", 130521); + IdCardGenerator.areaCode.put("临城县", 130522); + IdCardGenerator.areaCode.put("内丘县", 130523); + IdCardGenerator.areaCode.put("柏乡县", 130524); + IdCardGenerator.areaCode.put("隆尧县", 130525); + IdCardGenerator.areaCode.put("任 县", 130526); + IdCardGenerator.areaCode.put("南和县", 130527); + IdCardGenerator.areaCode.put("宁晋县", 130528); + IdCardGenerator.areaCode.put("巨鹿县", 130529); + IdCardGenerator.areaCode.put("新河县", 130530); + IdCardGenerator.areaCode.put("广宗县", 130531); + IdCardGenerator.areaCode.put("平乡县", 130532); + IdCardGenerator.areaCode.put("威 县", 130533); + IdCardGenerator.areaCode.put("清河县", 130534); + IdCardGenerator.areaCode.put("临西县", 130535); + IdCardGenerator.areaCode.put("南宫市", 130581); + IdCardGenerator.areaCode.put("沙河市", 130582); + IdCardGenerator.areaCode.put("保定市", 130600); + IdCardGenerator.areaCode.put("市辖区", 130601); + IdCardGenerator.areaCode.put("新市区", 130602); + IdCardGenerator.areaCode.put("北市区", 130603); + IdCardGenerator.areaCode.put("南市区", 130604); + IdCardGenerator.areaCode.put("满城县", 130621); + IdCardGenerator.areaCode.put("清苑县", 130622); + IdCardGenerator.areaCode.put("涞水县", 130623); + IdCardGenerator.areaCode.put("阜平县", 130624); + IdCardGenerator.areaCode.put("徐水县", 130625); + IdCardGenerator.areaCode.put("定兴县", 130626); + IdCardGenerator.areaCode.put("唐 县", 130627); + IdCardGenerator.areaCode.put("高阳县", 130628); + IdCardGenerator.areaCode.put("容城县", 130629); + IdCardGenerator.areaCode.put("涞源县", 130630); + IdCardGenerator.areaCode.put("望都县", 130631); + IdCardGenerator.areaCode.put("安新县", 130632); + IdCardGenerator.areaCode.put("易 县", 130633); + IdCardGenerator.areaCode.put("曲阳县", 130634); + IdCardGenerator.areaCode.put("蠡 县", 130635); + IdCardGenerator.areaCode.put("顺平县", 130636); + IdCardGenerator.areaCode.put("博野县", 130637); + IdCardGenerator.areaCode.put("雄 县", 130638); + IdCardGenerator.areaCode.put("涿州市", 130681); + IdCardGenerator.areaCode.put("定州市", 130682); + IdCardGenerator.areaCode.put("安国市", 130683); + IdCardGenerator.areaCode.put("高碑店市", 130684); + IdCardGenerator.areaCode.put("张家口市", 130700); + IdCardGenerator.areaCode.put("市辖区", 130701); + IdCardGenerator.areaCode.put("桥东区", 130702); + IdCardGenerator.areaCode.put("桥西区", 130703); + IdCardGenerator.areaCode.put("宣化区", 130705); + IdCardGenerator.areaCode.put("下花园区", 130706); + IdCardGenerator.areaCode.put("宣化县", 130721); + IdCardGenerator.areaCode.put("张北县", 130722); + IdCardGenerator.areaCode.put("康保县", 130723); + IdCardGenerator.areaCode.put("沽源县", 130724); + IdCardGenerator.areaCode.put("尚义县", 130725); + IdCardGenerator.areaCode.put("蔚 县", 130726); + IdCardGenerator.areaCode.put("阳原县", 130727); + IdCardGenerator.areaCode.put("怀安县", 130728); + IdCardGenerator.areaCode.put("万全县", 130729); + IdCardGenerator.areaCode.put("怀来县", 130730); + IdCardGenerator.areaCode.put("涿鹿县", 130731); + IdCardGenerator.areaCode.put("赤城县", 130732); + IdCardGenerator.areaCode.put("崇礼县", 130733); + IdCardGenerator.areaCode.put("承德市", 130800); + IdCardGenerator.areaCode.put("市辖区", 130801); + IdCardGenerator.areaCode.put("双桥区", 130802); + IdCardGenerator.areaCode.put("双滦区", 130803); + IdCardGenerator.areaCode.put("鹰手营子矿区", 130804); + IdCardGenerator.areaCode.put("承德县", 130821); + IdCardGenerator.areaCode.put("兴隆县", 130822); + IdCardGenerator.areaCode.put("平泉县", 130823); + IdCardGenerator.areaCode.put("滦平县", 130824); + IdCardGenerator.areaCode.put("隆化县", 130825); + IdCardGenerator.areaCode.put("丰宁满族自治县", 130826); + IdCardGenerator.areaCode.put("宽城满族自治县", 130827); + IdCardGenerator.areaCode.put("围场满族蒙古族自治县", 130828); + IdCardGenerator.areaCode.put("沧州市", 130900); + IdCardGenerator.areaCode.put("市辖区", 130901); + IdCardGenerator.areaCode.put("新华区", 130902); + IdCardGenerator.areaCode.put("运河区", 130903); + IdCardGenerator.areaCode.put("沧 县", 130921); + IdCardGenerator.areaCode.put("青 县", 130922); + IdCardGenerator.areaCode.put("东光县", 130923); + IdCardGenerator.areaCode.put("海兴县", 130924); + IdCardGenerator.areaCode.put("盐山县", 130925); + IdCardGenerator.areaCode.put("肃宁县", 130926); + IdCardGenerator.areaCode.put("南皮县", 130927); + IdCardGenerator.areaCode.put("吴桥县", 130928); + IdCardGenerator.areaCode.put("献 县", 130929); + IdCardGenerator.areaCode.put("孟村回族自治县", 130930); + IdCardGenerator.areaCode.put("泊头市", 130981); + IdCardGenerator.areaCode.put("任丘市", 130982); + IdCardGenerator.areaCode.put("黄骅市", 130983); + IdCardGenerator.areaCode.put("河间市", 130984); + IdCardGenerator.areaCode.put("廊坊市", 131000); + IdCardGenerator.areaCode.put("市辖区", 131001); + IdCardGenerator.areaCode.put("安次区", 131002); + IdCardGenerator.areaCode.put("广阳区", 131003); + IdCardGenerator.areaCode.put("固安县", 131022); + IdCardGenerator.areaCode.put("永清县", 131023); + IdCardGenerator.areaCode.put("香河县", 131024); + IdCardGenerator.areaCode.put("大城县", 131025); + IdCardGenerator.areaCode.put("文安县", 131026); + IdCardGenerator.areaCode.put("大厂回族自治县", 131028); + IdCardGenerator.areaCode.put("霸州市", 131081); + IdCardGenerator.areaCode.put("三河市", 131082); + IdCardGenerator.areaCode.put("衡水市", 131100); + IdCardGenerator.areaCode.put("市辖区", 131101); + IdCardGenerator.areaCode.put("桃城区", 131102); + IdCardGenerator.areaCode.put("枣强县", 131121); + IdCardGenerator.areaCode.put("武邑县", 131122); + IdCardGenerator.areaCode.put("武强县", 131123); + IdCardGenerator.areaCode.put("饶阳县", 131124); + IdCardGenerator.areaCode.put("安平县", 131125); + IdCardGenerator.areaCode.put("故城县", 131126); + IdCardGenerator.areaCode.put("景 县", 131127); + IdCardGenerator.areaCode.put("阜城县", 131128); + IdCardGenerator.areaCode.put("冀州市", 131181); + IdCardGenerator.areaCode.put("深州市", 131182); + IdCardGenerator.areaCode.put("山西省", 140000); + IdCardGenerator.areaCode.put("太原市", 140100); + IdCardGenerator.areaCode.put("市辖区", 140101); + IdCardGenerator.areaCode.put("小店区", 140105); + IdCardGenerator.areaCode.put("迎泽区", 140106); + IdCardGenerator.areaCode.put("杏花岭区", 140107); + IdCardGenerator.areaCode.put("尖草坪区", 140108); + IdCardGenerator.areaCode.put("万柏林区", 140109); + IdCardGenerator.areaCode.put("晋源区", 140110); + IdCardGenerator.areaCode.put("清徐县", 140121); + IdCardGenerator.areaCode.put("阳曲县", 140122); + IdCardGenerator.areaCode.put("娄烦县", 140123); + IdCardGenerator.areaCode.put("古交市", 140181); + IdCardGenerator.areaCode.put("大同市", 140200); + IdCardGenerator.areaCode.put("市辖区", 140201); + IdCardGenerator.areaCode.put("城 区", 140202); + IdCardGenerator.areaCode.put("矿 区", 140203); + IdCardGenerator.areaCode.put("南郊区", 140211); + IdCardGenerator.areaCode.put("新荣区", 140212); + IdCardGenerator.areaCode.put("阳高县", 140221); + IdCardGenerator.areaCode.put("天镇县", 140222); + IdCardGenerator.areaCode.put("广灵县", 140223); + IdCardGenerator.areaCode.put("灵丘县", 140224); + IdCardGenerator.areaCode.put("浑源县", 140225); + IdCardGenerator.areaCode.put("左云县", 140226); + IdCardGenerator.areaCode.put("大同县", 140227); + IdCardGenerator.areaCode.put("阳泉市", 140300); + IdCardGenerator.areaCode.put("市辖区", 140301); + IdCardGenerator.areaCode.put("城 区", 140302); + IdCardGenerator.areaCode.put("矿 区", 140303); + IdCardGenerator.areaCode.put("郊 区", 140311); + IdCardGenerator.areaCode.put("平定县", 140321); + IdCardGenerator.areaCode.put("盂 县", 140322); + IdCardGenerator.areaCode.put("长治市", 140400); + IdCardGenerator.areaCode.put("市辖区", 140401); + IdCardGenerator.areaCode.put("城 区", 140402); + IdCardGenerator.areaCode.put("郊 区", 140411); + IdCardGenerator.areaCode.put("长治县", 140421); + IdCardGenerator.areaCode.put("襄垣县", 140423); + IdCardGenerator.areaCode.put("屯留县", 140424); + IdCardGenerator.areaCode.put("平顺县", 140425); + IdCardGenerator.areaCode.put("黎城县", 140426); + IdCardGenerator.areaCode.put("壶关县", 140427); + IdCardGenerator.areaCode.put("长子县", 140428); + IdCardGenerator.areaCode.put("武乡县", 140429); + IdCardGenerator.areaCode.put("沁 县", 140430); + IdCardGenerator.areaCode.put("沁源县", 140431); + IdCardGenerator.areaCode.put("潞城市", 140481); + IdCardGenerator.areaCode.put("晋城市", 140500); + IdCardGenerator.areaCode.put("市辖区", 140501); + IdCardGenerator.areaCode.put("城 区", 140502); + IdCardGenerator.areaCode.put("沁水县", 140521); + IdCardGenerator.areaCode.put("阳城县", 140522); + IdCardGenerator.areaCode.put("陵川县", 140524); + IdCardGenerator.areaCode.put("泽州县", 140525); + IdCardGenerator.areaCode.put("高平市", 140581); + IdCardGenerator.areaCode.put("朔州市", 140600); + IdCardGenerator.areaCode.put("市辖区", 140601); + IdCardGenerator.areaCode.put("朔城区", 140602); + IdCardGenerator.areaCode.put("平鲁区", 140603); + IdCardGenerator.areaCode.put("山阴县", 140621); + IdCardGenerator.areaCode.put("应 县", 140622); + IdCardGenerator.areaCode.put("右玉县", 140623); + IdCardGenerator.areaCode.put("怀仁县", 140624); + IdCardGenerator.areaCode.put("晋中市", 140700); + IdCardGenerator.areaCode.put("市辖区", 140701); + IdCardGenerator.areaCode.put("榆次区", 140702); + IdCardGenerator.areaCode.put("榆社县", 140721); + IdCardGenerator.areaCode.put("左权县", 140722); + IdCardGenerator.areaCode.put("和顺县", 140723); + IdCardGenerator.areaCode.put("昔阳县", 140724); + IdCardGenerator.areaCode.put("寿阳县", 140725); + IdCardGenerator.areaCode.put("太谷县", 140726); + IdCardGenerator.areaCode.put("祁 县", 140727); + IdCardGenerator.areaCode.put("平遥县", 140728); + IdCardGenerator.areaCode.put("灵石县", 140729); + IdCardGenerator.areaCode.put("介休市", 140781); + IdCardGenerator.areaCode.put("运城市", 140800); + IdCardGenerator.areaCode.put("市辖区", 140801); + IdCardGenerator.areaCode.put("盐湖区", 140802); + IdCardGenerator.areaCode.put("临猗县", 140821); + IdCardGenerator.areaCode.put("万荣县", 140822); + IdCardGenerator.areaCode.put("闻喜县", 140823); + IdCardGenerator.areaCode.put("稷山县", 140824); + IdCardGenerator.areaCode.put("新绛县", 140825); + IdCardGenerator.areaCode.put("绛 县", 140826); + IdCardGenerator.areaCode.put("垣曲县", 140827); + IdCardGenerator.areaCode.put("夏 县", 140828); + IdCardGenerator.areaCode.put("平陆县", 140829); + IdCardGenerator.areaCode.put("芮城县", 140830); + IdCardGenerator.areaCode.put("永济市", 140881); + IdCardGenerator.areaCode.put("河津市", 140882); + IdCardGenerator.areaCode.put("忻州市", 140900); + IdCardGenerator.areaCode.put("市辖区", 140901); + IdCardGenerator.areaCode.put("忻府区", 140902); + IdCardGenerator.areaCode.put("定襄县", 140921); + IdCardGenerator.areaCode.put("五台县", 140922); + IdCardGenerator.areaCode.put("代 县", 140923); + IdCardGenerator.areaCode.put("繁峙县", 140924); + IdCardGenerator.areaCode.put("宁武县", 140925); + IdCardGenerator.areaCode.put("静乐县", 140926); + IdCardGenerator.areaCode.put("神池县", 140927); + IdCardGenerator.areaCode.put("五寨县", 140928); + IdCardGenerator.areaCode.put("岢岚县", 140929); + IdCardGenerator.areaCode.put("河曲县", 140930); + IdCardGenerator.areaCode.put("保德县", 140931); + IdCardGenerator.areaCode.put("偏关县", 140932); + IdCardGenerator.areaCode.put("原平市", 140981); + IdCardGenerator.areaCode.put("临汾市", 141000); + IdCardGenerator.areaCode.put("市辖区", 141001); + IdCardGenerator.areaCode.put("尧都区", 141002); + IdCardGenerator.areaCode.put("曲沃县", 141021); + IdCardGenerator.areaCode.put("翼城县", 141022); + IdCardGenerator.areaCode.put("襄汾县", 141023); + IdCardGenerator.areaCode.put("洪洞县", 141024); + IdCardGenerator.areaCode.put("古 县", 141025); + IdCardGenerator.areaCode.put("安泽县", 141026); + IdCardGenerator.areaCode.put("浮山县", 141027); + IdCardGenerator.areaCode.put("吉 县", 141028); + IdCardGenerator.areaCode.put("乡宁县", 141029); + IdCardGenerator.areaCode.put("大宁县", 141030); + IdCardGenerator.areaCode.put("隰 县", 141031); + IdCardGenerator.areaCode.put("永和县", 141032); + IdCardGenerator.areaCode.put("蒲 县", 141033); + IdCardGenerator.areaCode.put("汾西县", 141034); + IdCardGenerator.areaCode.put("侯马市", 141081); + IdCardGenerator.areaCode.put("霍州市", 141082); + IdCardGenerator.areaCode.put("吕梁市", 141100); + IdCardGenerator.areaCode.put("市辖区", 141101); + IdCardGenerator.areaCode.put("离石区", 141102); + IdCardGenerator.areaCode.put("文水县", 141121); + IdCardGenerator.areaCode.put("交城县", 141122); + IdCardGenerator.areaCode.put("兴 县", 141123); + IdCardGenerator.areaCode.put("临 县", 141124); + IdCardGenerator.areaCode.put("柳林县", 141125); + IdCardGenerator.areaCode.put("石楼县", 141126); + IdCardGenerator.areaCode.put("岚 县", 141127); + IdCardGenerator.areaCode.put("方山县", 141128); + IdCardGenerator.areaCode.put("中阳县", 141129); + IdCardGenerator.areaCode.put("交口县", 141130); + IdCardGenerator.areaCode.put("孝义市", 141181); + IdCardGenerator.areaCode.put("汾阳市", 141182); + IdCardGenerator.areaCode.put("内蒙古自治区", 150000); + IdCardGenerator.areaCode.put("呼和浩特市", 150100); + IdCardGenerator.areaCode.put("市辖区", 150101); + IdCardGenerator.areaCode.put("新城区", 150102); + IdCardGenerator.areaCode.put("回民区", 150103); + IdCardGenerator.areaCode.put("玉泉区", 150104); + IdCardGenerator.areaCode.put("赛罕区", 150105); + IdCardGenerator.areaCode.put("土默特左旗", 150121); + IdCardGenerator.areaCode.put("托克托县", 150122); + IdCardGenerator.areaCode.put("和林格尔县", 150123); + IdCardGenerator.areaCode.put("清水河县", 150124); + IdCardGenerator.areaCode.put("武川县", 150125); + IdCardGenerator.areaCode.put("包头市", 150200); + IdCardGenerator.areaCode.put("市辖区", 150201); + IdCardGenerator.areaCode.put("东河区", 150202); + IdCardGenerator.areaCode.put("昆都仑区", 150203); + IdCardGenerator.areaCode.put("青山区", 150204); + IdCardGenerator.areaCode.put("石拐区", 150205); + IdCardGenerator.areaCode.put("白云鄂博矿区", 150206); + IdCardGenerator.areaCode.put("九原区", 150207); + IdCardGenerator.areaCode.put("土默特右旗", 150221); + IdCardGenerator.areaCode.put("固阳县", 150222); + IdCardGenerator.areaCode.put("达尔罕茂明安联合旗", 150223); + IdCardGenerator.areaCode.put("乌海市", 150300); + IdCardGenerator.areaCode.put("市辖区", 150301); + IdCardGenerator.areaCode.put("海勃湾区", 150302); + IdCardGenerator.areaCode.put("海南区", 150303); + IdCardGenerator.areaCode.put("乌达区", 150304); + IdCardGenerator.areaCode.put("赤峰市", 150400); + IdCardGenerator.areaCode.put("市辖区", 150401); + IdCardGenerator.areaCode.put("红山区", 150402); + IdCardGenerator.areaCode.put("元宝山区", 150403); + IdCardGenerator.areaCode.put("松山区", 150404); + IdCardGenerator.areaCode.put("阿鲁科尔沁旗", 150421); + IdCardGenerator.areaCode.put("巴林左旗", 150422); + IdCardGenerator.areaCode.put("巴林右旗", 150423); + IdCardGenerator.areaCode.put("林西县", 150424); + IdCardGenerator.areaCode.put("克什克腾旗", 150425); + IdCardGenerator.areaCode.put("翁牛特旗", 150426); + IdCardGenerator.areaCode.put("喀喇沁旗", 150428); + IdCardGenerator.areaCode.put("宁城县", 150429); + IdCardGenerator.areaCode.put("敖汉旗", 150430); + IdCardGenerator.areaCode.put("通辽市", 150500); + IdCardGenerator.areaCode.put("市辖区", 150501); + IdCardGenerator.areaCode.put("科尔沁区", 150502); + IdCardGenerator.areaCode.put("科尔沁左翼中旗", 150521); + IdCardGenerator.areaCode.put("科尔沁左翼后旗", 150522); + IdCardGenerator.areaCode.put("开鲁县", 150523); + IdCardGenerator.areaCode.put("库伦旗", 150524); + IdCardGenerator.areaCode.put("奈曼旗", 150525); + IdCardGenerator.areaCode.put("扎鲁特旗", 150526); + IdCardGenerator.areaCode.put("霍林郭勒市", 150581); + IdCardGenerator.areaCode.put("鄂尔多斯市", 150600); + IdCardGenerator.areaCode.put("市辖区", 150601); + IdCardGenerator.areaCode.put(" 东胜区", 150602); + IdCardGenerator.areaCode.put("达拉特旗", 150621); + IdCardGenerator.areaCode.put("准格尔旗", 150622); + IdCardGenerator.areaCode.put("鄂托克前旗", 150623); + IdCardGenerator.areaCode.put("鄂托克旗", 150624); + IdCardGenerator.areaCode.put("杭锦旗", 150625); + IdCardGenerator.areaCode.put("乌审旗", 150626); + IdCardGenerator.areaCode.put("伊金霍洛旗", 150627); + IdCardGenerator.areaCode.put("呼伦贝尔市", 150700); + IdCardGenerator.areaCode.put("市辖区", 150701); + IdCardGenerator.areaCode.put("海拉尔区", 150702); + IdCardGenerator.areaCode.put("阿荣旗", 150721); + IdCardGenerator.areaCode.put("莫力达瓦达斡尔族自治旗", 150722); + IdCardGenerator.areaCode.put("鄂伦春自治旗", 150723); + IdCardGenerator.areaCode.put("鄂温克族自治旗", 150724); + IdCardGenerator.areaCode.put("陈巴尔虎旗", 150725); + IdCardGenerator.areaCode.put("新巴尔虎左旗", 150726); + IdCardGenerator.areaCode.put("新巴尔虎右旗", 150727); + IdCardGenerator.areaCode.put("满洲里市", 150781); + IdCardGenerator.areaCode.put("牙克石市", 150782); + IdCardGenerator.areaCode.put("扎兰屯市", 150783); + IdCardGenerator.areaCode.put("额尔古纳市", 150784); + IdCardGenerator.areaCode.put("根河市", 150785); + IdCardGenerator.areaCode.put("巴彦淖尔市", 150800); + IdCardGenerator.areaCode.put("市辖区", 150801); + IdCardGenerator.areaCode.put("临河区", 150802); + IdCardGenerator.areaCode.put("五原县", 150821); + IdCardGenerator.areaCode.put("磴口县", 150822); + IdCardGenerator.areaCode.put("乌拉特前旗", 150823); + IdCardGenerator.areaCode.put("乌拉特中旗", 150824); + IdCardGenerator.areaCode.put("乌拉特后旗", 150825); + IdCardGenerator.areaCode.put("杭锦后旗", 150826); + IdCardGenerator.areaCode.put("乌兰察布市", 150900); + IdCardGenerator.areaCode.put("市辖区", 150901); + IdCardGenerator.areaCode.put("集宁区", 150902); + IdCardGenerator.areaCode.put("卓资县", 150921); + IdCardGenerator.areaCode.put("化德县", 150922); + IdCardGenerator.areaCode.put("商都县", 150923); + IdCardGenerator.areaCode.put("兴和县", 150924); + IdCardGenerator.areaCode.put("凉城县", 150925); + IdCardGenerator.areaCode.put("察哈尔右翼前旗", 150926); + IdCardGenerator.areaCode.put("察哈尔右翼中旗", 150927); + IdCardGenerator.areaCode.put("察哈尔右翼后旗", 150928); + IdCardGenerator.areaCode.put("四子王旗", 150929); + IdCardGenerator.areaCode.put("丰镇市", 150981); + IdCardGenerator.areaCode.put("兴安盟", 152200); + IdCardGenerator.areaCode.put("乌兰浩特市", 152201); + IdCardGenerator.areaCode.put("阿尔山市", 152202); + IdCardGenerator.areaCode.put("科尔沁右翼前旗", 152221); + IdCardGenerator.areaCode.put("科尔沁右翼中旗", 152222); + IdCardGenerator.areaCode.put("扎赉特旗", 152223); + IdCardGenerator.areaCode.put("突泉县", 152224); + IdCardGenerator.areaCode.put("锡林郭勒盟", 152500); + IdCardGenerator.areaCode.put("二连浩特市", 152501); + IdCardGenerator.areaCode.put("锡林浩特市", 152502); + IdCardGenerator.areaCode.put("阿巴嘎旗", 152522); + IdCardGenerator.areaCode.put("苏尼特左旗", 152523); + IdCardGenerator.areaCode.put("苏尼特右旗", 152524); + IdCardGenerator.areaCode.put("东乌珠穆沁旗", 152525); + IdCardGenerator.areaCode.put("西乌珠穆沁旗", 152526); + IdCardGenerator.areaCode.put("太仆寺旗", 152527); + IdCardGenerator.areaCode.put("镶黄旗", 152528); + IdCardGenerator.areaCode.put("正镶白旗", 152529); + IdCardGenerator.areaCode.put("正蓝旗", 152530); + IdCardGenerator.areaCode.put("多伦县", 152531); + IdCardGenerator.areaCode.put("阿拉善盟", 152900); + IdCardGenerator.areaCode.put("阿拉善左旗", 152921); + IdCardGenerator.areaCode.put("阿拉善右旗", 152922); + IdCardGenerator.areaCode.put("额济纳旗", 152923); + IdCardGenerator.areaCode.put("辽宁省", 210000); + IdCardGenerator.areaCode.put("沈阳市", 210100); + IdCardGenerator.areaCode.put("市辖区", 210101); + IdCardGenerator.areaCode.put("和平区", 210102); + IdCardGenerator.areaCode.put("沈河区", 210103); + IdCardGenerator.areaCode.put("大东区", 210104); + IdCardGenerator.areaCode.put("皇姑区", 210105); + IdCardGenerator.areaCode.put("铁西区", 210106); + IdCardGenerator.areaCode.put("苏家屯区", 210111); + IdCardGenerator.areaCode.put("东陵区", 210112); + IdCardGenerator.areaCode.put("沈北新区", 210113); + IdCardGenerator.areaCode.put("于洪区", 210114); + IdCardGenerator.areaCode.put("辽中县", 210122); + IdCardGenerator.areaCode.put("康平县", 210123); + IdCardGenerator.areaCode.put("法库县", 210124); + IdCardGenerator.areaCode.put("新民市", 210181); + IdCardGenerator.areaCode.put("大连市", 210200); + IdCardGenerator.areaCode.put("市辖区", 210201); + IdCardGenerator.areaCode.put("中山区", 210202); + IdCardGenerator.areaCode.put("西岗区", 210203); + IdCardGenerator.areaCode.put("沙河口区", 210204); + IdCardGenerator.areaCode.put("甘井子区", 210211); + IdCardGenerator.areaCode.put("旅顺口区", 210212); + IdCardGenerator.areaCode.put("金州区", 210213); + IdCardGenerator.areaCode.put("长海县", 210224); + IdCardGenerator.areaCode.put("瓦房店市", 210281); + IdCardGenerator.areaCode.put("普兰店市", 210282); + IdCardGenerator.areaCode.put("庄河市", 210283); + IdCardGenerator.areaCode.put("鞍山市", 210300); + IdCardGenerator.areaCode.put("市辖区", 210301); + IdCardGenerator.areaCode.put("铁东区", 210302); + IdCardGenerator.areaCode.put("铁西区", 210303); + IdCardGenerator.areaCode.put("立山区", 210304); + IdCardGenerator.areaCode.put("千山区", 210311); + IdCardGenerator.areaCode.put("台安县", 210321); + IdCardGenerator.areaCode.put("岫岩满族自治县", 210323); + IdCardGenerator.areaCode.put("海城市", 210381); + IdCardGenerator.areaCode.put("抚顺市", 210400); + IdCardGenerator.areaCode.put("市辖区", 210401); + IdCardGenerator.areaCode.put("新抚区", 210402); + IdCardGenerator.areaCode.put("东洲区", 210403); + IdCardGenerator.areaCode.put("望花区", 210404); + IdCardGenerator.areaCode.put("顺城区", 210411); + IdCardGenerator.areaCode.put("抚顺县", 210421); + IdCardGenerator.areaCode.put("新宾满族自治县", 210422); + IdCardGenerator.areaCode.put("清原满族自治县", 210423); + IdCardGenerator.areaCode.put("本溪市", 210500); + IdCardGenerator.areaCode.put("市辖区", 210501); + IdCardGenerator.areaCode.put("平山区", 210502); + IdCardGenerator.areaCode.put("溪湖区", 210503); + IdCardGenerator.areaCode.put("明山区", 210504); + IdCardGenerator.areaCode.put("南芬区", 210505); + IdCardGenerator.areaCode.put("本溪满族自治县", 210521); + IdCardGenerator.areaCode.put("桓仁满族自治县", 210522); + IdCardGenerator.areaCode.put("丹东市", 210600); + IdCardGenerator.areaCode.put("市辖区", 210601); + IdCardGenerator.areaCode.put("元宝区", 210602); + IdCardGenerator.areaCode.put("振兴区", 210603); + IdCardGenerator.areaCode.put("振安区", 210604); + IdCardGenerator.areaCode.put("宽甸满族自治县", 210624); + IdCardGenerator.areaCode.put("东港市", 210681); + IdCardGenerator.areaCode.put("凤城市", 210682); + IdCardGenerator.areaCode.put("锦州市", 210700); + IdCardGenerator.areaCode.put("市辖区", 210701); + IdCardGenerator.areaCode.put("古塔区", 210702); + IdCardGenerator.areaCode.put("凌河区", 210703); + IdCardGenerator.areaCode.put("太和区", 210711); + IdCardGenerator.areaCode.put("黑山县", 210726); + IdCardGenerator.areaCode.put("义 县", 210727); + IdCardGenerator.areaCode.put("凌海市", 210781); + IdCardGenerator.areaCode.put("北镇市", 210782); + IdCardGenerator.areaCode.put("营口市", 210800); + IdCardGenerator.areaCode.put("市辖区", 210801); + IdCardGenerator.areaCode.put("站前区", 210802); + IdCardGenerator.areaCode.put("西市区", 210803); + IdCardGenerator.areaCode.put("鲅鱼圈区", 210804); + IdCardGenerator.areaCode.put("老边区", 210811); + IdCardGenerator.areaCode.put("盖州市", 210881); + IdCardGenerator.areaCode.put("大石桥市", 210882); + IdCardGenerator.areaCode.put("阜新市", 210900); + IdCardGenerator.areaCode.put("市辖区", 210901); + IdCardGenerator.areaCode.put("海州区", 210902); + IdCardGenerator.areaCode.put("新邱区", 210903); + IdCardGenerator.areaCode.put("太平区", 210904); + IdCardGenerator.areaCode.put("清河门区", 210905); + IdCardGenerator.areaCode.put("细河区", 210911); + IdCardGenerator.areaCode.put("阜新蒙古族自治县", 210921); + IdCardGenerator.areaCode.put("彰武县", 210922); + IdCardGenerator.areaCode.put("辽阳市", 211000); + IdCardGenerator.areaCode.put("市辖区", 211001); + IdCardGenerator.areaCode.put("白塔区", 211002); + IdCardGenerator.areaCode.put("文圣区", 211003); + IdCardGenerator.areaCode.put("宏伟区", 211004); + IdCardGenerator.areaCode.put("弓长岭区", 211005); + IdCardGenerator.areaCode.put("太子河区", 211011); + IdCardGenerator.areaCode.put("辽阳县", 211021); + IdCardGenerator.areaCode.put("灯塔市", 211081); + IdCardGenerator.areaCode.put("盘锦市", 211100); + IdCardGenerator.areaCode.put("市辖区", 211101); + IdCardGenerator.areaCode.put("双台子区", 211102); + IdCardGenerator.areaCode.put("兴隆台区", 211103); + IdCardGenerator.areaCode.put("大洼县", 211121); + IdCardGenerator.areaCode.put("盘山县", 211122); + IdCardGenerator.areaCode.put("铁岭市", 211200); + IdCardGenerator.areaCode.put("市辖区", 211201); + IdCardGenerator.areaCode.put("银州区", 211202); + IdCardGenerator.areaCode.put("清河区", 211204); + IdCardGenerator.areaCode.put("铁岭县", 211221); + IdCardGenerator.areaCode.put("西丰县", 211223); + IdCardGenerator.areaCode.put("昌图县", 211224); + IdCardGenerator.areaCode.put("调兵山市", 211281); + IdCardGenerator.areaCode.put("开原市", 211282); + IdCardGenerator.areaCode.put("朝阳市", 211300); + IdCardGenerator.areaCode.put("市辖区", 211301); + IdCardGenerator.areaCode.put("双塔区", 211302); + IdCardGenerator.areaCode.put("龙城区", 211303); + IdCardGenerator.areaCode.put("朝阳县", 211321); + IdCardGenerator.areaCode.put("建平县", 211322); + IdCardGenerator.areaCode.put("喀喇沁左翼蒙古族自治县", 211324); + IdCardGenerator.areaCode.put("北票市", 211381); + IdCardGenerator.areaCode.put("凌源市", 211382); + IdCardGenerator.areaCode.put("葫芦岛市", 211400); + IdCardGenerator.areaCode.put("市辖区", 211401); + IdCardGenerator.areaCode.put("连山区", 211402); + IdCardGenerator.areaCode.put("龙港区", 211403); + IdCardGenerator.areaCode.put("南票区", 211404); + IdCardGenerator.areaCode.put("绥中县", 211421); + IdCardGenerator.areaCode.put("建昌县", 211422); + IdCardGenerator.areaCode.put("兴城市", 211481); + IdCardGenerator.areaCode.put("吉林省", 220000); + IdCardGenerator.areaCode.put("长春市", 220100); + IdCardGenerator.areaCode.put("市辖区", 220101); + IdCardGenerator.areaCode.put("南关区", 220102); + IdCardGenerator.areaCode.put("宽城区", 220103); + IdCardGenerator.areaCode.put("朝阳区", 220104); + IdCardGenerator.areaCode.put("二道区", 220105); + IdCardGenerator.areaCode.put("绿园区", 220106); + IdCardGenerator.areaCode.put("双阳区", 220112); + IdCardGenerator.areaCode.put("农安县", 220122); + IdCardGenerator.areaCode.put("九台市", 220181); + IdCardGenerator.areaCode.put("榆树市", 220182); + IdCardGenerator.areaCode.put("德惠市", 220183); + IdCardGenerator.areaCode.put("吉林市", 220200); + IdCardGenerator.areaCode.put("市辖区", 220201); + IdCardGenerator.areaCode.put("昌邑区", 220202); + IdCardGenerator.areaCode.put("龙潭区", 220203); + IdCardGenerator.areaCode.put("船营区", 220204); + IdCardGenerator.areaCode.put("丰满区", 220211); + IdCardGenerator.areaCode.put("永吉县", 220221); + IdCardGenerator.areaCode.put("蛟河市", 220281); + IdCardGenerator.areaCode.put("桦甸市", 220282); + IdCardGenerator.areaCode.put("舒兰市", 220283); + IdCardGenerator.areaCode.put("磐石市", 220284); + IdCardGenerator.areaCode.put("四平市", 220300); + IdCardGenerator.areaCode.put("市辖区", 220301); + IdCardGenerator.areaCode.put("铁西区", 220302); + IdCardGenerator.areaCode.put("铁东区", 220303); + IdCardGenerator.areaCode.put("梨树县", 220322); + IdCardGenerator.areaCode.put("伊通满族自治县", 220323); + IdCardGenerator.areaCode.put("公主岭市", 220381); + IdCardGenerator.areaCode.put("双辽市", 220382); + IdCardGenerator.areaCode.put("辽源市", 220400); + IdCardGenerator.areaCode.put("市辖区", 220401); + IdCardGenerator.areaCode.put("龙山区", 220402); + IdCardGenerator.areaCode.put("西安区", 220403); + IdCardGenerator.areaCode.put("东丰县", 220421); + IdCardGenerator.areaCode.put("东辽县", 220422); + IdCardGenerator.areaCode.put("通化市", 220500); + IdCardGenerator.areaCode.put("市辖区", 220501); + IdCardGenerator.areaCode.put("东昌区", 220502); + IdCardGenerator.areaCode.put("二道江区", 220503); + IdCardGenerator.areaCode.put("通化县", 220521); + IdCardGenerator.areaCode.put("辉南县", 220523); + IdCardGenerator.areaCode.put("柳河县", 220524); + IdCardGenerator.areaCode.put("梅河口市", 220581); + IdCardGenerator.areaCode.put("集安市", 220582); + IdCardGenerator.areaCode.put("白山市", 220600); + IdCardGenerator.areaCode.put("市辖区", 220601); + IdCardGenerator.areaCode.put("八道江区", 220602); + IdCardGenerator.areaCode.put(" 江源区", 220605); + IdCardGenerator.areaCode.put("抚松县", 220621); + IdCardGenerator.areaCode.put("靖宇县", 220622); + IdCardGenerator.areaCode.put("长白朝鲜族自治县", 220623); + IdCardGenerator.areaCode.put("临江市", 220681); + IdCardGenerator.areaCode.put("松原市", 220700); + IdCardGenerator.areaCode.put("市辖区", 220701); + IdCardGenerator.areaCode.put("宁江区", 220702); + IdCardGenerator.areaCode.put("前郭尔罗斯蒙古族自治县", 220721); + IdCardGenerator.areaCode.put("长岭县", 220722); + IdCardGenerator.areaCode.put("乾安县", 220723); + IdCardGenerator.areaCode.put("扶余县", 220724); + IdCardGenerator.areaCode.put("白城市", 220800); + IdCardGenerator.areaCode.put("市辖区", 220801); + IdCardGenerator.areaCode.put("洮北区", 220802); + IdCardGenerator.areaCode.put("镇赉县", 220821); + IdCardGenerator.areaCode.put("通榆县", 220822); + IdCardGenerator.areaCode.put("洮南市", 220881); + IdCardGenerator.areaCode.put("大安市", 220882); + IdCardGenerator.areaCode.put("延边朝鲜族自治州", 222400); + IdCardGenerator.areaCode.put("延吉市", 222401); + IdCardGenerator.areaCode.put("图们市", 222402); + IdCardGenerator.areaCode.put("敦化市", 222403); + IdCardGenerator.areaCode.put("珲春市", 222404); + IdCardGenerator.areaCode.put("龙井市", 222405); + IdCardGenerator.areaCode.put("和龙市", 222406); + IdCardGenerator.areaCode.put("汪清县", 222424); + IdCardGenerator.areaCode.put("安图县", 222426); + IdCardGenerator.areaCode.put("黑龙江省", 230000); + IdCardGenerator.areaCode.put("哈尔滨市", 230100); + IdCardGenerator.areaCode.put("市辖区", 230101); + IdCardGenerator.areaCode.put("道里区", 230102); + IdCardGenerator.areaCode.put("南岗区", 230103); + IdCardGenerator.areaCode.put("道外区", 230104); + IdCardGenerator.areaCode.put("平房区", 230108); + IdCardGenerator.areaCode.put("松北区", 230109); + IdCardGenerator.areaCode.put("香坊区", 230110); + IdCardGenerator.areaCode.put("呼兰区", 230111); + IdCardGenerator.areaCode.put("依兰县", 230123); + IdCardGenerator.areaCode.put("方正县", 230124); + IdCardGenerator.areaCode.put("宾 县", 230125); + IdCardGenerator.areaCode.put("巴彦县", 230126); + IdCardGenerator.areaCode.put("木兰县", 230127); + IdCardGenerator.areaCode.put("通河县", 230128); + IdCardGenerator.areaCode.put("延寿县", 230129); + IdCardGenerator.areaCode.put("双城市", 230182); + IdCardGenerator.areaCode.put("尚志市", 230183); + IdCardGenerator.areaCode.put("五常市", 230184); + IdCardGenerator.areaCode.put("齐齐哈尔市", 230200); + IdCardGenerator.areaCode.put("市辖区", 230201); + IdCardGenerator.areaCode.put("龙沙区", 230202); + IdCardGenerator.areaCode.put("建华区", 230203); + IdCardGenerator.areaCode.put("铁锋区", 230204); + IdCardGenerator.areaCode.put("昂昂溪区", 230205); + IdCardGenerator.areaCode.put("富拉尔基区", 230206); + IdCardGenerator.areaCode.put("碾子山区", 230207); + IdCardGenerator.areaCode.put("梅里斯达斡尔族区", 230208); + IdCardGenerator.areaCode.put("龙江县", 230221); + IdCardGenerator.areaCode.put("依安县", 230223); + IdCardGenerator.areaCode.put("泰来县", 230224); + IdCardGenerator.areaCode.put("甘南县", 230225); + IdCardGenerator.areaCode.put("富裕县", 230227); + IdCardGenerator.areaCode.put("克山县", 230229); + IdCardGenerator.areaCode.put("克东县", 230230); + IdCardGenerator.areaCode.put("拜泉县", 230231); + IdCardGenerator.areaCode.put("讷河市", 230281); + IdCardGenerator.areaCode.put("鸡西市", 230300); + IdCardGenerator.areaCode.put("市辖区", 230301); + IdCardGenerator.areaCode.put("鸡冠区", 230302); + IdCardGenerator.areaCode.put("恒山区", 230303); + IdCardGenerator.areaCode.put("滴道区", 230304); + IdCardGenerator.areaCode.put("梨树区", 230305); + IdCardGenerator.areaCode.put("城子河区", 230306); + IdCardGenerator.areaCode.put("麻山区", 230307); + IdCardGenerator.areaCode.put("鸡东县", 230321); + IdCardGenerator.areaCode.put("虎林市", 230381); + IdCardGenerator.areaCode.put("密山市", 230382); + IdCardGenerator.areaCode.put("鹤岗市", 230400); + IdCardGenerator.areaCode.put("市辖区", 230401); + IdCardGenerator.areaCode.put("向阳区", 230402); + IdCardGenerator.areaCode.put("工农区", 230403); + IdCardGenerator.areaCode.put("南山区", 230404); + IdCardGenerator.areaCode.put("兴安区", 230405); + IdCardGenerator.areaCode.put("东山区", 230406); + IdCardGenerator.areaCode.put("兴山区", 230407); + IdCardGenerator.areaCode.put("萝北县", 230421); + IdCardGenerator.areaCode.put("绥滨县", 230422); + IdCardGenerator.areaCode.put("双鸭山市", 230500); + IdCardGenerator.areaCode.put("市辖区", 230501); + IdCardGenerator.areaCode.put("尖山区", 230502); + IdCardGenerator.areaCode.put("岭东区", 230503); + IdCardGenerator.areaCode.put("四方台区", 230505); + IdCardGenerator.areaCode.put("宝山区", 230506); + IdCardGenerator.areaCode.put("集贤县", 230521); + IdCardGenerator.areaCode.put("友谊县", 230522); + IdCardGenerator.areaCode.put("宝清县", 230523); + IdCardGenerator.areaCode.put("饶河县", 230524); + IdCardGenerator.areaCode.put("大庆市", 230600); + IdCardGenerator.areaCode.put("市辖区", 230601); + IdCardGenerator.areaCode.put("萨尔图区", 230602); + IdCardGenerator.areaCode.put("龙凤区", 230603); + IdCardGenerator.areaCode.put("让胡路区", 230604); + IdCardGenerator.areaCode.put("红岗区", 230605); + IdCardGenerator.areaCode.put("大同区", 230606); + IdCardGenerator.areaCode.put("肇州县", 230621); + IdCardGenerator.areaCode.put("肇源县", 230622); + IdCardGenerator.areaCode.put("林甸县", 230623); + IdCardGenerator.areaCode.put("杜尔伯特蒙古族自治县", 230624); + IdCardGenerator.areaCode.put("伊春市", 230700); + IdCardGenerator.areaCode.put("市辖区", 230701); + IdCardGenerator.areaCode.put("伊春区", 230702); + IdCardGenerator.areaCode.put("南岔区", 230703); + IdCardGenerator.areaCode.put("友好区", 230704); + IdCardGenerator.areaCode.put("西林区", 230705); + IdCardGenerator.areaCode.put("翠峦区", 230706); + IdCardGenerator.areaCode.put("新青区", 230707); + IdCardGenerator.areaCode.put("美溪区", 230708); + IdCardGenerator.areaCode.put("金山屯区", 230709); + IdCardGenerator.areaCode.put("五营区", 230710); + IdCardGenerator.areaCode.put("乌马河区", 230711); + IdCardGenerator.areaCode.put("汤旺河区", 230712); + IdCardGenerator.areaCode.put("带岭区", 230713); + IdCardGenerator.areaCode.put("乌伊岭区", 230714); + IdCardGenerator.areaCode.put("红星区", 230715); + IdCardGenerator.areaCode.put("上甘岭区", 230716); + IdCardGenerator.areaCode.put("嘉荫县", 230722); + IdCardGenerator.areaCode.put("铁力市", 230781); + IdCardGenerator.areaCode.put("佳木斯市", 230800); + IdCardGenerator.areaCode.put("市辖区", 230801); + IdCardGenerator.areaCode.put("向阳区", 230803); + IdCardGenerator.areaCode.put("前进区", 230804); + IdCardGenerator.areaCode.put("东风区", 230805); + IdCardGenerator.areaCode.put("郊 区", 230811); + IdCardGenerator.areaCode.put("桦南县", 230822); + IdCardGenerator.areaCode.put("桦川县", 230826); + IdCardGenerator.areaCode.put("汤原县", 230828); + IdCardGenerator.areaCode.put("抚远县", 230833); + IdCardGenerator.areaCode.put("同江市", 230881); + IdCardGenerator.areaCode.put("富锦市", 230882); + IdCardGenerator.areaCode.put("七台河市", 230900); + IdCardGenerator.areaCode.put("市辖区", 230901); + IdCardGenerator.areaCode.put("新兴区", 230902); + IdCardGenerator.areaCode.put("桃山区", 230903); + IdCardGenerator.areaCode.put("茄子河区", 230904); + IdCardGenerator.areaCode.put("勃利县", 230921); + IdCardGenerator.areaCode.put("牡丹江市", 231000); + IdCardGenerator.areaCode.put("市辖区", 231001); + IdCardGenerator.areaCode.put("东安区", 231002); + IdCardGenerator.areaCode.put("阳明区", 231003); + IdCardGenerator.areaCode.put("爱民区", 231004); + IdCardGenerator.areaCode.put("西安区", 231005); + IdCardGenerator.areaCode.put("东宁县", 231024); + IdCardGenerator.areaCode.put("林口县", 231025); + IdCardGenerator.areaCode.put("绥芬河市", 231081); + IdCardGenerator.areaCode.put("海林市", 231083); + IdCardGenerator.areaCode.put("宁安市", 231084); + IdCardGenerator.areaCode.put("穆棱市", 231085); + IdCardGenerator.areaCode.put("黑河市", 231100); + IdCardGenerator.areaCode.put("市辖区", 231101); + IdCardGenerator.areaCode.put("爱辉区", 231102); + IdCardGenerator.areaCode.put("嫩江县", 231121); + IdCardGenerator.areaCode.put("逊克县", 231123); + IdCardGenerator.areaCode.put("孙吴县", 231124); + IdCardGenerator.areaCode.put("北安市", 231181); + IdCardGenerator.areaCode.put("五大连池市", 231182); + IdCardGenerator.areaCode.put("绥化市", 231200); + IdCardGenerator.areaCode.put("市辖区", 231201); + IdCardGenerator.areaCode.put("北林区", 231202); + IdCardGenerator.areaCode.put("望奎县", 231221); + IdCardGenerator.areaCode.put("兰西县", 231222); + IdCardGenerator.areaCode.put("青冈县", 231223); + IdCardGenerator.areaCode.put("庆安县", 231224); + IdCardGenerator.areaCode.put("明水县", 231225); + IdCardGenerator.areaCode.put("绥棱县", 231226); + IdCardGenerator.areaCode.put("安达市", 231281); + IdCardGenerator.areaCode.put("肇东市", 231282); + IdCardGenerator.areaCode.put("海伦市", 231283); + IdCardGenerator.areaCode.put("大兴安岭地区", 232700); + IdCardGenerator.areaCode.put("呼玛县", 232721); + IdCardGenerator.areaCode.put("塔河县", 232722); + IdCardGenerator.areaCode.put("漠河县", 232723); + IdCardGenerator.areaCode.put("上海市", 310000); + IdCardGenerator.areaCode.put("市辖区", 310100); + IdCardGenerator.areaCode.put("黄浦区", 310101); + IdCardGenerator.areaCode.put("卢湾区", 310103); + IdCardGenerator.areaCode.put("徐汇区", 310104); + IdCardGenerator.areaCode.put("长宁区", 310105); + IdCardGenerator.areaCode.put("静安区", 310106); + IdCardGenerator.areaCode.put("普陀区", 310107); + IdCardGenerator.areaCode.put("闸北区", 310108); + IdCardGenerator.areaCode.put("虹口区", 310109); + IdCardGenerator.areaCode.put("杨浦区", 310110); + IdCardGenerator.areaCode.put("闵行区", 310112); + IdCardGenerator.areaCode.put("宝山区", 310113); + IdCardGenerator.areaCode.put("嘉定区", 310114); + IdCardGenerator.areaCode.put("浦东新区 (*)", 310115); + IdCardGenerator.areaCode.put("金山区", 310116); + IdCardGenerator.areaCode.put("松江区", 310117); + IdCardGenerator.areaCode.put("青浦区", 310118); + IdCardGenerator.areaCode.put("奉贤区", 310120); + IdCardGenerator.areaCode.put("县", 310200); + IdCardGenerator.areaCode.put("崇明县", 310230); + IdCardGenerator.areaCode.put("江苏省", 320000); + IdCardGenerator.areaCode.put("南京市", 320100); + IdCardGenerator.areaCode.put("市辖区", 320101); + IdCardGenerator.areaCode.put("玄武区", 320102); + IdCardGenerator.areaCode.put("白下区", 320103); + IdCardGenerator.areaCode.put("秦淮区", 320104); + IdCardGenerator.areaCode.put("建邺区", 320105); + IdCardGenerator.areaCode.put("鼓楼区", 320106); + IdCardGenerator.areaCode.put("下关区", 320107); + IdCardGenerator.areaCode.put("浦口区", 320111); + IdCardGenerator.areaCode.put("栖霞区", 320113); + IdCardGenerator.areaCode.put("雨花台区", 320114); + IdCardGenerator.areaCode.put("江宁区", 320115); + IdCardGenerator.areaCode.put("六合区", 320116); + IdCardGenerator.areaCode.put("溧水县", 320124); + IdCardGenerator.areaCode.put("高淳县", 320125); + IdCardGenerator.areaCode.put("无锡市", 320200); + IdCardGenerator.areaCode.put("市辖区", 320201); + IdCardGenerator.areaCode.put("崇安区", 320202); + IdCardGenerator.areaCode.put("南长区", 320203); + IdCardGenerator.areaCode.put("北塘区", 320204); + IdCardGenerator.areaCode.put("锡山区", 320205); + IdCardGenerator.areaCode.put("惠山区", 320206); + IdCardGenerator.areaCode.put("滨湖区", 320211); + IdCardGenerator.areaCode.put("江阴市", 320281); + IdCardGenerator.areaCode.put("宜兴市", 320282); + IdCardGenerator.areaCode.put("徐州市", 320300); + IdCardGenerator.areaCode.put("市辖区", 320301); + IdCardGenerator.areaCode.put("鼓楼区", 320302); + IdCardGenerator.areaCode.put("云龙区", 320303); + IdCardGenerator.areaCode.put("九里区", 320304); + IdCardGenerator.areaCode.put("贾汪区", 320305); + IdCardGenerator.areaCode.put("泉山区", 320311); + IdCardGenerator.areaCode.put("丰 县", 320321); + IdCardGenerator.areaCode.put("沛 县", 320322); + IdCardGenerator.areaCode.put("铜山县", 320323); + IdCardGenerator.areaCode.put("睢宁县", 320324); + IdCardGenerator.areaCode.put("新沂市", 320381); + IdCardGenerator.areaCode.put("邳州市", 320382); + IdCardGenerator.areaCode.put("常州市", 320400); + IdCardGenerator.areaCode.put("市辖区", 320401); + IdCardGenerator.areaCode.put("天宁区", 320402); + IdCardGenerator.areaCode.put("钟楼区", 320404); + IdCardGenerator.areaCode.put("戚墅堰区", 320405); + IdCardGenerator.areaCode.put("新北区", 320411); + IdCardGenerator.areaCode.put("武进区", 320412); + IdCardGenerator.areaCode.put("溧阳市", 320481); + IdCardGenerator.areaCode.put("金坛市", 320482); + IdCardGenerator.areaCode.put("苏州市", 320500); + IdCardGenerator.areaCode.put("市辖区", 320501); + IdCardGenerator.areaCode.put("沧浪区", 320502); + IdCardGenerator.areaCode.put("平江区", 320503); + IdCardGenerator.areaCode.put("金阊区", 320504); + IdCardGenerator.areaCode.put("虎丘区", 320505); + IdCardGenerator.areaCode.put("吴中区", 320506); + IdCardGenerator.areaCode.put("相城区", 320507); + IdCardGenerator.areaCode.put("常熟市", 320581); + IdCardGenerator.areaCode.put("张家港市", 320582); + IdCardGenerator.areaCode.put("昆山市", 320583); + IdCardGenerator.areaCode.put("吴江市", 320584); + IdCardGenerator.areaCode.put("太仓市", 320585); + IdCardGenerator.areaCode.put("南通市", 320600); + IdCardGenerator.areaCode.put("市辖区", 320601); + IdCardGenerator.areaCode.put("崇川区", 320602); + IdCardGenerator.areaCode.put("港闸区", 320611); + IdCardGenerator.areaCode.put("海安县", 320621); + IdCardGenerator.areaCode.put("如东县", 320623); + IdCardGenerator.areaCode.put("启东市", 320681); + IdCardGenerator.areaCode.put("如皋市", 320682); + IdCardGenerator.areaCode.put("海门市", 320684); + IdCardGenerator.areaCode.put("连云港市", 320700); + IdCardGenerator.areaCode.put("市辖区", 320701); + IdCardGenerator.areaCode.put("连云区", 320703); + IdCardGenerator.areaCode.put("新浦区", 320705); + IdCardGenerator.areaCode.put("海州区", 320706); + IdCardGenerator.areaCode.put("赣榆县", 320721); + IdCardGenerator.areaCode.put("东海县", 320722); + IdCardGenerator.areaCode.put("灌云县", 320723); + IdCardGenerator.areaCode.put("灌南县", 320724); + IdCardGenerator.areaCode.put("淮安市", 320800); + IdCardGenerator.areaCode.put("市辖区", 320801); + IdCardGenerator.areaCode.put("清河区", 320802); + IdCardGenerator.areaCode.put("楚州区", 320803); + IdCardGenerator.areaCode.put("淮阴区", 320804); + IdCardGenerator.areaCode.put("清浦区", 320811); + IdCardGenerator.areaCode.put("涟水县", 320826); + IdCardGenerator.areaCode.put("洪泽县", 320829); + IdCardGenerator.areaCode.put("盱眙县", 320830); + IdCardGenerator.areaCode.put("金湖县", 320831); + IdCardGenerator.areaCode.put("盐城市", 320900); + IdCardGenerator.areaCode.put("市辖区", 320901); + IdCardGenerator.areaCode.put("亭湖区", 320902); + IdCardGenerator.areaCode.put("盐都区", 320903); + IdCardGenerator.areaCode.put("响水县", 320921); + IdCardGenerator.areaCode.put("滨海县", 320922); + IdCardGenerator.areaCode.put("阜宁县", 320923); + IdCardGenerator.areaCode.put("射阳县", 320924); + IdCardGenerator.areaCode.put("建湖县", 320925); + IdCardGenerator.areaCode.put("东台市", 320981); + IdCardGenerator.areaCode.put("大丰市", 320982); + IdCardGenerator.areaCode.put("扬州市", 321000); + IdCardGenerator.areaCode.put("市辖区", 321001); + IdCardGenerator.areaCode.put("广陵区", 321002); + IdCardGenerator.areaCode.put("邗江区", 321003); + IdCardGenerator.areaCode.put("维扬区", 321011); + IdCardGenerator.areaCode.put("宝应县", 321023); + IdCardGenerator.areaCode.put("仪征市", 321081); + IdCardGenerator.areaCode.put("高邮市", 321084); + IdCardGenerator.areaCode.put("江都市", 321088); + IdCardGenerator.areaCode.put("镇江市", 321100); + IdCardGenerator.areaCode.put("市辖区", 321101); + IdCardGenerator.areaCode.put("京口区", 321102); + IdCardGenerator.areaCode.put("润州区", 321111); + IdCardGenerator.areaCode.put("丹徒区", 321112); + IdCardGenerator.areaCode.put("丹阳市", 321181); + IdCardGenerator.areaCode.put("扬中市", 321182); + IdCardGenerator.areaCode.put("句容市", 321183); + IdCardGenerator.areaCode.put("泰州市", 321200); + IdCardGenerator.areaCode.put("市辖区", 321201); + IdCardGenerator.areaCode.put("海陵区", 321202); + IdCardGenerator.areaCode.put("高港区", 321203); + IdCardGenerator.areaCode.put("兴化市", 321281); + IdCardGenerator.areaCode.put("靖江市", 321282); + IdCardGenerator.areaCode.put("泰兴市", 321283); + IdCardGenerator.areaCode.put("姜堰市", 321284); + IdCardGenerator.areaCode.put("宿迁市", 321300); + IdCardGenerator.areaCode.put("市辖区", 321301); + IdCardGenerator.areaCode.put("宿城区", 321302); + IdCardGenerator.areaCode.put("宿豫区", 321311); + IdCardGenerator.areaCode.put("沭阳县", 321322); + IdCardGenerator.areaCode.put("泗阳县", 321323); + IdCardGenerator.areaCode.put("泗洪县", 321324); + IdCardGenerator.areaCode.put("浙江省", 330000); + IdCardGenerator.areaCode.put("杭州市", 330100); + IdCardGenerator.areaCode.put("市辖区", 330101); + IdCardGenerator.areaCode.put("上城区", 330102); + IdCardGenerator.areaCode.put("下城区", 330103); + IdCardGenerator.areaCode.put("江干区", 330104); + IdCardGenerator.areaCode.put("拱墅区", 330105); + IdCardGenerator.areaCode.put("西湖区", 330106); + IdCardGenerator.areaCode.put("滨江区", 330108); + IdCardGenerator.areaCode.put("萧山区", 330109); + IdCardGenerator.areaCode.put("余杭区", 330110); + IdCardGenerator.areaCode.put("桐庐县", 330122); + IdCardGenerator.areaCode.put("淳安县", 330127); + IdCardGenerator.areaCode.put("建德市", 330182); + IdCardGenerator.areaCode.put("富阳市", 330183); + IdCardGenerator.areaCode.put("临安市", 330185); + IdCardGenerator.areaCode.put("宁波市", 330200); + IdCardGenerator.areaCode.put("市辖区", 330201); + IdCardGenerator.areaCode.put("海曙区", 330203); + IdCardGenerator.areaCode.put("江东区", 330204); + IdCardGenerator.areaCode.put("江北区", 330205); + IdCardGenerator.areaCode.put("北仑区", 330206); + IdCardGenerator.areaCode.put("镇海区", 330211); + IdCardGenerator.areaCode.put("鄞州区", 330212); + IdCardGenerator.areaCode.put("象山县", 330225); + IdCardGenerator.areaCode.put("宁海县", 330226); + IdCardGenerator.areaCode.put("余姚市", 330281); + IdCardGenerator.areaCode.put("慈溪市", 330282); + IdCardGenerator.areaCode.put("奉化市", 330283); + IdCardGenerator.areaCode.put("温州市", 330300); + IdCardGenerator.areaCode.put("市辖区", 330301); + IdCardGenerator.areaCode.put("鹿城区", 330302); + IdCardGenerator.areaCode.put("龙湾区", 330303); + IdCardGenerator.areaCode.put("瓯海区", 330304); + IdCardGenerator.areaCode.put("洞头县", 330322); + IdCardGenerator.areaCode.put("永嘉县", 330324); + IdCardGenerator.areaCode.put("平阳县", 330326); + IdCardGenerator.areaCode.put("苍南县", 330327); + IdCardGenerator.areaCode.put("文成县", 330328); + IdCardGenerator.areaCode.put("泰顺县", 330329); + IdCardGenerator.areaCode.put("瑞安市", 330381); + IdCardGenerator.areaCode.put("乐清市", 330382); + IdCardGenerator.areaCode.put("嘉兴市", 330400); + IdCardGenerator.areaCode.put("市辖区", 330401); + IdCardGenerator.areaCode.put("南湖区", 330402); + IdCardGenerator.areaCode.put("秀洲区", 330411); + IdCardGenerator.areaCode.put("嘉善县", 330421); + IdCardGenerator.areaCode.put("海盐县", 330424); + IdCardGenerator.areaCode.put("海宁市", 330481); + IdCardGenerator.areaCode.put("平湖市", 330482); + IdCardGenerator.areaCode.put("桐乡市", 330483); + IdCardGenerator.areaCode.put("湖州市", 330500); + IdCardGenerator.areaCode.put("市辖区", 330501); + IdCardGenerator.areaCode.put("吴兴区", 330502); + IdCardGenerator.areaCode.put("南浔区", 330503); + IdCardGenerator.areaCode.put("德清县", 330521); + IdCardGenerator.areaCode.put("长兴县", 330522); + IdCardGenerator.areaCode.put("安吉县", 330523); + IdCardGenerator.areaCode.put("绍兴市", 330600); + IdCardGenerator.areaCode.put("市辖区", 330601); + IdCardGenerator.areaCode.put("越城区", 330602); + IdCardGenerator.areaCode.put("绍兴县", 330621); + IdCardGenerator.areaCode.put("新昌县", 330624); + IdCardGenerator.areaCode.put("诸暨市", 330681); + IdCardGenerator.areaCode.put("上虞市", 330682); + IdCardGenerator.areaCode.put("嵊州市", 330683); + IdCardGenerator.areaCode.put("金华市", 330700); + IdCardGenerator.areaCode.put("市辖区", 330701); + IdCardGenerator.areaCode.put("婺城区", 330702); + IdCardGenerator.areaCode.put("金东区", 330703); + IdCardGenerator.areaCode.put("武义县", 330723); + IdCardGenerator.areaCode.put("浦江县", 330726); + IdCardGenerator.areaCode.put("磐安县", 330727); + IdCardGenerator.areaCode.put("兰溪市", 330781); + IdCardGenerator.areaCode.put("义乌市", 330782); + IdCardGenerator.areaCode.put("东阳市", 330783); + IdCardGenerator.areaCode.put("永康市", 330784); + IdCardGenerator.areaCode.put("衢州市", 330800); + IdCardGenerator.areaCode.put("市辖区", 330801); + IdCardGenerator.areaCode.put("柯城区", 330802); + IdCardGenerator.areaCode.put("衢江区", 330803); + IdCardGenerator.areaCode.put("常山县", 330822); + IdCardGenerator.areaCode.put("开化县", 330824); + IdCardGenerator.areaCode.put("龙游县", 330825); + IdCardGenerator.areaCode.put("江山市", 330881); + IdCardGenerator.areaCode.put("舟山市", 330900); + IdCardGenerator.areaCode.put("市辖区", 330901); + IdCardGenerator.areaCode.put("定海区", 330902); + IdCardGenerator.areaCode.put("普陀区", 330903); + IdCardGenerator.areaCode.put("岱山县", 330921); + IdCardGenerator.areaCode.put("嵊泗县", 330922); + IdCardGenerator.areaCode.put("台州市", 331000); + IdCardGenerator.areaCode.put("市辖区", 331001); + IdCardGenerator.areaCode.put("椒江区", 331002); + IdCardGenerator.areaCode.put("黄岩区", 331003); + IdCardGenerator.areaCode.put("路桥区", 331004); + IdCardGenerator.areaCode.put("玉环县", 331021); + IdCardGenerator.areaCode.put("三门县", 331022); + IdCardGenerator.areaCode.put("天台县", 331023); + IdCardGenerator.areaCode.put("仙居县", 331024); + IdCardGenerator.areaCode.put("温岭市", 331081); + IdCardGenerator.areaCode.put("临海市", 331082); + IdCardGenerator.areaCode.put("丽水市", 331100); + IdCardGenerator.areaCode.put("市辖区", 331101); + IdCardGenerator.areaCode.put("莲都区", 331102); + IdCardGenerator.areaCode.put("青田县", 331121); + IdCardGenerator.areaCode.put("缙云县", 331122); + IdCardGenerator.areaCode.put("遂昌县", 331123); + IdCardGenerator.areaCode.put("松阳县", 331124); + IdCardGenerator.areaCode.put("云和县", 331125); + IdCardGenerator.areaCode.put("庆元县", 331126); + IdCardGenerator.areaCode.put("景宁畲族自治县", 331127); + IdCardGenerator.areaCode.put("龙泉市", 331181); + IdCardGenerator.areaCode.put("安徽省", 340000); + IdCardGenerator.areaCode.put("合肥市", 340100); + IdCardGenerator.areaCode.put("市辖区", 340101); + IdCardGenerator.areaCode.put("瑶海区", 340102); + IdCardGenerator.areaCode.put("庐阳区", 340103); + IdCardGenerator.areaCode.put("蜀山区", 340104); + IdCardGenerator.areaCode.put("包河区", 340111); + IdCardGenerator.areaCode.put("长丰县", 340121); + IdCardGenerator.areaCode.put("肥东县", 340122); + IdCardGenerator.areaCode.put("肥西县", 340123); + IdCardGenerator.areaCode.put("芜湖市", 340200); + IdCardGenerator.areaCode.put("市辖区", 340201); + IdCardGenerator.areaCode.put("镜湖区", 340202); + IdCardGenerator.areaCode.put("弋江区", 340203); + IdCardGenerator.areaCode.put("鸠江区", 340207); + IdCardGenerator.areaCode.put("三山区", 340208); + IdCardGenerator.areaCode.put("芜湖县", 340221); + IdCardGenerator.areaCode.put("繁昌县", 340222); + IdCardGenerator.areaCode.put("南陵县", 340223); + IdCardGenerator.areaCode.put("蚌埠市", 340300); + IdCardGenerator.areaCode.put("市辖区", 340301); + IdCardGenerator.areaCode.put("龙子湖区", 340302); + IdCardGenerator.areaCode.put("蚌山区", 340303); + IdCardGenerator.areaCode.put("禹会区", 340304); + IdCardGenerator.areaCode.put("淮上区", 340311); + IdCardGenerator.areaCode.put("怀远县", 340321); + IdCardGenerator.areaCode.put("五河县", 340322); + IdCardGenerator.areaCode.put("固镇县", 340323); + IdCardGenerator.areaCode.put("淮南市", 340400); + IdCardGenerator.areaCode.put("市辖区", 340401); + IdCardGenerator.areaCode.put("大通区", 340402); + IdCardGenerator.areaCode.put("田家庵区", 340403); + IdCardGenerator.areaCode.put("谢家集区", 340404); + IdCardGenerator.areaCode.put("八公山区", 340405); + IdCardGenerator.areaCode.put("潘集区", 340406); + IdCardGenerator.areaCode.put("凤台县", 340421); + IdCardGenerator.areaCode.put("马鞍山市", 340500); + IdCardGenerator.areaCode.put("市辖区", 340501); + IdCardGenerator.areaCode.put("金家庄区", 340502); + IdCardGenerator.areaCode.put("花山区", 340503); + IdCardGenerator.areaCode.put("雨山区", 340504); + IdCardGenerator.areaCode.put("当涂县", 340521); + IdCardGenerator.areaCode.put("淮北市", 340600); + IdCardGenerator.areaCode.put("市辖区", 340601); + IdCardGenerator.areaCode.put("杜集区", 340602); + IdCardGenerator.areaCode.put("相山区", 340603); + IdCardGenerator.areaCode.put("烈山区", 340604); + IdCardGenerator.areaCode.put("濉溪县", 340621); + IdCardGenerator.areaCode.put("铜陵市", 340700); + IdCardGenerator.areaCode.put("市辖区", 340701); + IdCardGenerator.areaCode.put("铜官山区", 340702); + IdCardGenerator.areaCode.put("狮子山区", 340703); + IdCardGenerator.areaCode.put("郊 区", 340711); + IdCardGenerator.areaCode.put("铜陵县", 340721); + IdCardGenerator.areaCode.put("安庆市", 340800); + IdCardGenerator.areaCode.put("市辖区", 340801); + IdCardGenerator.areaCode.put("迎江区", 340802); + IdCardGenerator.areaCode.put("大观区", 340803); + IdCardGenerator.areaCode.put("宜秀区", 340811); + IdCardGenerator.areaCode.put("怀宁县", 340822); + IdCardGenerator.areaCode.put("枞阳县", 340823); + IdCardGenerator.areaCode.put("潜山县", 340824); + IdCardGenerator.areaCode.put("太湖县", 340825); + IdCardGenerator.areaCode.put("宿松县", 340826); + IdCardGenerator.areaCode.put("望江县", 340827); + IdCardGenerator.areaCode.put("岳西县", 340828); + IdCardGenerator.areaCode.put("桐城市", 340881); + IdCardGenerator.areaCode.put("黄山市", 341000); + IdCardGenerator.areaCode.put("市辖区", 341001); + IdCardGenerator.areaCode.put("屯溪区", 341002); + IdCardGenerator.areaCode.put("黄山区", 341003); + IdCardGenerator.areaCode.put("徽州区", 341004); + IdCardGenerator.areaCode.put("歙 县", 341021); + IdCardGenerator.areaCode.put("休宁县", 341022); + IdCardGenerator.areaCode.put("黟 县", 341023); + IdCardGenerator.areaCode.put("祁门县", 341024); + IdCardGenerator.areaCode.put("滁州市", 341100); + IdCardGenerator.areaCode.put("市辖区", 341101); + IdCardGenerator.areaCode.put("琅琊区", 341102); + IdCardGenerator.areaCode.put("南谯区", 341103); + IdCardGenerator.areaCode.put("来安县", 341122); + IdCardGenerator.areaCode.put("全椒县", 341124); + IdCardGenerator.areaCode.put("定远县", 341125); + IdCardGenerator.areaCode.put("凤阳县", 341126); + IdCardGenerator.areaCode.put("天长市", 341181); + IdCardGenerator.areaCode.put("明光市", 341182); + IdCardGenerator.areaCode.put("阜阳市", 341200); + IdCardGenerator.areaCode.put("市辖区", 341201); + IdCardGenerator.areaCode.put("颍州区", 341202); + IdCardGenerator.areaCode.put("颍东区", 341203); + IdCardGenerator.areaCode.put("颍泉区", 341204); + IdCardGenerator.areaCode.put("临泉县", 341221); + IdCardGenerator.areaCode.put("太和县", 341222); + IdCardGenerator.areaCode.put("阜南县", 341225); + IdCardGenerator.areaCode.put("颍上县", 341226); + IdCardGenerator.areaCode.put("界首市", 341282); + IdCardGenerator.areaCode.put("宿州市", 341300); + IdCardGenerator.areaCode.put("市辖区", 341301); + IdCardGenerator.areaCode.put("埇桥区", 341302); + IdCardGenerator.areaCode.put("砀山县", 341321); + IdCardGenerator.areaCode.put("萧 县", 341322); + IdCardGenerator.areaCode.put("灵璧县", 341323); + IdCardGenerator.areaCode.put("泗 县", 341324); + IdCardGenerator.areaCode.put("巢湖市", 341400); + IdCardGenerator.areaCode.put("市辖区", 341401); + IdCardGenerator.areaCode.put("居巢区", 341402); + IdCardGenerator.areaCode.put("庐江县", 341421); + IdCardGenerator.areaCode.put("无为县", 341422); + IdCardGenerator.areaCode.put("含山县", 341423); + IdCardGenerator.areaCode.put("和 县", 341424); + IdCardGenerator.areaCode.put("六安市", 341500); + IdCardGenerator.areaCode.put("市辖区", 341501); + IdCardGenerator.areaCode.put("金安区", 341502); + IdCardGenerator.areaCode.put("裕安区", 341503); + IdCardGenerator.areaCode.put("寿 县", 341521); + IdCardGenerator.areaCode.put("霍邱县", 341522); + IdCardGenerator.areaCode.put("舒城县", 341523); + IdCardGenerator.areaCode.put("金寨县", 341524); + IdCardGenerator.areaCode.put("霍山县", 341525); + IdCardGenerator.areaCode.put("亳州市", 341600); + IdCardGenerator.areaCode.put("市辖区", 341601); + IdCardGenerator.areaCode.put("谯城区", 341602); + IdCardGenerator.areaCode.put("涡阳县", 341621); + IdCardGenerator.areaCode.put("蒙城县", 341622); + IdCardGenerator.areaCode.put("利辛县", 341623); + IdCardGenerator.areaCode.put("池州市", 341700); + IdCardGenerator.areaCode.put("市辖区", 341701); + IdCardGenerator.areaCode.put("贵池区", 341702); + IdCardGenerator.areaCode.put("东至县", 341721); + IdCardGenerator.areaCode.put("石台县", 341722); + IdCardGenerator.areaCode.put("青阳县", 341723); + IdCardGenerator.areaCode.put("宣城市", 341800); + IdCardGenerator.areaCode.put("市辖区", 341801); + IdCardGenerator.areaCode.put("宣州区", 341802); + IdCardGenerator.areaCode.put("郎溪县", 341821); + IdCardGenerator.areaCode.put("广德县", 341822); + IdCardGenerator.areaCode.put("泾 县", 341823); + IdCardGenerator.areaCode.put("绩溪县", 341824); + IdCardGenerator.areaCode.put("旌德县", 341825); + IdCardGenerator.areaCode.put("宁国市", 341881); + IdCardGenerator.areaCode.put("福建省", 350000); + IdCardGenerator.areaCode.put("福州市", 350100); + IdCardGenerator.areaCode.put("市辖区", 350101); + IdCardGenerator.areaCode.put("鼓楼区", 350102); + IdCardGenerator.areaCode.put("台江区", 350103); + IdCardGenerator.areaCode.put("仓山区", 350104); + IdCardGenerator.areaCode.put("马尾区", 350105); + IdCardGenerator.areaCode.put("晋安区", 350111); + IdCardGenerator.areaCode.put("闽侯县", 350121); + IdCardGenerator.areaCode.put("连江县", 350122); + IdCardGenerator.areaCode.put("罗源县", 350123); + IdCardGenerator.areaCode.put("闽清县", 350124); + IdCardGenerator.areaCode.put("永泰县", 350125); + IdCardGenerator.areaCode.put("平潭县", 350128); + IdCardGenerator.areaCode.put("福清市", 350181); + IdCardGenerator.areaCode.put("长乐市", 350182); + IdCardGenerator.areaCode.put("厦门市", 350200); + IdCardGenerator.areaCode.put("市辖区", 350201); + IdCardGenerator.areaCode.put("思明区", 350203); + IdCardGenerator.areaCode.put("海沧区", 350205); + IdCardGenerator.areaCode.put("湖里区", 350206); + IdCardGenerator.areaCode.put("集美区", 350211); + IdCardGenerator.areaCode.put("同安区", 350212); + IdCardGenerator.areaCode.put("翔安区", 350213); + IdCardGenerator.areaCode.put("莆田市", 350300); + IdCardGenerator.areaCode.put("市辖区", 350301); + IdCardGenerator.areaCode.put("城厢区", 350302); + IdCardGenerator.areaCode.put("涵江区", 350303); + IdCardGenerator.areaCode.put("荔城区", 350304); + IdCardGenerator.areaCode.put("秀屿区", 350305); + IdCardGenerator.areaCode.put("仙游县", 350322); + IdCardGenerator.areaCode.put("三明市", 350400); + IdCardGenerator.areaCode.put("市辖区", 350401); + IdCardGenerator.areaCode.put("梅列区", 350402); + IdCardGenerator.areaCode.put("三元区", 350403); + IdCardGenerator.areaCode.put("明溪县", 350421); + IdCardGenerator.areaCode.put("清流县", 350423); + IdCardGenerator.areaCode.put("宁化县", 350424); + IdCardGenerator.areaCode.put("大田县", 350425); + IdCardGenerator.areaCode.put("尤溪县", 350426); + IdCardGenerator.areaCode.put("沙 县", 350427); + IdCardGenerator.areaCode.put("将乐县", 350428); + IdCardGenerator.areaCode.put("泰宁县", 350429); + IdCardGenerator.areaCode.put("建宁县", 350430); + IdCardGenerator.areaCode.put("永安市", 350481); + IdCardGenerator.areaCode.put("泉州市", 350500); + IdCardGenerator.areaCode.put("市辖区", 350501); + IdCardGenerator.areaCode.put("鲤城区", 350502); + IdCardGenerator.areaCode.put("丰泽区", 350503); + IdCardGenerator.areaCode.put("洛江区", 350504); + IdCardGenerator.areaCode.put("泉港区", 350505); + IdCardGenerator.areaCode.put("惠安县", 350521); + IdCardGenerator.areaCode.put("安溪县", 350524); + IdCardGenerator.areaCode.put("永春县", 350525); + IdCardGenerator.areaCode.put("德化县", 350526); + IdCardGenerator.areaCode.put("金门县", 350527); + IdCardGenerator.areaCode.put("石狮市", 350581); + IdCardGenerator.areaCode.put("晋江市", 350582); + IdCardGenerator.areaCode.put("南安市", 350583); + IdCardGenerator.areaCode.put("漳州市", 350600); + IdCardGenerator.areaCode.put("市辖区", 350601); + IdCardGenerator.areaCode.put("芗城区", 350602); + IdCardGenerator.areaCode.put("龙文区", 350603); + IdCardGenerator.areaCode.put("云霄县", 350622); + IdCardGenerator.areaCode.put("漳浦县", 350623); + IdCardGenerator.areaCode.put("诏安县", 350624); + IdCardGenerator.areaCode.put("长泰县", 350625); + IdCardGenerator.areaCode.put("东山县", 350626); + IdCardGenerator.areaCode.put("南靖县", 350627); + IdCardGenerator.areaCode.put("平和县", 350628); + IdCardGenerator.areaCode.put("华安县", 350629); + IdCardGenerator.areaCode.put("龙海市", 350681); + IdCardGenerator.areaCode.put("南平市", 350700); + IdCardGenerator.areaCode.put("市辖区", 350701); + IdCardGenerator.areaCode.put("延平区", 350702); + IdCardGenerator.areaCode.put("顺昌县", 350721); + IdCardGenerator.areaCode.put("浦城县", 350722); + IdCardGenerator.areaCode.put("光泽县", 350723); + IdCardGenerator.areaCode.put("松溪县", 350724); + IdCardGenerator.areaCode.put("政和县", 350725); + IdCardGenerator.areaCode.put("邵武市", 350781); + IdCardGenerator.areaCode.put("武夷山市", 350782); + IdCardGenerator.areaCode.put("建瓯市", 350783); + IdCardGenerator.areaCode.put("建阳市", 350784); + IdCardGenerator.areaCode.put("龙岩市", 350800); + IdCardGenerator.areaCode.put("市辖区", 350801); + IdCardGenerator.areaCode.put("新罗区", 350802); + IdCardGenerator.areaCode.put("长汀县", 350821); + IdCardGenerator.areaCode.put("永定县", 350822); + IdCardGenerator.areaCode.put("上杭县", 350823); + IdCardGenerator.areaCode.put("武平县", 350824); + IdCardGenerator.areaCode.put("连城县", 350825); + IdCardGenerator.areaCode.put("漳平市", 350881); + IdCardGenerator.areaCode.put("宁德市", 350900); + IdCardGenerator.areaCode.put("市辖区", 350901); + IdCardGenerator.areaCode.put("蕉城区", 350902); + IdCardGenerator.areaCode.put("霞浦县", 350921); + IdCardGenerator.areaCode.put("古田县", 350922); + IdCardGenerator.areaCode.put("屏南县", 350923); + IdCardGenerator.areaCode.put("寿宁县", 350924); + IdCardGenerator.areaCode.put("周宁县", 350925); + IdCardGenerator.areaCode.put("柘荣县", 350926); + IdCardGenerator.areaCode.put("福安市", 350981); + IdCardGenerator.areaCode.put("福鼎市", 350982); + IdCardGenerator.areaCode.put("江西省", 360000); + IdCardGenerator.areaCode.put("南昌市", 360100); + IdCardGenerator.areaCode.put("市辖区", 360101); + IdCardGenerator.areaCode.put("东湖区", 360102); + IdCardGenerator.areaCode.put("西湖区", 360103); + IdCardGenerator.areaCode.put("青云谱区", 360104); + IdCardGenerator.areaCode.put("湾里区", 360105); + IdCardGenerator.areaCode.put("青山湖区", 360111); + IdCardGenerator.areaCode.put("南昌县", 360121); + IdCardGenerator.areaCode.put("新建县", 360122); + IdCardGenerator.areaCode.put("安义县", 360123); + IdCardGenerator.areaCode.put("进贤县", 360124); + IdCardGenerator.areaCode.put("景德镇市", 360200); + IdCardGenerator.areaCode.put("市辖区", 360201); + IdCardGenerator.areaCode.put("昌江区", 360202); + IdCardGenerator.areaCode.put("珠山区", 360203); + IdCardGenerator.areaCode.put("浮梁县", 360222); + IdCardGenerator.areaCode.put("乐平市", 360281); + IdCardGenerator.areaCode.put("萍乡市", 360300); + IdCardGenerator.areaCode.put("市辖区", 360301); + IdCardGenerator.areaCode.put("安源区", 360302); + IdCardGenerator.areaCode.put("湘东区", 360313); + IdCardGenerator.areaCode.put("莲花县", 360321); + IdCardGenerator.areaCode.put("上栗县", 360322); + IdCardGenerator.areaCode.put("芦溪县", 360323); + IdCardGenerator.areaCode.put("九江市", 360400); + IdCardGenerator.areaCode.put("市辖区", 360401); + IdCardGenerator.areaCode.put("庐山区", 360402); + IdCardGenerator.areaCode.put("浔阳区", 360403); + IdCardGenerator.areaCode.put("九江县", 360421); + IdCardGenerator.areaCode.put("武宁县", 360423); + IdCardGenerator.areaCode.put("修水县", 360424); + IdCardGenerator.areaCode.put("永修县", 360425); + IdCardGenerator.areaCode.put("德安县", 360426); + IdCardGenerator.areaCode.put("星子县", 360427); + IdCardGenerator.areaCode.put("都昌县", 360428); + IdCardGenerator.areaCode.put("湖口县", 360429); + IdCardGenerator.areaCode.put("彭泽县", 360430); + IdCardGenerator.areaCode.put("瑞昌市", 360481); + IdCardGenerator.areaCode.put("新余市", 360500); + IdCardGenerator.areaCode.put("市辖区", 360501); + IdCardGenerator.areaCode.put("渝水区", 360502); + IdCardGenerator.areaCode.put("分宜县", 360521); + IdCardGenerator.areaCode.put("鹰潭市", 360600); + IdCardGenerator.areaCode.put("市辖区", 360601); + IdCardGenerator.areaCode.put("月湖区", 360602); + IdCardGenerator.areaCode.put("余江县", 360622); + IdCardGenerator.areaCode.put("贵溪市", 360681); + IdCardGenerator.areaCode.put("赣州市", 360700); + IdCardGenerator.areaCode.put("市辖区", 360701); + IdCardGenerator.areaCode.put("章贡区", 360702); + IdCardGenerator.areaCode.put("赣 县", 360721); + IdCardGenerator.areaCode.put("信丰县", 360722); + IdCardGenerator.areaCode.put("大余县", 360723); + IdCardGenerator.areaCode.put("上犹县", 360724); + IdCardGenerator.areaCode.put("崇义县", 360725); + IdCardGenerator.areaCode.put("安远县", 360726); + IdCardGenerator.areaCode.put("龙南县", 360727); + IdCardGenerator.areaCode.put("定南县", 360728); + IdCardGenerator.areaCode.put("全南县", 360729); + IdCardGenerator.areaCode.put("宁都县", 360730); + IdCardGenerator.areaCode.put("于都县", 360731); + IdCardGenerator.areaCode.put("兴国县", 360732); + IdCardGenerator.areaCode.put("会昌县", 360733); + IdCardGenerator.areaCode.put("寻乌县", 360734); + IdCardGenerator.areaCode.put("石城县", 360735); + IdCardGenerator.areaCode.put("瑞金市", 360781); + IdCardGenerator.areaCode.put("南康市", 360782); + IdCardGenerator.areaCode.put("吉安市", 360800); + IdCardGenerator.areaCode.put("市辖区", 360801); + IdCardGenerator.areaCode.put("吉州区", 360802); + IdCardGenerator.areaCode.put("青原区", 360803); + IdCardGenerator.areaCode.put("吉安县", 360821); + IdCardGenerator.areaCode.put("吉水县", 360822); + IdCardGenerator.areaCode.put("峡江县", 360823); + IdCardGenerator.areaCode.put("新干县", 360824); + IdCardGenerator.areaCode.put("永丰县", 360825); + IdCardGenerator.areaCode.put("泰和县", 360826); + IdCardGenerator.areaCode.put("遂川县", 360827); + IdCardGenerator.areaCode.put("万安县", 360828); + IdCardGenerator.areaCode.put("安福县", 360829); + IdCardGenerator.areaCode.put("永新县", 360830); + IdCardGenerator.areaCode.put("井冈山市", 360881); + IdCardGenerator.areaCode.put("宜春市", 360900); + IdCardGenerator.areaCode.put("市辖区", 360901); + IdCardGenerator.areaCode.put("袁州区", 360902); + IdCardGenerator.areaCode.put("奉新县", 360921); + IdCardGenerator.areaCode.put("万载县", 360922); + IdCardGenerator.areaCode.put("上高县", 360923); + IdCardGenerator.areaCode.put("宜丰县", 360924); + IdCardGenerator.areaCode.put("靖安县", 360925); + IdCardGenerator.areaCode.put("铜鼓县", 360926); + IdCardGenerator.areaCode.put("丰城市", 360981); + IdCardGenerator.areaCode.put("樟树市", 360982); + IdCardGenerator.areaCode.put("高安市", 360983); + IdCardGenerator.areaCode.put("抚州市", 361000); + IdCardGenerator.areaCode.put("市辖区", 361001); + IdCardGenerator.areaCode.put("临川区", 361002); + IdCardGenerator.areaCode.put("南城县", 361021); + IdCardGenerator.areaCode.put("黎川县", 361022); + IdCardGenerator.areaCode.put("南丰县", 361023); + IdCardGenerator.areaCode.put("崇仁县", 361024); + IdCardGenerator.areaCode.put("乐安县", 361025); + IdCardGenerator.areaCode.put("宜黄县", 361026); + IdCardGenerator.areaCode.put("金溪县", 361027); + IdCardGenerator.areaCode.put("资溪县", 361028); + IdCardGenerator.areaCode.put("东乡县", 361029); + IdCardGenerator.areaCode.put("广昌县", 361030); + IdCardGenerator.areaCode.put("上饶市", 361100); + IdCardGenerator.areaCode.put("市辖区", 361101); + IdCardGenerator.areaCode.put("信州区", 361102); + IdCardGenerator.areaCode.put("上饶县", 361121); + IdCardGenerator.areaCode.put("广丰县", 361122); + IdCardGenerator.areaCode.put("玉山县", 361123); + IdCardGenerator.areaCode.put("铅山县", 361124); + IdCardGenerator.areaCode.put("横峰县", 361125); + IdCardGenerator.areaCode.put("弋阳县", 361126); + IdCardGenerator.areaCode.put("余干县", 361127); + IdCardGenerator.areaCode.put("鄱阳县", 361128); + IdCardGenerator.areaCode.put("万年县", 361129); + IdCardGenerator.areaCode.put("婺源县", 361130); + IdCardGenerator.areaCode.put("德兴市", 361181); + IdCardGenerator.areaCode.put("山东省", 370000); + IdCardGenerator.areaCode.put("济南市", 370100); + IdCardGenerator.areaCode.put("市辖区", 370101); + IdCardGenerator.areaCode.put("历下区", 370102); + IdCardGenerator.areaCode.put("市中区", 370103); + IdCardGenerator.areaCode.put("槐荫区", 370104); + IdCardGenerator.areaCode.put("天桥区", 370105); + IdCardGenerator.areaCode.put("历城区", 370112); + IdCardGenerator.areaCode.put("长清区", 370113); + IdCardGenerator.areaCode.put("平阴县", 370124); + IdCardGenerator.areaCode.put("济阳县", 370125); + IdCardGenerator.areaCode.put("商河县", 370126); + IdCardGenerator.areaCode.put("章丘市", 370181); + IdCardGenerator.areaCode.put("青岛市", 370200); + IdCardGenerator.areaCode.put("市辖区", 370201); + IdCardGenerator.areaCode.put("市南区", 370202); + IdCardGenerator.areaCode.put("市北区", 370203); + IdCardGenerator.areaCode.put("四方区", 370205); + IdCardGenerator.areaCode.put("黄岛区", 370211); + IdCardGenerator.areaCode.put("崂山区", 370212); + IdCardGenerator.areaCode.put("李沧区", 370213); + IdCardGenerator.areaCode.put("城阳区", 370214); + IdCardGenerator.areaCode.put("胶州市", 370281); + IdCardGenerator.areaCode.put("即墨市", 370282); + IdCardGenerator.areaCode.put("平度市", 370283); + IdCardGenerator.areaCode.put("胶南市", 370284); + IdCardGenerator.areaCode.put("莱西市", 370285); + IdCardGenerator.areaCode.put("淄博市", 370300); + IdCardGenerator.areaCode.put("市辖区", 370301); + IdCardGenerator.areaCode.put("淄川区", 370302); + IdCardGenerator.areaCode.put("张店区", 370303); + IdCardGenerator.areaCode.put("博山区", 370304); + IdCardGenerator.areaCode.put("临淄区", 370305); + IdCardGenerator.areaCode.put("周村区", 370306); + IdCardGenerator.areaCode.put("桓台县", 370321); + IdCardGenerator.areaCode.put("高青县", 370322); + IdCardGenerator.areaCode.put("沂源县", 370323); + IdCardGenerator.areaCode.put("枣庄市", 370400); + IdCardGenerator.areaCode.put("市辖区", 370401); + IdCardGenerator.areaCode.put("市中区", 370402); + IdCardGenerator.areaCode.put("薛城区", 370403); + IdCardGenerator.areaCode.put("峄城区", 370404); + IdCardGenerator.areaCode.put("台儿庄区", 370405); + IdCardGenerator.areaCode.put("山亭区", 370406); + IdCardGenerator.areaCode.put("滕州市", 370481); + IdCardGenerator.areaCode.put("东营市", 370500); + IdCardGenerator.areaCode.put("市辖区", 370501); + IdCardGenerator.areaCode.put("东营区", 370502); + IdCardGenerator.areaCode.put("河口区", 370503); + IdCardGenerator.areaCode.put("垦利县", 370521); + IdCardGenerator.areaCode.put("利津县", 370522); + IdCardGenerator.areaCode.put("广饶县", 370523); + IdCardGenerator.areaCode.put("烟台市", 370600); + IdCardGenerator.areaCode.put("市辖区", 370601); + IdCardGenerator.areaCode.put("芝罘区", 370602); + IdCardGenerator.areaCode.put("福山区", 370611); + IdCardGenerator.areaCode.put("牟平区", 370612); + IdCardGenerator.areaCode.put("莱山区", 370613); + IdCardGenerator.areaCode.put("长岛县", 370634); + IdCardGenerator.areaCode.put("龙口市", 370681); + IdCardGenerator.areaCode.put("莱阳市", 370682); + IdCardGenerator.areaCode.put("莱州市", 370683); + IdCardGenerator.areaCode.put("蓬莱市", 370684); + IdCardGenerator.areaCode.put("招远市", 370685); + IdCardGenerator.areaCode.put("栖霞市", 370686); + IdCardGenerator.areaCode.put("海阳市", 370687); + IdCardGenerator.areaCode.put("潍坊市", 370700); + IdCardGenerator.areaCode.put("市辖区", 370701); + IdCardGenerator.areaCode.put("潍城区", 370702); + IdCardGenerator.areaCode.put("寒亭区", 370703); + IdCardGenerator.areaCode.put("坊子区", 370704); + IdCardGenerator.areaCode.put("奎文区", 370705); + IdCardGenerator.areaCode.put("临朐县", 370724); + IdCardGenerator.areaCode.put("昌乐县", 370725); + IdCardGenerator.areaCode.put("青州市", 370781); + IdCardGenerator.areaCode.put("诸城市", 370782); + IdCardGenerator.areaCode.put("寿光市", 370783); + IdCardGenerator.areaCode.put("安丘市", 370784); + IdCardGenerator.areaCode.put("高密市", 370785); + IdCardGenerator.areaCode.put("昌邑市", 370786); + IdCardGenerator.areaCode.put("济宁市", 370800); + IdCardGenerator.areaCode.put("市辖区", 370801); + IdCardGenerator.areaCode.put("市中区", 370802); + IdCardGenerator.areaCode.put("任城区", 370811); + IdCardGenerator.areaCode.put("微山县", 370826); + IdCardGenerator.areaCode.put("鱼台县", 370827); + IdCardGenerator.areaCode.put("金乡县", 370828); + IdCardGenerator.areaCode.put("嘉祥县", 370829); + IdCardGenerator.areaCode.put("汶上县", 370830); + IdCardGenerator.areaCode.put("泗水县", 370831); + IdCardGenerator.areaCode.put("梁山县", 370832); + IdCardGenerator.areaCode.put("曲阜市", 370881); + IdCardGenerator.areaCode.put("兖州市", 370882); + IdCardGenerator.areaCode.put("邹城市", 370883); + IdCardGenerator.areaCode.put("泰安市", 370900); + IdCardGenerator.areaCode.put("市辖区", 370901); + IdCardGenerator.areaCode.put("泰山区", 370902); + IdCardGenerator.areaCode.put("岱岳区", 370911); + IdCardGenerator.areaCode.put("宁阳县", 370921); + IdCardGenerator.areaCode.put("东平县", 370923); + IdCardGenerator.areaCode.put("新泰市", 370982); + IdCardGenerator.areaCode.put("肥城市", 370983); + IdCardGenerator.areaCode.put("威海市", 371000); + IdCardGenerator.areaCode.put("市辖区", 371001); + IdCardGenerator.areaCode.put("环翠区", 371002); + IdCardGenerator.areaCode.put("文登市", 371081); + IdCardGenerator.areaCode.put("荣成市", 371082); + IdCardGenerator.areaCode.put("乳山市", 371083); + IdCardGenerator.areaCode.put("日照市", 371100); + IdCardGenerator.areaCode.put("市辖区", 371101); + IdCardGenerator.areaCode.put("东港区", 371102); + IdCardGenerator.areaCode.put("岚山区", 371103); + IdCardGenerator.areaCode.put("五莲县", 371121); + IdCardGenerator.areaCode.put("莒 县", 371122); + IdCardGenerator.areaCode.put("莱芜市", 371200); + IdCardGenerator.areaCode.put("市辖区", 371201); + IdCardGenerator.areaCode.put("莱城区", 371202); + IdCardGenerator.areaCode.put("钢城区", 371203); + IdCardGenerator.areaCode.put("临沂市", 371300); + IdCardGenerator.areaCode.put("市辖区", 371301); + IdCardGenerator.areaCode.put("兰山区", 371302); + IdCardGenerator.areaCode.put("罗庄区", 371311); + IdCardGenerator.areaCode.put("河东区", 371312); + IdCardGenerator.areaCode.put("沂南县", 371321); + IdCardGenerator.areaCode.put("郯城县", 371322); + IdCardGenerator.areaCode.put("沂水县", 371323); + IdCardGenerator.areaCode.put("苍山县", 371324); + IdCardGenerator.areaCode.put("费 县", 371325); + IdCardGenerator.areaCode.put("平邑县", 371326); + IdCardGenerator.areaCode.put("莒南县", 371327); + IdCardGenerator.areaCode.put("蒙阴县", 371328); + IdCardGenerator.areaCode.put("临沭县", 371329); + IdCardGenerator.areaCode.put("德州市", 371400); + IdCardGenerator.areaCode.put("市辖区", 371401); + IdCardGenerator.areaCode.put("德城区", 371402); + IdCardGenerator.areaCode.put("陵 县", 371421); + IdCardGenerator.areaCode.put("宁津县", 371422); + IdCardGenerator.areaCode.put("庆云县", 371423); + IdCardGenerator.areaCode.put("临邑县", 371424); + IdCardGenerator.areaCode.put("齐河县", 371425); + IdCardGenerator.areaCode.put("平原县", 371426); + IdCardGenerator.areaCode.put("夏津县", 371427); + IdCardGenerator.areaCode.put("武城县", 371428); + IdCardGenerator.areaCode.put("乐陵市", 371481); + IdCardGenerator.areaCode.put("禹城市", 371482); + IdCardGenerator.areaCode.put("聊城市", 371500); + IdCardGenerator.areaCode.put("市辖区", 371501); + IdCardGenerator.areaCode.put("东昌府区", 371502); + IdCardGenerator.areaCode.put("阳谷县", 371521); + IdCardGenerator.areaCode.put("莘 县", 371522); + IdCardGenerator.areaCode.put("茌平县", 371523); + IdCardGenerator.areaCode.put("东阿县", 371524); + IdCardGenerator.areaCode.put("冠 县", 371525); + IdCardGenerator.areaCode.put("高唐县", 371526); + IdCardGenerator.areaCode.put("临清市", 371581); + IdCardGenerator.areaCode.put("滨州市", 371600); + IdCardGenerator.areaCode.put("市辖区", 371601); + IdCardGenerator.areaCode.put("滨城区", 371602); + IdCardGenerator.areaCode.put("惠民县", 371621); + IdCardGenerator.areaCode.put("阳信县", 371622); + IdCardGenerator.areaCode.put("无棣县", 371623); + IdCardGenerator.areaCode.put("沾化县", 371624); + IdCardGenerator.areaCode.put("博兴县", 371625); + IdCardGenerator.areaCode.put("邹平县", 371626); + IdCardGenerator.areaCode.put("菏泽市", 371700); + IdCardGenerator.areaCode.put("市辖区", 371701); + IdCardGenerator.areaCode.put("牡丹区", 371702); + IdCardGenerator.areaCode.put("曹 县", 371721); + IdCardGenerator.areaCode.put("单 县", 371722); + IdCardGenerator.areaCode.put("成武县", 371723); + IdCardGenerator.areaCode.put("巨野县", 371724); + IdCardGenerator.areaCode.put("郓城县", 371725); + IdCardGenerator.areaCode.put("鄄城县", 371726); + IdCardGenerator.areaCode.put("定陶县", 371727); + IdCardGenerator.areaCode.put("东明县", 371728); + IdCardGenerator.areaCode.put("河南省", 410000); + IdCardGenerator.areaCode.put("郑州市", 410100); + IdCardGenerator.areaCode.put("市辖区", 410101); + IdCardGenerator.areaCode.put("中原区", 410102); + IdCardGenerator.areaCode.put("二七区", 410103); + IdCardGenerator.areaCode.put("管城回族区", 410104); + IdCardGenerator.areaCode.put("金水区", 410105); + IdCardGenerator.areaCode.put("上街区", 410106); + IdCardGenerator.areaCode.put("惠济区", 410108); + IdCardGenerator.areaCode.put("中牟县", 410122); + IdCardGenerator.areaCode.put("巩义市", 410181); + IdCardGenerator.areaCode.put("荥阳市", 410182); + IdCardGenerator.areaCode.put("新密市", 410183); + IdCardGenerator.areaCode.put("新郑市", 410184); + IdCardGenerator.areaCode.put("登封市", 410185); + IdCardGenerator.areaCode.put("开封市", 410200); + IdCardGenerator.areaCode.put("市辖区", 410201); + IdCardGenerator.areaCode.put("龙亭区", 410202); + IdCardGenerator.areaCode.put("顺河回族区", 410203); + IdCardGenerator.areaCode.put("鼓楼区", 410204); + IdCardGenerator.areaCode.put("禹王台区", 410205); + IdCardGenerator.areaCode.put("金明区", 410211); + IdCardGenerator.areaCode.put("杞 县", 410221); + IdCardGenerator.areaCode.put("通许县", 410222); + IdCardGenerator.areaCode.put("尉氏县", 410223); + IdCardGenerator.areaCode.put("开封县", 410224); + IdCardGenerator.areaCode.put("兰考县", 410225); + IdCardGenerator.areaCode.put("洛阳市", 410300); + IdCardGenerator.areaCode.put("市辖区", 410301); + IdCardGenerator.areaCode.put("老城区", 410302); + IdCardGenerator.areaCode.put("西工区", 410303); + IdCardGenerator.areaCode.put("瀍河回族区", 410304); + IdCardGenerator.areaCode.put("涧西区", 410305); + IdCardGenerator.areaCode.put("吉利区", 410306); + IdCardGenerator.areaCode.put("洛龙区", 410311); + IdCardGenerator.areaCode.put("孟津县", 410322); + IdCardGenerator.areaCode.put("新安县", 410323); + IdCardGenerator.areaCode.put("栾川县", 410324); + IdCardGenerator.areaCode.put("嵩 县", 410325); + IdCardGenerator.areaCode.put("汝阳县", 410326); + IdCardGenerator.areaCode.put("宜阳县", 410327); + IdCardGenerator.areaCode.put("洛宁县", 410328); + IdCardGenerator.areaCode.put("伊川县", 410329); + IdCardGenerator.areaCode.put("偃师市", 410381); + IdCardGenerator.areaCode.put("平顶山市", 410400); + IdCardGenerator.areaCode.put("市辖区", 410401); + IdCardGenerator.areaCode.put("新华区", 410402); + IdCardGenerator.areaCode.put("卫东区", 410403); + IdCardGenerator.areaCode.put("石龙区", 410404); + IdCardGenerator.areaCode.put("湛河区", 410411); + IdCardGenerator.areaCode.put("宝丰县", 410421); + IdCardGenerator.areaCode.put("叶 县", 410422); + IdCardGenerator.areaCode.put("鲁山县", 410423); + IdCardGenerator.areaCode.put("郏 县", 410425); + IdCardGenerator.areaCode.put("舞钢市", 410481); + IdCardGenerator.areaCode.put("汝州市", 410482); + IdCardGenerator.areaCode.put("安阳市", 410500); + IdCardGenerator.areaCode.put("市辖区", 410501); + IdCardGenerator.areaCode.put("文峰区", 410502); + IdCardGenerator.areaCode.put("北关区", 410503); + IdCardGenerator.areaCode.put("殷都区", 410505); + IdCardGenerator.areaCode.put("龙安区", 410506); + IdCardGenerator.areaCode.put("安阳县", 410522); + IdCardGenerator.areaCode.put("汤阴县", 410523); + IdCardGenerator.areaCode.put("滑 县", 410526); + IdCardGenerator.areaCode.put("内黄县", 410527); + IdCardGenerator.areaCode.put("林州市", 410581); + IdCardGenerator.areaCode.put("鹤壁市", 410600); + IdCardGenerator.areaCode.put("市辖区", 410601); + IdCardGenerator.areaCode.put("鹤山区", 410602); + IdCardGenerator.areaCode.put("山城区", 410603); + IdCardGenerator.areaCode.put("淇滨区", 410611); + IdCardGenerator.areaCode.put("浚 县", 410621); + IdCardGenerator.areaCode.put("淇 县", 410622); + IdCardGenerator.areaCode.put("新乡市", 410700); + IdCardGenerator.areaCode.put("市辖区", 410701); + IdCardGenerator.areaCode.put("红旗区", 410702); + IdCardGenerator.areaCode.put("卫滨区", 410703); + IdCardGenerator.areaCode.put("凤泉区", 410704); + IdCardGenerator.areaCode.put("牧野区", 410711); + IdCardGenerator.areaCode.put("新乡县", 410721); + IdCardGenerator.areaCode.put("获嘉县", 410724); + IdCardGenerator.areaCode.put("原阳县", 410725); + IdCardGenerator.areaCode.put("延津县", 410726); + IdCardGenerator.areaCode.put("封丘县", 410727); + IdCardGenerator.areaCode.put("长垣县", 410728); + IdCardGenerator.areaCode.put("卫辉市", 410781); + IdCardGenerator.areaCode.put("辉县市", 410782); + IdCardGenerator.areaCode.put("焦作市", 410800); + IdCardGenerator.areaCode.put("市辖区", 410801); + IdCardGenerator.areaCode.put("解放区", 410802); + IdCardGenerator.areaCode.put("中站区", 410803); + IdCardGenerator.areaCode.put("马村区", 410804); + IdCardGenerator.areaCode.put("山阳区", 410811); + IdCardGenerator.areaCode.put("修武县", 410821); + IdCardGenerator.areaCode.put("博爱县", 410822); + IdCardGenerator.areaCode.put("武陟县", 410823); + IdCardGenerator.areaCode.put("温 县", 410825); + IdCardGenerator.areaCode.put("沁阳市", 410882); + IdCardGenerator.areaCode.put("孟州市", 410883); + IdCardGenerator.areaCode.put("濮阳市", 410900); + IdCardGenerator.areaCode.put("市辖区", 410901); + IdCardGenerator.areaCode.put("华龙区", 410902); + IdCardGenerator.areaCode.put("清丰县", 410922); + IdCardGenerator.areaCode.put("南乐县", 410923); + IdCardGenerator.areaCode.put("范 县", 410926); + IdCardGenerator.areaCode.put("台前县", 410927); + IdCardGenerator.areaCode.put("濮阳县", 410928); + IdCardGenerator.areaCode.put("许昌市", 411000); + IdCardGenerator.areaCode.put("市辖区", 411001); + IdCardGenerator.areaCode.put("魏都区", 411002); + IdCardGenerator.areaCode.put("许昌县", 411023); + IdCardGenerator.areaCode.put("鄢陵县", 411024); + IdCardGenerator.areaCode.put("襄城县", 411025); + IdCardGenerator.areaCode.put("禹州市", 411081); + IdCardGenerator.areaCode.put("长葛市", 411082); + IdCardGenerator.areaCode.put("漯河市", 411100); + IdCardGenerator.areaCode.put("市辖区", 411101); + IdCardGenerator.areaCode.put("源汇区", 411102); + IdCardGenerator.areaCode.put("郾城区", 411103); + IdCardGenerator.areaCode.put("召陵区", 411104); + IdCardGenerator.areaCode.put("舞阳县", 411121); + IdCardGenerator.areaCode.put("临颍县", 411122); + IdCardGenerator.areaCode.put("三门峡市", 411200); + IdCardGenerator.areaCode.put("市辖区", 411201); + IdCardGenerator.areaCode.put("湖滨区", 411202); + IdCardGenerator.areaCode.put("渑池县", 411221); + IdCardGenerator.areaCode.put("陕 县", 411222); + IdCardGenerator.areaCode.put("卢氏县", 411224); + IdCardGenerator.areaCode.put("义马市", 411281); + IdCardGenerator.areaCode.put("灵宝市", 411282); + IdCardGenerator.areaCode.put("南阳市", 411300); + IdCardGenerator.areaCode.put("市辖区", 411301); + IdCardGenerator.areaCode.put("宛城区", 411302); + IdCardGenerator.areaCode.put("卧龙区", 411303); + IdCardGenerator.areaCode.put("南召县", 411321); + IdCardGenerator.areaCode.put("方城县", 411322); + IdCardGenerator.areaCode.put("西峡县", 411323); + IdCardGenerator.areaCode.put("镇平县", 411324); + IdCardGenerator.areaCode.put("内乡县", 411325); + IdCardGenerator.areaCode.put("淅川县", 411326); + IdCardGenerator.areaCode.put("社旗县", 411327); + IdCardGenerator.areaCode.put("唐河县", 411328); + IdCardGenerator.areaCode.put("新野县", 411329); + IdCardGenerator.areaCode.put("桐柏县", 411330); + IdCardGenerator.areaCode.put("邓州市", 411381); + IdCardGenerator.areaCode.put("商丘市", 411400); + IdCardGenerator.areaCode.put("市辖区", 411401); + IdCardGenerator.areaCode.put("梁园区", 411402); + IdCardGenerator.areaCode.put("睢阳区", 411403); + IdCardGenerator.areaCode.put("民权县", 411421); + IdCardGenerator.areaCode.put("睢 县", 411422); + IdCardGenerator.areaCode.put("宁陵县", 411423); + IdCardGenerator.areaCode.put("柘城县", 411424); + IdCardGenerator.areaCode.put("虞城县", 411425); + IdCardGenerator.areaCode.put("夏邑县", 411426); + IdCardGenerator.areaCode.put("永城市", 411481); + IdCardGenerator.areaCode.put("信阳市", 411500); + IdCardGenerator.areaCode.put("市辖区", 411501); + IdCardGenerator.areaCode.put("浉河区", 411502); + IdCardGenerator.areaCode.put("平桥区", 411503); + IdCardGenerator.areaCode.put("罗山县", 411521); + IdCardGenerator.areaCode.put("光山县", 411522); + IdCardGenerator.areaCode.put("新 县", 411523); + IdCardGenerator.areaCode.put("商城县", 411524); + IdCardGenerator.areaCode.put("固始县", 411525); + IdCardGenerator.areaCode.put("潢川县", 411526); + IdCardGenerator.areaCode.put("淮滨县", 411527); + IdCardGenerator.areaCode.put("息 县", 411528); + IdCardGenerator.areaCode.put("周口市", 411600); + IdCardGenerator.areaCode.put("市辖区", 411601); + IdCardGenerator.areaCode.put("川汇区", 411602); + IdCardGenerator.areaCode.put("扶沟县", 411621); + IdCardGenerator.areaCode.put("西华县", 411622); + IdCardGenerator.areaCode.put("商水县", 411623); + IdCardGenerator.areaCode.put("沈丘县", 411624); + IdCardGenerator.areaCode.put("郸城县", 411625); + IdCardGenerator.areaCode.put("淮阳县", 411626); + IdCardGenerator.areaCode.put("太康县", 411627); + IdCardGenerator.areaCode.put("鹿邑县", 411628); + IdCardGenerator.areaCode.put("项城市", 411681); + IdCardGenerator.areaCode.put("驻马店市", 411700); + IdCardGenerator.areaCode.put("市辖区", 411701); + IdCardGenerator.areaCode.put("驿城区", 411702); + IdCardGenerator.areaCode.put("西平县", 411721); + IdCardGenerator.areaCode.put("上蔡县", 411722); + IdCardGenerator.areaCode.put("平舆县", 411723); + IdCardGenerator.areaCode.put("正阳县", 411724); + IdCardGenerator.areaCode.put("确山县", 411725); + IdCardGenerator.areaCode.put("泌阳县", 411726); + IdCardGenerator.areaCode.put("汝南县", 411727); + IdCardGenerator.areaCode.put("遂平县", 411728); + IdCardGenerator.areaCode.put("新蔡县", 411729); + IdCardGenerator.areaCode.put("济源市", 419001); + IdCardGenerator.areaCode.put("湖北省", 420000); + IdCardGenerator.areaCode.put("武汉市", 420100); + IdCardGenerator.areaCode.put("市辖区", 420101); + IdCardGenerator.areaCode.put("江岸区", 420102); + IdCardGenerator.areaCode.put("江汉区", 420103); + IdCardGenerator.areaCode.put("硚口区", 420104); + IdCardGenerator.areaCode.put("汉阳区", 420105); + IdCardGenerator.areaCode.put("武昌区", 420106); + IdCardGenerator.areaCode.put("青山区", 420107); + IdCardGenerator.areaCode.put("洪山区", 420111); + IdCardGenerator.areaCode.put("东西湖区", 420112); + IdCardGenerator.areaCode.put("汉南区", 420113); + IdCardGenerator.areaCode.put("蔡甸区", 420114); + IdCardGenerator.areaCode.put("江夏区", 420115); + IdCardGenerator.areaCode.put("黄陂区", 420116); + IdCardGenerator.areaCode.put("新洲区", 420117); + IdCardGenerator.areaCode.put("黄石市", 420200); + IdCardGenerator.areaCode.put("市辖区", 420201); + IdCardGenerator.areaCode.put("黄石港区", 420202); + IdCardGenerator.areaCode.put("西塞山区", 420203); + IdCardGenerator.areaCode.put("下陆区", 420204); + IdCardGenerator.areaCode.put("铁山区", 420205); + IdCardGenerator.areaCode.put("阳新县", 420222); + IdCardGenerator.areaCode.put("大冶市", 420281); + IdCardGenerator.areaCode.put("十堰市", 420300); + IdCardGenerator.areaCode.put("市辖区", 420301); + IdCardGenerator.areaCode.put("茅箭区", 420302); + IdCardGenerator.areaCode.put("张湾区", 420303); + IdCardGenerator.areaCode.put("郧 县", 420321); + IdCardGenerator.areaCode.put("郧西县", 420322); + IdCardGenerator.areaCode.put("竹山县", 420323); + IdCardGenerator.areaCode.put("竹溪县", 420324); + IdCardGenerator.areaCode.put("房 县", 420325); + IdCardGenerator.areaCode.put("丹江口市", 420381); + IdCardGenerator.areaCode.put("宜昌市", 420500); + IdCardGenerator.areaCode.put("市辖区", 420501); + IdCardGenerator.areaCode.put("西陵区", 420502); + IdCardGenerator.areaCode.put("伍家岗区", 420503); + IdCardGenerator.areaCode.put("点军区", 420504); + IdCardGenerator.areaCode.put("猇亭区", 420505); + IdCardGenerator.areaCode.put("夷陵区", 420506); + IdCardGenerator.areaCode.put("远安县", 420525); + IdCardGenerator.areaCode.put("兴山县", 420526); + IdCardGenerator.areaCode.put("秭归县", 420527); + IdCardGenerator.areaCode.put("长阳土家族自治县", 420528); + IdCardGenerator.areaCode.put("五峰土家族自治县", 420529); + IdCardGenerator.areaCode.put("宜都市", 420581); + IdCardGenerator.areaCode.put("当阳市", 420582); + IdCardGenerator.areaCode.put("枝江市", 420583); + IdCardGenerator.areaCode.put("襄樊市", 420600); + IdCardGenerator.areaCode.put("市辖区", 420601); + IdCardGenerator.areaCode.put("襄城区", 420602); + IdCardGenerator.areaCode.put("樊城区", 420606); + IdCardGenerator.areaCode.put("襄阳区", 420607); + IdCardGenerator.areaCode.put("南漳县", 420624); + IdCardGenerator.areaCode.put("谷城县", 420625); + IdCardGenerator.areaCode.put("保康县", 420626); + IdCardGenerator.areaCode.put("老河口市", 420682); + IdCardGenerator.areaCode.put("枣阳市", 420683); + IdCardGenerator.areaCode.put("宜城市", 420684); + IdCardGenerator.areaCode.put("鄂州市", 420700); + IdCardGenerator.areaCode.put("市辖区", 420701); + IdCardGenerator.areaCode.put("梁子湖区", 420702); + IdCardGenerator.areaCode.put("华容区", 420703); + IdCardGenerator.areaCode.put("鄂城区", 420704); + IdCardGenerator.areaCode.put("荆门市", 420800); + IdCardGenerator.areaCode.put("市辖区", 420801); + IdCardGenerator.areaCode.put("东宝区", 420802); + IdCardGenerator.areaCode.put("掇刀区", 420804); + IdCardGenerator.areaCode.put("京山县", 420821); + IdCardGenerator.areaCode.put("沙洋县", 420822); + IdCardGenerator.areaCode.put("钟祥市", 420881); + IdCardGenerator.areaCode.put("孝感市", 420900); + IdCardGenerator.areaCode.put("市辖区", 420901); + IdCardGenerator.areaCode.put("孝南区", 420902); + IdCardGenerator.areaCode.put("孝昌县", 420921); + IdCardGenerator.areaCode.put("大悟县", 420922); + IdCardGenerator.areaCode.put("云梦县", 420923); + IdCardGenerator.areaCode.put("应城市", 420981); + IdCardGenerator.areaCode.put("安陆市", 420982); + IdCardGenerator.areaCode.put("汉川市", 420984); + IdCardGenerator.areaCode.put("荆州市", 421000); + IdCardGenerator.areaCode.put("市辖区", 421001); + IdCardGenerator.areaCode.put("沙市区", 421002); + IdCardGenerator.areaCode.put("荆州区", 421003); + IdCardGenerator.areaCode.put("公安县", 421022); + IdCardGenerator.areaCode.put("监利县", 421023); + IdCardGenerator.areaCode.put("江陵县", 421024); + IdCardGenerator.areaCode.put("石首市", 421081); + IdCardGenerator.areaCode.put("洪湖市", 421083); + IdCardGenerator.areaCode.put("松滋市", 421087); + IdCardGenerator.areaCode.put("黄冈市", 421100); + IdCardGenerator.areaCode.put("市辖区", 421101); + IdCardGenerator.areaCode.put("黄州区", 421102); + IdCardGenerator.areaCode.put("团风县", 421121); + IdCardGenerator.areaCode.put("红安县", 421122); + IdCardGenerator.areaCode.put("罗田县", 421123); + IdCardGenerator.areaCode.put("英山县", 421124); + IdCardGenerator.areaCode.put("浠水县", 421125); + IdCardGenerator.areaCode.put("蕲春县", 421126); + IdCardGenerator.areaCode.put("黄梅县", 421127); + IdCardGenerator.areaCode.put("麻城市", 421181); + IdCardGenerator.areaCode.put("武穴市", 421182); + IdCardGenerator.areaCode.put("咸宁市", 421200); + IdCardGenerator.areaCode.put("市辖区", 421201); + IdCardGenerator.areaCode.put("咸安区", 421202); + IdCardGenerator.areaCode.put("嘉鱼县", 421221); + IdCardGenerator.areaCode.put("通城县", 421222); + IdCardGenerator.areaCode.put("崇阳县", 421223); + IdCardGenerator.areaCode.put("通山县", 421224); + IdCardGenerator.areaCode.put("赤壁市", 421281); + IdCardGenerator.areaCode.put("随州市", 421300); + IdCardGenerator.areaCode.put("市辖区", 421301); + IdCardGenerator.areaCode.put("曾都区 (*)", 421303); + IdCardGenerator.areaCode.put("广水市", 421381); + IdCardGenerator.areaCode.put("恩施土家族苗族自治州", 422800); + IdCardGenerator.areaCode.put("恩施市", 422801); + IdCardGenerator.areaCode.put("利川市", 422802); + IdCardGenerator.areaCode.put("建始县", 422822); + IdCardGenerator.areaCode.put("巴东县", 422823); + IdCardGenerator.areaCode.put("宣恩县", 422825); + IdCardGenerator.areaCode.put("咸丰县", 422826); + IdCardGenerator.areaCode.put("来凤县", 422827); + IdCardGenerator.areaCode.put("鹤峰县", 422828); + IdCardGenerator.areaCode.put("省直辖县级行政区划", 429000); + IdCardGenerator.areaCode.put("仙桃市", 429004); + IdCardGenerator.areaCode.put("潜江市", 429005); + IdCardGenerator.areaCode.put("天门市", 429006); + IdCardGenerator.areaCode.put("神农架林区", 429021); + IdCardGenerator.areaCode.put("湖南省", 430000); + IdCardGenerator.areaCode.put("长沙市", 430100); + IdCardGenerator.areaCode.put("市辖区", 430101); + IdCardGenerator.areaCode.put("芙蓉区", 430102); + IdCardGenerator.areaCode.put("天心区", 430103); + IdCardGenerator.areaCode.put("岳麓区", 430104); + IdCardGenerator.areaCode.put("开福区", 430105); + IdCardGenerator.areaCode.put("雨花区", 430111); + IdCardGenerator.areaCode.put("长沙县", 430121); + IdCardGenerator.areaCode.put("望城县", 430122); + IdCardGenerator.areaCode.put("宁乡县", 430124); + IdCardGenerator.areaCode.put("浏阳市", 430181); + IdCardGenerator.areaCode.put("株洲市", 430200); + IdCardGenerator.areaCode.put("市辖区", 430201); + IdCardGenerator.areaCode.put("荷塘区", 430202); + IdCardGenerator.areaCode.put("芦淞区", 430203); + IdCardGenerator.areaCode.put("石峰区", 430204); + IdCardGenerator.areaCode.put("天元区", 430211); + IdCardGenerator.areaCode.put("株洲县", 430221); + IdCardGenerator.areaCode.put("攸 县", 430223); + IdCardGenerator.areaCode.put("茶陵县", 430224); + IdCardGenerator.areaCode.put("炎陵县", 430225); + IdCardGenerator.areaCode.put("醴陵市", 430281); + IdCardGenerator.areaCode.put("湘潭市", 430300); + IdCardGenerator.areaCode.put("市辖区", 430301); + IdCardGenerator.areaCode.put("雨湖区", 430302); + IdCardGenerator.areaCode.put("岳塘区", 430304); + IdCardGenerator.areaCode.put("湘潭县", 430321); + IdCardGenerator.areaCode.put("湘乡市", 430381); + IdCardGenerator.areaCode.put("韶山市", 430382); + IdCardGenerator.areaCode.put("衡阳市", 430400); + IdCardGenerator.areaCode.put("市辖区", 430401); + IdCardGenerator.areaCode.put("珠晖区", 430405); + IdCardGenerator.areaCode.put("雁峰区", 430406); + IdCardGenerator.areaCode.put("石鼓区", 430407); + IdCardGenerator.areaCode.put("蒸湘区", 430408); + IdCardGenerator.areaCode.put("南岳区", 430412); + IdCardGenerator.areaCode.put("衡阳县", 430421); + IdCardGenerator.areaCode.put("衡南县", 430422); + IdCardGenerator.areaCode.put("衡山县", 430423); + IdCardGenerator.areaCode.put("衡东县", 430424); + IdCardGenerator.areaCode.put("祁东县", 430426); + IdCardGenerator.areaCode.put("耒阳市", 430481); + IdCardGenerator.areaCode.put("常宁市", 430482); + IdCardGenerator.areaCode.put("邵阳市", 430500); + IdCardGenerator.areaCode.put("市辖区", 430501); + IdCardGenerator.areaCode.put("双清区", 430502); + IdCardGenerator.areaCode.put("大祥区", 430503); + IdCardGenerator.areaCode.put("北塔区", 430511); + IdCardGenerator.areaCode.put("邵东县", 430521); + IdCardGenerator.areaCode.put("新邵县", 430522); + IdCardGenerator.areaCode.put("邵阳县", 430523); + IdCardGenerator.areaCode.put("隆回县", 430524); + IdCardGenerator.areaCode.put("洞口县", 430525); + IdCardGenerator.areaCode.put("绥宁县", 430527); + IdCardGenerator.areaCode.put("新宁县", 430528); + IdCardGenerator.areaCode.put("城步苗族自治县", 430529); + IdCardGenerator.areaCode.put("武冈市", 430581); + IdCardGenerator.areaCode.put("岳阳市", 430600); + IdCardGenerator.areaCode.put("市辖区", 430601); + IdCardGenerator.areaCode.put("岳阳楼区", 430602); + IdCardGenerator.areaCode.put("云溪区", 430603); + IdCardGenerator.areaCode.put("君山区", 430611); + IdCardGenerator.areaCode.put("岳阳县", 430621); + IdCardGenerator.areaCode.put("华容县", 430623); + IdCardGenerator.areaCode.put("湘阴县", 430624); + IdCardGenerator.areaCode.put("平江县", 430626); + IdCardGenerator.areaCode.put("汨罗市", 430681); + IdCardGenerator.areaCode.put("临湘市", 430682); + IdCardGenerator.areaCode.put("常德市", 430700); + IdCardGenerator.areaCode.put("市辖区", 430701); + IdCardGenerator.areaCode.put("武陵区", 430702); + IdCardGenerator.areaCode.put("鼎城区", 430703); + IdCardGenerator.areaCode.put("安乡县", 430721); + IdCardGenerator.areaCode.put("汉寿县", 430722); + IdCardGenerator.areaCode.put("澧 县", 430723); + IdCardGenerator.areaCode.put("临澧县", 430724); + IdCardGenerator.areaCode.put("桃源县", 430725); + IdCardGenerator.areaCode.put("石门县", 430726); + IdCardGenerator.areaCode.put("津市市", 430781); + IdCardGenerator.areaCode.put("张家界市", 430800); + IdCardGenerator.areaCode.put("市辖区", 430801); + IdCardGenerator.areaCode.put("永定区", 430802); + IdCardGenerator.areaCode.put("武陵源区", 430811); + IdCardGenerator.areaCode.put("慈利县", 430821); + IdCardGenerator.areaCode.put("桑植县", 430822); + IdCardGenerator.areaCode.put("益阳市", 430900); + IdCardGenerator.areaCode.put("市辖区", 430901); + IdCardGenerator.areaCode.put("资阳区", 430902); + IdCardGenerator.areaCode.put("赫山区", 430903); + IdCardGenerator.areaCode.put("南 县", 430921); + IdCardGenerator.areaCode.put("桃江县", 430922); + IdCardGenerator.areaCode.put("安化县", 430923); + IdCardGenerator.areaCode.put("沅江市", 430981); + IdCardGenerator.areaCode.put("郴州市", 431000); + IdCardGenerator.areaCode.put("市辖区", 431001); + IdCardGenerator.areaCode.put("北湖区", 431002); + IdCardGenerator.areaCode.put("苏仙区", 431003); + IdCardGenerator.areaCode.put("桂阳县", 431021); + IdCardGenerator.areaCode.put("宜章县", 431022); + IdCardGenerator.areaCode.put("永兴县", 431023); + IdCardGenerator.areaCode.put("嘉禾县", 431024); + IdCardGenerator.areaCode.put("临武县", 431025); + IdCardGenerator.areaCode.put("汝城县", 431026); + IdCardGenerator.areaCode.put("桂东县", 431027); + IdCardGenerator.areaCode.put("安仁县", 431028); + IdCardGenerator.areaCode.put("资兴市", 431081); + IdCardGenerator.areaCode.put("永州市", 431100); + IdCardGenerator.areaCode.put("市辖区", 431101); + IdCardGenerator.areaCode.put("零陵区", 431102); + IdCardGenerator.areaCode.put("冷水滩区", 431103); + IdCardGenerator.areaCode.put("祁阳县", 431121); + IdCardGenerator.areaCode.put("东安县", 431122); + IdCardGenerator.areaCode.put("双牌县", 431123); + IdCardGenerator.areaCode.put("道 县", 431124); + IdCardGenerator.areaCode.put("江永县", 431125); + IdCardGenerator.areaCode.put("宁远县", 431126); + IdCardGenerator.areaCode.put("蓝山县", 431127); + IdCardGenerator.areaCode.put("新田县", 431128); + IdCardGenerator.areaCode.put("江华瑶族自治县", 431129); + IdCardGenerator.areaCode.put("怀化市", 431200); + IdCardGenerator.areaCode.put("市辖区", 431201); + IdCardGenerator.areaCode.put("鹤城区", 431202); + IdCardGenerator.areaCode.put("中方县", 431221); + IdCardGenerator.areaCode.put("沅陵县", 431222); + IdCardGenerator.areaCode.put("辰溪县", 431223); + IdCardGenerator.areaCode.put("溆浦县", 431224); + IdCardGenerator.areaCode.put("会同县", 431225); + IdCardGenerator.areaCode.put("麻阳苗族自治县", 431226); + IdCardGenerator.areaCode.put("新晃侗族自治县", 431227); + IdCardGenerator.areaCode.put("芷江侗族自治县", 431228); + IdCardGenerator.areaCode.put("靖州苗族侗族自治县", 431229); + IdCardGenerator.areaCode.put("通道侗族自治县", 431230); + IdCardGenerator.areaCode.put("洪江市", 431281); + IdCardGenerator.areaCode.put("娄底市", 431300); + IdCardGenerator.areaCode.put("市辖区", 431301); + IdCardGenerator.areaCode.put("娄星区", 431302); + IdCardGenerator.areaCode.put("双峰县", 431321); + IdCardGenerator.areaCode.put("新化县", 431322); + IdCardGenerator.areaCode.put("冷水江市", 431381); + IdCardGenerator.areaCode.put("涟源市", 431382); + IdCardGenerator.areaCode.put("湘西土家族苗族自治州", 433100); + IdCardGenerator.areaCode.put("吉首市", 433101); + IdCardGenerator.areaCode.put("泸溪县", 433122); + IdCardGenerator.areaCode.put("凤凰县", 433123); + IdCardGenerator.areaCode.put("花垣县", 433124); + IdCardGenerator.areaCode.put("保靖县", 433125); + IdCardGenerator.areaCode.put("古丈县", 433126); + IdCardGenerator.areaCode.put("永顺县", 433127); + IdCardGenerator.areaCode.put("龙山县", 433130); + IdCardGenerator.areaCode.put("广东省", 440000); + IdCardGenerator.areaCode.put("广州市", 440100); + IdCardGenerator.areaCode.put("市辖区", 440101); + IdCardGenerator.areaCode.put("荔湾区", 440103); + IdCardGenerator.areaCode.put("越秀区", 440104); + IdCardGenerator.areaCode.put("海珠区", 440105); + IdCardGenerator.areaCode.put("天河区", 440106); + IdCardGenerator.areaCode.put("白云区", 440111); + IdCardGenerator.areaCode.put("黄埔区", 440112); + IdCardGenerator.areaCode.put("番禺区", 440113); + IdCardGenerator.areaCode.put("花都区", 440114); + IdCardGenerator.areaCode.put("南沙区", 440115); + IdCardGenerator.areaCode.put("萝岗区", 440116); + IdCardGenerator.areaCode.put("增城市", 440183); + IdCardGenerator.areaCode.put("从化市", 440184); + IdCardGenerator.areaCode.put("韶关市", 440200); + IdCardGenerator.areaCode.put("市辖区", 440201); + IdCardGenerator.areaCode.put("武江区", 440203); + IdCardGenerator.areaCode.put("浈江区", 440204); + IdCardGenerator.areaCode.put("曲江区", 440205); + IdCardGenerator.areaCode.put("始兴县", 440222); + IdCardGenerator.areaCode.put("仁化县", 440224); + IdCardGenerator.areaCode.put("翁源县", 440229); + IdCardGenerator.areaCode.put("乳源瑶族自治县", 440232); + IdCardGenerator.areaCode.put("新丰县", 440233); + IdCardGenerator.areaCode.put("乐昌市", 440281); + IdCardGenerator.areaCode.put("南雄市", 440282); + IdCardGenerator.areaCode.put("深圳市", 440300); + IdCardGenerator.areaCode.put("市辖区", 440301); + IdCardGenerator.areaCode.put("罗湖区", 440303); + IdCardGenerator.areaCode.put("福田区", 440304); + IdCardGenerator.areaCode.put("南山区", 440305); + IdCardGenerator.areaCode.put("宝安区", 440306); + IdCardGenerator.areaCode.put("龙岗区", 440307); + IdCardGenerator.areaCode.put("盐田区", 440308); + IdCardGenerator.areaCode.put("珠海市", 440400); + IdCardGenerator.areaCode.put("市辖区", 440401); + IdCardGenerator.areaCode.put("香洲区", 440402); + IdCardGenerator.areaCode.put("斗门区", 440403); + IdCardGenerator.areaCode.put("金湾区", 440404); + IdCardGenerator.areaCode.put("汕头市", 440500); + IdCardGenerator.areaCode.put("市辖区", 440501); + IdCardGenerator.areaCode.put("龙湖区", 440507); + IdCardGenerator.areaCode.put("金平区", 440511); + IdCardGenerator.areaCode.put("濠江区", 440512); + IdCardGenerator.areaCode.put("潮阳区", 440513); + IdCardGenerator.areaCode.put("潮南区", 440514); + IdCardGenerator.areaCode.put("澄海区", 440515); + IdCardGenerator.areaCode.put("南澳县", 440523); + IdCardGenerator.areaCode.put("佛山市", 440600); + IdCardGenerator.areaCode.put("市辖区", 440601); + IdCardGenerator.areaCode.put("禅城区", 440604); + IdCardGenerator.areaCode.put("南海区", 440605); + IdCardGenerator.areaCode.put("顺德区", 440606); + IdCardGenerator.areaCode.put("三水区", 440607); + IdCardGenerator.areaCode.put("高明区", 440608); + IdCardGenerator.areaCode.put("江门市", 440700); + IdCardGenerator.areaCode.put("市辖区", 440701); + IdCardGenerator.areaCode.put("蓬江区", 440703); + IdCardGenerator.areaCode.put("江海区", 440704); + IdCardGenerator.areaCode.put("新会区", 440705); + IdCardGenerator.areaCode.put("台山市", 440781); + IdCardGenerator.areaCode.put("开平市", 440783); + IdCardGenerator.areaCode.put("鹤山市", 440784); + IdCardGenerator.areaCode.put("恩平市", 440785); + IdCardGenerator.areaCode.put("湛江市", 440800); + IdCardGenerator.areaCode.put("市辖区", 440801); + IdCardGenerator.areaCode.put("赤坎区", 440802); + IdCardGenerator.areaCode.put("霞山区", 440803); + IdCardGenerator.areaCode.put("坡头区", 440804); + IdCardGenerator.areaCode.put("麻章区", 440811); + IdCardGenerator.areaCode.put("遂溪县", 440823); + IdCardGenerator.areaCode.put("徐闻县", 440825); + IdCardGenerator.areaCode.put("廉江市", 440881); + IdCardGenerator.areaCode.put("雷州市", 440882); + IdCardGenerator.areaCode.put("吴川市", 440883); + IdCardGenerator.areaCode.put("茂名市", 440900); + IdCardGenerator.areaCode.put("市辖区", 440901); + IdCardGenerator.areaCode.put("茂南区", 440902); + IdCardGenerator.areaCode.put("茂港区", 440903); + IdCardGenerator.areaCode.put("电白县", 440923); + IdCardGenerator.areaCode.put("高州市", 440981); + IdCardGenerator.areaCode.put("化州市", 440982); + IdCardGenerator.areaCode.put("信宜市", 440983); + IdCardGenerator.areaCode.put("肇庆市", 441200); + IdCardGenerator.areaCode.put("市辖区", 441201); + IdCardGenerator.areaCode.put("端州区", 441202); + IdCardGenerator.areaCode.put("鼎湖区", 441203); + IdCardGenerator.areaCode.put("广宁县", 441223); + IdCardGenerator.areaCode.put("怀集县", 441224); + IdCardGenerator.areaCode.put("封开县", 441225); + IdCardGenerator.areaCode.put("德庆县", 441226); + IdCardGenerator.areaCode.put("高要市", 441283); + IdCardGenerator.areaCode.put("四会市", 441284); + IdCardGenerator.areaCode.put("惠州市", 441300); + IdCardGenerator.areaCode.put("市辖区", 441301); + IdCardGenerator.areaCode.put("惠城区", 441302); + IdCardGenerator.areaCode.put("惠阳区", 441303); + IdCardGenerator.areaCode.put("博罗县", 441322); + IdCardGenerator.areaCode.put("惠东县", 441323); + IdCardGenerator.areaCode.put("龙门县", 441324); + IdCardGenerator.areaCode.put("梅州市", 441400); + IdCardGenerator.areaCode.put("市辖区", 441401); + IdCardGenerator.areaCode.put("梅江区", 441402); + IdCardGenerator.areaCode.put("梅 县", 441421); + IdCardGenerator.areaCode.put("大埔县", 441422); + IdCardGenerator.areaCode.put("丰顺县", 441423); + IdCardGenerator.areaCode.put("五华县", 441424); + IdCardGenerator.areaCode.put("平远县", 441426); + IdCardGenerator.areaCode.put("蕉岭县", 441427); + IdCardGenerator.areaCode.put("兴宁市", 441481); + IdCardGenerator.areaCode.put("汕尾市", 441500); + IdCardGenerator.areaCode.put("市辖区", 441501); + IdCardGenerator.areaCode.put("城 区", 441502); + IdCardGenerator.areaCode.put("海丰县", 441521); + IdCardGenerator.areaCode.put("陆河县", 441523); + IdCardGenerator.areaCode.put("陆丰市", 441581); + IdCardGenerator.areaCode.put("河源市", 441600); + IdCardGenerator.areaCode.put("市辖区", 441601); + IdCardGenerator.areaCode.put("源城区", 441602); + IdCardGenerator.areaCode.put("紫金县", 441621); + IdCardGenerator.areaCode.put("龙川县", 441622); + IdCardGenerator.areaCode.put("连平县", 441623); + IdCardGenerator.areaCode.put("和平县", 441624); + IdCardGenerator.areaCode.put("东源县", 441625); + IdCardGenerator.areaCode.put("阳江市", 441700); + IdCardGenerator.areaCode.put("市辖区", 441701); + IdCardGenerator.areaCode.put("江城区", 441702); + IdCardGenerator.areaCode.put("阳西县", 441721); + IdCardGenerator.areaCode.put("阳东县", 441723); + IdCardGenerator.areaCode.put("阳春市", 441781); + IdCardGenerator.areaCode.put("清远市", 441800); + IdCardGenerator.areaCode.put("市辖区", 441801); + IdCardGenerator.areaCode.put("清城区", 441802); + IdCardGenerator.areaCode.put("佛冈县", 441821); + IdCardGenerator.areaCode.put("阳山县", 441823); + IdCardGenerator.areaCode.put("连山壮族瑶族自治县", 441825); + IdCardGenerator.areaCode.put("连南瑶族自治县", 441826); + IdCardGenerator.areaCode.put("清新县", 441827); + IdCardGenerator.areaCode.put("英德市", 441881); + IdCardGenerator.areaCode.put("连州市", 441882); + IdCardGenerator.areaCode.put("东莞市", 441900); + IdCardGenerator.areaCode.put("中山市", 442000); + IdCardGenerator.areaCode.put("潮州市", 445100); + IdCardGenerator.areaCode.put("市辖区", 445101); + IdCardGenerator.areaCode.put("湘桥区", 445102); + IdCardGenerator.areaCode.put("潮安县", 445121); + IdCardGenerator.areaCode.put("饶平县", 445122); + IdCardGenerator.areaCode.put("揭阳市", 445200); + IdCardGenerator.areaCode.put("市辖区", 445201); + IdCardGenerator.areaCode.put("榕城区", 445202); + IdCardGenerator.areaCode.put("揭东县", 445221); + IdCardGenerator.areaCode.put("揭西县", 445222); + IdCardGenerator.areaCode.put("惠来县", 445224); + IdCardGenerator.areaCode.put("普宁市", 445281); + IdCardGenerator.areaCode.put("云浮市", 445300); + IdCardGenerator.areaCode.put("市辖区", 445301); + IdCardGenerator.areaCode.put("云城区", 445302); + IdCardGenerator.areaCode.put("新兴县", 445321); + IdCardGenerator.areaCode.put("郁南县", 445322); + IdCardGenerator.areaCode.put("云安县", 445323); + IdCardGenerator.areaCode.put("罗定市", 445381); + IdCardGenerator.areaCode.put("广西壮族自治区", 450000); + IdCardGenerator.areaCode.put("南宁市", 450100); + IdCardGenerator.areaCode.put("市辖区", 450101); + IdCardGenerator.areaCode.put("兴宁区", 450102); + IdCardGenerator.areaCode.put("青秀区", 450103); + IdCardGenerator.areaCode.put("江南区", 450105); + IdCardGenerator.areaCode.put("西乡塘区", 450107); + IdCardGenerator.areaCode.put("良庆区", 450108); + IdCardGenerator.areaCode.put("邕宁区", 450109); + IdCardGenerator.areaCode.put("武鸣县", 450122); + IdCardGenerator.areaCode.put("隆安县", 450123); + IdCardGenerator.areaCode.put("马山县", 450124); + IdCardGenerator.areaCode.put("上林县", 450125); + IdCardGenerator.areaCode.put("宾阳县", 450126); + IdCardGenerator.areaCode.put("横 县", 450127); + IdCardGenerator.areaCode.put("柳州市", 450200); + IdCardGenerator.areaCode.put("市辖区", 450201); + IdCardGenerator.areaCode.put("城中区", 450202); + IdCardGenerator.areaCode.put("鱼峰区", 450203); + IdCardGenerator.areaCode.put("柳南区", 450204); + IdCardGenerator.areaCode.put("柳北区", 450205); + IdCardGenerator.areaCode.put("柳江县", 450221); + IdCardGenerator.areaCode.put("柳城县", 450222); + IdCardGenerator.areaCode.put("鹿寨县", 450223); + IdCardGenerator.areaCode.put("融安县", 450224); + IdCardGenerator.areaCode.put("融水苗族自治县", 450225); + IdCardGenerator.areaCode.put("三江侗族自治县", 450226); + IdCardGenerator.areaCode.put("桂林市", 450300); + IdCardGenerator.areaCode.put("市辖区", 450301); + IdCardGenerator.areaCode.put("秀峰区", 450302); + IdCardGenerator.areaCode.put("叠彩区", 450303); + IdCardGenerator.areaCode.put("象山区", 450304); + IdCardGenerator.areaCode.put("七星区", 450305); + IdCardGenerator.areaCode.put("雁山区", 450311); + IdCardGenerator.areaCode.put("阳朔县", 450321); + IdCardGenerator.areaCode.put("临桂县", 450322); + IdCardGenerator.areaCode.put("灵川县", 450323); + IdCardGenerator.areaCode.put("全州县", 450324); + IdCardGenerator.areaCode.put("兴安县", 450325); + IdCardGenerator.areaCode.put("永福县", 450326); + IdCardGenerator.areaCode.put("灌阳县", 450327); + IdCardGenerator.areaCode.put("龙胜各族自治县", 450328); + IdCardGenerator.areaCode.put("资源县", 450329); + IdCardGenerator.areaCode.put("平乐县", 450330); + IdCardGenerator.areaCode.put("荔蒲县", 450331); + IdCardGenerator.areaCode.put("恭城瑶族自治县", 450332); + IdCardGenerator.areaCode.put("梧州市", 450400); + IdCardGenerator.areaCode.put("市辖区", 450401); + IdCardGenerator.areaCode.put("万秀区", 450403); + IdCardGenerator.areaCode.put("蝶山区", 450404); + IdCardGenerator.areaCode.put("长洲区", 450405); + IdCardGenerator.areaCode.put("苍梧县", 450421); + IdCardGenerator.areaCode.put("藤 县", 450422); + IdCardGenerator.areaCode.put("蒙山县", 450423); + IdCardGenerator.areaCode.put("岑溪市", 450481); + IdCardGenerator.areaCode.put("北海市", 450500); + IdCardGenerator.areaCode.put("市辖区", 450501); + IdCardGenerator.areaCode.put("海城区", 450502); + IdCardGenerator.areaCode.put("银海区", 450503); + IdCardGenerator.areaCode.put("铁山港区", 450512); + IdCardGenerator.areaCode.put("合浦县", 450521); + IdCardGenerator.areaCode.put("防城港市", 450600); + IdCardGenerator.areaCode.put("市辖区", 450601); + IdCardGenerator.areaCode.put("港口区", 450602); + IdCardGenerator.areaCode.put("防城区", 450603); + IdCardGenerator.areaCode.put("上思县", 450621); + IdCardGenerator.areaCode.put("东兴市", 450681); + IdCardGenerator.areaCode.put("钦州市", 450700); + IdCardGenerator.areaCode.put("市辖区", 450701); + IdCardGenerator.areaCode.put("钦南区", 450702); + IdCardGenerator.areaCode.put("钦北区", 450703); + IdCardGenerator.areaCode.put("灵山县", 450721); + IdCardGenerator.areaCode.put("浦北县", 450722); + IdCardGenerator.areaCode.put("贵港市", 450800); + IdCardGenerator.areaCode.put("市辖区", 450801); + IdCardGenerator.areaCode.put("港北区", 450802); + IdCardGenerator.areaCode.put("港南区", 450803); + IdCardGenerator.areaCode.put("覃塘区", 450804); + IdCardGenerator.areaCode.put("平南县", 450821); + IdCardGenerator.areaCode.put("桂平市", 450881); + IdCardGenerator.areaCode.put("玉林市", 450900); + IdCardGenerator.areaCode.put("市辖区", 450901); + IdCardGenerator.areaCode.put("玉州区", 450902); + IdCardGenerator.areaCode.put("容 县", 450921); + IdCardGenerator.areaCode.put("陆川县", 450922); + IdCardGenerator.areaCode.put("博白县", 450923); + IdCardGenerator.areaCode.put("兴业县", 450924); + IdCardGenerator.areaCode.put("北流市", 450981); + IdCardGenerator.areaCode.put("百色市", 451000); + IdCardGenerator.areaCode.put("市辖区", 451001); + IdCardGenerator.areaCode.put("右江区", 451002); + IdCardGenerator.areaCode.put("田阳县", 451021); + IdCardGenerator.areaCode.put("田东县", 451022); + IdCardGenerator.areaCode.put("平果县", 451023); + IdCardGenerator.areaCode.put("德保县", 451024); + IdCardGenerator.areaCode.put("靖西县", 451025); + IdCardGenerator.areaCode.put("那坡县", 451026); + IdCardGenerator.areaCode.put("凌云县", 451027); + IdCardGenerator.areaCode.put("乐业县", 451028); + IdCardGenerator.areaCode.put("田林县", 451029); + IdCardGenerator.areaCode.put("西林县", 451030); + IdCardGenerator.areaCode.put("隆林各族自治县", 451031); + IdCardGenerator.areaCode.put("贺州市", 451100); + IdCardGenerator.areaCode.put("市辖区", 451101); + IdCardGenerator.areaCode.put("八步区", 451102); + IdCardGenerator.areaCode.put("昭平县", 451121); + IdCardGenerator.areaCode.put("钟山县", 451122); + IdCardGenerator.areaCode.put("富川瑶族自治县", 451123); + IdCardGenerator.areaCode.put("河池市", 451200); + IdCardGenerator.areaCode.put("市辖区", 451201); + IdCardGenerator.areaCode.put("金城江区", 451202); + IdCardGenerator.areaCode.put("南丹县", 451221); + IdCardGenerator.areaCode.put("天峨县", 451222); + IdCardGenerator.areaCode.put("凤山县", 451223); + IdCardGenerator.areaCode.put("东兰县", 451224); + IdCardGenerator.areaCode.put("罗城仫佬族自治县", 451225); + IdCardGenerator.areaCode.put("环江毛南族自治县", 451226); + IdCardGenerator.areaCode.put("巴马瑶族自治县", 451227); + IdCardGenerator.areaCode.put("都安瑶族自治县", 451228); + IdCardGenerator.areaCode.put("大化瑶族自治县", 451229); + IdCardGenerator.areaCode.put("宜州市", 451281); + IdCardGenerator.areaCode.put("来宾市", 451300); + IdCardGenerator.areaCode.put("市辖区", 451301); + IdCardGenerator.areaCode.put("兴宾区", 451302); + IdCardGenerator.areaCode.put("忻城县", 451321); + IdCardGenerator.areaCode.put("象州县", 451322); + IdCardGenerator.areaCode.put("武宣县", 451323); + IdCardGenerator.areaCode.put("金秀瑶族自治县", 451324); + IdCardGenerator.areaCode.put("合山市", 451381); + IdCardGenerator.areaCode.put("崇左市", 451400); + IdCardGenerator.areaCode.put("市辖区", 451401); + IdCardGenerator.areaCode.put("江洲区", 451402); + IdCardGenerator.areaCode.put("扶绥县", 451421); + IdCardGenerator.areaCode.put("宁明县", 451422); + IdCardGenerator.areaCode.put("龙州县", 451423); + IdCardGenerator.areaCode.put("大新县", 451424); + IdCardGenerator.areaCode.put("天等县", 451425); + IdCardGenerator.areaCode.put("凭祥市", 451481); + IdCardGenerator.areaCode.put("海南省", 460000); + IdCardGenerator.areaCode.put("海口市", 460100); + IdCardGenerator.areaCode.put("市辖区", 460101); + IdCardGenerator.areaCode.put("秀英区", 460105); + IdCardGenerator.areaCode.put("龙华区", 460106); + IdCardGenerator.areaCode.put("琼山区", 460107); + IdCardGenerator.areaCode.put("美兰区", 460108); + IdCardGenerator.areaCode.put("三亚市", 460200); + IdCardGenerator.areaCode.put("市辖区", 460201); + IdCardGenerator.areaCode.put("省直辖县级行政区划", 469000); + IdCardGenerator.areaCode.put("五指山市", 469001); + IdCardGenerator.areaCode.put("琼海市", 469002); + IdCardGenerator.areaCode.put("儋州市", 469003); + IdCardGenerator.areaCode.put("文昌市", 469005); + IdCardGenerator.areaCode.put("万宁市", 469006); + IdCardGenerator.areaCode.put("东方市", 469007); + IdCardGenerator.areaCode.put("定安县", 469021); + IdCardGenerator.areaCode.put("屯昌县", 469022); + IdCardGenerator.areaCode.put("澄迈县", 469023); + IdCardGenerator.areaCode.put("临高县", 469024); + IdCardGenerator.areaCode.put("白沙黎族自治县", 469025); + IdCardGenerator.areaCode.put("昌江黎族自治县", 469026); + IdCardGenerator.areaCode.put("乐东黎族自治县", 469027); + IdCardGenerator.areaCode.put("陵水黎族自治县", 469028); + IdCardGenerator.areaCode.put("保亭黎族苗族自治县", 469029); + IdCardGenerator.areaCode.put("琼中黎族苗族自治县", 469030); + IdCardGenerator.areaCode.put("西沙群岛", 469031); + IdCardGenerator.areaCode.put("南沙群岛", 469032); + IdCardGenerator.areaCode.put("中沙群岛的岛礁及其海域", 469033); + IdCardGenerator.areaCode.put("重庆市", 500000); + IdCardGenerator.areaCode.put("市辖区", 500100); + IdCardGenerator.areaCode.put("万州区", 500101); + IdCardGenerator.areaCode.put("涪陵区", 500102); + IdCardGenerator.areaCode.put("渝中区", 500103); + IdCardGenerator.areaCode.put("大渡口区", 500104); + IdCardGenerator.areaCode.put("江北区", 500105); + IdCardGenerator.areaCode.put("沙坪坝区", 500106); + IdCardGenerator.areaCode.put("九龙坡区", 500107); + IdCardGenerator.areaCode.put("南岸区", 500108); + IdCardGenerator.areaCode.put("北碚区", 500109); + IdCardGenerator.areaCode.put("万盛区", 500110); + IdCardGenerator.areaCode.put("双桥区", 500111); + IdCardGenerator.areaCode.put("渝北区", 500112); + IdCardGenerator.areaCode.put("巴南区", 500113); + IdCardGenerator.areaCode.put("黔江区", 500114); + IdCardGenerator.areaCode.put("长寿区", 500115); + IdCardGenerator.areaCode.put("江津区", 500116); + IdCardGenerator.areaCode.put("合川区", 500117); + IdCardGenerator.areaCode.put("永川区", 500118); + IdCardGenerator.areaCode.put("南川区", 500119); + IdCardGenerator.areaCode.put("县", 500200); + IdCardGenerator.areaCode.put("綦江县", 500222); + IdCardGenerator.areaCode.put("潼南县", 500223); + IdCardGenerator.areaCode.put("铜梁县", 500224); + IdCardGenerator.areaCode.put("大足县", 500225); + IdCardGenerator.areaCode.put("荣昌县", 500226); + IdCardGenerator.areaCode.put("璧山县", 500227); + IdCardGenerator.areaCode.put("梁平县", 500228); + IdCardGenerator.areaCode.put("城口县", 500229); + IdCardGenerator.areaCode.put("丰都县", 500230); + IdCardGenerator.areaCode.put("垫江县", 500231); + IdCardGenerator.areaCode.put("武隆县", 500232); + IdCardGenerator.areaCode.put("忠 县", 500233); + IdCardGenerator.areaCode.put("开 县", 500234); + IdCardGenerator.areaCode.put("云阳县", 500235); + IdCardGenerator.areaCode.put("奉节县", 500236); + IdCardGenerator.areaCode.put("巫山县", 500237); + IdCardGenerator.areaCode.put("巫溪县", 500238); + IdCardGenerator.areaCode.put("石柱土家族自治县", 500240); + IdCardGenerator.areaCode.put("秀山土家族苗族自治县", 500241); + IdCardGenerator.areaCode.put("酉阳土家族苗族自治县", 500242); + IdCardGenerator.areaCode.put("彭水苗族土家族自治县", 500243); + IdCardGenerator.areaCode.put("四川省", 510000); + IdCardGenerator.areaCode.put("成都市", 510100); + IdCardGenerator.areaCode.put("市辖区", 510101); + IdCardGenerator.areaCode.put("锦江区", 510104); + IdCardGenerator.areaCode.put("青羊区", 510105); + IdCardGenerator.areaCode.put("金牛区", 510106); + IdCardGenerator.areaCode.put("武侯区", 510107); + IdCardGenerator.areaCode.put("成华区", 510108); + IdCardGenerator.areaCode.put("龙泉驿区", 510112); + IdCardGenerator.areaCode.put("青白江区", 510113); + IdCardGenerator.areaCode.put("新都区", 510114); + IdCardGenerator.areaCode.put("温江区", 510115); + IdCardGenerator.areaCode.put("金堂县", 510121); + IdCardGenerator.areaCode.put("双流县", 510122); + IdCardGenerator.areaCode.put("郫 县", 510124); + IdCardGenerator.areaCode.put("大邑县", 510129); + IdCardGenerator.areaCode.put("蒲江县", 510131); + IdCardGenerator.areaCode.put("新津县", 510132); + IdCardGenerator.areaCode.put("都江堰市", 510181); + IdCardGenerator.areaCode.put("彭州市", 510182); + IdCardGenerator.areaCode.put("邛崃市", 510183); + IdCardGenerator.areaCode.put("崇州市", 510184); + IdCardGenerator.areaCode.put("自贡市", 510300); + IdCardGenerator.areaCode.put("市辖区", 510301); + IdCardGenerator.areaCode.put("自流井区", 510302); + IdCardGenerator.areaCode.put("贡井区", 510303); + IdCardGenerator.areaCode.put("大安区", 510304); + IdCardGenerator.areaCode.put("沿滩区", 510311); + IdCardGenerator.areaCode.put("荣 县", 510321); + IdCardGenerator.areaCode.put("富顺县", 510322); + IdCardGenerator.areaCode.put("攀枝花市", 510400); + IdCardGenerator.areaCode.put("市辖区", 510401); + IdCardGenerator.areaCode.put("东 区", 510402); + IdCardGenerator.areaCode.put("西 区", 510403); + IdCardGenerator.areaCode.put("仁和区", 510411); + IdCardGenerator.areaCode.put("米易县", 510421); + IdCardGenerator.areaCode.put("盐边县", 510422); + IdCardGenerator.areaCode.put("泸州市", 510500); + IdCardGenerator.areaCode.put("市辖区", 510501); + IdCardGenerator.areaCode.put("江阳区", 510502); + IdCardGenerator.areaCode.put("纳溪区", 510503); + IdCardGenerator.areaCode.put("龙马潭区", 510504); + IdCardGenerator.areaCode.put("泸 县", 510521); + IdCardGenerator.areaCode.put("合江县", 510522); + IdCardGenerator.areaCode.put("叙永县", 510524); + IdCardGenerator.areaCode.put("古蔺县", 510525); + IdCardGenerator.areaCode.put("德阳市", 510600); + IdCardGenerator.areaCode.put("市辖区", 510601); + IdCardGenerator.areaCode.put("旌阳区", 510603); + IdCardGenerator.areaCode.put("中江县", 510623); + IdCardGenerator.areaCode.put("罗江县", 510626); + IdCardGenerator.areaCode.put("广汉市", 510681); + IdCardGenerator.areaCode.put("什邡市", 510682); + IdCardGenerator.areaCode.put("绵竹市", 510683); + IdCardGenerator.areaCode.put("绵阳市", 510700); + IdCardGenerator.areaCode.put("市辖区", 510701); + IdCardGenerator.areaCode.put("涪城区", 510703); + IdCardGenerator.areaCode.put("游仙区", 510704); + IdCardGenerator.areaCode.put("三台县", 510722); + IdCardGenerator.areaCode.put("盐亭县", 510723); + IdCardGenerator.areaCode.put("安 县", 510724); + IdCardGenerator.areaCode.put("梓潼县", 510725); + IdCardGenerator.areaCode.put("北川羌族自治县", 510726); + IdCardGenerator.areaCode.put("平武县", 510727); + IdCardGenerator.areaCode.put("江油市", 510781); + IdCardGenerator.areaCode.put("广元市", 510800); + IdCardGenerator.areaCode.put("市辖区", 510801); + IdCardGenerator.areaCode.put("利州区", 510802); + IdCardGenerator.areaCode.put("元坝区", 510811); + IdCardGenerator.areaCode.put("朝天区", 510812); + IdCardGenerator.areaCode.put("旺苍县", 510821); + IdCardGenerator.areaCode.put("青川县", 510822); + IdCardGenerator.areaCode.put("剑阁县", 510823); + IdCardGenerator.areaCode.put("苍溪县", 510824); + IdCardGenerator.areaCode.put("遂宁市", 510900); + IdCardGenerator.areaCode.put("市辖区", 510901); + IdCardGenerator.areaCode.put("船山区", 510903); + IdCardGenerator.areaCode.put("安居区", 510904); + IdCardGenerator.areaCode.put("蓬溪县", 510921); + IdCardGenerator.areaCode.put("射洪县", 510922); + IdCardGenerator.areaCode.put("大英县", 510923); + IdCardGenerator.areaCode.put("内江市", 511000); + IdCardGenerator.areaCode.put("市辖区", 511001); + IdCardGenerator.areaCode.put("市中区", 511002); + IdCardGenerator.areaCode.put("东兴区", 511011); + IdCardGenerator.areaCode.put("威远县", 511024); + IdCardGenerator.areaCode.put("资中县", 511025); + IdCardGenerator.areaCode.put("隆昌县", 511028); + IdCardGenerator.areaCode.put("乐山市", 511100); + IdCardGenerator.areaCode.put("市辖区", 511101); + IdCardGenerator.areaCode.put("市中区", 511102); + IdCardGenerator.areaCode.put("沙湾区", 511111); + IdCardGenerator.areaCode.put("五通桥区", 511112); + IdCardGenerator.areaCode.put("金口河区", 511113); + IdCardGenerator.areaCode.put("犍为县", 511123); + IdCardGenerator.areaCode.put("井研县", 511124); + IdCardGenerator.areaCode.put("夹江县", 511126); + IdCardGenerator.areaCode.put("沐川县", 511129); + IdCardGenerator.areaCode.put("峨边彝族自治县", 511132); + IdCardGenerator.areaCode.put("马边彝族自治县", 511133); + IdCardGenerator.areaCode.put("峨眉山市", 511181); + IdCardGenerator.areaCode.put("南充市", 511300); + IdCardGenerator.areaCode.put("市辖区", 511301); + IdCardGenerator.areaCode.put("顺庆区", 511302); + IdCardGenerator.areaCode.put("高坪区", 511303); + IdCardGenerator.areaCode.put("嘉陵区", 511304); + IdCardGenerator.areaCode.put("南部县", 511321); + IdCardGenerator.areaCode.put("营山县", 511322); + IdCardGenerator.areaCode.put("蓬安县", 511323); + IdCardGenerator.areaCode.put("仪陇县", 511324); + IdCardGenerator.areaCode.put("西充县", 511325); + IdCardGenerator.areaCode.put("阆中市", 511381); + IdCardGenerator.areaCode.put("眉山市", 511400); + IdCardGenerator.areaCode.put("市辖区", 511401); + IdCardGenerator.areaCode.put("东坡区", 511402); + IdCardGenerator.areaCode.put("仁寿县", 511421); + IdCardGenerator.areaCode.put("彭山县", 511422); + IdCardGenerator.areaCode.put("洪雅县", 511423); + IdCardGenerator.areaCode.put("丹棱县", 511424); + IdCardGenerator.areaCode.put("青神县", 511425); + IdCardGenerator.areaCode.put("宜宾市", 511500); + IdCardGenerator.areaCode.put("市辖区", 511501); + IdCardGenerator.areaCode.put("翠屏区", 511502); + IdCardGenerator.areaCode.put("宜宾县", 511521); + IdCardGenerator.areaCode.put("南溪县", 511522); + IdCardGenerator.areaCode.put("江安县", 511523); + IdCardGenerator.areaCode.put("长宁县", 511524); + IdCardGenerator.areaCode.put("高 县", 511525); + IdCardGenerator.areaCode.put("珙 县", 511526); + IdCardGenerator.areaCode.put("筠连县", 511527); + IdCardGenerator.areaCode.put("兴文县", 511528); + IdCardGenerator.areaCode.put("屏山县", 511529); + IdCardGenerator.areaCode.put("广安市", 511600); + IdCardGenerator.areaCode.put("市辖区", 511601); + IdCardGenerator.areaCode.put("广安区", 511602); + IdCardGenerator.areaCode.put("岳池县", 511621); + IdCardGenerator.areaCode.put("武胜县", 511622); + IdCardGenerator.areaCode.put("邻水县", 511623); + IdCardGenerator.areaCode.put("华蓥市", 511681); + IdCardGenerator.areaCode.put("达州市", 511700); + IdCardGenerator.areaCode.put("市辖区", 511701); + IdCardGenerator.areaCode.put("通川区", 511702); + IdCardGenerator.areaCode.put("达 县", 511721); + IdCardGenerator.areaCode.put("宣汉县", 511722); + IdCardGenerator.areaCode.put("开江县", 511723); + IdCardGenerator.areaCode.put("大竹县", 511724); + IdCardGenerator.areaCode.put("渠 县", 511725); + IdCardGenerator.areaCode.put("万源市", 511781); + IdCardGenerator.areaCode.put("雅安市", 511800); + IdCardGenerator.areaCode.put("市辖区", 511801); + IdCardGenerator.areaCode.put("雨城区", 511802); + IdCardGenerator.areaCode.put("名山县", 511821); + IdCardGenerator.areaCode.put("荥经县", 511822); + IdCardGenerator.areaCode.put("汉源县", 511823); + IdCardGenerator.areaCode.put("石棉县", 511824); + IdCardGenerator.areaCode.put("天全县", 511825); + IdCardGenerator.areaCode.put("芦山县", 511826); + IdCardGenerator.areaCode.put("宝兴县", 511827); + IdCardGenerator.areaCode.put("巴中市", 511900); + IdCardGenerator.areaCode.put("市辖区", 511901); + IdCardGenerator.areaCode.put("巴州区", 511902); + IdCardGenerator.areaCode.put("通江县", 511921); + IdCardGenerator.areaCode.put("南江县", 511922); + IdCardGenerator.areaCode.put("平昌县", 511923); + IdCardGenerator.areaCode.put("资阳市", 512000); + IdCardGenerator.areaCode.put("市辖区", 512001); + IdCardGenerator.areaCode.put("雁江区", 512002); + IdCardGenerator.areaCode.put("安岳县", 512021); + IdCardGenerator.areaCode.put("乐至县", 512022); + IdCardGenerator.areaCode.put("简阳市", 512081); + IdCardGenerator.areaCode.put("阿坝藏族羌族自治州", 513200); + IdCardGenerator.areaCode.put("汶川县", 513221); + IdCardGenerator.areaCode.put("理 县", 513222); + IdCardGenerator.areaCode.put("茂 县", 513223); + IdCardGenerator.areaCode.put("松潘县", 513224); + IdCardGenerator.areaCode.put("九寨沟县", 513225); + IdCardGenerator.areaCode.put("金川县", 513226); + IdCardGenerator.areaCode.put("小金县", 513227); + IdCardGenerator.areaCode.put("黑水县", 513228); + IdCardGenerator.areaCode.put("马尔康县", 513229); + IdCardGenerator.areaCode.put("壤塘县", 513230); + IdCardGenerator.areaCode.put("阿坝县", 513231); + IdCardGenerator.areaCode.put("若尔盖县", 513232); + IdCardGenerator.areaCode.put("红原县", 513233); + IdCardGenerator.areaCode.put("甘孜藏族自治州", 513300); + IdCardGenerator.areaCode.put("康定县", 513321); + IdCardGenerator.areaCode.put("泸定县", 513322); + IdCardGenerator.areaCode.put("丹巴县", 513323); + IdCardGenerator.areaCode.put("九龙县", 513324); + IdCardGenerator.areaCode.put("雅江县", 513325); + IdCardGenerator.areaCode.put("道孚县", 513326); + IdCardGenerator.areaCode.put("炉霍县", 513327); + IdCardGenerator.areaCode.put("甘孜县", 513328); + IdCardGenerator.areaCode.put("新龙县", 513329); + IdCardGenerator.areaCode.put("德格县", 513330); + IdCardGenerator.areaCode.put("白玉县", 513331); + IdCardGenerator.areaCode.put("石渠县", 513332); + IdCardGenerator.areaCode.put("色达县", 513333); + IdCardGenerator.areaCode.put("理塘县", 513334); + IdCardGenerator.areaCode.put("巴塘县", 513335); + IdCardGenerator.areaCode.put("乡城县", 513336); + IdCardGenerator.areaCode.put("稻城县", 513337); + IdCardGenerator.areaCode.put("得荣县", 513338); + IdCardGenerator.areaCode.put("凉山彝族自治州", 513400); + IdCardGenerator.areaCode.put("西昌市", 513401); + IdCardGenerator.areaCode.put("木里藏族自治县", 513422); + IdCardGenerator.areaCode.put("盐源县", 513423); + IdCardGenerator.areaCode.put("德昌县", 513424); + IdCardGenerator.areaCode.put("会理县", 513425); + IdCardGenerator.areaCode.put("会东县", 513426); + IdCardGenerator.areaCode.put("宁南县", 513427); + IdCardGenerator.areaCode.put("普格县", 513428); + IdCardGenerator.areaCode.put("布拖县", 513429); + IdCardGenerator.areaCode.put("金阳县", 513430); + IdCardGenerator.areaCode.put("昭觉县", 513431); + IdCardGenerator.areaCode.put("喜德县", 513432); + IdCardGenerator.areaCode.put("冕宁县", 513433); + IdCardGenerator.areaCode.put("越西县", 513434); + IdCardGenerator.areaCode.put("甘洛县", 513435); + IdCardGenerator.areaCode.put("美姑县", 513436); + IdCardGenerator.areaCode.put("雷波县", 513437); + IdCardGenerator.areaCode.put("贵州省", 520000); + IdCardGenerator.areaCode.put("贵阳市", 520100); + IdCardGenerator.areaCode.put("市辖区", 520101); + IdCardGenerator.areaCode.put("南明区", 520102); + IdCardGenerator.areaCode.put("云岩区", 520103); + IdCardGenerator.areaCode.put("花溪区", 520111); + IdCardGenerator.areaCode.put("乌当区", 520112); + IdCardGenerator.areaCode.put("白云区", 520113); + IdCardGenerator.areaCode.put("小河区", 520114); + IdCardGenerator.areaCode.put("开阳县", 520121); + IdCardGenerator.areaCode.put("息烽县", 520122); + IdCardGenerator.areaCode.put("修文县", 520123); + IdCardGenerator.areaCode.put("清镇市", 520181); + IdCardGenerator.areaCode.put("六盘水市", 520200); + IdCardGenerator.areaCode.put("钟山区", 520201); + IdCardGenerator.areaCode.put("六枝特区", 520203); + IdCardGenerator.areaCode.put("水城县", 520221); + IdCardGenerator.areaCode.put("盘 县", 520222); + IdCardGenerator.areaCode.put("遵义市", 520300); + IdCardGenerator.areaCode.put("市辖区", 520301); + IdCardGenerator.areaCode.put("红花岗区", 520302); + IdCardGenerator.areaCode.put("汇川区", 520303); + IdCardGenerator.areaCode.put("遵义县", 520321); + IdCardGenerator.areaCode.put("桐梓县", 520322); + IdCardGenerator.areaCode.put("绥阳县", 520323); + IdCardGenerator.areaCode.put("正安县", 520324); + IdCardGenerator.areaCode.put("道真仡佬族苗族自治县", 520325); + IdCardGenerator.areaCode.put("务川仡佬族苗族自治县", 520326); + IdCardGenerator.areaCode.put("凤冈县", 520327); + IdCardGenerator.areaCode.put("湄潭县", 520328); + IdCardGenerator.areaCode.put("余庆县", 520329); + IdCardGenerator.areaCode.put("习水县", 520330); + IdCardGenerator.areaCode.put("赤水市", 520381); + IdCardGenerator.areaCode.put("仁怀市", 520382); + IdCardGenerator.areaCode.put("安顺市", 520400); + IdCardGenerator.areaCode.put("市辖区", 520401); + IdCardGenerator.areaCode.put("西秀区", 520402); + IdCardGenerator.areaCode.put("平坝县", 520421); + IdCardGenerator.areaCode.put("普定县", 520422); + IdCardGenerator.areaCode.put("镇宁布依族苗族自治县", 520423); + IdCardGenerator.areaCode.put("关岭布依族苗族自治县", 520424); + IdCardGenerator.areaCode.put("紫云苗族布依族自治县", 520425); + IdCardGenerator.areaCode.put("铜仁地区", 522200); + IdCardGenerator.areaCode.put("铜仁市", 522201); + IdCardGenerator.areaCode.put("江口县", 522222); + IdCardGenerator.areaCode.put("玉屏侗族自治县", 522223); + IdCardGenerator.areaCode.put("石阡县", 522224); + IdCardGenerator.areaCode.put("思南县", 522225); + IdCardGenerator.areaCode.put("印江土家族苗族自治县", 522226); + IdCardGenerator.areaCode.put("德江县", 522227); + IdCardGenerator.areaCode.put("沿河土家族自治县", 522228); + IdCardGenerator.areaCode.put("松桃苗族自治县", 522229); + IdCardGenerator.areaCode.put("万山特区", 522230); + IdCardGenerator.areaCode.put("黔西南布依族苗族自治州", 522300); + IdCardGenerator.areaCode.put("兴义市", 522301); + IdCardGenerator.areaCode.put("兴仁县", 522322); + IdCardGenerator.areaCode.put("普安县", 522323); + IdCardGenerator.areaCode.put("晴隆县", 522324); + IdCardGenerator.areaCode.put("贞丰县", 522325); + IdCardGenerator.areaCode.put("望谟县", 522326); + IdCardGenerator.areaCode.put("册亨县", 522327); + IdCardGenerator.areaCode.put("安龙县", 522328); + IdCardGenerator.areaCode.put("毕节地区", 522400); + IdCardGenerator.areaCode.put("毕节市", 522401); + IdCardGenerator.areaCode.put("大方县", 522422); + IdCardGenerator.areaCode.put("黔西县", 522423); + IdCardGenerator.areaCode.put("金沙县", 522424); + IdCardGenerator.areaCode.put("织金县", 522425); + IdCardGenerator.areaCode.put("纳雍县", 522426); + IdCardGenerator.areaCode.put("威宁彝族回族苗族自治县", 522427); + IdCardGenerator.areaCode.put("赫章县", 522428); + IdCardGenerator.areaCode.put("黔东南苗族侗族自治州", 522600); + IdCardGenerator.areaCode.put("凯里市", 522601); + IdCardGenerator.areaCode.put("黄平县", 522622); + IdCardGenerator.areaCode.put("施秉县", 522623); + IdCardGenerator.areaCode.put("三穗县", 522624); + IdCardGenerator.areaCode.put("镇远县", 522625); + IdCardGenerator.areaCode.put("岑巩县", 522626); + IdCardGenerator.areaCode.put("天柱县", 522627); + IdCardGenerator.areaCode.put("锦屏县", 522628); + IdCardGenerator.areaCode.put("剑河县", 522629); + IdCardGenerator.areaCode.put("台江县", 522630); + IdCardGenerator.areaCode.put("黎平县", 522631); + IdCardGenerator.areaCode.put("榕江县", 522632); + IdCardGenerator.areaCode.put("从江县", 522633); + IdCardGenerator.areaCode.put("雷山县", 522634); + IdCardGenerator.areaCode.put("麻江县", 522635); + IdCardGenerator.areaCode.put("丹寨县", 522636); + IdCardGenerator.areaCode.put("黔南布依族苗族自治州", 522700); + IdCardGenerator.areaCode.put("都匀市", 522701); + IdCardGenerator.areaCode.put("福泉市", 522702); + IdCardGenerator.areaCode.put("荔波县", 522722); + IdCardGenerator.areaCode.put("贵定县", 522723); + IdCardGenerator.areaCode.put("瓮安县", 522725); + IdCardGenerator.areaCode.put("独山县", 522726); + IdCardGenerator.areaCode.put("平塘县", 522727); + IdCardGenerator.areaCode.put("罗甸县", 522728); + IdCardGenerator.areaCode.put("长顺县", 522729); + IdCardGenerator.areaCode.put("龙里县", 522730); + IdCardGenerator.areaCode.put("惠水县", 522731); + IdCardGenerator.areaCode.put("三都水族自治县", 522732); + IdCardGenerator.areaCode.put("云南省", 530000); + IdCardGenerator.areaCode.put("昆明市", 530100); + IdCardGenerator.areaCode.put("市辖区", 530101); + IdCardGenerator.areaCode.put("五华区", 530102); + IdCardGenerator.areaCode.put("盘龙区", 530103); + IdCardGenerator.areaCode.put("官渡区", 530111); + IdCardGenerator.areaCode.put("西山区", 530112); + IdCardGenerator.areaCode.put("东川区", 530113); + IdCardGenerator.areaCode.put("呈贡县", 530121); + IdCardGenerator.areaCode.put("晋宁县", 530122); + IdCardGenerator.areaCode.put("富民县", 530124); + IdCardGenerator.areaCode.put("宜良县", 530125); + IdCardGenerator.areaCode.put("石林彝族自治县", 530126); + IdCardGenerator.areaCode.put("嵩明县", 530127); + IdCardGenerator.areaCode.put("禄劝彝族苗族自治县", 530128); + IdCardGenerator.areaCode.put("寻甸回族彝族自治县", 530129); + IdCardGenerator.areaCode.put("安宁市", 530181); + IdCardGenerator.areaCode.put("曲靖市", 530300); + IdCardGenerator.areaCode.put("市辖区", 530301); + IdCardGenerator.areaCode.put("麒麟区", 530302); + IdCardGenerator.areaCode.put("马龙县", 530321); + IdCardGenerator.areaCode.put("陆良县", 530322); + IdCardGenerator.areaCode.put("师宗县", 530323); + IdCardGenerator.areaCode.put("罗平县", 530324); + IdCardGenerator.areaCode.put("富源县", 530325); + IdCardGenerator.areaCode.put("会泽县", 530326); + IdCardGenerator.areaCode.put("沾益县", 530328); + IdCardGenerator.areaCode.put("宣威市", 530381); + IdCardGenerator.areaCode.put("玉溪市", 530400); + IdCardGenerator.areaCode.put("市辖区", 530401); + IdCardGenerator.areaCode.put("红塔区", 530402); + IdCardGenerator.areaCode.put("江川县", 530421); + IdCardGenerator.areaCode.put("澄江县", 530422); + IdCardGenerator.areaCode.put("通海县", 530423); + IdCardGenerator.areaCode.put("华宁县", 530424); + IdCardGenerator.areaCode.put("易门县", 530425); + IdCardGenerator.areaCode.put("峨山彝族自治县", 530426); + IdCardGenerator.areaCode.put("新平彝族傣族自治县", 530427); + IdCardGenerator.areaCode.put("元江哈尼族彝族傣族自治县", 530428); + IdCardGenerator.areaCode.put("保山市", 530500); + IdCardGenerator.areaCode.put("市辖区", 530501); + IdCardGenerator.areaCode.put("隆阳区", 530502); + IdCardGenerator.areaCode.put("施甸县", 530521); + IdCardGenerator.areaCode.put("腾冲县", 530522); + IdCardGenerator.areaCode.put("龙陵县", 530523); + IdCardGenerator.areaCode.put("昌宁县", 530524); + IdCardGenerator.areaCode.put("昭通市", 530600); + IdCardGenerator.areaCode.put("市辖区", 530601); + IdCardGenerator.areaCode.put("昭阳区", 530602); + IdCardGenerator.areaCode.put("鲁甸县", 530621); + IdCardGenerator.areaCode.put("巧家县", 530622); + IdCardGenerator.areaCode.put("盐津县", 530623); + IdCardGenerator.areaCode.put("大关县", 530624); + IdCardGenerator.areaCode.put("永善县", 530625); + IdCardGenerator.areaCode.put("绥江县", 530626); + IdCardGenerator.areaCode.put("镇雄县", 530627); + IdCardGenerator.areaCode.put("彝良县", 530628); + IdCardGenerator.areaCode.put("威信县", 530629); + IdCardGenerator.areaCode.put("水富县", 530630); + IdCardGenerator.areaCode.put("丽江市", 530700); + IdCardGenerator.areaCode.put("市辖区", 530701); + IdCardGenerator.areaCode.put("古城区", 530702); + IdCardGenerator.areaCode.put("玉龙纳西族自治县", 530721); + IdCardGenerator.areaCode.put("永胜县", 530722); + IdCardGenerator.areaCode.put("华坪县", 530723); + IdCardGenerator.areaCode.put("宁蒗彝族自治县", 530724); + IdCardGenerator.areaCode.put("普洱市", 530800); + IdCardGenerator.areaCode.put("市辖区", 530801); + IdCardGenerator.areaCode.put("思茅区", 530802); + IdCardGenerator.areaCode.put("宁洱哈尼族彝族自治县", 530821); + IdCardGenerator.areaCode.put("墨江哈尼族自治县", 530822); + IdCardGenerator.areaCode.put("景东彝族自治县", 530823); + IdCardGenerator.areaCode.put("景谷傣族彝族自治县", 530824); + IdCardGenerator.areaCode.put("镇沅彝族哈尼族拉祜族自治县", 530825); + IdCardGenerator.areaCode.put("江城哈尼族彝族自治县", 530826); + IdCardGenerator.areaCode.put("孟连傣族拉祜族佤族自治县", 530827); + IdCardGenerator.areaCode.put("澜沧拉祜族自治县", 530828); + IdCardGenerator.areaCode.put("西盟佤族自治县", 530829); + IdCardGenerator.areaCode.put("临沧市", 530900); + IdCardGenerator.areaCode.put("市辖区", 530901); + IdCardGenerator.areaCode.put("临翔区", 530902); + IdCardGenerator.areaCode.put("凤庆县", 530921); + IdCardGenerator.areaCode.put("云 县", 530922); + IdCardGenerator.areaCode.put("永德县", 530923); + IdCardGenerator.areaCode.put("镇康县", 530924); + IdCardGenerator.areaCode.put("双江拉祜族佤族布朗族傣族自治县", 530925); + IdCardGenerator.areaCode.put("耿马傣族佤族自治县", 530926); + IdCardGenerator.areaCode.put("沧源佤族自治县", 530927); + IdCardGenerator.areaCode.put("楚雄彝族自治州", 532300); + IdCardGenerator.areaCode.put("楚雄市", 532301); + IdCardGenerator.areaCode.put("双柏县", 532322); + IdCardGenerator.areaCode.put("牟定县", 532323); + IdCardGenerator.areaCode.put("南华县", 532324); + IdCardGenerator.areaCode.put("姚安县", 532325); + IdCardGenerator.areaCode.put("大姚县", 532326); + IdCardGenerator.areaCode.put("永仁县", 532327); + IdCardGenerator.areaCode.put("元谋县", 532328); + IdCardGenerator.areaCode.put("武定县", 532329); + IdCardGenerator.areaCode.put("禄丰县", 532331); + IdCardGenerator.areaCode.put("红河哈尼族彝族自治州", 532500); + IdCardGenerator.areaCode.put("个旧市", 532501); + IdCardGenerator.areaCode.put("开远市", 532502); + IdCardGenerator.areaCode.put("蒙自县", 532522); + IdCardGenerator.areaCode.put("屏边苗族自治县", 532523); + IdCardGenerator.areaCode.put("建水县", 532524); + IdCardGenerator.areaCode.put("石屏县", 532525); + IdCardGenerator.areaCode.put("弥勒县", 532526); + IdCardGenerator.areaCode.put("泸西县", 532527); + IdCardGenerator.areaCode.put("元阳县", 532528); + IdCardGenerator.areaCode.put("红河县", 532529); + IdCardGenerator.areaCode.put("金平苗族瑶族傣族自治县", 532530); + IdCardGenerator.areaCode.put("绿春县", 532531); + IdCardGenerator.areaCode.put("河口瑶族自治县", 532532); + IdCardGenerator.areaCode.put("文山壮族苗族自治州", 532600); + IdCardGenerator.areaCode.put("文山县", 532621); + IdCardGenerator.areaCode.put("砚山县", 532622); + IdCardGenerator.areaCode.put("西畴县", 532623); + IdCardGenerator.areaCode.put("麻栗坡县", 532624); + IdCardGenerator.areaCode.put("马关县", 532625); + IdCardGenerator.areaCode.put("丘北县", 532626); + IdCardGenerator.areaCode.put("广南县", 532627); + IdCardGenerator.areaCode.put("富宁县", 532628); + IdCardGenerator.areaCode.put("西双版纳傣族自治州", 532800); + IdCardGenerator.areaCode.put("景洪市", 532801); + IdCardGenerator.areaCode.put("勐海县", 532822); + IdCardGenerator.areaCode.put("勐腊县", 532823); + IdCardGenerator.areaCode.put("大理白族自治州", 532900); + IdCardGenerator.areaCode.put("大理市", 532901); + IdCardGenerator.areaCode.put("漾濞彝族自治县", 532922); + IdCardGenerator.areaCode.put("祥云县", 532923); + IdCardGenerator.areaCode.put("宾川县", 532924); + IdCardGenerator.areaCode.put("弥渡县", 532925); + IdCardGenerator.areaCode.put("南涧彝族自治县", 532926); + IdCardGenerator.areaCode.put("巍山彝族回族自治县", 532927); + IdCardGenerator.areaCode.put("永平县", 532928); + IdCardGenerator.areaCode.put("云龙县", 532929); + IdCardGenerator.areaCode.put("洱源县", 532930); + IdCardGenerator.areaCode.put("剑川县", 532931); + IdCardGenerator.areaCode.put("鹤庆县", 532932); + IdCardGenerator.areaCode.put("德宏傣族景颇族自治州", 533100); + IdCardGenerator.areaCode.put("瑞丽市", 533102); + IdCardGenerator.areaCode.put("潞西市", 533103); + IdCardGenerator.areaCode.put("梁河县", 533122); + IdCardGenerator.areaCode.put("盈江县", 533123); + IdCardGenerator.areaCode.put("陇川县", 533124); + IdCardGenerator.areaCode.put("怒江傈僳族自治州", 533300); + IdCardGenerator.areaCode.put("泸水县", 533321); + IdCardGenerator.areaCode.put("福贡县", 533323); + IdCardGenerator.areaCode.put("贡山独龙族怒族自治县", 533324); + IdCardGenerator.areaCode.put("兰坪白族普米族自治县", 533325); + IdCardGenerator.areaCode.put("迪庆藏族自治州", 533400); + IdCardGenerator.areaCode.put("香格里拉县", 533421); + IdCardGenerator.areaCode.put("德钦县", 533422); + IdCardGenerator.areaCode.put("维西傈僳族自治县", 533423); + IdCardGenerator.areaCode.put("西藏自治区", 540000); + IdCardGenerator.areaCode.put("拉萨市", 540100); + IdCardGenerator.areaCode.put("市辖区", 540101); + IdCardGenerator.areaCode.put("城关区", 540102); + IdCardGenerator.areaCode.put("林周县", 540121); + IdCardGenerator.areaCode.put("当雄县", 540122); + IdCardGenerator.areaCode.put("尼木县", 540123); + IdCardGenerator.areaCode.put("曲水县", 540124); + IdCardGenerator.areaCode.put("堆龙德庆县", 540125); + IdCardGenerator.areaCode.put("达孜县", 540126); + IdCardGenerator.areaCode.put("墨竹工卡县", 540127); + IdCardGenerator.areaCode.put("昌都地区", 542100); + IdCardGenerator.areaCode.put("昌都县", 542121); + IdCardGenerator.areaCode.put("江达县", 542122); + IdCardGenerator.areaCode.put("贡觉县", 542123); + IdCardGenerator.areaCode.put("类乌齐县", 542124); + IdCardGenerator.areaCode.put("丁青县", 542125); + IdCardGenerator.areaCode.put("察雅县", 542126); + IdCardGenerator.areaCode.put("八宿县", 542127); + IdCardGenerator.areaCode.put("左贡县", 542128); + IdCardGenerator.areaCode.put("芒康县", 542129); + IdCardGenerator.areaCode.put("洛隆县", 542132); + IdCardGenerator.areaCode.put("边坝县", 542133); + IdCardGenerator.areaCode.put("山南地区", 542200); + IdCardGenerator.areaCode.put("乃东县", 542221); + IdCardGenerator.areaCode.put("扎囊县", 542222); + IdCardGenerator.areaCode.put("贡嘎县", 542223); + IdCardGenerator.areaCode.put("桑日县", 542224); + IdCardGenerator.areaCode.put("琼结县", 542225); + IdCardGenerator.areaCode.put("曲松县", 542226); + IdCardGenerator.areaCode.put("措美县", 542227); + IdCardGenerator.areaCode.put("洛扎县", 542228); + IdCardGenerator.areaCode.put("加查县", 542229); + IdCardGenerator.areaCode.put("隆子县", 542231); + IdCardGenerator.areaCode.put("错那县", 542232); + IdCardGenerator.areaCode.put("浪卡子县", 542233); + IdCardGenerator.areaCode.put("日喀则地区", 542300); + IdCardGenerator.areaCode.put("日喀则市", 542301); + IdCardGenerator.areaCode.put("南木林县", 542322); + IdCardGenerator.areaCode.put("江孜县", 542323); + IdCardGenerator.areaCode.put("定日县", 542324); + IdCardGenerator.areaCode.put("萨迦县", 542325); + IdCardGenerator.areaCode.put("拉孜县", 542326); + IdCardGenerator.areaCode.put("昂仁县", 542327); + IdCardGenerator.areaCode.put("谢通门县", 542328); + IdCardGenerator.areaCode.put("白朗县", 542329); + IdCardGenerator.areaCode.put("仁布县", 542330); + IdCardGenerator.areaCode.put("康马县", 542331); + IdCardGenerator.areaCode.put("定结县", 542332); + IdCardGenerator.areaCode.put("仲巴县", 542333); + IdCardGenerator.areaCode.put("亚东县", 542334); + IdCardGenerator.areaCode.put("吉隆县", 542335); + IdCardGenerator.areaCode.put("聂拉木县", 542336); + IdCardGenerator.areaCode.put("萨嘎县", 542337); + IdCardGenerator.areaCode.put("岗巴县", 542338); + IdCardGenerator.areaCode.put("那曲地区", 542400); + IdCardGenerator.areaCode.put("那曲县", 542421); + IdCardGenerator.areaCode.put("嘉黎县", 542422); + IdCardGenerator.areaCode.put("比如县", 542423); + IdCardGenerator.areaCode.put("聂荣县", 542424); + IdCardGenerator.areaCode.put("安多县", 542425); + IdCardGenerator.areaCode.put("申扎县", 542426); + IdCardGenerator.areaCode.put("索 县", 542427); + IdCardGenerator.areaCode.put("班戈县", 542428); + IdCardGenerator.areaCode.put("巴青县", 542429); + IdCardGenerator.areaCode.put("尼玛县", 542430); + IdCardGenerator.areaCode.put("阿里地区", 542500); + IdCardGenerator.areaCode.put("普兰县", 542521); + IdCardGenerator.areaCode.put("札达县", 542522); + IdCardGenerator.areaCode.put("噶尔县", 542523); + IdCardGenerator.areaCode.put("日土县", 542524); + IdCardGenerator.areaCode.put("革吉县", 542525); + IdCardGenerator.areaCode.put("改则县", 542526); + IdCardGenerator.areaCode.put("措勤县", 542527); + IdCardGenerator.areaCode.put("林芝地区", 542600); + IdCardGenerator.areaCode.put("林芝县", 542621); + IdCardGenerator.areaCode.put("工布江达县", 542622); + IdCardGenerator.areaCode.put("米林县", 542623); + IdCardGenerator.areaCode.put("墨脱县", 542624); + IdCardGenerator.areaCode.put("波密县", 542625); + IdCardGenerator.areaCode.put("察隅县", 542626); + IdCardGenerator.areaCode.put("朗 县", 542627); + IdCardGenerator.areaCode.put("陕西省", 610000); + IdCardGenerator.areaCode.put("西安市", 610100); + IdCardGenerator.areaCode.put("市辖区", 610101); + IdCardGenerator.areaCode.put("新城区", 610102); + IdCardGenerator.areaCode.put("碑林区", 610103); + IdCardGenerator.areaCode.put("莲湖区", 610104); + IdCardGenerator.areaCode.put("灞桥区", 610111); + IdCardGenerator.areaCode.put("未央区", 610112); + IdCardGenerator.areaCode.put("雁塔区", 610113); + IdCardGenerator.areaCode.put("阎良区", 610114); + IdCardGenerator.areaCode.put("临潼区", 610115); + IdCardGenerator.areaCode.put("长安区", 610116); + IdCardGenerator.areaCode.put("蓝田县", 610122); + IdCardGenerator.areaCode.put("周至县", 610124); + IdCardGenerator.areaCode.put("户 县", 610125); + IdCardGenerator.areaCode.put("高陵县", 610126); + IdCardGenerator.areaCode.put("铜川市", 610200); + IdCardGenerator.areaCode.put("市辖区", 610201); + IdCardGenerator.areaCode.put("王益区", 610202); + IdCardGenerator.areaCode.put("印台区", 610203); + IdCardGenerator.areaCode.put("耀州区", 610204); + IdCardGenerator.areaCode.put("宜君县", 610222); + IdCardGenerator.areaCode.put("宝鸡市", 610300); + IdCardGenerator.areaCode.put("市辖区", 610301); + IdCardGenerator.areaCode.put("渭滨区", 610302); + IdCardGenerator.areaCode.put("金台区", 610303); + IdCardGenerator.areaCode.put("陈仓区", 610304); + IdCardGenerator.areaCode.put("凤翔县", 610322); + IdCardGenerator.areaCode.put("岐山县", 610323); + IdCardGenerator.areaCode.put("扶风县", 610324); + IdCardGenerator.areaCode.put("眉 县", 610326); + IdCardGenerator.areaCode.put("陇 县", 610327); + IdCardGenerator.areaCode.put("千阳县", 610328); + IdCardGenerator.areaCode.put("麟游县", 610329); + IdCardGenerator.areaCode.put("凤 县", 610330); + IdCardGenerator.areaCode.put("太白县", 610331); + IdCardGenerator.areaCode.put("咸阳市", 610400); + IdCardGenerator.areaCode.put("市辖区", 610401); + IdCardGenerator.areaCode.put("秦都区", 610402); + IdCardGenerator.areaCode.put("杨陵区", 610403); + IdCardGenerator.areaCode.put("渭城区", 610404); + IdCardGenerator.areaCode.put("三原县", 610422); + IdCardGenerator.areaCode.put("泾阳县", 610423); + IdCardGenerator.areaCode.put("乾 县", 610424); + IdCardGenerator.areaCode.put("礼泉县", 610425); + IdCardGenerator.areaCode.put("永寿县", 610426); + IdCardGenerator.areaCode.put("彬 县", 610427); + IdCardGenerator.areaCode.put("长武县", 610428); + IdCardGenerator.areaCode.put("旬邑县", 610429); + IdCardGenerator.areaCode.put("淳化县", 610430); + IdCardGenerator.areaCode.put("武功县", 610431); + IdCardGenerator.areaCode.put("兴平市", 610481); + IdCardGenerator.areaCode.put("渭南市", 610500); + IdCardGenerator.areaCode.put("市辖区", 610501); + IdCardGenerator.areaCode.put("临渭区", 610502); + IdCardGenerator.areaCode.put("华 县", 610521); + IdCardGenerator.areaCode.put("潼关县", 610522); + IdCardGenerator.areaCode.put("大荔县", 610523); + IdCardGenerator.areaCode.put("合阳县", 610524); + IdCardGenerator.areaCode.put("澄城县", 610525); + IdCardGenerator.areaCode.put("蒲城县", 610526); + IdCardGenerator.areaCode.put("白水县", 610527); + IdCardGenerator.areaCode.put("富平县", 610528); + IdCardGenerator.areaCode.put("韩城市", 610581); + IdCardGenerator.areaCode.put("华阴市", 610582); + IdCardGenerator.areaCode.put("延安市", 610600); + IdCardGenerator.areaCode.put("市辖区", 610601); + IdCardGenerator.areaCode.put("宝塔区", 610602); + IdCardGenerator.areaCode.put("延长县", 610621); + IdCardGenerator.areaCode.put("延川县", 610622); + IdCardGenerator.areaCode.put("子长县", 610623); + IdCardGenerator.areaCode.put("安塞县", 610624); + IdCardGenerator.areaCode.put("志丹县", 610625); + IdCardGenerator.areaCode.put("吴起县", 610626); + IdCardGenerator.areaCode.put("甘泉县", 610627); + IdCardGenerator.areaCode.put("富 县", 610628); + IdCardGenerator.areaCode.put("洛川县", 610629); + IdCardGenerator.areaCode.put("宜川县", 610630); + IdCardGenerator.areaCode.put("黄龙县", 610631); + IdCardGenerator.areaCode.put("黄陵县", 610632); + IdCardGenerator.areaCode.put("汉中市", 610700); + IdCardGenerator.areaCode.put("市辖区", 610701); + IdCardGenerator.areaCode.put("汉台区", 610702); + IdCardGenerator.areaCode.put("南郑县", 610721); + IdCardGenerator.areaCode.put("城固县", 610722); + IdCardGenerator.areaCode.put("洋 县", 610723); + IdCardGenerator.areaCode.put("西乡县", 610724); + IdCardGenerator.areaCode.put("勉 县", 610725); + IdCardGenerator.areaCode.put("宁强县", 610726); + IdCardGenerator.areaCode.put("略阳县", 610727); + IdCardGenerator.areaCode.put("镇巴县", 610728); + IdCardGenerator.areaCode.put("留坝县", 610729); + IdCardGenerator.areaCode.put("佛坪县", 610730); + IdCardGenerator.areaCode.put("榆林市", 610800); + IdCardGenerator.areaCode.put("市辖区", 610801); + IdCardGenerator.areaCode.put("榆阳区", 610802); + IdCardGenerator.areaCode.put("神木县", 610821); + IdCardGenerator.areaCode.put("府谷县", 610822); + IdCardGenerator.areaCode.put("横山县", 610823); + IdCardGenerator.areaCode.put("靖边县", 610824); + IdCardGenerator.areaCode.put("定边县", 610825); + IdCardGenerator.areaCode.put("绥德县", 610826); + IdCardGenerator.areaCode.put("米脂县", 610827); + IdCardGenerator.areaCode.put("佳 县", 610828); + IdCardGenerator.areaCode.put("吴堡县", 610829); + IdCardGenerator.areaCode.put("清涧县", 610830); + IdCardGenerator.areaCode.put("子洲县", 610831); + IdCardGenerator.areaCode.put("安康市", 610900); + IdCardGenerator.areaCode.put("市辖区", 610901); + IdCardGenerator.areaCode.put("汉滨区", 610902); + IdCardGenerator.areaCode.put("汉阴县", 610921); + IdCardGenerator.areaCode.put("石泉县", 610922); + IdCardGenerator.areaCode.put("宁陕县", 610923); + IdCardGenerator.areaCode.put("紫阳县", 610924); + IdCardGenerator.areaCode.put("岚皋县", 610925); + IdCardGenerator.areaCode.put("平利县", 610926); + IdCardGenerator.areaCode.put("镇坪县", 610927); + IdCardGenerator.areaCode.put("旬阳县", 610928); + IdCardGenerator.areaCode.put("白河县", 610929); + IdCardGenerator.areaCode.put("商洛市", 611000); + IdCardGenerator.areaCode.put("市辖区", 611001); + IdCardGenerator.areaCode.put("商州区", 611002); + IdCardGenerator.areaCode.put("洛南县", 611021); + IdCardGenerator.areaCode.put("丹凤县", 611022); + IdCardGenerator.areaCode.put("商南县", 611023); + IdCardGenerator.areaCode.put("山阳县", 611024); + IdCardGenerator.areaCode.put("镇安县", 611025); + IdCardGenerator.areaCode.put("柞水县", 611026); + IdCardGenerator.areaCode.put("甘肃省", 620000); + IdCardGenerator.areaCode.put("兰州市", 620100); + IdCardGenerator.areaCode.put("市辖区", 620101); + IdCardGenerator.areaCode.put("城关区", 620102); + IdCardGenerator.areaCode.put("七里河区", 620103); + IdCardGenerator.areaCode.put("西固区", 620104); + IdCardGenerator.areaCode.put("安宁区", 620105); + IdCardGenerator.areaCode.put("红古区", 620111); + IdCardGenerator.areaCode.put("永登县", 620121); + IdCardGenerator.areaCode.put("皋兰县", 620122); + IdCardGenerator.areaCode.put("榆中县", 620123); + IdCardGenerator.areaCode.put("嘉峪关市", 620200); + IdCardGenerator.areaCode.put("市辖区", 620201); + IdCardGenerator.areaCode.put("金昌市", 620300); + IdCardGenerator.areaCode.put("市辖区", 620301); + IdCardGenerator.areaCode.put("金川区", 620302); + IdCardGenerator.areaCode.put("永昌县", 620321); + IdCardGenerator.areaCode.put("白银市", 620400); + IdCardGenerator.areaCode.put("市辖区", 620401); + IdCardGenerator.areaCode.put("白银区", 620402); + IdCardGenerator.areaCode.put("平川区", 620403); + IdCardGenerator.areaCode.put("靖远县", 620421); + IdCardGenerator.areaCode.put("会宁县", 620422); + IdCardGenerator.areaCode.put("景泰县", 620423); + IdCardGenerator.areaCode.put("天水市", 620500); + IdCardGenerator.areaCode.put("市辖区", 620501); + IdCardGenerator.areaCode.put("秦州区", 620502); + IdCardGenerator.areaCode.put("麦积区", 620503); + IdCardGenerator.areaCode.put("清水县", 620521); + IdCardGenerator.areaCode.put("秦安县", 620522); + IdCardGenerator.areaCode.put("甘谷县", 620523); + IdCardGenerator.areaCode.put("武山县", 620524); + IdCardGenerator.areaCode.put("张家川回族自治县", 620525); + IdCardGenerator.areaCode.put("武威市", 620600); + IdCardGenerator.areaCode.put("市辖区", 620601); + IdCardGenerator.areaCode.put("凉州区", 620602); + IdCardGenerator.areaCode.put("民勤县", 620621); + IdCardGenerator.areaCode.put("古浪县", 620622); + IdCardGenerator.areaCode.put("天祝藏族自治县", 620623); + IdCardGenerator.areaCode.put("张掖市", 620700); + IdCardGenerator.areaCode.put("市辖区", 620701); + IdCardGenerator.areaCode.put("甘州区", 620702); + IdCardGenerator.areaCode.put("肃南裕固族自治县", 620721); + IdCardGenerator.areaCode.put("民乐县", 620722); + IdCardGenerator.areaCode.put("临泽县", 620723); + IdCardGenerator.areaCode.put("高台县", 620724); + IdCardGenerator.areaCode.put("山丹县", 620725); + IdCardGenerator.areaCode.put("平凉市", 620800); + IdCardGenerator.areaCode.put("市辖区", 620801); + IdCardGenerator.areaCode.put("崆峒区", 620802); + IdCardGenerator.areaCode.put("泾川县", 620821); + IdCardGenerator.areaCode.put("灵台县", 620822); + IdCardGenerator.areaCode.put("崇信县", 620823); + IdCardGenerator.areaCode.put("华亭县", 620824); + IdCardGenerator.areaCode.put("庄浪县", 620825); + IdCardGenerator.areaCode.put("静宁县", 620826); + IdCardGenerator.areaCode.put("酒泉市", 620900); + IdCardGenerator.areaCode.put("市辖区", 620901); + IdCardGenerator.areaCode.put("肃州区", 620902); + IdCardGenerator.areaCode.put("金塔县", 620921); + IdCardGenerator.areaCode.put("瓜州县", 620922); + IdCardGenerator.areaCode.put("肃北蒙古族自治县", 620923); + IdCardGenerator.areaCode.put("阿克塞哈萨克族自治县", 620924); + IdCardGenerator.areaCode.put("玉门市", 620981); + IdCardGenerator.areaCode.put("敦煌市", 620982); + IdCardGenerator.areaCode.put("庆阳市", 621000); + IdCardGenerator.areaCode.put("市辖区", 621001); + IdCardGenerator.areaCode.put("西峰区", 621002); + IdCardGenerator.areaCode.put("庆城县", 621021); + IdCardGenerator.areaCode.put("环 县", 621022); + IdCardGenerator.areaCode.put("华池县", 621023); + IdCardGenerator.areaCode.put("合水县", 621024); + IdCardGenerator.areaCode.put("正宁县", 621025); + IdCardGenerator.areaCode.put("宁 县", 621026); + IdCardGenerator.areaCode.put("镇原县", 621027); + IdCardGenerator.areaCode.put("定西市", 621100); + IdCardGenerator.areaCode.put("市辖区", 621101); + IdCardGenerator.areaCode.put("安定区", 621102); + IdCardGenerator.areaCode.put("通渭县", 621121); + IdCardGenerator.areaCode.put("陇西县", 621122); + IdCardGenerator.areaCode.put("渭源县", 621123); + IdCardGenerator.areaCode.put("临洮县", 621124); + IdCardGenerator.areaCode.put("漳 县", 621125); + IdCardGenerator.areaCode.put("岷 县", 621126); + IdCardGenerator.areaCode.put("陇南市", 621200); + IdCardGenerator.areaCode.put("市辖区", 621201); + IdCardGenerator.areaCode.put("武都区", 621202); + IdCardGenerator.areaCode.put("成 县", 621221); + IdCardGenerator.areaCode.put("文 县", 621222); + IdCardGenerator.areaCode.put("宕昌县", 621223); + IdCardGenerator.areaCode.put("康 县", 621224); + IdCardGenerator.areaCode.put("西和县", 621225); + IdCardGenerator.areaCode.put("礼 县", 621226); + IdCardGenerator.areaCode.put("徽 县", 621227); + IdCardGenerator.areaCode.put("两当县", 621228); + IdCardGenerator.areaCode.put("临夏回族自治州", 622900); + IdCardGenerator.areaCode.put("临夏市", 622901); + IdCardGenerator.areaCode.put("临夏县", 622921); + IdCardGenerator.areaCode.put("康乐县", 622922); + IdCardGenerator.areaCode.put("永靖县", 622923); + IdCardGenerator.areaCode.put("广河县", 622924); + IdCardGenerator.areaCode.put("和政县", 622925); + IdCardGenerator.areaCode.put("东乡族自治县", 622926); + IdCardGenerator.areaCode.put("积石山保安族东乡族撒拉族自治县", 622927); + IdCardGenerator.areaCode.put("甘南藏族自治州", 623000); + IdCardGenerator.areaCode.put("合作市", 623001); + IdCardGenerator.areaCode.put("临潭县", 623021); + IdCardGenerator.areaCode.put("卓尼县", 623022); + IdCardGenerator.areaCode.put("舟曲县", 623023); + IdCardGenerator.areaCode.put("迭部县", 623024); + IdCardGenerator.areaCode.put("玛曲县", 623025); + IdCardGenerator.areaCode.put("碌曲县", 623026); + IdCardGenerator.areaCode.put("夏河县", 623027); + IdCardGenerator.areaCode.put("青海省", 630000); + IdCardGenerator.areaCode.put("西宁市", 630100); + IdCardGenerator.areaCode.put("市辖区", 630101); + IdCardGenerator.areaCode.put("城东区", 630102); + IdCardGenerator.areaCode.put("城中区", 630103); + IdCardGenerator.areaCode.put("城西区", 630104); + IdCardGenerator.areaCode.put("城北区", 630105); + IdCardGenerator.areaCode.put("大通回族土族自治县", 630121); + IdCardGenerator.areaCode.put("湟中县", 630122); + IdCardGenerator.areaCode.put("湟源县", 630123); + IdCardGenerator.areaCode.put("海东地区", 632100); + IdCardGenerator.areaCode.put("平安县", 632121); + IdCardGenerator.areaCode.put("民和回族土族自治县", 632122); + IdCardGenerator.areaCode.put("乐都县", 632123); + IdCardGenerator.areaCode.put("互助土族自治县", 632126); + IdCardGenerator.areaCode.put("化隆回族自治县", 632127); + IdCardGenerator.areaCode.put("循化撒拉族自治县", 632128); + IdCardGenerator.areaCode.put("海北藏族自治州", 632200); + IdCardGenerator.areaCode.put("门源回族自治县", 632221); + IdCardGenerator.areaCode.put("祁连县", 632222); + IdCardGenerator.areaCode.put("海晏县", 632223); + IdCardGenerator.areaCode.put("刚察县", 632224); + IdCardGenerator.areaCode.put("黄南藏族自治州", 632300); + IdCardGenerator.areaCode.put("同仁县", 632321); + IdCardGenerator.areaCode.put("尖扎县", 632322); + IdCardGenerator.areaCode.put("泽库县", 632323); + IdCardGenerator.areaCode.put("河南蒙古族自治县", 632324); + IdCardGenerator.areaCode.put("海南藏族自治州", 632500); + IdCardGenerator.areaCode.put("共和县", 632521); + IdCardGenerator.areaCode.put("同德县", 632522); + IdCardGenerator.areaCode.put("贵德县", 632523); + IdCardGenerator.areaCode.put("兴海县", 632524); + IdCardGenerator.areaCode.put("贵南县", 632525); + IdCardGenerator.areaCode.put("果洛藏族自治州", 632600); + IdCardGenerator.areaCode.put("玛沁县", 632621); + IdCardGenerator.areaCode.put("班玛县", 632622); + IdCardGenerator.areaCode.put("甘德县", 632623); + IdCardGenerator.areaCode.put("达日县", 632624); + IdCardGenerator.areaCode.put("久治县", 632625); + IdCardGenerator.areaCode.put("玛多县", 632626); + IdCardGenerator.areaCode.put("玉树藏族自治州", 632700); + IdCardGenerator.areaCode.put("玉树县", 632721); + IdCardGenerator.areaCode.put("杂多县", 632722); + IdCardGenerator.areaCode.put("称多县", 632723); + IdCardGenerator.areaCode.put("治多县", 632724); + IdCardGenerator.areaCode.put("囊谦县", 632725); + IdCardGenerator.areaCode.put("曲麻莱县", 632726); + IdCardGenerator.areaCode.put("海西蒙古族藏族自治州", 632800); + IdCardGenerator.areaCode.put("格尔木市", 632801); + IdCardGenerator.areaCode.put("德令哈市", 632802); + IdCardGenerator.areaCode.put("乌兰县", 632821); + IdCardGenerator.areaCode.put("都兰县", 632822); + IdCardGenerator.areaCode.put("天峻县", 632823); + IdCardGenerator.areaCode.put("宁夏回族自治区", 640000); + IdCardGenerator.areaCode.put("银川市", 640100); + IdCardGenerator.areaCode.put("市辖区", 640101); + IdCardGenerator.areaCode.put("兴庆区", 640104); + IdCardGenerator.areaCode.put("西夏区", 640105); + IdCardGenerator.areaCode.put("金凤区", 640106); + IdCardGenerator.areaCode.put("永宁县", 640121); + IdCardGenerator.areaCode.put("贺兰县", 640122); + IdCardGenerator.areaCode.put("灵武市", 640181); + IdCardGenerator.areaCode.put("石嘴山市", 640200); + IdCardGenerator.areaCode.put("市辖区", 640201); + IdCardGenerator.areaCode.put("大武口区", 640202); + IdCardGenerator.areaCode.put("惠农区", 640205); + IdCardGenerator.areaCode.put("平罗县", 640221); + IdCardGenerator.areaCode.put("吴忠市", 640300); + IdCardGenerator.areaCode.put("市辖区", 640301); + IdCardGenerator.areaCode.put("利通区", 640302); + IdCardGenerator.areaCode.put("红寺堡区 (*)", 640303); + IdCardGenerator.areaCode.put("盐池县", 640323); + IdCardGenerator.areaCode.put("同心县", 640324); + IdCardGenerator.areaCode.put("青铜峡市", 640381); + IdCardGenerator.areaCode.put("固原市", 640400); + IdCardGenerator.areaCode.put("市辖区", 640401); + IdCardGenerator.areaCode.put("原州区", 640402); + IdCardGenerator.areaCode.put("西吉县", 640422); + IdCardGenerator.areaCode.put("隆德县", 640423); + IdCardGenerator.areaCode.put("泾源县", 640424); + IdCardGenerator.areaCode.put("彭阳县", 640425); + IdCardGenerator.areaCode.put("中卫市", 640500); + IdCardGenerator.areaCode.put("市辖区", 640501); + IdCardGenerator.areaCode.put("沙坡头区", 640502); + IdCardGenerator.areaCode.put("中宁县", 640521); + IdCardGenerator.areaCode.put("海原县", 640522); + IdCardGenerator.areaCode.put("新疆维吾尔自治区", 650000); + IdCardGenerator.areaCode.put("乌鲁木齐市", 650100); + IdCardGenerator.areaCode.put("市辖区", 650101); + IdCardGenerator.areaCode.put("天山区", 650102); + IdCardGenerator.areaCode.put("沙依巴克区", 650103); + IdCardGenerator.areaCode.put("新市区", 650104); + IdCardGenerator.areaCode.put("水磨沟区", 650105); + IdCardGenerator.areaCode.put("头屯河区", 650106); + IdCardGenerator.areaCode.put("达坂城区", 650107); + IdCardGenerator.areaCode.put("米东区", 650109); + IdCardGenerator.areaCode.put("乌鲁木齐县", 650121); + IdCardGenerator.areaCode.put("克拉玛依市", 650200); + IdCardGenerator.areaCode.put("市辖区", 650201); + IdCardGenerator.areaCode.put("独山子区", 650202); + IdCardGenerator.areaCode.put("克拉玛依区", 650203); + IdCardGenerator.areaCode.put("白碱滩区", 650204); + IdCardGenerator.areaCode.put("乌尔禾区", 650205); + IdCardGenerator.areaCode.put("吐鲁番地区", 652100); + IdCardGenerator.areaCode.put("吐鲁番市", 652101); + IdCardGenerator.areaCode.put("鄯善县", 652122); + IdCardGenerator.areaCode.put("托克逊县", 652123); + IdCardGenerator.areaCode.put("哈密地区", 652200); + IdCardGenerator.areaCode.put("哈密市", 652201); + IdCardGenerator.areaCode.put("巴里坤哈萨克自治县", 652222); + IdCardGenerator.areaCode.put("伊吾县", 652223); + IdCardGenerator.areaCode.put("昌吉回族自治州", 652300); + IdCardGenerator.areaCode.put("昌吉市", 652301); + IdCardGenerator.areaCode.put("阜康市", 652302); + IdCardGenerator.areaCode.put("呼图壁县", 652323); + IdCardGenerator.areaCode.put("玛纳斯县", 652324); + IdCardGenerator.areaCode.put("奇台县", 652325); + IdCardGenerator.areaCode.put("吉木萨尔县", 652327); + IdCardGenerator.areaCode.put("木垒哈萨克自治县", 652328); + IdCardGenerator.areaCode.put("博尔塔拉蒙古自治州", 652700); + IdCardGenerator.areaCode.put("博乐市", 652701); + IdCardGenerator.areaCode.put("精河县", 652722); + IdCardGenerator.areaCode.put("温泉县", 652723); + IdCardGenerator.areaCode.put("巴音郭楞蒙古自治州", 652800); + IdCardGenerator.areaCode.put("库尔勒市", 652801); + IdCardGenerator.areaCode.put("轮台县", 652822); + IdCardGenerator.areaCode.put("尉犁县", 652823); + IdCardGenerator.areaCode.put("若羌县", 652824); + IdCardGenerator.areaCode.put("且末县", 652825); + IdCardGenerator.areaCode.put("焉耆回族自治县", 652826); + IdCardGenerator.areaCode.put("和静县", 652827); + IdCardGenerator.areaCode.put("和硕县", 652828); + IdCardGenerator.areaCode.put("博湖县", 652829); + IdCardGenerator.areaCode.put("阿克苏地区", 652900); + IdCardGenerator.areaCode.put("阿克苏市", 652901); + IdCardGenerator.areaCode.put("温宿县", 652922); + IdCardGenerator.areaCode.put("库车县", 652923); + IdCardGenerator.areaCode.put("沙雅县", 652924); + IdCardGenerator.areaCode.put("新和县", 652925); + IdCardGenerator.areaCode.put("拜城县", 652926); + IdCardGenerator.areaCode.put("乌什县", 652927); + IdCardGenerator.areaCode.put("阿瓦提县", 652928); + IdCardGenerator.areaCode.put("柯坪县", 652929); + IdCardGenerator.areaCode.put("克孜勒苏柯尔克孜自治州", 653000); + IdCardGenerator.areaCode.put("阿图什市", 653001); + IdCardGenerator.areaCode.put("阿克陶县", 653022); + IdCardGenerator.areaCode.put("阿合奇县", 653023); + IdCardGenerator.areaCode.put("乌恰县", 653024); + IdCardGenerator.areaCode.put("喀什地区", 653100); + IdCardGenerator.areaCode.put("喀什市", 653101); + IdCardGenerator.areaCode.put("疏附县", 653121); + IdCardGenerator.areaCode.put("疏勒县", 653122); + IdCardGenerator.areaCode.put("英吉沙县", 653123); + IdCardGenerator.areaCode.put("泽普县", 653124); + IdCardGenerator.areaCode.put("莎车县", 653125); + IdCardGenerator.areaCode.put("叶城县", 653126); + IdCardGenerator.areaCode.put("麦盖提县", 653127); + IdCardGenerator.areaCode.put("岳普湖县", 653128); + IdCardGenerator.areaCode.put("伽师县", 653129); + IdCardGenerator.areaCode.put("巴楚县", 653130); + IdCardGenerator.areaCode.put("塔什库尔干塔吉克自治县", 653131); + IdCardGenerator.areaCode.put("和田地区", 653200); + IdCardGenerator.areaCode.put("和田市", 653201); + IdCardGenerator.areaCode.put("和田县", 653221); + IdCardGenerator.areaCode.put("墨玉县", 653222); + IdCardGenerator.areaCode.put("皮山县", 653223); + IdCardGenerator.areaCode.put("洛浦县", 653224); + IdCardGenerator.areaCode.put("策勒县", 653225); + IdCardGenerator.areaCode.put("于田县", 653226); + IdCardGenerator.areaCode.put("民丰县", 653227); + IdCardGenerator.areaCode.put("伊犁哈萨克自治州", 654000); + IdCardGenerator.areaCode.put("伊宁市", 654002); + IdCardGenerator.areaCode.put("奎屯市", 654003); + IdCardGenerator.areaCode.put("伊宁县", 654021); + IdCardGenerator.areaCode.put("察布查尔锡伯自治县", 654022); + IdCardGenerator.areaCode.put("霍城县", 654023); + IdCardGenerator.areaCode.put("巩留县", 654024); + IdCardGenerator.areaCode.put("新源县", 654025); + IdCardGenerator.areaCode.put("昭苏县", 654026); + IdCardGenerator.areaCode.put("特克斯县", 654027); + IdCardGenerator.areaCode.put("尼勒克县", 654028); + IdCardGenerator.areaCode.put("塔城地区", 654200); + IdCardGenerator.areaCode.put("塔城市", 654201); + IdCardGenerator.areaCode.put("乌苏市", 654202); + IdCardGenerator.areaCode.put("额敏县", 654221); + IdCardGenerator.areaCode.put("沙湾县", 654223); + IdCardGenerator.areaCode.put("托里县", 654224); + IdCardGenerator.areaCode.put("裕民县", 654225); + IdCardGenerator.areaCode.put("和布克赛尔蒙古自治县", 654226); + IdCardGenerator.areaCode.put("阿勒泰地区", 654300); + IdCardGenerator.areaCode.put("阿勒泰市", 654301); + IdCardGenerator.areaCode.put("布尔津县", 654321); + IdCardGenerator.areaCode.put("富蕴县", 654322); + IdCardGenerator.areaCode.put("福海县", 654323); + IdCardGenerator.areaCode.put("哈巴河县", 654324); + IdCardGenerator.areaCode.put("青河县", 654325); + IdCardGenerator.areaCode.put("吉木乃县", 654326); + IdCardGenerator.areaCode.put("自治区直辖县级行政区划", 659000); + IdCardGenerator.areaCode.put("石河子市", 659001); + IdCardGenerator.areaCode.put("阿拉尔市", 659002); + IdCardGenerator.areaCode.put("图木舒克市", 659003); + IdCardGenerator.areaCode.put("五家渠市", 659004); + IdCardGenerator.areaCode.put("台湾省", 710000); + IdCardGenerator.areaCode.put("香港特别行政区", 810000); + IdCardGenerator.areaCode.put("澳门特别行政区", 820000); + } - /** - * 根据年龄获取身份证号 - * @param age - * @return - */ - public String generate(int age) { - StringBuilder generator= new StringBuilder(); - generator.append(this.randomAreaCode()); - generator.append(this.randomBirthday(age)); + public IdCardGenerator() {} - generator.append(this.randomCode()); - generator.append(this.calcTrailingNumber(generator.toString().toCharArray())); - return generator.toString(); - } + /** + * 根据年龄获取身份证号 + * + * @param age + * @return + */ + public String generate(int age) { + StringBuilder generator = new StringBuilder(); + generator.append(this.randomAreaCode()); + generator.append(this.randomBirthday(age)); - public int randomAreaCode() { - int index = (int) (Math.random() * IdCardGenerator.areaCode.size()); - Collection values = IdCardGenerator.areaCode.values(); - Iterator it = values.iterator(); - int i = 0; - int code = 0; - while (i < index && it.hasNext()) { - i++; - code = it.next(); - } - return code; - } + generator.append(this.randomCode()); + generator.append(this.calcTrailingNumber(generator.toString().toCharArray())); + return generator.toString(); + } - /** - * 获取随机生日 - * @param age - * @return - */ - public String randomBirthday(int age) { + public int randomAreaCode() { + int index = (int) (Math.random() * IdCardGenerator.areaCode.size()); + Collection values = IdCardGenerator.areaCode.values(); + Iterator it = values.iterator(); + int i = 0; + int code = 0; + while (i < index && it.hasNext()) { + i++; + code = it.next(); + } + return code; + } - StringBuilder builder = new StringBuilder(); - int month = RandomGenerator.getBirthMonth(); - int year = RandomGenerator.getBirthYear(age); - int date = RandomGenerator.getBirthDay(month, year); - builder.append(year); + /** + * 获取随机生日 + * + * @param age + * @return + */ + public String randomBirthday(int age) { - if (month < 10) { - builder.append("0"); - } - builder.append(month); + StringBuilder builder = new StringBuilder(); + int month = RandomGenerator.getBirthMonth(); + int year = RandomGenerator.getBirthYear(age); + int date = RandomGenerator.getBirthDay(month, year); + builder.append(year); - if (date < 10) { - builder.append("0"); - } - builder.append(date); - return builder.toString(); - } + if (month < 10) { + builder.append("0"); + } + builder.append(month); - /* - *

18位身份证验证

- * 根据〖中华人民共和国国家标准 GB 11643-1999〗中有关公民身份号码的规定,公民身份号码是特征组合码,由十七位数字本体码和一位数字校验码组成。 - * 排列顺序从左至右依次为:六位数字地址码,八位数字出生日期码,三位数字顺序码和一位数字校验码。 - * 第十八位数字(校验码)的计算方法为: - * 1.将前面的身份证号码17位数分别乘以不同的系数。从第一位到第十七位的系数分别为:7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2 - * 2.将这17位数字和系数相乘的结果相加。 - * 3.用加出来和除以11,看余数是多少? - * 4.余数只可能有0 1 2 3 4 5 6 7 8 9 10这11个数字。其分别对应的最后一位身份证的号码为1 0 X 9 8 7 6 5 4 3 2。 - * 5.通过上面得知如果余数是2,就会在身份证的第18位数字上出现罗马数字的Ⅹ。如果余数是10,身份证的最后一位号码就是2。 - */ - public char calcTrailingNumber(char[] chars) { - if (chars.length < 17) { - return ' '; - } - int[] c = { 7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2 }; - char[] r = { '1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2' }; - int[] n = new int[17]; - int result = 0; - for (int i = 0; i < n.length; i++) { - n[i] = Integer.parseInt(chars[i] + ""); - } - for (int i = 0; i < n.length; i++) { - result += c[i] * n[i]; - } - return r[result % 11]; - } + if (date < 10) { + builder.append("0"); + } + builder.append(date); + return builder.toString(); + } - public String randomCode() { -// int code = (int) (Math.random() * 1000); - int code = RandomGenerator.generateRandomInt(1000); - if (code < 10) { - return "00" + code; - } else if (code < 100) { - return "0" + code; - } else { - return "" + code; - } - } + /* + *

18位身份证验证

+ * 根据〖中华人民共和国国家标准 GB 11643-1999〗中有关公民身份号码的规定,公民身份号码是特征组合码,由十七位数字本体码和一位数字校验码组成。 + * 排列顺序从左至右依次为:六位数字地址码,八位数字出生日期码,三位数字顺序码和一位数字校验码。 + * 第十八位数字(校验码)的计算方法为: + * 1.将前面的身份证号码17位数分别乘以不同的系数。从第一位到第十七位的系数分别为:7 9 10 5 8 4 2 1 6 3 7 9 10 5 8 4 2 + * 2.将这17位数字和系数相乘的结果相加。 + * 3.用加出来和除以11,看余数是多少? + * 4.余数只可能有0 1 2 3 4 5 6 7 8 9 10这11个数字。其分别对应的最后一位身份证的号码为1 0 X 9 8 7 6 5 4 3 2。 + * 5.通过上面得知如果余数是2,就会在身份证的第18位数字上出现罗马数字的Ⅹ。如果余数是10,身份证的最后一位号码就是2。 + */ + public char calcTrailingNumber(char[] chars) { + if (chars.length < 17) { + return ' '; + } + int[] c = {7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2}; + char[] r = {'1', '0', 'X', '9', '8', '7', '6', '5', '4', '3', '2'}; + int[] n = new int[17]; + int result = 0; + for (int i = 0; i < n.length; i++) { + n[i] = Integer.parseInt(chars[i] + ""); + } + for (int i = 0; i < n.length; i++) { + result += c[i] * n[i]; + } + return r[result % 11]; + } + public String randomCode() { + // int code = (int) (Math.random() * 1000); + int code = RandomGenerator.generateRandomInt(1000); + if (code < 10) { + return "00" + code; + } else if (code < 100) { + return "0" + code; + } else { + return "" + code; + } + } } diff --git a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/random/RandomGenerator.java b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/random/RandomGenerator.java index f571294..2c3df9b 100644 --- a/components/fluent-testlibs/src/main/java/io/fluent/testlibs/random/RandomGenerator.java +++ b/components/fluent-testlibs/src/main/java/io/fluent/testlibs/random/RandomGenerator.java @@ -1,272 +1,259 @@ package io.fluent.testlibs.random; - import com.google.common.collect.Lists; - import java.util.*; import java.util.regex.Pattern; - -/** - * 随机数生成工具,包括 - * 1. 移动号码 - * 2. 用户名 - * 3. 密码 - * 4. 地址 - */ +/** 随机数生成工具,包括 1. 移动号码 2. 用户名 3. 密码 4. 地址 */ public class RandomGenerator { - private static RandomGenerator instance = new RandomGenerator(); - private static Random random = new Random(); - private static final String NUMBERS = "0123456789"; - private static final Map> MOBILE_OPERATOR_MAP = new HashMap>(); - - static { - MOBILE_OPERATOR_MAP.put("CM", Lists.newArrayList("137", "138", "139")); - MOBILE_OPERATOR_MAP.put("CU", Lists.newArrayList("186", "187", "189", "188")); - MOBILE_OPERATOR_MAP.put("CT", Lists.newArrayList("150", "151", "152", "153")); - } - - private static final List USERNAME_PREFIX = Lists.newArrayList("tn", "nt", "at"); - private static final List USERNAME_POSTFIX = Lists.newArrayList("t", "s", "n"); - - public static RandomGenerator getInstance() { - return instance; - } - - private RandomGenerator() { - } - - /** - * 生成随机手机号码 - * - * @return - */ - public static String generateMobilePhoneNumber() { - return generateMobilePhoneNumber(11); - } - - - /** - * 生成随机手机号码 - * - * @param digital - * @return - */ - public static String generateMobilePhoneNumber(int digital) { - StringBuilder sb = new StringBuilder(); - //todo 目前默认是CU - String mobile_prefix = MOBILE_OPERATOR_MAP.get("CU").get(random. - nextInt(MOBILE_OPERATOR_MAP.get("CU").size())); - sb.append(mobile_prefix); - for (int i = 0; i < digital - 3; i++) { - sb.append(NUMBERS.charAt(random.nextInt(NUMBERS.length()))); - } - - return sb.toString(); - } - - /** - * 生成随机用户名 - * - * @return - */ - public static String generateUserName() { - StringBuilder sb = new StringBuilder(); - String prefix = USERNAME_PREFIX.get(random.nextInt(USERNAME_PREFIX.size())); - sb.append(prefix); - for (int i = 0; i < 3; i++) { - sb.append(NUMBERS.charAt(random.nextInt(NUMBERS.length()))); - } - sb.append(USERNAME_POSTFIX.get(random.nextInt(USERNAME_POSTFIX.size()))); - return sb.toString(); - } - - /** - * 生成年纪 - * - * @return - */ - public static int generateAge() { //more thank 18 and less than 40 - int age = 18; - age = age + random.nextInt(40 - 18); - return age; - } - - /** - * 生日年份 - * - * @param age - * @return - */ - public static int getBirthYear(int age) { - return Calendar.getInstance().get(Calendar.YEAR) - age; - } - - /** - * 随机生日月份 - * - * @return - */ - public static int getBirthMonth() { - return random.nextInt(13); - } - - /** - * 生日日期 - * - * @param month - * @param year - * @return - */ - public static int getBirthDay(int month, int year) { - if (month == 2) { - if (year % 4 == 0 && year % 100 != 0) { - return random.nextInt(28); //闰年 - } else { - return random.nextInt(29); - } - } - - List month1 = Lists.newArrayList(1, 3, 5, 7, 8, 10, 12); - List month2 = Lists.newArrayList(4, 6, 9, 11); - if (month1.contains(month)) { - return random.nextInt(31); - } - - if (month2.contains(month)) { - return random.nextInt(30); - } - - return random.nextInt(28); + private static RandomGenerator instance = new RandomGenerator(); + private static Random random = new Random(); + private static final String NUMBERS = "0123456789"; + private static final Map> MOBILE_OPERATOR_MAP = + new HashMap>(); + + static { + MOBILE_OPERATOR_MAP.put("CM", Lists.newArrayList("137", "138", "139")); + MOBILE_OPERATOR_MAP.put("CU", Lists.newArrayList("186", "187", "189", "188")); + MOBILE_OPERATOR_MAP.put("CT", Lists.newArrayList("150", "151", "152", "153")); + } + + private static final List USERNAME_PREFIX = Lists.newArrayList("tn", "nt", "at"); + private static final List USERNAME_POSTFIX = Lists.newArrayList("t", "s", "n"); + + public static RandomGenerator getInstance() { + return instance; + } + + private RandomGenerator() {} + + /** + * 生成随机手机号码 + * + * @return + */ + public static String generateMobilePhoneNumber() { + return generateMobilePhoneNumber(11); + } + + /** + * 生成随机手机号码 + * + * @param digital + * @return + */ + public static String generateMobilePhoneNumber(int digital) { + StringBuilder sb = new StringBuilder(); + // todo 目前默认是CU + String mobile_prefix = + MOBILE_OPERATOR_MAP.get("CU").get(random.nextInt(MOBILE_OPERATOR_MAP.get("CU").size())); + sb.append(mobile_prefix); + for (int i = 0; i < digital - 3; i++) { + sb.append(NUMBERS.charAt(random.nextInt(NUMBERS.length()))); } - /** - * 身份证号码 - * - * @param age - * @return - */ - public static String generateIdCardNumberByAge(int age) { - IdCardGenerator generator = new IdCardGenerator(); - return generator.generate(age); - - } - - /** - * 身份证号码 - * - * @return - */ - public static String generateIdCardNumber() { - - IdCardGenerator generator = new IdCardGenerator(); - return generator.generate(generateAge()); - - } - - /** - * 随机号 - * - * @return - */ - public static String generateReferenceId() { - - return String.valueOf(random.nextInt(1000000)); - } - - /** - * 随机QQ号 - * - * @return - */ - public static String generateQQNumber() { - return String.valueOf(random.nextInt(100000)); - } - - /** - * 随机数 - * - * @param length - * @return - */ - public static String generateRandomValue(int length) { - StringBuilder sb = new StringBuilder(); - for (int i = 0; i < length; i++) { - sb.append(NUMBERS.charAt(random.nextInt(NUMBERS.length()))); - } - - return sb.toString(); - - } - - public static int generateRandomInt(int bound) { - return random.nextInt(bound); - } - - /** - * 获取某个范围内的int 值 - * - * @param min - * @param max - * @return - */ - public static int getFixedLengthInt(final int min, final int max) { - if (Integer.MIN_VALUE == min) return 0; - int tmp = Math.abs(random.nextInt()); - return tmp % (max - min + 1) + min; + return sb.toString(); + } + + /** + * 生成随机用户名 + * + * @return + */ + public static String generateUserName() { + StringBuilder sb = new StringBuilder(); + String prefix = USERNAME_PREFIX.get(random.nextInt(USERNAME_PREFIX.size())); + sb.append(prefix); + for (int i = 0; i < 3; i++) { + sb.append(NUMBERS.charAt(random.nextInt(NUMBERS.length()))); } - - /** - * 获取某个范围内的int 值 - * - * @param min - * @param max - * @return - */ - public static String getNumAsString(final int min, final int max) { - if (Integer.MIN_VALUE == min) return "0"; - int tmp = Math.abs(random.nextInt()); - return String.valueOf(tmp % (max - min + 1) + min); - } - - - private static final Pattern UUID_PATTERN = Pattern.compile("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"); - - public static String generateUUID() { - return UUID.randomUUID().toString(); + sb.append(USERNAME_POSTFIX.get(random.nextInt(USERNAME_POSTFIX.size()))); + return sb.toString(); + } + + /** + * 生成年纪 + * + * @return + */ + public static int generateAge() { // more thank 18 and less than 40 + int age = 18; + age = age + random.nextInt(40 - 18); + return age; + } + + /** + * 生日年份 + * + * @param age + * @return + */ + public static int getBirthYear(int age) { + return Calendar.getInstance().get(Calendar.YEAR) - age; + } + + /** + * 随机生日月份 + * + * @return + */ + public static int getBirthMonth() { + return random.nextInt(13); + } + + /** + * 生日日期 + * + * @param month + * @param year + * @return + */ + public static int getBirthDay(int month, int year) { + if (month == 2) { + if (year % 4 == 0 && year % 100 != 0) { + return random.nextInt(28); // 闰年 + } else { + return random.nextInt(29); + } } - public static boolean hasMatchingUUID(String timeToken, String oneTimeToken) { - boolean userTokenValid = UUID_PATTERN.matcher(oneTimeToken).matches(); - //boolean userTokenValid = oneTimeToken != null && timeToken != null && UUID_PATTERN.matcher(oneTimeToken).matches(); - boolean matchingTokenValid = oneTimeToken != null && UUID_PATTERN.matcher(oneTimeToken).matches(); - return userTokenValid && matchingTokenValid && timeToken.equals(oneTimeToken); + List month1 = Lists.newArrayList(1, 3, 5, 7, 8, 10, 12); + List month2 = Lists.newArrayList(4, 6, 9, 11); + if (month1.contains(month)) { + return random.nextInt(31); } - /** - * 或者指定列表的随机值 - * - * @param source - * @return - */ - public static String getRandomFrom(List source) { - if (source.size() == 0) throw new RuntimeException("输入必须有值"); - int size = source.size(); - return source.get(RandomGenerator.generateRandomInt(size)); + if (month2.contains(month)) { + return random.nextInt(30); } - /** - * 或者指定数组的随机值 - * - * @param source - * @return - */ - public static String getRandomFrom(String[] source) { - if (source.length == 0) throw new RuntimeException("输入数组必须有值"); - int size = source.length; - return source[RandomGenerator.generateRandomInt(size)]; + return random.nextInt(28); + } + + /** + * 身份证号码 + * + * @param age + * @return + */ + public static String generateIdCardNumberByAge(int age) { + IdCardGenerator generator = new IdCardGenerator(); + return generator.generate(age); + } + + /** + * 身份证号码 + * + * @return + */ + public static String generateIdCardNumber() { + + IdCardGenerator generator = new IdCardGenerator(); + return generator.generate(generateAge()); + } + + /** + * 随机号 + * + * @return + */ + public static String generateReferenceId() { + + return String.valueOf(random.nextInt(1000000)); + } + + /** + * 随机QQ号 + * + * @return + */ + public static String generateQQNumber() { + return String.valueOf(random.nextInt(100000)); + } + + /** + * 随机数 + * + * @param length + * @return + */ + public static String generateRandomValue(int length) { + StringBuilder sb = new StringBuilder(); + for (int i = 0; i < length; i++) { + sb.append(NUMBERS.charAt(random.nextInt(NUMBERS.length()))); } - + return sb.toString(); + } + + public static int generateRandomInt(int bound) { + return random.nextInt(bound); + } + + /** + * 获取某个范围内的int 值 + * + * @param min + * @param max + * @return + */ + public static int getFixedLengthInt(final int min, final int max) { + if (Integer.MIN_VALUE == min) return 0; + int tmp = Math.abs(random.nextInt()); + return tmp % (max - min + 1) + min; + } + + /** + * 获取某个范围内的int 值 + * + * @param min + * @param max + * @return + */ + public static String getNumAsString(final int min, final int max) { + if (Integer.MIN_VALUE == min) return "0"; + int tmp = Math.abs(random.nextInt()); + return String.valueOf(tmp % (max - min + 1) + min); + } + + private static final Pattern UUID_PATTERN = + Pattern.compile("^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$"); + + public static String generateUUID() { + return UUID.randomUUID().toString(); + } + + public static boolean hasMatchingUUID(String timeToken, String oneTimeToken) { + boolean userTokenValid = UUID_PATTERN.matcher(oneTimeToken).matches(); + // boolean userTokenValid = oneTimeToken != null && timeToken != null && + // UUID_PATTERN.matcher(oneTimeToken).matches(); + boolean matchingTokenValid = + oneTimeToken != null && UUID_PATTERN.matcher(oneTimeToken).matches(); + return userTokenValid && matchingTokenValid && timeToken.equals(oneTimeToken); + } + + /** + * 或者指定列表的随机值 + * + * @param source + * @return + */ + public static String getRandomFrom(List source) { + if (source.size() == 0) throw new RuntimeException("输入必须有值"); + int size = source.size(); + return source.get(RandomGenerator.generateRandomInt(size)); + } + + /** + * 或者指定数组的随机值 + * + * @param source + * @return + */ + public static String getRandomFrom(String[] source) { + if (source.length == 0) throw new RuntimeException("输入数组必须有值"); + int size = source.length; + return source[RandomGenerator.generateRandomInt(size)]; + } } diff --git a/components/fluent-testlibs/src/test/java/io/fluent/testlibs/datafactory/DataFactory.java b/components/fluent-testlibs/src/test/java/io/fluent/testlibs/datafactory/DataFactory.java index 8f40d77..1dca09a 100644 --- a/components/fluent-testlibs/src/test/java/io/fluent/testlibs/datafactory/DataFactory.java +++ b/components/fluent-testlibs/src/test/java/io/fluent/testlibs/datafactory/DataFactory.java @@ -1,11 +1,9 @@ package io.fluent.testlibs.datafactory; -import org.instancio.Instancio; -import org.instancio.internal.util.ReflectionUtils; public class DataFactory { - public T populateData(Class clazz){ + public T populateData(Class clazz) { return null; } } diff --git a/components/fluent-testlibs/src/test/java/io/fluent/testlibs/datatransform/DemoClass.java b/components/fluent-testlibs/src/test/java/io/fluent/testlibs/datatransform/DemoClass.java index 55489c9..98eb0fe 100644 --- a/components/fluent-testlibs/src/test/java/io/fluent/testlibs/datatransform/DemoClass.java +++ b/components/fluent-testlibs/src/test/java/io/fluent/testlibs/datatransform/DemoClass.java @@ -3,57 +3,56 @@ import com.github.mfatihercik.dsb.DSM; import com.github.mfatihercik.dsb.DSMBuilder; -import java.util.Map; - public class DemoClass { public static void main(String[] args) { - String jsonStr = "{\n" + - " \"id\": 1,\n" + - " \"name\": \"Van Kedisi\",\n" + - " \"status\": \"sold\",\n" + - " \"createDate\": \"01/24/2019\",\n" + - " \"category\": {\"id\": 1,\"name\": \"Cats\"},\n" + - " \"tags\": [\n" + - " {\"id\": 1,\"name\": \"Cute\"},\n" + - " {\"id\": 2,\"name\": \"Popular\"}\n" + - " ],\n" + - " \"photoUrls\": [\"url1\",\"url2\" ]\n" + - "}"; - String xmlStr = "\n" + - "\n" + - "\n" + - " Van Kedisi\n" + - " sold\n" + - " 01/24/2019\n" + - " \n" + - " 1\n" + - " Cats\n" + - " \n" + - " \n" + - " \n" + - " 1\n" + - " Cute\n" + - " \n" + - " \n" + - " 2\n" + - " Popular\n" + - " \n" + - " \n" + - " \n" + - " url1\n" + - " url2\n" + - " \n" + - ""; + String jsonStr = + "{\n" + + " \"id\": 1,\n" + + " \"name\": \"Van Kedisi\",\n" + + " \"status\": \"sold\",\n" + + " \"createDate\": \"01/24/2019\",\n" + + " \"category\": {\"id\": 1,\"name\": \"Cats\"},\n" + + " \"tags\": [\n" + + " {\"id\": 1,\"name\": \"Cute\"},\n" + + " {\"id\": 2,\"name\": \"Popular\"}\n" + + " ],\n" + + " \"photoUrls\": [\"url1\",\"url2\" ]\n" + + "}"; + String xmlStr = + "\n" + + "\n" + + "\n" + + " Van Kedisi\n" + + " sold\n" + + " 01/24/2019\n" + + " \n" + + " 1\n" + + " Cats\n" + + " \n" + + " \n" + + " \n" + + " 1\n" + + " Cute\n" + + " \n" + + " \n" + + " 2\n" + + " Popular\n" + + " \n" + + " \n" + + " \n" + + " url1\n" + + " url2\n" + + " \n" + + ""; DSMBuilder builder = new DSMBuilder("dsm.config.yaml"); DSM dsm = builder.setType(DSMBuilder.TYPE.XML).create(); - Object pet = dsm.toObject(xmlStr); // read data from xml file - System.out.println(pet);// read data from json file + Object pet = dsm.toObject(xmlStr); // read data from xml file + System.out.println(pet); // read data from json file dsm = builder.setType(DSMBuilder.TYPE.JSON).create(); - Object petXml = dsm.toObject(jsonStr); // read data from xml file - System.out.println(pet);// read data from json file - System.out.println(petXml);// read data from json file - + Object petXml = dsm.toObject(jsonStr); // read data from xml file + System.out.println(pet); // read data from json file + System.out.println(petXml); // read data from json file } } diff --git a/components/fluent-testlibs/src/test/java/io/fluent/testlibs/datatransform/PetEntity.java b/components/fluent-testlibs/src/test/java/io/fluent/testlibs/datatransform/PetEntity.java index f75d2c3..ff0165a 100644 --- a/components/fluent-testlibs/src/test/java/io/fluent/testlibs/datatransform/PetEntity.java +++ b/components/fluent-testlibs/src/test/java/io/fluent/testlibs/datatransform/PetEntity.java @@ -1,20 +1,19 @@ package io.fluent.testlibs.datatransform; -import lombok.Data; - import java.util.Date; import java.util.List; +import lombok.Data; @Data public class PetEntity { - private int id; - private String name; - private boolean isPopular; - private String status; - private String category; - private Date createDate; - private List tags; + private int id; + private String name; + private boolean isPopular; + private String status; + private String category; + private Date createDate; + private List tags; - // getter/setter + // getter/setter - } +} diff --git a/components/fluent-testlibs/src/test/java/io/fluent/testlibs/instanceio/Address.java b/components/fluent-testlibs/src/test/java/io/fluent/testlibs/instanceio/Address.java index 804a0be..6682893 100644 --- a/components/fluent-testlibs/src/test/java/io/fluent/testlibs/instanceio/Address.java +++ b/components/fluent-testlibs/src/test/java/io/fluent/testlibs/instanceio/Address.java @@ -4,5 +4,5 @@ @Data public class Address { - private String city; + private String city; } diff --git a/components/fluent-testlibs/src/test/java/io/fluent/testlibs/instanceio/DemoInstance.java b/components/fluent-testlibs/src/test/java/io/fluent/testlibs/instanceio/DemoInstance.java index 558d637..1064cfa 100644 --- a/components/fluent-testlibs/src/test/java/io/fluent/testlibs/instanceio/DemoInstance.java +++ b/components/fluent-testlibs/src/test/java/io/fluent/testlibs/instanceio/DemoInstance.java @@ -1,31 +1,34 @@ package io.fluent.testlibs.instanceio; -import org.instancio.Instancio; -import org.instancio.Model; - import static org.instancio.Select.all; import static org.instancio.Select.field; -//https://github.com/instancio/instancio.git +import org.instancio.Instancio; +import org.instancio.Model; + +// https://github.com/instancio/instancio.git public class DemoInstance { - public static void main(String[] args) { - Model simpsons = Instancio.of(Person.class) - .set(field(Person::getLastName), "Simpson") - .set(field(Address::getCity), "Springfield") - .generate(field(Person::getAge), gen -> gen.ints().range(40, 50)) - .toModel(); + public static void main(String[] args) { + Model simpsons = + Instancio.of(Person.class) + .set(field(Person::getLastName), "Simpson") + .set(field(Address::getCity), "Springfield") + .generate(field(Person::getAge), gen -> gen.ints().range(40, 50)) + .toModel(); - Person homer = Instancio.of(simpsons) - .set(field(Person::getFirstName), "Homer") - .set(all(Gender.class), Gender.MALE) - .create(); + Person homer = + Instancio.of(simpsons) + .set(field(Person::getFirstName), "Homer") + .set(all(Gender.class), Gender.MALE) + .create(); - Person marge = Instancio.of(simpsons) - .set(field(Person::getFirstName), "Marge") - .set(all(Gender.class), Gender.FEMALE) - .create(); - System.out.println(simpsons); - System.out.println(homer); - System.out.println(marge); - } + Person marge = + Instancio.of(simpsons) + .set(field(Person::getFirstName), "Marge") + .set(all(Gender.class), Gender.FEMALE) + .create(); + System.out.println(simpsons); + System.out.println(homer); + System.out.println(marge); + } } diff --git a/components/fluent-testlibs/src/test/java/io/fluent/testlibs/instanceio/Gender.java b/components/fluent-testlibs/src/test/java/io/fluent/testlibs/instanceio/Gender.java index 45ab121..6321621 100644 --- a/components/fluent-testlibs/src/test/java/io/fluent/testlibs/instanceio/Gender.java +++ b/components/fluent-testlibs/src/test/java/io/fluent/testlibs/instanceio/Gender.java @@ -1,5 +1,6 @@ package io.fluent.testlibs.instanceio; public enum Gender { - MALE,FEMALE + MALE, + FEMALE } diff --git a/components/fluent-testlibs/src/test/java/io/fluent/testlibs/instanceio/Person.java b/components/fluent-testlibs/src/test/java/io/fluent/testlibs/instanceio/Person.java index c7284e3..14f7aef 100644 --- a/components/fluent-testlibs/src/test/java/io/fluent/testlibs/instanceio/Person.java +++ b/components/fluent-testlibs/src/test/java/io/fluent/testlibs/instanceio/Person.java @@ -4,9 +4,9 @@ @Data public class Person { - private String firstName; - private String lastName; - private Address city; - private Gender gender; - private int age; + private String firstName; + private String lastName; + private Address city; + private Gender gender; + private int age; } diff --git a/components/fluent-testlibs/src/test/java/io/fluent/testlibs/ngork/NgorkChannels.java b/components/fluent-testlibs/src/test/java/io/fluent/testlibs/ngork/NgorkChannels.java index 204828e..35dbff5 100644 --- a/components/fluent-testlibs/src/test/java/io/fluent/testlibs/ngork/NgorkChannels.java +++ b/components/fluent-testlibs/src/test/java/io/fluent/testlibs/ngork/NgorkChannels.java @@ -6,22 +6,20 @@ import com.github.alexdlaird.ngrok.protocol.Tunnel; public class NgorkChannels { - //https://github.com/anderspitman/awesome-tunneling + // https://github.com/anderspitman/awesome-tunneling // https://github.com/alexdlaird/java-ngrok.git public static void main(String[] args) { final NgrokClient ngrokClient = new NgrokClient.Builder().build(); -// Open a HTTP tunnel on the default port 80 -// .ngrok.io" -> "http://localhost:80"> + // Open a HTTP tunnel on the default port 80 + // .ngrok.io" -> "http://localhost:80"> final Tunnel httpTunnel = ngrokClient.connect(); -// Open a SSH tunnel -// "localhost:22"> - final CreateTunnel sshCreateTunnel = new CreateTunnel.Builder() - .withProto(Proto.TCP) - .withAddr(22) - .build(); + // Open a SSH tunnel + // "localhost:22"> + final CreateTunnel sshCreateTunnel = + new CreateTunnel.Builder().withProto(Proto.TCP).withAddr(22).build(); final Tunnel sshTunnel = ngrokClient.connect(sshCreateTunnel); System.out.println(sshTunnel.getPublicUrl()); } diff --git a/components/fluent-testlibs/src/test/java/io/fluent/testlibs/package-info.java b/components/fluent-testlibs/src/test/java/io/fluent/testlibs/package-info.java index f39b2c8..fa3b428 100644 --- a/components/fluent-testlibs/src/test/java/io/fluent/testlibs/package-info.java +++ b/components/fluent-testlibs/src/test/java/io/fluent/testlibs/package-info.java @@ -1 +1 @@ -package io.fluent.testlibs; \ No newline at end of file +package io.fluent.testlibs; diff --git a/components/fluentqa-md/src/main/java/io/fluentqa/md/MarkdownAccessor.java b/components/fluentqa-md/src/main/java/io/fluentqa/md/MarkdownAccessor.java index 76593ea..71c6e55 100644 --- a/components/fluentqa-md/src/main/java/io/fluentqa/md/MarkdownAccessor.java +++ b/components/fluentqa-md/src/main/java/io/fluentqa/md/MarkdownAccessor.java @@ -1,4 +1,3 @@ package io.fluentqa.md; -public class MarkdownAccessor { -} +public class MarkdownAccessor {} diff --git a/components/fluentqa-md/src/main/java/io/fluentqa/md/package-info.java b/components/fluentqa-md/src/main/java/io/fluentqa/md/package-info.java index 0868d5e..cd7930c 100644 --- a/components/fluentqa-md/src/main/java/io/fluentqa/md/package-info.java +++ b/components/fluentqa-md/src/main/java/io/fluentqa/md/package-info.java @@ -1 +1 @@ -package io.fluentqa.md; \ No newline at end of file +package io.fluentqa.md; diff --git a/components/fluentqa-md/src/main/java/io/fluentqa/md/parser/FieldParseConfig.java b/components/fluentqa-md/src/main/java/io/fluentqa/md/parser/FieldParseConfig.java index 03d280f..d4a5c1c 100644 --- a/components/fluentqa-md/src/main/java/io/fluentqa/md/parser/FieldParseConfig.java +++ b/components/fluentqa-md/src/main/java/io/fluentqa/md/parser/FieldParseConfig.java @@ -1,12 +1,12 @@ package io.fluentqa.md.parser; +import java.util.function.Function; + import lombok.Data; import org.jsoup.nodes.Element; -import java.util.function.Function; - @Data public class FieldParseConfig { - private String key; - private Function extractFunc; + private String key; + private Function extractFunc; } diff --git a/components/fluentqa-md/src/main/java/io/fluentqa/md/parser/ParseConfig.java b/components/fluentqa-md/src/main/java/io/fluentqa/md/parser/ParseConfig.java index 1b0d3b5..aff5edb 100644 --- a/components/fluentqa-md/src/main/java/io/fluentqa/md/parser/ParseConfig.java +++ b/components/fluentqa-md/src/main/java/io/fluentqa/md/parser/ParseConfig.java @@ -1,22 +1,19 @@ package io.fluentqa.md.parser; import cn.hutool.core.util.ReflectUtil; -import lombok.Data; - import java.util.ArrayList; -import java.util.HashMap; import java.util.List; -import java.util.Map; import java.util.concurrent.ConcurrentHashMap; +import lombok.Data; @Data public class ParseConfig { - private List> configs =new ArrayList<>(); - private ConcurrentHashMap> configMap; + private List> configs = new ArrayList<>(); + private ConcurrentHashMap> configMap; - public void flat(){ - for (FieldParseConfig config : configs) { - ReflectUtil.setFieldValue(this,config.getKey(),config); - } + public void flat() { + for (FieldParseConfig config : configs) { + ReflectUtil.setFieldValue(this, config.getKey(), config); } + } } diff --git a/components/fluentqa-md/src/main/java/io/fluentqa/md/parser/awesome/AwesomeListParserConfig.java b/components/fluentqa-md/src/main/java/io/fluentqa/md/parser/awesome/AwesomeListParserConfig.java index f5388cd..856eaeb 100644 --- a/components/fluentqa-md/src/main/java/io/fluentqa/md/parser/awesome/AwesomeListParserConfig.java +++ b/components/fluentqa-md/src/main/java/io/fluentqa/md/parser/awesome/AwesomeListParserConfig.java @@ -5,10 +5,9 @@ @Data public class AwesomeListParserConfig { - private FieldParseConfig category; - private FieldParseConfig name; - private FieldParseConfig url; - private FieldParseConfig desc; - private FieldParseConfig additional; - + private FieldParseConfig category; + private FieldParseConfig name; + private FieldParseConfig url; + private FieldParseConfig desc; + private FieldParseConfig additional; } diff --git a/components/fluentqa-md/src/main/java/io/fluentqa/md/parser/awesome/AwesomeModel.java b/components/fluentqa-md/src/main/java/io/fluentqa/md/parser/awesome/AwesomeModel.java index ead20ce..e9f23c6 100644 --- a/components/fluentqa-md/src/main/java/io/fluentqa/md/parser/awesome/AwesomeModel.java +++ b/components/fluentqa-md/src/main/java/io/fluentqa/md/parser/awesome/AwesomeModel.java @@ -4,9 +4,8 @@ @Data public class AwesomeModel { - private String category; - private String url; - private String name; - private String desc; - + private String category; + private String url; + private String name; + private String desc; } diff --git a/components/fluentqa-md/src/main/java/io/fluentqa/md/parser/awesome/MarkdownAwesomeListParser.java b/components/fluentqa-md/src/main/java/io/fluentqa/md/parser/awesome/MarkdownAwesomeListParser.java index 80150e4..c45bbe3 100644 --- a/components/fluentqa-md/src/main/java/io/fluentqa/md/parser/awesome/MarkdownAwesomeListParser.java +++ b/components/fluentqa-md/src/main/java/io/fluentqa/md/parser/awesome/MarkdownAwesomeListParser.java @@ -3,45 +3,48 @@ import com.vladsch.flexmark.html.HtmlRenderer; import com.vladsch.flexmark.parser.Parser; import com.vladsch.flexmark.util.ast.Node; - import io.fluent.builtin.JavaProjectFileUtils; -import org.jsoup.Jsoup; -import org.jsoup.nodes.Document; -import org.jsoup.nodes.Element; - import java.io.File; import java.nio.charset.Charset; import java.util.List; import java.util.stream.Collectors; +import org.jsoup.Jsoup; +import org.jsoup.nodes.Document; +import org.jsoup.nodes.Element; public class MarkdownAwesomeListParser { - private Node parseMarkdownDoc(String mdFilePath){ - String filePath = JavaProjectFileUtils.getFilePath(mdFilePath); - String mdStr = JavaProjectFileUtils.readString(new File(filePath), Charset.defaultCharset()); - Parser parser = Parser.builder().build(); - return parser.parse(mdStr); - } + private Node parseMarkdownDoc(String mdFilePath) { + String filePath = JavaProjectFileUtils.getFilePath(mdFilePath); + String mdStr = JavaProjectFileUtils.readString(new File(filePath), Charset.defaultCharset()); + Parser parser = Parser.builder().build(); + return parser.parse(mdStr); + } + + private String renderToHtml(Node doc) { + HtmlRenderer renderer = HtmlRenderer.builder().build(); + return renderer.render(doc); + } - private String renderToHtml(Node doc){ - HtmlRenderer renderer = HtmlRenderer.builder().build(); - return renderer.render(doc); - } + private String toHtml(String mdFilePath) { + return renderToHtml(parseMarkdownDoc(mdFilePath)); + } - private String toHtml(String mdFilePath){ - return renderToHtml(parseMarkdownDoc(mdFilePath)); - } - public List transform(String path){ - String htmlStr = toHtml(path); - Document htmlDocs = Jsoup.parse(htmlStr); - List elementList= htmlDocs.select("ul>li"); - return elementList.stream().map(element -> { - AwesomeModel awesome = new AwesomeModel(); - awesome.setCategory(element.parent().previousSibling().previousSibling().childNode(0).toString()); - awesome.setName(element.selectFirst("a").text()); - awesome.setDesc(element.text()); - awesome.setUrl(element.selectFirst("a").attr("href")); - return awesome; - }).collect(Collectors.toList()); - } + public List transform(String path) { + String htmlStr = toHtml(path); + Document htmlDocs = Jsoup.parse(htmlStr); + List elementList = htmlDocs.select("ul>li"); + return elementList.stream() + .map( + element -> { + AwesomeModel awesome = new AwesomeModel(); + awesome.setCategory( + element.parent().previousSibling().previousSibling().childNode(0).toString()); + awesome.setName(element.selectFirst("a").text()); + awesome.setDesc(element.text()); + awesome.setUrl(element.selectFirst("a").attr("href")); + return awesome; + }) + .collect(Collectors.toList()); + } } diff --git a/components/fluentqa-md/src/test/java/io/fluentqa/md/parsers/MarkdownAwesomeListParserTest.java b/components/fluentqa-md/src/test/java/io/fluentqa/md/parsers/MarkdownAwesomeListParserTest.java index e867e2b..61fbe09 100644 --- a/components/fluentqa-md/src/test/java/io/fluentqa/md/parsers/MarkdownAwesomeListParserTest.java +++ b/components/fluentqa-md/src/test/java/io/fluentqa/md/parsers/MarkdownAwesomeListParserTest.java @@ -10,78 +10,82 @@ import io.fluent.builtin.JavaProjectFileUtils; import io.fluentqa.md.parser.awesome.AwesomeModel; import io.fluentqa.md.parser.awesome.MarkdownAwesomeListParser; +import java.io.File; +import java.nio.charset.Charset; +import java.util.List; import org.jsoup.Jsoup; import org.jsoup.nodes.Document; import org.jsoup.nodes.Element; import org.junit.jupiter.api.Test; -import java.io.File; -import java.nio.charset.Charset; -import java.util.List; - public class MarkdownAwesomeListParserTest { - MarkdownAwesomeListParser parser = new MarkdownAwesomeListParser(); - private Node parseMarkdownDoc(String fileName){ - String filePath = JavaProjectFileUtils.getFilePath(fileName); - String mdStr = JavaProjectFileUtils.readString(new File(filePath), Charset.defaultCharset()); - Parser parser = Parser.builder().build(); - return parser.parse(mdStr); - } + MarkdownAwesomeListParser parser = new MarkdownAwesomeListParser(); - private String renderToHtml(Node doc){ - HtmlRenderer renderer = HtmlRenderer.builder().build(); - return renderer.render(doc); - } - @Test - void testTransformByMarkdownNodes() { - Node document = parseMarkdownDoc("low-code-1.md"); - if(document.getFirstChild()==null) return; - Node nextNode = document.getFirstChild().getNext(); - while(nextNode!=null){ - if(nextNode instanceof Heading){ - if(((Heading) nextNode).getLevel()==3){ - System.out.println(((Heading) nextNode).getText()); - } - } - if(nextNode instanceof BulletList){ - System.out.println(nextNode.getChars()); - } - if(nextNode instanceof BulletListItem){ - System.out.println(nextNode.getChars()); - } - nextNode = nextNode.getNext(); + private Node parseMarkdownDoc(String fileName) { + String filePath = JavaProjectFileUtils.getFilePath(fileName); + String mdStr = JavaProjectFileUtils.readString(new File(filePath), Charset.defaultCharset()); + Parser parser = Parser.builder().build(); + return parser.parse(mdStr); + } + + private String renderToHtml(Node doc) { + HtmlRenderer renderer = HtmlRenderer.builder().build(); + return renderer.render(doc); + } + + @Test + void testTransformByMarkdownNodes() { + Node document = parseMarkdownDoc("low-code-1.md"); + if (document.getFirstChild() == null) return; + Node nextNode = document.getFirstChild().getNext(); + while (nextNode != null) { + if (nextNode instanceof Heading) { + if (((Heading) nextNode).getLevel() == 3) { + System.out.println(((Heading) nextNode).getText()); } - System.out.println(document); + } + if (nextNode instanceof BulletList) { + System.out.println(nextNode.getChars()); + } + if (nextNode instanceof BulletListItem) { + System.out.println(nextNode.getChars()); + } + nextNode = nextNode.getNext(); } - //next sibling element: list - @Test - public void testTransformByXmlPath(){ - Node document = parseMarkdownDoc("low-code-1.md"); - String htmlStr = renderToHtml(document); - JavaProjectFileUtils.writeToFile("low-code.html",htmlStr); - Document htmlDocs = Jsoup.parse(htmlStr); - List elementList= htmlDocs.select("ul>li"); - for (Element element : elementList) { - System.out.println("category:"+element.parent().previousSibling().previousSibling().childNode(0).toString()); - System.out.println("url:"+element.selectFirst("a").attr("href")); - System.out.println("name:"+element.selectFirst("a").text()); - System.out.println("desc:"+element.text()); - } + System.out.println(document); + } + // next sibling element: list + @Test + public void testTransformByXmlPath() { + Node document = parseMarkdownDoc("low-code-1.md"); + String htmlStr = renderToHtml(document); + JavaProjectFileUtils.writeToFile("low-code.html", htmlStr); + Document htmlDocs = Jsoup.parse(htmlStr); + List elementList = htmlDocs.select("ul>li"); + for (Element element : elementList) { + System.out.println( + "category:" + + element.parent().previousSibling().previousSibling().childNode(0).toString()); + System.out.println("url:" + element.selectFirst("a").attr("href")); + System.out.println("name:" + element.selectFirst("a").text()); + System.out.println("desc:" + element.text()); } + } + @Test - public void testToHtml(){ + public void testToHtml() { Node document = parseMarkdownDoc("test-resources.md"); String htmlStr = renderToHtml(document); - JavaProjectFileUtils.writeToFile("test-resources.html",htmlStr); + JavaProjectFileUtils.writeToFile("test-resources.html", htmlStr); } -// @Test - public void testTransform(){ - for (int i = 3; i < 7 ; i++) { - List repos = parser.transform("low-code-%d.md".formatted(i)); - System.out.println(repos); - JavaProjectFileUtils.writeToFile("low-code-%d.json".formatted(i),JSONUtil.toJsonPrettyStr(repos)); - } - + // @Test + public void testTransform() { + for (int i = 3; i < 7; i++) { + List repos = parser.transform("low-code-%d.md".formatted(i)); + System.out.println(repos); + JavaProjectFileUtils.writeToFile( + "low-code-%d.json".formatted(i), JSONUtil.toJsonPrettyStr(repos)); } -} \ No newline at end of file + } +} diff --git a/docs/1-FEATURES/1-API-Sepc-Mgr.md b/docs/1-FEATURES/1-API-Sepc-Mgr.md new file mode 100644 index 0000000..31867a8 --- /dev/null +++ b/docs/1-FEATURES/1-API-Sepc-Mgr.md @@ -0,0 +1,14 @@ +## 1. 可对接 swagger 文档,自动/手动导入接口信息 + +A. 背景内容: 什么是swagger文档? + +```可对接 swagger 文档,自动/手动导入接口信息```,对这个功能进行拆解和转化为要实现的代码功能如下: +1. swagger文档-JSON文档,保存这个文档到数据库 +2. 将这个文档解析保存成更好理解的HTTP API结构形式到数据库 +3. 可以展示所有项目相关的接口信息 + + +## + +> prompt: +> 拆解功能***对接 swagger 文档,自动/手动导入接口信息*** 成需要实现的小功能,使用中文Markdown形式展示 \ No newline at end of file diff --git a/docs/1-FEATURES/README.md b/docs/1-FEATURES/README.md new file mode 100644 index 0000000..56c1a0d --- /dev/null +++ b/docs/1-FEATURES/README.md @@ -0,0 +1,31 @@ +# README + +这个仓库用于回答一下论坛的问题有一定意义,This Project is the answer to : + +``` +接口自动化测试平台需求: +1、可对接 swagger 文档,自动/手动导入接口信息 +2、具备接口信息管理、测试用例管理、测试步骤管理、测试报告管理的功能 +3、具备接口调试的功能 +4、以测试集为单位执行多个测试用例,并生成测试报告 + +API Automation Testing Platform Requirements: + +1. Capable of integrating with Swagger documentation, with the ability to automatically/ manually import interface information. +2. with functions for managing interface information, test case management, test step management, and test report management. +3. Possesses the capability for interface debugging. +4. Executes multiple test cases as a test suite and generates test reports. +``` + +意义在哪里? +1. 最简单构建一个平台需要什么成本? +2. 在low-code工具比较多的情况下,如何结合不同的工具快速完成可以满足完成基本功能的系统 +3. 是不是有另外一些思路,如何利用好开源,已经有的工具就可以完成基本使用了? +4. 有了一定东西之后,在看到底需要什么东西? +5. 做东西的时候可以更客观的了解自己的技术不足和需要的帮助 +6. 如果需要快速完成一些内容需要沉淀哪些内容,日常需要积累哪些东西? + +## 开始动手完成功能 + + + diff --git "a/docs/buzzwords/1-\345\244\226\345\214\205.md" "b/docs/10-THOUGHTS/1-\345\244\226\345\214\205.md" similarity index 100% rename from "docs/buzzwords/1-\345\244\226\345\214\205.md" rename to "docs/10-THOUGHTS/1-\345\244\226\345\214\205.md" diff --git "a/docs/buzzwords/2-\347\262\276\345\207\206\346\265\213\350\257\225.md" "b/docs/10-THOUGHTS/2-\347\262\276\345\207\206\346\265\213\350\257\225.md" similarity index 100% rename from "docs/buzzwords/2-\347\262\276\345\207\206\346\265\213\350\257\225.md" rename to "docs/10-THOUGHTS/2-\347\262\276\345\207\206\346\265\213\350\257\225.md" diff --git "a/docs/buzzwords/3-\344\270\272\344\273\200\344\271\210\350\247\211\345\276\227\345\255\246\344\270\215\345\210\260\344\270\234\350\245\277.md" "b/docs/10-THOUGHTS/3-\344\270\272\344\273\200\344\271\210\350\247\211\345\276\227\345\255\246\344\270\215\345\210\260\344\270\234\350\245\277.md" similarity index 100% rename from "docs/buzzwords/3-\344\270\272\344\273\200\344\271\210\350\247\211\345\276\227\345\255\246\344\270\215\345\210\260\344\270\234\350\245\277.md" rename to "docs/10-THOUGHTS/3-\344\270\272\344\273\200\344\271\210\350\247\211\345\276\227\345\255\246\344\270\215\345\210\260\344\270\234\350\245\277.md" diff --git a/docs/README.md b/docs/README.md index f7d83be..299ec48 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1,5 +1,7 @@ # README + + 工具,平台都好,但是如何快速构建一些可以使用的应用。一般测试开发团队需要开发能力配置: 1. 前端开发 2. 后端开发 diff --git a/docs/features/authing-integrations.md b/docs/features/authing-integrations.md deleted file mode 100644 index 17441f9..0000000 --- a/docs/features/authing-integrations.md +++ /dev/null @@ -1,2 +0,0 @@ -# Authing Integration - diff --git a/docs/framework/README.md b/docs/framework/README.md deleted file mode 100644 index 73408f4..0000000 --- a/docs/framework/README.md +++ /dev/null @@ -1,3 +0,0 @@ -# README - -- [caf-framework](https://gitee.com/ubml/caf-framework) \ No newline at end of file diff --git a/docs/lessons/database/database-schema.png b/docs/lessons/database/database-schema.png deleted file mode 100644 index 69cfbf33a147830c052f22bbf53b948bf04b6b43..0000000000000000000000000000000000000000 GIT binary patch literal 0 HcmV?d00001 literal 44238 zcmdSBcRbbq|2KXd9EZ#!Ib~ToS%*e>hD0`K0jO;jO6p@({k&%&|S(Gi= zgd8h-U(Zv0#`kkw-{1AU{`}p#-QKtNEzWs8U(fM)+}E>+o0_Ur6wDM52!u)vqofUi z5amE1&{J?2_?!Hdg#-u$3sF;&*Y!5Ve;`lMoh#oN{rROip_-pMQ5%k87dNCYZZ<4D zTsrYQiW+#GXEHD_=EUf5wdbVZ)d#QTZx6i&_P2~y9}Efd6$D73v#7;WHMn)MF$Xj5 z_O5w13@0P1=5!nsZdC|2B{2A_aEyQP%NC!ryQ4FMDM}t{v=5HssI< z(1&Cx%&$>OHW7XlmvfY#xLvboo_plYEg}ANkywo^O9K)~@${sb@Nskx6D3*-_75$a^@K3|_&f2n_}!JWXzV<*d>L~c+3N#b+uz5UWlc#)=$>@K2*z*7Cm0CD!6c+QHRm)!=r!IYFIT>KDLMI}#Jh*sqg{Q5EPq z_r@iV=NI91o{Dz27i0*(7@{3W#<+>hUFAJ8`#osh<;&$}No(<$>ZJMZ=8?=7 z2AI^VnlO1kdIK>E7-CHGkAPN>!rqg6V6O5oy~hdudWz>6GSO+;foicL17{Pn8hCYd z6RDM?4G~67s?hoO?_*+@WZ%8a?XVJMo$dA4iaJg_)`MPCh&)a`mZVP+RlY_Vtj&*7 zexxNy+kt`ed_Ki7#WnS7?EP`Zdre`&(wkoNCubaaJo2HTqrG((n1=tkLHn4n@2ntZK^BcD1WnHtt2FgBrzlb zM$g3^BO+qddo!q=+?A`i--I8fhFpZgsJPAuw7&$apvhZM1!0y8(R`NTkKUYlui337 zD*~p8Ghy3pMCpXjkKb3|PA-wML@qQTI@w?sN1?t*!TJjt9}=fIU>!uK;~pI;e7Ciq zMZN_SP8$#5ba(!Ga_e?}i-$dPx(#?CZlPs%zJ0BIy`aaLoSASQ6-}PR{@wd|zb5;b zE_9qWJWSDA!+oZ?wYp`qPVx$4TdJ`IouOv=)q3Itjfl z6uD(;x>DgdGCf#qwwf$twvsGp@-tb$aQcjZ!Q|HG%M-h8k4`aG?`_QUB)g4dDMx*; z_1QRd6KwPRo*X-Dv+}*_es|iHW4f*q%Hs9#d+%9#N?78%_DolzGTN5krX3{pthe`6 z^i+aBvfi>8t8Lr2yL)C`cSTo-j~{ovXD#<$pAHEK=?UrV?EL<%+~LEGH!oj0uayi8 z3>3Y3MNxdd^4_R^gfx}?o9$bd0j!8yx<+Vcj2bQ^8SXZu6RzJ{vXxbS_gaE<nw~s3IX?1ddSc1Mw*E~v_Flf3o2>Wh@zDg^upswJRM+hB z^2VP(&pPLCwfO$17?$06t^dX|H#c`YAF401>m9(n(MT~D`1+gYf`7uarCFn=cjXGH`oFZ+6bf6|=aTg$&BMZ(FxGwbK5fkepbN8VJxp}4s7HgN+@Zo96#?z`LXW1rlF5{u@pWGShU zcah|{e~n|gtT0E~7L5>&OkdDO=&PtA4J@DDZw{rBsjPDFivIp^`<#h1D7~T#`r>t- zvCpnPtYEJU6N+KHf+nRFwTL98y~dCzkw*e+U(a#Z($+^=2WjOkVDf(6q;7|XvZKnP z(r3{s%F&^-3Bc5^w~s36ACF2DR1LW6WLNf>!JA3|Ob@BkYdRvdfayL+r#P@}7*-7Tkn>r-Ynm;Qi=WK&>zcqC=0 zmxOaDR$8q#l$Q04;k(ugx6637NG%9;IFw#gXCg5<>u#f}+FIA<0Lf`$iWnZ3Xg*WF zws>czb0t4DRn-b2&x%6%^xRw2-Y#Zwl_g8O$l>;N_yCGSswDrk8j+H;TADQfRsA=n z^n50_Obq8L0@jK~ooydhPWPS+y{Vm*u3Rq~{l3kyy65rWz)^u|?^h|q%F?3P_mGH$ z+Pdc=%|d;nDq6}ONeA;ym1Eblzg1mYt#Fa`&3_zl+}%`pDEZ+-!TO_B(~(HMxVivt zof7-GR|9pOsg2M(=(dD~p7p143ThI*{@-_kiOl8mc=-lu(JE@?*u)Da`RA85hvQ;n zgyYoN-jg71(4s6tLOQEI8&_Bh*$lsJd{c9zQn~f()Y!P^ttuy{>h7wEW6AA9`^v3+ z#u^XS`_2OnLp=3Dk2}5etL^&gJjHB2yXHn+8;dMW5}{41`dBh=5b80kQZJM~m|W~O z^!PCMAT~At?=L(RP(z=ewrX^v>Pva_)sxs*fVs-At776YDlyD+D<5`byt>|0 zJ{a@3#kjLLZ-%~i3v>P1r7^0#yDyDP9esKw6ADDit-CyB=WGtPm&b(^MZIxah_)ny zM~oTL&-m4$T-tiybBPfz5)qiiUXPa|w$>)v?q#6t@xhm7$>nkcZy;_)ejTW+eEIU_ zr(JgbEcS+%hx1P)z1&8T;h9L>{kluAJhKDqIoT7TN|}o59@d`WlkXsDSKNM7>z&uH zW+*wq(G^)-+UQL3{?J?8d`XLYhI7BlroZ_6*X)34f8nhxWVB%PBB$4{#HaJJPal*V zR1Q}=sF==qu5|kQ=Isy6Tef<`$2>=uS4Qd&KVCg)iaNfM?DuPAUTu_7U8wFb@+7)s zh6nvdES32h9Oj9CiGh%FhC{ezY&|Y=p;a`WU3Pj7onW_x7&P!kFnF1V!s0bXtx4k9 zWYwP(U5kwQa>DER<-qDf4GBVCi3r2H(|u{@99HhVDHK!(AKdT<{!m^|Mbo*_7 zDT_?4E9?XhJ75=8MQ$EB2xvcW`Z}t%dRaVejYcJ3Gd-a}*!t(i`a;zn(_@d5g;jJ$$gsr(FyvDgPIAC>v)>BjYcxX@5D4RvyxtQeOpUAg~qq5(Tne|=j|ij=`2L> z9Eph;ZH{?s(4Sk5+Nrz7a4z@Ss5P@{r-XmY&uZO|lxZZVM30?+&30V97=kfKEt+Xy zVm^9NVqQT}v*k7ZbKAsAk42_Frg7frq!y-Opij)5^J~znPJHpm2$Sx+alIgn4i(aV zcYp%2i0#xbTpRtg`#`1lpxj@o+C=*LE#eo%k`uDek@RvN-&@`h&MfzbiGJrMZ-7Ny zuVjh@G;#{bP1Af}*UZ^q^Pkn)iM>4Gy75D3El&4|pjXZ1i3g*KBulA3i6_^XbQblxO z^yZcTF>L=nb=8+jdUXM3EU2W@0+UuFx*w@VUM+JHspT!f(Wyla41H>^Zxyq3Hj(;3 zS;XRn6%4{fo1c=GbTDFG;Sb;0H@I=3(Ain<5$4r{NhZ7X3FF12ZA7$ckT<4=2}N8f z_Pt)OIdgB-ZEWxOk|@!ZKM$H`+-svh;>tqjtO&YaAPbOPJjx60o8{A?hkRMef#=Y% z$Eph`CI(vvPxuTa37V{&lr%229q+z3tGC-YQ|UVJba>}MlyT*q;IqP$KJ~}VG!B#5 zI-XebgVFmNT@Wd}+hml`-cYv6V@*j=^JPd;9GJ|EMY`s|6k6UC&J!DzDHN?gvS-_pomCOB z@KQzG`Ij6t<$mqpo7&CVoE?V&NC8X%)1fB(;u}dUX6i*dQIZ!pEp7E%enT)zRT<`2 zM6}N{@H$@M@%HAAHpgft?j>yc>ok)yBs%Ygn{G;CNt)cC*j~&DB)Pljr&U~ciFa{V18iYV^u^ncZiG4|7f7WxW#4GaF05-_4sO6o zoN6F>E3ZFVQlHMI8cC9)F{4^qP5pw&H55MJe_Comlxdt!=>Z;xIsXjrqS!I3 zS3=8U^%Iq}Sx&G-T4@ZDL%Ych##DNjs*e5l@^+dHfsYO zB1aOQxFl&zs1E`Y9qpVYVYm5~I7y7*qTFcMVIQMFrt=GKb!dpaT#GJia`qaLTm0rh z`I_0UPpQ221`O<~@iVI8#U(7tR9ZjKcbRDiwc@pH)Eu=4)ckxWX{!yl>s{(cj6 zHx7m{H7`<#Eaedx#Zcc_vup$CYMW@@!p&K132zQ!{lTYU7qzx~;E)Q((3nNvIUUX< zkhkof*rFOo^_m2nQ1f!uwm7RjuS+O-zVmnqj!Sx8uuIxkU!Z0DPxp05-$W$tsfJ>` zm2^p_tSs+5&v&iJf+e~ZI|O_;H_`dSbVyED!(id29@X zJ(_7i_uG_9?lXp{?|GW(XA1CVbH5KguI)VPiIZI~kcwvAd)Xe$cjnyn55rGF%&tx| z7Fj&Gj-!(26@?f~9=?!Tt$jV{t;LU$$A+fWhrE)=+dK0y>weMFw=Fia0-nH-_WYgZ z*xkf&#ejw7C(AEiZr-%$hhZ!Z98YpmH6ESzU5jQCla5}ypZPi6e7d(3{G%F+Aa z|G{`@s`CCQ1LIK6DmbdAk~~rbYL2(h9?lvb)wxf%45z-cIp}BMe8EsyxIu53KQAqE zCc*4P{0!-ld6Qv8M2Yvfh4)z+foI6G&j*VpCeMF!C5805FV?YRYOMEFVN09yFRXl< zL$5PU*n;Ikay0TZ%Zh1R#06_kbli=wR5O=LBV|$T-H0o_j(bCz!^_}Voyj2rR_Vkd z^)gNJfV=l+5iTZH5$k**P02e!j(cRQ)gI|i>u-YfZ~Mj=Pwd%L9yJI27?Xr6Qz3Pj zW$$D$%8^Leh0!UeprpK~o)wKPIQWicuD11i&ITM<4@$OMi9X_o*!}pFI?h9{zBv$r zXhdhDse8p`fnY}{brXdDu|M+O!G6-c6Q^{TAvET&p9xbSVW`5>S4&G5K*7@|q8 zAzbe1rF%w$B4`2+7|0NIgrbO4mWGON?AoOcWC=Y{rlwSwmXkc!4TY-df9r^$xw?t9U5c6%%{vR+%~EL)o<>p8CbzUrz)QJeIew$|vdAlg0tPB`#c30L<>fIetBPcjj;ZU^Ue!3X0_p`i$PlnK*U<7dliFI`hPg5jS z6TB&6hSQ+48weB3Hz0^0ViNL@I2O}5W$NBGF?fV3h9q9_sQVHlpA#xKJ@|BAfwbI} z`%1heuVR`avadk}gNO*42J?-z#sr=l+cHdnK`?q^3d8SmE_HlhVFF=@dCoafG^Hr` zPu`M2lKd+$?UxnY%N}@K7wapo+wW|}5x5H-DLWDp7}Xtg zJFumrH5`^;8G~r*;Ie+wlg9p=lc_*@bJP-iadIaDr&z4YlxQ1!+$i~E zXbR-9rwi`gRAa$Zmr_IZtY1;{M1FDJ`!%=HB~)Jq|2=BMcKw0x?DzGWZqQ>Mu<#8S zAi$92B~gn9oD7th@|9p+1Q~)x^NeUa!s(1C3Qdp{q;bw|27WGJ%pLv0fG?nkQqMyo zEQA~TS&yWMX=Ba>61kkgpaL1FsL`9kl2l~p&M#S6k?;~>B;>K-bO^y9263RG>CBMJ zARCFyl~5(`1BplvC5|N9aPS=O&XqEWQ%w*=Ta1BqTUxfjU2}IJ65+Tt)9zYg2+s@; zq6rnU32B*zk#p_4DyeU7ft^RE?JZ{!qxBrZ#RVnjiQoPRupYu#^tBIjyL6f%8!@Of0WLH|&5VVx65@revFxkr*RDC_E?>wF8uM?%iUOl`u3PNdZwANPl)SoX0ZxwBPOCQy+BHT zg!EadrBzD_*I=obBs7pu36oqZM)-P0Y>0~=g#4K4W>AkxV#@;DqU32bE{GJNcqN8) zD(me^HWnrZEed{=J&=x%Eeo%hS0Gw z{c>5Mb4|=#yFB4*Nk|1iNnr%#1RQrQ#-+=2

h9oq7mp-IYASh`-1Q;dRz5xBxpuSRP* zQL*!dk059zMP`-LgNw^)_d=|`X?os=U$PE^t9jbu_@vTU+D}1= zF&ZO=m8(r%SSuTSgHuEp%vU>FEra~Z9%TsPP*n6*X>UyKL}7)cALLNFEjB0`m!gw6 zqZ%D;&`14C6s;7p`H|7gptFe0>K{+1;<)g^Pglgc(!3G6n!$mMkh91;&x#9r41_o+ zd4ZHq4f&ai*cJ(&n}%jAI%9uE%^-$DLCEEyTxdBpRg9xMXsFa*Nes8C)TgoJ+zsI# zcotN1#B|6UGQLhYulmnu&)c9l6!s4{dOiT4Y10{Fsa9B#@QCVDIH^=9IFbRZI-Up& zttOJ#HXKKZ+2SIOPc^*rMkes$WNu~crt1YN6k((GDNsuMfSSo4>fo6&tb1rn=&lFp$N35EW=R!1wrsC+dWt6Gf*d7)-jMw^5 zVvX%Dki7&T+_HC@>{&07-M2Ekm4)nB&-`@Hr&7neGhfBJ)w!kAD_}!lLe%1=Ev?N3L5@+^~$TJl;QQEy3%7{BCHu>r5XfR#^lk=OGns9MyV-a}bfTB8k3Ch@6Zr9h!>c2a+ zvVZpeT345s{{Gy((ejN0$yuD@ZJ-XA0Iqv5G`#(!zLvj)y??jzu1lE|{}~1r&*3{O zfE$eguAtV&5UEW>K6Dl(-x;$#6~@kuC8?Q>zxMs5R`&N8Rw-YS{noQiySx;hKT>V? z>lr!Gx3ecsj(3hvb)9~mYA7<=2tn_{ll_}-S*DQIJ@aRY-CSppwfGG@X{m9@*2OCr z$^#^;h{CH=IBt!!S?=rmy;A)Q=WiX%Au!>0CEedQe@?s7RX<*9{Vc2lNOR<4>M{TrF0n~4+{ z01rIh7?r;&cLWN5Irie+FDS1e6R$lX+XJNg`sI)1t(Na>KKr_pG*7&@Y>Sb36t)E< z*lYOaKijH**b+ng3O|`(xKD*#xA7}1wOqV>emO|c-aHHz>gL@qXYmAfMjYjox{5?# zL*~b7CRV#;PoNq8eRK$tOaX)U!&I!2-=!u9G7F@)bj~_rnU;ahl(yBdHTvx8k8b11 z%8%?UlR<0&S+P=JCnm(4Kb;Hh?M|0+$elHZ;7Ab1rr1yEUgJzPriw?UIybHks45QK zcDrsNrJ{`KqhdF8Gda)Ck68NrDe`k969#!Hjt+rEbD^2ei6~ff#?V_e0tO2@dqjtk zM+}F&V_v6WL#FU+{4Z8TPTUvWw;oG_MFA)EgHS|PYLSTpY`I5fp2cgzZ_GDG%zl%H z9Q7uORct3>8NyyCa}+K1J*8ykaNd0MnqXB~GVQs=84BeBEQz9ek=N>YohY>#ubdu~ z+;cjDXWx3awDGzBzTL_Ghn?|_;&m@&NgA`;(TY?|qAkU?o1l0{>u1PC^8c=Bf(jum z{8HQREV&$G*yY>(OEgit{8CVIl5<+t9hWmh63*dn_Gb!doK{20LpolBvHcXRKa3>7 z-8>WXl1!Px`?2nA8M$v|BW8Fb2EXvuO_4`A?s8BK;WHs_%Cj3yr-aZ%iv{`5UGp>i zA53o*8ooQcv^&~s>bIrm)vu+xH}}NEGxf%Yr>P9@KwYOjo#`Dx2M}b3z0|G?7G9S= z(C?Z81N<1pf)bIm&?4T5mFByoXRQ@nT>9FwGv?>esv!+El$^l@DW)J!;N||5@Fh1= z#B;85-a{rP(%&I3Ul-T4Zu#%V<$xJm#40K7Q-{_+hH2{p_bNkK*@o;fIQPQ73doYC zm^b4Rn@#WnwP=oxL{?*%i?)Dy%P}S`I0R09$HHGuvio|P?pe_GIK&Am-U&0ER*xyo zZabf+Z=L8$qK;;Pcxah_b8E}NRLcD4Vyc{y8Hbg-QN1oXhihz(Ud@j$?_2M`SJ1kI z`uY=!7JC=m@sl3&SSIxJMkAcspueG`q}rIctB#Jf!v`a;KQfi+{Fe5-sGL4I*Ow>v zf`5wA@G-vlRwQ`2I9?%#bZv3&1s^}|<|J0+oS4|VPx}3Gk*b)KL+XiWfn>a08^4sN zgZURC6o;e&3i_u*IXf4=wVdG6jQ*%r(slVoNJ3Ag2afMu7PRBjCxNE}Jh&`%V$3xs zc0CqF1%R&$4@OEFiRAmyukg;e)93NXbMmG4z5qd(8Lc3R{8uwp!T|Uh2Vf>0B8bwE zryB7sD_2_80Qkh2)L z=v#xgZQ~^;tTiQSDpP_Z`DRl@dm?K#7nE;;UrNV@3HRv}g@ZCx&Q-D>94;0D^UI+119zMGvi zda`S=Z*l1g4PQII)D@bD7wId%K1+STHf`-OWQnpBJ0p7^Hb zNv?(a6NP1#5$3Pp|U)Y+l7IpR=;mQ&Ek^S>?n25Q;>Bzh}_7AqzI%c{|xptifDJ3d*;T1^aP^ z;|Gh60{moH5-42E^P|h701s1NvV++Dfoo^P7kn^|L}a{;m161^vNh&9o*F}enb9}{ z>wFzg0RY|!-k9g_-_NF)*%h##oHf|DA2Cm&L-@usm zhrp5kzLIW96@L`7M5xllW7QE!xJ5{dy3`+Lpky>{&h(8){ga}obz2Zj3G)*Fg|UqQ z^*eeYy}hHV4ApbA7*XpmRdVzhFe5U z3i$6&&U21u#)2^pqq4a?50d4kO)USG;MaIK*A^^S?7MC+0RiB-sH0h~9FJXCGFgey_bG={^l(g`r0NbWzYHGPCbc^<$Lt=OeV zkoe8drK{#q%-+u4R*RRr>J0l)PG;RdUJWkSI6tubcK_C|dHY+xbd$gifp$z(!f?sk zWL4pn!nUxe4csgeaVXgWCzr>(1>^2V8Iw&ZS%tJjln5MD_+TFCb-aUdB^0Ef1112* z`o^x5RC`3yw!4l&trt--W5T0@F4%whO1CtqW{|fe5fhS7$zRhHX=VY+!L;z+!62B< zV-%x^bz2rpPE7?7$`^6qW}2JD_V{h z(@Zjk71W^QlAuHsf&y$+1cu=NpLfQj*O8+YI(~2rWKd#kY(855+Ia(Z{gFIC$2h!o zno%4g(EqiFInn3sdDFmSJ<1Wp+BdoXF)s|h z!r*{fx0O2i$f8wLLx3*?2x4>NI@UTLh8d?P=Sg4aH{ZZfa1+NHn!IVjo=*Jdvq@2R zq}gQ*VO02jNQn+{nAPOW6~0Rg@CZF*8ZwHWBibs7)#*-=kfyGl{<5p04D-(ioA|kE zulfnU{XIstQ5Hvj7;1TSPzS5+35kdxvi^U|B$HUIv0RpFoY zJV0TNuR9`ffPuAd4RkpSKb@4$j65fTF6?R64qbO>}jIN4uS+5rd zdG2=KdQ9Hk|L{!8N&Zb%%+}dU)xhuYto;7K!9wc8szxL<=jTuRfTQ&ciR1Ha6FdVC ze2MxDeSCZ_v>EE@&7BNhTw#oT3!)b2rU1JM|ATuLQWfXa=2A*-*R>w6Wj9t_Tsajh z<%wTAS-c~4FSVOybVe$Yoh{a+xNjcUtMZl3ePm`M9lxWgm2nTP8& zElxL#tNoIYxS)~?#$66ab>i5vGTCr`%4ctNh@+UTLPA#II-YCGX<;qLxs6cr=~=$R zN#u`?b*?gzSrB_ARuw*Zn~@!#uu?K(afu!65Tc3V#kWA#j_DffF= zX>GjRL+bpNje22ItQ%9vF1$wS^+{x6y?Qd})L7nUX=!}HZaeW`L%}DpY3OL+J-STMV!O-sLwA&x7?D2PwOuK%75vc5gS5a^l|xA@ zNm$)ZvhjVFiG%T-+W`3A9x5^!1Nd~w%<^EVsHW)0WGVjC#Eo~t_^60?_J3EXT{#?- zMQlJQgsXza!cq^@t*kHxS!F&&XhLkbNokDkmn1hFl7kKtj@x|H!L7ts(&Hw@PpzbC z6n=Bf^5J6Ats@5|=F8*m2}>hOL?=(py=T9+`Gy4XQWVqqOo?YP)|yt?U)LOkCSNeF za3?nN?TB?Dx_IlhOYVfezhG;vv&NhhzqD`|;O#DWjJ(Wd*tpvKY2{RG*~6Xtt06EN zHoV#DSk2H8-d6S+g#1K=_{^?$6RmZF;nZpY63aE)F|VB>6mg-m$q;8#Dj z&+N@-c-=Df$qjf;n15t*qi5|U$c5(_-qR5)O`IPUS^MC(zqvjHjUg#6VJj9{iyqqbvl(Tq%dnYBIrMXY z*x3cp>ZKvOM9|%e@yb-Rqp%WFtPDFrT!xcjO3O*2n4LKVj*`=vGkvu^Pn{9m)>6;g zyM}r6F{b0*`H47#?SWao@v5mSjc*-&3@xs5rl*S09I6KKT6}uHe&t?Q&&Makf0);a zlZk(k#>Up-M$XdUn}^dLegyWbNzQlvTNt~43IsuA-XKe}8^q?(uXX=Zib(ljpJ3H2 zqMnN7;l_{8V`rUer?>=%Q*ECwPJ{_v+7`-=SnSJx*hZPnmGot%)b_bgt16vnIgBiF zVQQ!TPS_r0jZg3J;og`UF`1RpUPZkYTd@`30j2X7@wq z=nWEf4$ykF@Pm?WYorLY)UHehD!qSort9=FAANOp;8exXBwJOrN~?p z*S5o)%#~h{VH`De?Z_<;;Uyo<{l?hqZc;Oz;B8_i_f*=)6-siE(gJ~TP6H>lKCDZb z(PZ|)*3Y?<1WmFW`C!;y_)L^goijN4J7yXZ7Sf#7B=DSl4FxEwZ}AH93CD8i(Ihf= zN-Fd;y|&SA?VaY(fd?5Z^uh1KEL(Rj^zBVa#C=n@HV8Z7?2T8@jRSSnGOq`lTYY9X zjL7c2V;k=02ZkyRs?PVo&^m!YSAjkt{&2hRhnnGbH3f;M~QrV@>-OL{3LbeeX30`5kE;Upp~^7txqUn zw$I5iyFpD;<3980_ZPmr@E-x(^CwrZLs3<0J zxRQHNY`WnfjD~%s5<~|vwXto`W)TY}|BI>Jv278n!c<+(-*1OqJa=8ira)joWST5( zMa;aQh%_*98L9o@GApihnNYeyOL|&AW2DKVRs3Z>%c}otXVAsh%Cl#qZ7PQsuta3n z>PObk{-rsS27Zl$@+63mFEl)Ayd^q{dHu$cQ`77Z7GA6Xfu{-xGY=&)H_ytJ%~_v6 zyu^EoEUn_n>LvtIxM`qyx_!139R7e~(vtQUQN<0!nKvWH52jRm{fl6|uZyXE@yRJ+ zt4yD1$OUnH4qa!K5SGB?AY256m5Q8)!-Z+bATWa`)EHq2_eHC?{l=x8@rObsR5BYh z0lUFB7@F=_pv+?Za-fLh#ut{K$PeURQB9neFgm;|d?rYQ+c9cp?qJe;-BkD3W3l&R z0Gq(*-ksV!)mXM;iFK3K@~M>J+$W|#<)h}D7nZ-3yT!^LOVCs$TT8ZTWW@b6qQ$(` zAnc??EJ;_Hkgx1#=2jUN!;Kvb8P~rm5D?vtnd%wI(cxpvYaaqn%*8?g$-!?vR{fHw z=PAJlm!-|a7^j%Pw^{QAVtX^Cm{Cvqa+F?_RpF5lUo3qMc`n*)sK&@prfgSp+S6vqubUJE?b} zA`m|MX!C!ZJ;8WAPkb**$CD)}PUm4t>8VnXY@)WPj^SWyiv?JAo`YdJrUWV0G#qED z`Qj}{-~N95$@f<#YF*j<8J68JG&9*C-Gv4|wdQ~=5)}?AI_UYupZ3GCf;EG23~BfI zyFC4eg*aYNEtTdj-7ScTOI{Q!H56>aeb!!n-Gc2mhk-aGoyPG$AQlNJoSGKh?t@9o zZ(V@Pq#vgrv&m5adKau<)pE%B8o$|M@Pl_rRAeyGNGnk38fi|ReL=6jO_gy3Q9+|) zi>=PpMBXcTO8+`dZ-NcJG{ifF*PX3X&>sfu9|n!P@`oTcHHw&!#l1uWmkP(oLxmv5 zRK+Bu^q#+kx+BMGS7;%ugqC>Xt`%W;@w^C%^k2-Sk*t|f%vzOK4OzksiQU|SE5QHy zSRuiR{&W_1d4LMc;lhT{WK*X4ZM5YbCY}d+L>U27{);vlY(M6g(jV@KC`k)$5kc>I zs$d#D54bP*G)NP%a>!$~vR(qajWmI%<5S`Lf6Y-e2Zsa-hteP6z~OQy)>bt}N;(DG z0R!Y=!+0Ye>v6!4g>)z!K_b0R z*Smom&JCoul%MgH6i?~>?SkC?2Vt7!Bq3vwg+@;nTjx6gD{d5oJB=0J@=4__$=y`J z;BEg32n?F%dh~fR0XctKH@j*KRDpxwmrW8f;E~(c&ECv&mIOVew-gB_)b~8R_l+~p z;qx3*N^wP&`GDB(PpAAEI@{-26EAxp&BQ+Xvs@EV{)<5=5i4;ssgNN zoSb=@H1qxllHlxFKLHedT!s;lPC-dWR`fiF$UPolvMdE%AL)RrX-1Pq&wjue*pcy{ zCHUBUH5ajEo7-9+O+9~Y)2|IUvXZb%}Cx*-w`ZB%s&SKcmB#5NjJc9gE70$YNcxvte4Zhy{#dG7x}YI9WkfedwDBkGR; z5&v1w=YV`9H}GZ<*p=FjUzDjzJ!mzRR4@Rul{!5OBTU)XoWEL>$eDCziPl(EXoT0j zFLKjk7Qq7lsTxTAo4NrQK5z@;flAd;323x2@YOn7A4bQ^>8GWDuTM<>{9AIl`&T`2 zxk_ZZLcw@a7*BQqUB@{qDniC|57gig%pJsoIPfpyS2?1Kl((2u1ML!$? zWc%n+R~^$i@d!<->X(5VIA=sD-Z&5MOoxa0Jz}hDx3RIgJ~6v$MA&zMFD>$6B;;wx zQ@kBAo@;YpqIpFmDXL!*kww8H+~RPhmekt%BVZhK@eJapO@9j-!h1CY5yT($YBD&k z)KW+)*{|z>Lqw7@(dwJva3U*p44HtGxZJPj7>PxteAu%vU1x&I7}@;KheC0}&uKCQ zf?=Na*x`aeMbWkOw9{wZfo4t#WYh>+6|j{mg@+j1biMxLlbks31M+=)6^tvTT0UNa z{kO8of^yjwwB72|q>>P!eL`%TSwd9c|66XPPN;Vvhy`S>bkAP@Ol0Lk`yG%EQj!>N zKPH~prQ_q55*Jptz!(fglmM&cJ1#b~n(gYts)wr|dLA>2e*>Xu*681AXIRHXIYDJ2 z)_Qb@-qYS(D;O+gCv{yqCz~S4m5w zJ9ay}^nTw<+SrzgYJb@lWtDDUe?zVEUtjKa2s}cW3Xc3s%f@G7EHN+7VuQ#KaP_Rx z%)rn4!;8;==pd}M2^^!UQ$n@vNvnk#0;8qYHByT?3AYL1*y79gzvDp`31?9M!8iZB zNvXhk^{WS!0gqo&We zr^$`7xuXAEX9c{722lIp&o2JxqSxdF;NiRF&1<&t}LZ)Y)%{fUGS{Pe`5}7>!6G@ssg9I#F)6ouj?V_Ic?7?&;rMg{Hupv zx-8)_yh@i1$Znz(K*n<6)4T3pZ;>(u@m{ ziE)MFBCKvVo(#Di@R8xxKIVEI`;6hRKKm_2LR%Ot142*lhwXi`^30I=UtYh}JUQL} zPYCb1pUhWtyA5|n;5MEsN0+bs`m?JA^t4S9eQ)n@9l9!AEv91r9ab)unoHF2ReCf} z(%Gb(8{zkt=+y+ooMs!GiIpKlgQJZJxKXsZ|>^Fj6Bn7n|3njMHB!<;ZR(pPElg$uzi8l-AIQL`_k(J}V>ZI{|o8{4| z(?0L|$I&|1hFi#p>xh>N8h%4m$3};E#z6uSDfv#)L3yC`gTT;1gfAz0AKkGvrc)$}_YUvDZblSIOV77eLyAs;so(?)Ak?2(#z6q(;>HoqY zYOK4uZUdw0eKU>h_gImRdm`I9oSghQ-`4iuRFd&jsF9u~M=u<12(6)v%O5-@>nCW9 z4`dH9-*ztN{nmKz{Bu`u@X9%3QS#l2LG{UB>3k)Rq>iqhEe!h8zANI){p0jJA6N*u zC3>VIrS5%mXXpDUGulkPD27#Y+F7s+aKHDhOs)30Pn4h!-1Zl=P7?i9G5I@{u~>F zLpAVf_2X2LVXnKRE(a*dd$HK=vZ-Co%G2?1A1XdD+2L81y4vQp_lQx7Kk>yrIj-*E8-kHbH!GwM;cAQk6nwV>o1 z_5lMX(!g(CN6I@Ef&K;bwvQqMCJ=y`?DymU(YwIj>`Q0%o`*rm>EeN!+64O>2lK&5 z$f;l?oFNejmTIPH5;~syO@zCpe1?D0BMQl&3L=FYZuNQ1#8rySBefImvI1|fj5skR z3|Nb#RCtgqjUnW<;{Td#?p+*&#ukgf2-u)-ldHkY+n=@N*n~4%*13|Y5g3%PCL7g} zBPHQ8rGFhQfD#y4E2!f)a48iDbcjBW#yq@L2%2Dq{W8TAmJugW5khx~CVxg{AtVKW z)~LwLnFw-RFnPR;h!l}0nbPz$G7GWru%Cu{r?No5mwIYue10j*h)ys z(>`;;X5?~q4)@mrc}8((K$R2#*h*v-R4{S+VhivnS@2(^{QuzffP1_DwCVnb77t-$ zum3#h|HawSuc47;nO<4_+PC#!Qhukyc5k%{>>Gt4(AN`CN_W!7WnRJ2{-LJG6dvMunJjjTY5nN!{oUEA}G^QVQF;TWonyB+t zRqibTSJQPk%CfV1Kc`*gAy)x6+CaFg=`FdG_}iEAD!`Z}o9Onz;LVr?a45~^(-%Hj zcWTA}ZmeBoi3!JAWXzwyAB;saz5AY@5ipfOtUtU$Ktb90M8wZ`y27Z=PCcpox1iL^ z@~c=k-KaAw;aoA!`57*uqor@Y7yoY_2!IrKAsn0)&D2t#sQl;0a%Kn)t^#~g{$j{! z){uFRK)Of&Lr6NJTVatzrdlBjB?`V9X(z2DN^ov$y3^*&oW@H(D_Z%CM7C@b;zZf( zN>U)fkTyK8b7RYc=IDjj^w!|=-0@X#4RfQop3mfG+q=TVF^~vl0Fi_?oCJ;9 z8F4wsvn>yZ_I=@hf-4<^2m$+sh_{=@fJFRK8@T|oNvy8z9OY@p_bSI$G_TB^E zsV2-5KevTPz}l~^JyKeuLja*{u;Km$;5HHe6rb7Wr$nO{%{AZ+63b#G5WLkA_pD(GS$8T+fPR4mKRBT;vJ@Qfy?z^AK`935vjMbs@k zqaITuo!@RgW3B(En-4ixLCuLnh4?$FaY%{Jij9kc>nST=6lpyC4rG?w5@~Z$A407K z0yIcd_D-GI7vWOU9qsgbA1G8eTNy!-bIa`PESIp7t;7mIM!sc_M9?`z6G!t0Fp&1| z&q4oBupJi~epB+~@RT$p)2;hz<>0I^6gKzmHY|J-zl9}Z9OM`Xb>X=Zimn`zQ>do> z%2YuNucFEfv3^RcGyo6ldAC(T|XP2xDbVsdU_jaL=e7qlr zUvnbV(if-Xi3rJkS2o09d34NV-{QpL>WDeRA62>JG08?0XvFlEsoB8dH6Vnw8B`ou zTY_N8z8n4+M|Ly_^Kfw7s{|3WHEc+*Wi>UYmYRVI1|?)mLX6pq{&P`5_;>QWGv;Qz zu*G!<+v3tl0S8FTu&_9NY5Sr{=!MhL=u5Xgetxk@3I@fk(;RL+@v_wNQ995Gu3%Uc z0b>VAZNq*!qhDAbsH8#=BwI-CC||u8jd<#8)aC?dbs0%x&(h@J@Kd5#F7kaS&G9%3k^oONKI)z(HQ| zpj(`Q{O5=gq#}hU8#q1?dMQ78720R7L2c(m|Gfe57OYye4)N-D2*?uy7-29B`OiR% zi>p9K6uoVyrWukj^Wtf^TyQ>NlxqXvistOSPgg?w(MDu+DwNBRb3Zsh$W)&A;mBfC z!gb?{WkSOXR`_-@5Jt$C$MZ=^tD{O%0_B40X(~o9UnBBqz#`gW4J5&Rg9ZtoiKoC!1h9Jm0%^ATq9U!pDDwruf# zevxPV|0+)PRCa0#b>-Fd)TNdE{?}T>|8D}7iOdG>7m;=)84z9_IxS`ko(w7X<=^m1 z;JzM-c6>eI1k}tt?^ABORv_I3%uOr^;2ftjm4GNUGy=@wJ~s}YtMEy&x2v=u1smd^ zE_|9<9sCn3lk`Sp9j2c6e!2S3rA{hp*Rynj1?@r9EGW&(6u78V)<&|GG(#yR%_HH}J`rT~f6HL7kQhWDJ~eM`Bt zx%~(S=A7T32!reiyOAtU3}g^|e**{8uD50+m860N1B|D2S_#et2#|5g64;KZ*bsZk z2A)^H-qdyFLNa9{Ay~`IUjgJ0aAo_~oHd&qZ!*^2TsOHa zoxp9TTMP*BCSCvtfS1CzpqqQN1hYXxF8<9qkWHY!vsej|Lx!D#w~6G)xF?yTfzr+J z5Zv9U#y?XOipEXO%q{Z-#o|&*Eh}LlmbRm$o`YwGVD|L;9%bI<-={G992US!slu%z za*A+6$e2uiZD28y8AYCBKF{IO5apwSW8hIlmh@F>jEJ}V7O7LUqyFcDh+-M_@9Jz1 z!bkhIR;6f=UUR?}tA@1LzybXkUOXF{$@dyRETTW*-^BU5DEfAQ^r#)U_d(s*UT{@o zgcKZTON_=4*#0c2z6~5crUaB6FuOOg;4WKGS{O;dg>0@}_kFMZhnEaU2{8d;j3Za$ zKmDDvt`>!$7J_mAb#KOLB9?=}tpzT0&T_^5F=jTLv$MvKJer@p3r;>e7i|vd_;XKe zorImz>{BA^3-q0qrx5Ahp?5lpIAH!sfUMt(bb`#@0#cAgkgy_9Y5QGR(LZT0%L=a}w==Hlt&bgm^Kjoftf6w!qf6nuq zyvOYK-fOS@TCeq5YyVY9PBWO_3?96`5HS@pqaH%fR@ma(HKe$@6qh(s%mvuzes2gL zH*~AApC5KsoaLk{ZY})p#@-!3$_B>4WK_|q?TeU7X9Kl7aDWF+vEd7+f$SV4VhGN0 zO}{6EYRB{Vd3?W)Svd9N#>t^4@VAeoKOX;khf(E8wIss)Z>CQ2*INJYq>09aSjtTz zKk3LHp|`&^f(}>tx)E!E)UOp*zp~ptM&eFeubx$|z`=kNa%%NcpIZvDGA}f}Q9AOE zr`LE=3jvb~;{I180H8wEV2$l_c8w0lb^o1Y(VR9$fO&d250s*-^LLN*zZDU$-7y*x(IsiXY z*7RH+!VG#o-HM$8z=j}7oz;0KHW$J8cfw`Vj4ZU6gDJVhYvG=x)0R2DnCxUfJm7pF z|G=uRQNZAD9~ZH!>KW1j+I>&){n1$USG8`CYLYOx$tzlYrqGDzT1euU=f+n`h7&`3 zCT5E)G5LhNWZ&;iQC}?)M6G5#Ji34{lB9SL+$Sdp#KQ&J0ABW?Gps)=l-W;8iNH8e7OS354b;wtdXREDcMqYe>#|4{Kk|Ig!L(4M*j4}O#k^$8jNZt|k`6TUQ( z-#|P$i38Am)PNSetxMcmqgce8*&B7T%?J~ng_^U-;<=`E!STEJqM|a33P*FfBXE_mcVTS?_FPyB=Zhku1DxD>?3J;2KK-3+P^~QAT(Nsur7-VPB zOO*yiq6g%_Qd1vgxj)4`;ffns07Hd3}fUSR4_F-e9YxrowzJydg@t87~Fs%g&rW!bIk;akMQxwNx|&j=4tUi zLBpMbeBBw(?Vb!pLE~nCBeS2}81xrr5X_SnJ8K93L#A(=>()YH z>uKnNPzcXHp+d#&i!CdgukHOHFt%*$PhQDe?KS?Gvaq!N6{y&j{kL$>p$!%#|7pa6 zK$z})zAU+O_}EfsGvMou=W@K|uBN!%C*}6$2`-!ap1J~j3oiHQ|2Y@`?vZpm>V*mx z((>>XM`o)m*omN$Sp;?xHRba=cGcY5US$mSX5`h`hL~E`$T+6X+B+S{IET5QoiQ(~ zZWy=#?&aFn2=zl=$irYU*7aeRkoM^93DYis^rQwinbJ`poU64`Huxq;kdM75u zhX65HMi7yp^+xxV-W_`#*{`_}g$I9+3C`y~MgNs^pVoaAhFA`*x=8j~eP4E7j_pbZ zQqCtaSep-|HN6tHkrP5U=v6iB!*q}5UwY2Y!Wb4{heziB!TF}oI6M^`@6Onmwwyu7 zCf@epAy$raKPMq+HSqh7bIZlSv|9d6De-~sADV&=_XZ!(4-;zc9oACK?6RnZPQ8|H zy|6#R^?phy@;1g7rSQFZ`f<)AP~qzm!;qjlKFM{Gm`rx%W#Br0DUeFe%N-uX`eVz{ z9y51*n@O45jtWhmSAmuQ;x`5*QJIvC7cW{H+`5&%@v;ssVGQ8w?Wbf)l%R$~qa2(% zpN15r=+EIRaJm|mpGSG&%G>K`IhI$g>zdSchTr*l`tHse4|KUa)Fm5z?NB;WJ(_g# zx33L?m{_E=Xmr+Q1Ko6Z&C#OqJBQuZ{7}1t`yiMcCZmB)2uXa(BIDpFcTEom4GU)A zQoBk97?+W>MpK@C8GZuCmR929uLcH2wZZ%7;9p&*`IA9`XcNW#q{lQhsZG`=8ua2r zE-KRoAB$r9yaIl+@`9nGES$sA9x-tiphNez*S!rlm$Q*z^FWF&dy%A$DWkpikjJiPP9n?#e3X4cx)Fq48lSp5>K`Y1z9~IbU~H zDBefC`tCF>3@7UAw7=DOz=&0Q#JaT2-yihwz5lgUYujL~#6Y0Nl_iHysDyFH-1L-@ z_R8RemC3H3h`H`tN6)C?zz_15R;=u}$);Z>x?+#IrvIUl{Eu)35ifbQu4Yz=KLx7V;`dFb+bH4=C~Fgar9% z?sM;F00Fu79-@%)v>5J8S7wbF?supI1fJiuBNa~H^$uR%n%b2{SGfx@Yk}%}uo)y1u2!;y$AeStrDmxivKL?fb3G8p}cn ztAV&sY|GvXyB*uEOe@{0?ztD3UE@4v144*Php_&bK656~#VzZ}>{%M29qVk|NLRf5 z9Imck#Eq#!A(CI(vxpufMztLric3oPoD~#RW?G4s-G6S*C zRTY*9B52$^u&K<@bXJHDVhTkK%ELaAad4GWg)!QBTnGnQy&0kI&5w@MvsAwm#Wzjx ziQ=w56UD_Yd)vW1xfq}rQD}X=&1^5v;?NR6A)dW?l42en1->Ohgz_~iq;*W^i}4ku zL_0W0a_qwK#o^Ng(Urc^g~mRBBM*JcE=Bz417V+s>-X$#1yhh5E}rFUZj+)PB9wvW z+B_e>Gg}}Ix-EtDEs1mnok!vlNu=wbcbpe3~WsJ1Jf9^L)7RWH* zX|}@k^S+>1@*BY!S(L&}hGbG2=OG|`iUY+6zd6fjMmvz4_k&mD5!#MHhE9E%SN{FZ z8Z{}_y2S0MRX#w(d_Fl`z!1~r{1HB@_^OsR)Iyvm{&55m<9uSd`Q!oIj-;UEcj^^C{rvAywW`RGd`q(Jv zm~YwV^0r-8f4#u~KPrt{ z#r4OsebaP(jxblE_*4 z${*`u;=OhXHa+>h2gPmV-IZodH^~Er#zKQx8!Q1P@7gG%l4Bk4GHVlco zO^o9u^VbeH`Yp>qOPPKe)~lc7o0e+E#vw++pSFX$C%S*SA9&{zg0nd8p{mf;m8*8|e;)cg4_NB2 zF8R?W@@>V^BGH5{_mRC@{I{t+xDW2Fa|O=^CT-PSw`c&9VA>r%=x zqjqERg-OQ3NZaRc%e{`*apqdf&lZKTS9)pK&(-@hy+nm*zj1o<*)sUh+jrcfz4kG; zdL5`X!*KZjd{qM4<_2-3eDi4MIPwF5yKyv-j!bv@A`JZ(m_UoF56^)_``0a6r$Ly!5$rT zCQHI3$>~Xta6Rra=pqx+iUnmoBOqn>S-w4C4m4`nqVJu3YPI~Doq+VqXhQ&c5?_5m zdAAvu&P)!?O{Hwm>ERM^gg_BJ5k%DZ0)(O;2)T)Xto)=SlAD_rqyyH*pa~IaN6Dh@ z;kJrxo^)Wy z;>UKS5g~tPwT1(}OAVWRP~i7X?gZJyhp5i3F68a7m9u&tpm6KW@dTH+Iw-Xy3xX~u zY6*Mv%Iy~&A3cB0K@Hvs@;5~`bx5a??8^-_?AWsW1&%8rUf(kM)p_pAw;8|Ovo=(M zCo~`IbaCi^;|}W@f3i~Qe*7A{0nJUNfiG-v49*qj6`fPBLl%&?n9U$2GM3)GCgA^8 zu1ctfUl)RGN=C#M-4g|+t0a(yUp+9(bQ$k^oXCyGPN25YHh?8amPK7=Chm%CTH7P7 zLrKvqf)~4(0h9n3=#wx_I72H%^b=ciI>0?<^RwTsuDw{%LVPQq3$A+OU973`0}3v@5O>-8Q|{#ux3~}%XV8gEI!@@t=)3j zqTK_U7N~59xwhr{JmLIBk%{SxpGCHbmsmn_?TPz(_j`Pg?`?ab?;0kXH8zgI?q#?8 zEMZn+i9~xI%+JgZQ*Sus)$E9Iz*L%u)1 zG=KBzzj4$gd2qL+Zc$)+Dva*p(1)$|yAxSJyZc#uc;HX3sR$ycJi?oa^of^tQylB9 zyBZZWF!vL589v1@J^?xO3a30jI9tt13BT3Rpp+G#LCEw z>Gm_jD@KfC?K=D2zR82)E5Wl*yc;WMurCfvF7kMPWc)RFJ`KCpR`FsTJK}Q>`39*j zmW>Tu*krN`WMb3o)EXW-!*CnsMgukYsCrET{AY0?$zs6iN#`n0)9zgAH80`1pBIK} zJ?Bjolx8^~BzaTqVN0SC8XtVuo;Drih?G+^98$xp1c>chLJ zzZ;7UoK~d)MFA{+%zdYkx4do}Ij7K}0GIO@(*8&?pdtjo(5K8qP64E|11qRm!EXYA z!jT;XXD{G2)Zs-f?-fB25DUnCfxMzsnsW?MD&H9Bwgy^5&7S(dv|p!KK$n=GF(|q} z*lY=)^2YZZxkt+IZu2tE zit5C3f^?K0Tp|+x0!C6@05D#F0Ht40yuwdkFKdIM87tQWVgZ z&nrM`2>);kco;OPStmorB|iIR`3!0s0Zl;h zV|NEjEETD89Ctkh=tW#}u4tZwC!p#8N!LOaK`{5h&}+3$6M= z_>06VoP+}cY|Hm(ZY&j@H(*(8l4++VfK;baRn>{lN-;jm+I8L>id>H}7WcZ&M`u{x& z`Nxo;g*dNVvWZ$k1*LFMj#XYp_*>=#%JFD{D1eq-;rkDhL}uQer1VD7{}x(((kp+; zK}@!T*mIR#mzZN$Mlb*arT7y5_0^SS)Fdbt$?~N;gFi8sE4iv1sUKwZ*;z9}a zYd28>*>9Fa@NL-TUn(UWh3c z`SX;}iE2gSXx~_xiabSi^&&G~8_*_Ria~p#0C)15PT)2FiX+9RK=Fev0)w7tVgHN% zF<`LI2Q&WNv2kllNZ;ozg-@8=mC6AL|2CuT#ayRN+bfm$@cwTf8MjqwFfMZy=_TJP zPi=m`=)!~6@fJz2e9fFn=>)EDD*3@YW83uj(BCk<`1Y5G<*)grKR@14wcaJ5R)|pIdH5r_?i+C4eZ|>d?`Kx=;L=KKQa-pf{M0s?u_V}}q^FsaJ+Zl(GGsw{%w_G_`zjxP$I#1*yVJv4CLuvgnG9SA)n%IgBt_`Te@(*PkeQ_S% z&3UmovHS7pL*#VRS7!B(SxrLq4ayt&RaddA8JDP!o8{LgVqS2x;m^+MDC$S}`5eLdVa3X<(bCYg-SFq1U&m}nX>VMcH`eDF z+C7{RdD_}!p5a1}y`)rHL5r&f)d~+Gje>xGoz=mN`T-^Dd3-3*3s5HURdr@j zy?uzd(cpRC7s^?#1cKL4ki3VT%*IZrGhCE#75KvYs>(AGkCNob=Y58Y+T!VR+BHId zcm(-{wjO-q@s%}{)DzN!wa0Cdz(1D=p6^}5ELBZ)6c0*2s&x2>ZFG#OtvNe0v0Q2P z$gFTOy6sxe4Wx_F+n*_e)4XW;bC#fm)c7zN>O8V)@8}az^j!)FxUWoNRC+#*5wzsy zY~08Z8O%u7p%qQoctwZgYjNyM`rg!}rl3^Z7N|pta<$r0IGjHNPc}O;&Wn@dI; zzEl0`-b@E=c49sss!G(z6K)!HJC;?nnntf7Bv6iw7;%Y@4(04b$t3R1C2&}i&RRyV zg*ohxTm7|0>=1`KPDgxi@0@d7|%BJR9f{d%Yu_A+-GE z&()3IebFtiKAq>cGIPCIb#K>ad<^MR=;5>pvl%y*-M{xvr}iDm__`(A>Dq-isf+R% zKBJD_kXJJa@^VCX0lhUHBUnNKC;%fCafHF4l%35-r(W4#-HHjby4;XzwqMr_XI~_! zeSt?!_^WZiog^IQJv$0pTIR|78nb_~!)N>4L$WC-S#sv$MD zR>;$O?5SDQDsvda+cLC7tV`AY{APQ!E=HA0;kaip<5m8z*8)Z7P&hHdh277Gkf&O~fx3jl<#5Y38je^G^0_iCWw)@Idp^d{Iq9`X zfKMhWbMP&CA7?Z(wCJ1Vk?{4Se9yy#^7m(0W*a0F?zNqB0Cz9Cw@^-Ft&aB~5M4j= za3A|=s^bj5^T8IHf#iS*&Nlh!zS>OQzWsgwv2pT~HwL9Jv7@rPU|IySAOfodG^8|~ z@33rPF|2ALFHQ?I?J8{U&}77l?)_}_{0w`$RZT^lf0heFvv-DvzdlEeoJz`IuQ+~E zG_&o&Jy6`JzZqdlP6=mum0_wkqD{jMdKo%6_uJ=7-5Fl+(z{+UR;|OG-{5CKar1Qa zRsDJox14L|B=t;Hm_8&6%sf-BQ0OcK7u)k0FZA44DdnG?ys1SdIOp$Phjj4lX4t{QbTfF3=<^gJg?3Q6uTj$L1{9 zd$s1|F<^#jI z%!Qv8jv1bT?^p+x>-juLjChP7dYfEooEr%mI(Xb0&D437UR^lMKR`ssTzYQ6B{*vD#)9nGUAb zT-dnXfCUcoX`50|Xfd$QJw&Ze6D8{T6jTV>hi41G46XAz<4=`0;JlhuG|q@;hxPZY zzrWb)i60;v7~r!QRs(zWr0lkWXGGM46cq3rVZ=>WdaYqDFtcadlx7|;4osa)K_oHs z0r6)}LT+)RkG^9=iaS248jC|WN0ZX~yiXg@C+=Z#_+d=qQYY{3307xr&2S*I!fkia zODItwuUa%k8o%50I%!4o`_b0n`LzWy;-|TC{>O-lE3{zZcjw7MRKjnAVU!V)4Vc`d zg*b9B@a9oOGm^ti*#+0{O>1Iui2vKm+|D29(k3KsG;K^ZbFnLt&OXfYMpieN>M(q>{4?R$?G-IUwctz3*qM9YPk@EEN)sjC zz<4-?X4{exQU+U%x=sp^4p0*FeCEvex~cHsy}2ySVVxgs{=IL!AM9zfBMZzoji+Bk z%=Aa88zfI6M?!xr$}o{KsC8;vcn!#W0xv$=qXyR;PL{BD;D*+Vo@K!_pbQ+zlec+L zBg3;+4i-!+#~Q(Kd%^!;cVCzyS#W}BZ29=^T$7`a4p;lWYY^rU}DhwHI#;0ojNk1FEj$R_3o(GQ|?hGfiw^w-1Z!tGWesp?w z+_A7`60Yb|5-73KTVAfUQruLNKAIj-*sB)uz-h+!bOvnk%j(pN_V49J^AbzXYdzj^ zBJXJD#U0%rPna(t^}RC{V8+o_Z0Yu~QC{-W^CUTTRm-&E&dK!@G&P2BXjY&yhKSNm zF2nH*HD@vZ*|GL`0%bF5OvQ>Gkp^#jv1XIuR&f@Y_udeDU*q!DwL?tp*Zjk^IfnA9#TJbRG1gY{o8aNNxBsL1{T4N*a8+P2?#`N3+CfRcic ziv42oL2;F;mwor-$GigH4^zc?gne%N%X!BKrB{O41nim&j-PLQ3s0s~S4dXF6k(q}QwMma)5x?I?S0<`;7dvj2o(d?i&DHb04QT}VAF&oCuEx3$$95AL@w@RE zW`r8`64?rUuH`wG5b)RBgT=9Bn!}FgqhlwB4SmE|>o&@s#eX1ZFWq;I4KCJ_LI)Vp zNew+K& zWt`@n6Y)D3z0?Wwqd?(m%{=0Mv5E&={|0Yh((UqeTf^jWpkAb#Swh4E8oCCTz&^W< z_t*qHY+RT`x6~Rz7mQ?5)uZh*Jc>rb-NJE(oh8&*l)&&&0tIAFvhm7h#cDjPC*JeQ z=8W<2W~N_;&h@?JOpdE#gc|&?n2T__<*WR#kh}A|_b1U4Ysq`PQhRtpaKSgMm&5w*deeI0_D8R$t$r9!r#~&kNCDyDS{pL(eN(m7DkN~) zyyQ?rH8fkOd#$6!8wF4s9_SvI#F;p9L-D`ty>}Kxl2cKvoOO@JL9Jl9PSw|bn~t(+ zp}rv~jY>$*FQGV{a~XNhw1^_WdNXcs?VUo_dVJHki{bEoTLz=PmQGWZaM1l=tw9dQo1A%XPPsj^hLgF3vW>9ZI)BEd+kBY$6oijJ zfmeG^`#NvQj@{V~S4(EXSGIAo2;b#mIksvdy+Y3};%uYR-a?Cdp9s*aL^kl~SB4H< zt$B`-E(EBPwkq^<$#z|mk%F3|A~NFHsx+oit*RrS;Z=p*>8(xBQ(c=c>~v1cy+s3e z4H4(DGrVISM@drpQ<>|xH@3Hr^Q2L2fry(J$^6%yy_08Nj%~H?T;VS@X_Q_3@=PXs z)n@aJ!(wmytKi+{SX)xIL8OX8Dw^(kMS|tkSN?IeX>4-L9DC}#FU{n8YTIkeyN<55 z#BGln39=0E8}N%>pk5zF?^&9y7@f~gS9ydS(+lGdWFODOveuS6{#}b z2>(yB0@X1@8tJSQ3{|3M`7m-mJNK$-i8N#4H9^9xgMrIYh=CtA3vo$Kk70d?+OpSG zrhmL%j!lr^PvgvMt@1q!o6fp5Et6d# zD1>l-l-2`csnyiUgNw+KS%C)d?YUoT9TInM=8|1cXT8c3mN1+(qNffoX!+7&BCH}> zVdyj3BKs#+sFZ)WF)%8`))!^Loq2Q=ln`&epA&fs>LSl&Ra_Tn=tMwpDOy8C(SV|( zhYO&fV)X}v;%AcpQfVkOYybmdCi4*YAbZ3C7k=6`cniRSH**D!o!azzb%)^yva&uk z_zQUkRhL{cRShc2t}@Y~*?YBhH&jDgtD!|+UPpMq78)ynHLHG_9@ayZ)D>7AE3#U zrBE7LtX!c=^K6tX-%>%2Gwk=^YpTOzSg%I47B3Bi_;vPxA;}a@6KK#gh-!8XGWpmASxg!r9vBaz=^KH+Ca{sfs>GeGHyyA z4u+#qHT4~@UEkdRagzxAtPsNy+^-I@3UGZ9<(;~FEhhLEc=w+~2miEQfufBj{4m9i z7PvU!c;|4TzA~s;l#+J&lKZ8{2tb}b8K}6iy=R_Ri0Q5KBR~A&yJqiszXrR^e$oJw z-_j!-H^>V8%$2VnR)Et4P5Mn2!@UU|!@~(*`|F0~;_wjPPJlX_17_zAf!GvO^asIr z-0>b0#1fa4^pevBL=EiQBStKJ>a4S%F|2*fjt+j-Pv)iZR{98kJgCwXRB&tR*%@9Z zj6{%-Wa}}D^PwN+U{M1(il^*emHQ&xYt2h~5K;;kq`n-`i-IQu(Jma}ZpKO3t~5C} zF#HzeicDPj85S=p^mW6CPZlE=kZ$L#RA~hEQ%bdmFXTTkJ!SV?Szt*9nu8;FB7;1o z_UuJrfj%+4o{ZGeB|7JI*>?Pb>#Bx^V+87}^uv5y2>>DG!;whEX07mube14-h|A+a z3`)u)B>Q9e1rg?wBnuhQfBmXTie>}ujObM1Y<=yZ#M}$zQ4tW-s!=V4B(9@0G5MK_ z4Y>dD{&lkyVB@tHlP1QTBY_?u9qW;WXKwORCtVHB?o%YBB=TIly78wK13boUpDQeb z-~dqzzY75QIauJ5D(Mp~SWd;^Ea3%JVV$(UEgr040}i*vxPt&xL=-VMAu#h8lqT>f zZh{aDhaD-;r$Xs$3h2t#5{SJx^mQRN-Sbx-J(zwi{?T@Sgx>mYESK4qg(hU-$6Lb% zbY~-ow6rH*D6hLto_H7TE=EB;t+9 z2%M`Nb_)ZU(m}4I(4|onkw*Q;l!`pANAU(|;T8dlTtBGrMB#}kRsIdU&@;@1-~A3C zupDh+&u}&)&(9+yhR2{*S2`aiODHj*lE8uIMyPRf-5c)!FzzyUp2ASDU z#w2dVYSV!D9;_&R4Gz#TEF_bez4$#0%m#$P4@iXKNHuE`I2z51!$K0XUIUYKuTX)T z#;SB`OT*3VbF;`UKt+Drr6aIQ`&>&Of&H3&E`Aw?BMN$D4|z4j>w zsgr7Osf_&xkNFTVaXw8w_|H=(F6bAS={GmPjHuE`C{^&o0_%sk@`D{6L&F`{l4?ZJ z{4iJ)AP(fBegNZ0#~X(VTmS*Y6KV)f5Xg_tXnVp3XsmO{8AzCP4ZmdGK`w3-Q}A;< z`yKhtfNy=v%TnlTG5O5p$dM?7ct0Qk-y~Y!WueY1&y-cDDCRK$CINK?FVL;;^V_1x z!77I6nr;>6GpoXP?$;lxEC36~4HPSWYg~E>-%LvXy}RGEC@hw`e#sqDWNECsrAvG# z)L_&b{$f?{C4I#`u?LT3kYh>dy(eZe515N;iVpBFALt+>E_3t!t3EgHgUH{GwxEJo z6Ttz6*n|fmG;Cnv_py+Z(*m5`pSe2ZpLA3xvAgQON z40d_V9awizf6%~M)Dpsas*?~}{rF~(uA$FDi^(h>(xwQ%c`PGB4V*Z#ACM&nI>|$; z=_;7O9tH(~<8R9YLH<6eJ!z6}9~G&m*BapiYvGqDs@%qTgF zz$`>{LG|FjS~MPyBThM}X{TZdrCDUj$S&htr^g10 z#S!J*T*>!1`WU;6!ar)IL`B4=M5@LS(_k~#jj_4Yn;v9C?pH`P-SDwEX;3ue^OpKkBvU6<^46dg9AOHqIQwDtL|>s zNbPNro_b1haG025XjWruxElg?Pq=#w3c`PT@Vm)lW-3AZr?l5$UBs!fy&m8|b2ZR~ zJkHS*fz54;M?oh)7uSdlv-bskm4S=u-6c;-iZbZbCZ$;fU(){9FMSnKR{$H7%V-USfK{Z|a}3R1av_D*+ZAP!_=!iI3H|Y{ z5f5SPz|(QNfp2t01FPPcICH{?s9nTvcQtBJLetsN0*6KzbPVgjf|)0LVrlFI9{u|$ zdyov-Nc$&_>WeS;LVRJDM-wIbxWGfRzu9Wt8bGP3BgDD>qx0fA7UkUe|NXpp7;o?; zGm9)Fn~(BX7_ub!FM(5FnB0l0`0oKppv+hLn|fXbi&qiP!GJ>e z4^X`X#!jE*hwMXa8jUV~!b;qLjF zCoW$y!N19fgX_Sm0YO2ZSRh&@nsSOh4q(n2Q62JsHdn-3g}yDu^}!evj$Q9XMZZ6k z<))pYUr6>~z3HG65K`EjHfD7A0{BC`b2kLe9Z~Y)4c;xBqf=;UD!h|fWj~qrY%W1X zcPw8~H&IE+>V%_C2b6=DOO`f`0HTZ@P?ytV)wCLiT3V-|*JE?5B5H47FnE~1{s-p9 zqZK7RU1CDw|1IxV@PJGl3l3`4leFJ|9e043KHG+%1(b}lF7cZh#R6tjZ~F-bBTRG= zdX+`?nacybgEa^P{=kKL;UsZ=6>c{g_>@}O$Ch|CIl1`lb6sf`w_LVW3UYDmCvFk= ztG`an1pcAeoRP#IUF-^a$s9NJun|7aeQEFyo?ixSM%A_`Wu%{{m=2fxJuSs?|d_DEZ`8CC5)g{Z@wV5~|eTDXQeRhBQ_HV31TOf+M%qi=* ze(kHI-OfS;=-c~br7dBme{E@JcTndJeSd#%cy5LT+fcE{G&=)tyT-kWk&0Qt59`T= zEsR|$Q9N2t?U~U~%e#{gRL^M8d5KS5YVG`w_4lovNHeJka?sIR|jLo?}m1?N@om zt9+UlG6~>aMny3}9LMo)#^D>?qu$dPZys|N!IN-?AUakLAJMcsZ2SL?L5o@xM$4~| zkrOc(k?M(~AbKrPr{J0x`f~tZK1g|?{QWi|13d$C)=xOSUYha?N%`?>3op6;dzJxo zrBNip6z(EV*(HTf8YzgK<}!35A%POnQ~ypk@GE^+5u0TvpF^Ehhj^5~r(nJEcz@tV# z3D8%Zba4++&y-vKh+l4C2rq`Ts#2)2Fl*Kct7$Y00=V`^qT)}u)aNflb;Z~pa&{G|67KcG3(!?@LN<84V6 zWEVek0ahK1xa!Akrcpwkb(932PPqUTfc>9=kN}PV9|~o^6-~*CybQ8$|1BEwy^;0@ z&`|_9;;g>Ut;|esxPWtBsd7Qil5=>rmxZIgkAzZR%SdRFMRljPeT2Zi&k18N49@sCgNE@DlEQ5e2boJL{1GHc)3Cvx zTN#mQoj9|ghQ+Z$`a}TuL6*%v1Q3m9KMH_xnj|ClWln;&B9Ilj#MDd(=%V)C;*e|$ zHa!S1x|%#2xR*hpnQ?MtpZ5#(@828#pi01=!P@}w%?c#WxdVM;jQ(Mfg%xO=p*h+X z5R(WIWWK}PR)8D(uaHRvZXi4JWbJc78Tc9*&|T#B`{s8wk^-1r#he%d zbUI&vZkS9n0#D8vI*tecI`}k~pKcf)-{Q@jAGX9&_$S8(B1r>~?i+$Q?o;L!XqSTk z%0-?YCcg7~f}Z^|tHva5z}!ZQV<}WE=Se^nfQ#pyRn86rUgw4xzd7ziTqGEcuYVjZMq3>tss%iEpSPJO%s*$H5iJ0n>z=|ZX zMe;LObe_Q7o0W3jdq&|&v~j86Gxq8EAIBpB!`H`D{REF$?>c!D5z+r~#Q*$sR{Sn) zG+3m3uCT;h9DZ0Jpn95aos@!fT2!THkehIo*XD&bOoRN z?$u@zas)@Xp&7YQzB;@nkFbB4Hpi7Cn^I)<99QAlkM}}1wI?sy&wKuUz6aP4XtQdx zHijrEP$MV4RfbqV%LIM+9n%bZ0Ty4+6f=}yfGeN?NM^u1`SYtj!h4=rvYFVUfzf%T$?t}*e2*@p zyID@P-IfY|=sI4(opyC@_U5^2Ap>DQ3{6+t12G%tzO_y#f&Diip7M!F1RJ!o(FN^> zPt)s%-OXnlBIP5`|F1;7cmDK!=1aFYB-}8pJ}VO(v|eIlain%FBiS>9J#tst6bHIl zQoY`-vwFfwz|r)hsGy?9zeY_g!2%>v$aouIqREszDs3-II7@7~A*oZ)CS*ELAV1Acsxs44FR~u@x5d zqx*aiL7Aq62SLDxYYr>kRD~}(JbeSu^OV9ptkH*sI@Yex0Y9yF!BVjVD-lHAKSz4+ z^Qy2Yvd+fg0ocC~e6FtFY-zLS?m@gK`ql(&i2%N&QtRe)1nK{5ZP}dw?>%82REkh; z2q8i7C#7q3mv6Q=UhPiTi7653UQTEBKfgi)`qoCCyW-zcwQ%LbTMx!a>bO)h^fTi8 zT6TCk8b77C3IHVIM6P$g#Ml`1ru{6O@3AY%xV(Dl;j<>bjZLvq6@ICu@Pc2OJBP`F z8JCz)6HhQ=*x^#Tk;+~ZQ|vb6q3j^7rp)!VMdJWiDei8#i5- zL=^T89+igkclksz^)AsCT8(g=zi;ah*e&NUai#u4Y3?SSKkiiyOnGwj+jN&5n$EAc z!G7WXta#n*IJi;!ocmr&mTGJZqmC>+QXDO4ToQK_u(>$+HMi8FUSe+t)KsblACG(X zs^Z!FI4RUoRUZL74Z_mO@yKx!U=b+7OS{_lSFI;F_#bz{z+QFY$xBGrqCP ztv^l(_ig-@KJ6gCe{1JxyNMHY{3u(E5DDZ`vaxd9-&&H&Tm?5_XGh(03MS~=UYR&= zIbH*EUYg`MYwv!mBFJ~7@k;o-71ean7kkEes@vkbTph)y=7ZF zE0Knm=&d_T;5@70!O}=McaX?#;~P}JSmOsHaw=4cgYH*Os|k*tbCRcL58UqslMEbO z66mu#3s-n()9BXmsf7Y>*5$My`*HOASnFV74YT7KcWg$KNJOU!mkuRSwx+y(?i_d{ zZ9RqWr??=LnkZ%#k2QLHh+VAZq7zc(Ip5>{MUgxr;uQ0nsPDcGqg9S;N7uH;8K>Ph zzN$yzP3T1H=Ak$vXtk?}FMj)g7kuKyo-E!Pfpn9rk&>->SkMyq(JHugq$|_z-4;;D zc}oGkE4K97=@69ynnz0P?f~9M|!?>g~5Lz=jjF6on=baZW#UUyY)^%u}$*# zr{4$sN}Xh%e{i2O=;#Np{5jA}qx1f8u^ZCq?cQSHj1%G4T=~NVmhxA`gmB~Q#qs;Y z%PcbF8~ss*?LDdH>5@cnmFtJ+;^0d;y`22`u@gcMDlVIl(7ix3ug>gvUkAx3(Awmf z5Fh>Vp{#q#LN?mEA^1H#m$)XlD-R+Y zy#Av@i~*EhM=gGNpAQEE(fI)G*kfM##qs0qg$u0?HZl^yM+ZNjm4W-|q3^aERvz`j zz${mV$;tV<6B7GOHyA<=cS6B^WtQe%on`|QELi$D=YkYueF)EyFo+@mY=14G zN>fI3=Y4!U;X+yGO~@g-`{+`od?{4nd+8Nb^)y*#l4nUJ{jv6)_TV- zQKFs+b~YNXX=P9m(660t2%LvaMxWkWjgn^%S`FiD{nSR(p)^xaSQ68#o&auU1&U$r z#r7hpHYfSDXdUXyS4Y36{g}R?d0$vXz`|KoT8@YQJDUCvYVwioSg3mWya}Kii zO$*Spy26kWZ%ogvbOC--SJ~7icb6Mb%zXUOC~G3;5PE);bw^o<*WEj%`3-M5Q1Lyu z!$1!y-OSs9O8~~US-G3@F;k=7-WS>T!QL5T{H_2n*MpdV>GK-r_ zSIhTsUwiBIbG(0|2Jg`68JK!^ZUcFRZ}ZteL#t76!~UWxb1KwQc;SN>gB!{6W(K%yy&l|J8Km@lbx>-)=Cr z5+O^CWekdH>|rcpELp~qB^iz7V{1j(iRxqDTkK_q85v7iifs90%TzR$ArwjmiDakm zo%;Qr=kMpd&OPVc=bq(#&ryzm{`eN=N8jjt6N-lKAzbq78dasLU!oUev7w;?=A0mP z!-6?%%D+2h?^v(oFZ5UVOv4diO zek+5nD02#Su%x$Ccd@bZpxb#Lu`MdBE`+rDA0)5z*xH`k={$`E7#rKQXLXDO-d; zDX2SpaB$ftAd`_BN>2oUqNzL%```q>tChn?wKISlccqDn_2hmU8Q zT8sEc_6-q<0TyN(zP~ls*bcmZu&pu5ixLzRsK`|%8|sik%MWD$+I559C+NLZqGz;S zE}1&=$(?}Jb{=`wAKswMYI|BQg%}0 z`L!lnRU~9hzci?%apF%Fe36!HT!bj5hS6d20d!|Ig_N_vlv1YHQLJ>t_`IYCC8zM- zGU);8O~j9lkMAyMO8;FgioL(b%@f=WNO1P^G#;z{Oxjs)`>of32}1*B{lJP16Cr*- zzp4uS4NJTTwz*GXj(3ZlgyQ^o(vN{_C#6j~5le#1h*u5u)65UWuF}gdXLU%B@-;KC zn~P!=J_jbghMz~jDGXITa8Fdj&>hE-Dg(N*)kJsxH0J7|f+xreDg!(Q!I5z;CGWev zG1*Jl3TvkYeB;3>K~R!>e`~bP*!bBN%*|7i0|OW>t#faZp6{`sj2(}sS{*u#b4?~B zfAD%3K6bWH2U*!Ky#eWElAYzBN*45qQDwpgA{&Nf$=(?!ajtiBwl*Jb?n|)aP)++J zyQV5Tl(D5O(NDKoT8Yx|#LOIA*556QCGgew={|=Fw6=AzNJ`PKEsJ1M2SegxY5vk=moe+1(D=s$ zs9sA!WvthT9NFL4&GvnHa@~aTc(TovCT6(KKXnmhEDFu2>J%#<$n0wwdc^unsTu0j zvbmeLe3vyT&B1*H?mhy=Ouq+khTCf6Q}?J4}eOB;h_`T zo{kgG|B?j*-Gs`l9%7gA_wPk2pFCDmV;UfG>f@D8{_@X116rrhW`63%&w|}`VrW8` z)W>p;I^p;r9kMrsH#~ zI!`F;40c6=AWGf-n|sARA{Ml@|i)zQh>)!)#9r% z9t$CjpreE!xTuP=P_m>Cm9g^TkCh3lMS^+DKywZ9Qx1SVe&nyJ! z8x-pLi%8KKP4~e4nG&xLp@8Y}D~=PAlUEt!@@O^KB5%jP$@ZS{AmW?up2W!5T%AI%SE|5ZkNdgsIEirRd zo6ktqc)co*SkCDpYKnEus{$3D3hSr^2~)F%2S>#+Bv8F*^M>i;x3em~W8s;; zdJNF)W*c;s^;&!VD~_0y3++`x>EU= zje=yG_twWd!C)29B`|MZ+)H!vCjL3NMKry{ulZ4^s%?M!X7RW>zRP504$Pgu^d5iM zz$0R*-gE8Sz>4qp1>ckrXUk%Iae!)6!N~m8fS2V(_+^jlRAf+b_00O5Px{W>&fLO^ z&+?6unCR_^F0D&v-}$Yb+W4gvZQ9CJ9Q>22+3mI~vY{S1GFppY*jNc_oD5$maf>{9 z$D=^a(`YSolwh9yiW$p9!G#CFUwP8~!}4RFVDGt=yISd=pKa2&HCT*qaEeD~xJAPBvHJ&PcoUp` z6Kpt5Hl4TJa2#NO8^^{7kie<n(jk z&H@r;~SaPrY!_2nL6F2G3#TfLN zvJJnr==H62gStKFPV`@kj#&N~X8mM2W_x$dsiyXQ?WfGPELItD{WQ0QpKIOP(ZWKX z6<5+fPHS?)j=>yhJZO4UlK-BlX>JURX0E)OjG22EkBE2wMaZ zi#+>_S;>6>Fp(dZsP^LoVyNZxq&xY$&SsHCNX+`i(Bd9aw=8jw$jp|y)zJ+4X3f5w zTdCc2jXd5eCX;faOHq?uxb;YJ+U1b~I~Y@DNH(l}eNxt{(fqGmMq=5(0WsqMp1Ap- zT!!f>a|JDwHy>O)Ucvd0I@bg^uPFH{zpgJ??SI&IV1*PbLp~=XZGydsj3*#o|9%=V zSYUVI@S(IcTbL}-cG~!KF%4pY2)5<58NkBS)U`vsh&n7u1u7+8&^+9iui&{iHETez zsb_h$!E3ZRiTTbdlTOZE$5yi4ODu4LIJQt-%_qJctW^KNBtkkbICnbpRDCEBv|TVRwk|m4!S|xRkrvZe?dp+_Hp+wfa~{+6pjE~`!mDK^ z8IkSkXb>x<0twbW33eZUxA&{qzW zcqx%2#Mv24xoY6Z#dSU%ur?Ve5o@Iq6@m&$g7pp4 zxuLWWqiNgDTkd=%Xdw$!jv``ASuJZ(vK(jeCh(vqFY-M?lePIC`>0uj)t<|V##nUf;lN6HY)|THQA_^ld3X|Q;NJnWWc51g zz+nR8f+_9QIN|!(75PXaSTdb8n3=l{xJ;G_;wTm|T$0VM`uhy$6(KF<`u@F?~-T|iGM zHV;J#mbJ(&a@GYp@B2T6pJ}8mH?Z5Dg5>g=kOvQ*Rc&c^x+jqHN61Ak3|}`FMw|Wk ta?S com.github.xiaoymin knife4j-openapi2-spring-boot-starter - 4.3.0 + 4.4.0 diff --git a/fluent-apps/qaserver/src/main/java/io/fluentqa/github/FluentGithubModule.java b/fluent-apps/qaserver/src/main/java/io/fluentqa/github/FluentGithubModule.java index 7cbf7ff..ed5d62f 100644 --- a/fluent-apps/qaserver/src/main/java/io/fluentqa/github/FluentGithubModule.java +++ b/fluent-apps/qaserver/src/main/java/io/fluentqa/github/FluentGithubModule.java @@ -1,5 +1,6 @@ package io.fluentqa.github; +import io.fluentqa.github.model.AwesomeResource; import io.fluentqa.github.model.GithubStarredRepo; import org.springframework.boot.autoconfigure.domain.EntityScan; import org.springframework.boot.context.properties.EnableConfigurationProperties; @@ -39,11 +40,17 @@ public void run() { public List initMenus() { List menus = new ArrayList<>(); menus.add(MetaMenu.createRootMenu("$github", "github管理", "fa fa-github", 1000)); - MetaMenu starredMenu =MetaMenu.createEruptClassMenu(GithubStarredRepo.class, menus.get(0), 0, MenuTypeEnum.TABLE); + MetaMenu starredMenu = MetaMenu.createEruptClassMenu(GithubStarredRepo.class, menus.get(0), 0, MenuTypeEnum.TABLE); starredMenu.setIcon("fa fa-star"); starredMenu.setName("github收藏"); starredMenu.setCode("$github-starred"); menus.add(starredMenu); + + MetaMenu awesomeModule = MetaMenu.createEruptClassMenu(AwesomeResource.class, menus.get(0), 1, MenuTypeEnum.TABLE); + awesomeModule.setIcon("fa fa-font-awesome"); + awesomeModule.setName("awesomes"); + awesomeModule.setCode("$awesomes"); + menus.add(awesomeModule); return menus; } diff --git a/fluent-apps/qaserver/src/main/java/io/fluentqa/github/model/AwesomeResource.java b/fluent-apps/qaserver/src/main/java/io/fluentqa/github/model/AwesomeResource.java new file mode 100644 index 0000000..c9205b0 --- /dev/null +++ b/fluent-apps/qaserver/src/main/java/io/fluentqa/github/model/AwesomeResource.java @@ -0,0 +1,29 @@ +package io.fluentqa.github.model; + +import lombok.Data; +import xyz.erupt.annotation.Erupt; +import xyz.erupt.annotation.EruptField; +import xyz.erupt.annotation.sub_erupt.Power; +import xyz.erupt.annotation.sub_field.Edit; +import xyz.erupt.annotation.sub_field.EditType; +import xyz.erupt.annotation.sub_field.View; +import xyz.erupt.annotation.sub_field.sub_edit.InputType; +import xyz.erupt.annotation.sub_field.sub_edit.Search; +import xyz.erupt.jpa.model.MetaModel; + +import javax.persistence.Entity; + +@Data +@Entity +@Erupt(name = "Awesome Resource", power = @Power(importable = true, export = true)) +public class AwesomeResource extends MetaModel { + @EruptField(views = @View(title = "名称"), edit = @Edit(title = "名称", type = EditType.INPUT, search = @Search, notNull = true, inputType = @InputType)) + private String name; + @EruptField(views = @View(title = "URL"), edit = @Edit(title = "URL", type = EditType.TEXTAREA, + search = @Search, notNull = true, inputType = @InputType)) + private String url; + + @EruptField(views = @View(title = "content"), edit = @Edit(title = "content", type = EditType.HTML_EDITOR, + search = @Search, notNull = true, inputType = @InputType)) + private String content; +} diff --git a/fluent-apps/qaserver/src/main/java/io/fluentqa/github/model/GithubStarredRepo.java b/fluent-apps/qaserver/src/main/java/io/fluentqa/github/model/GithubStarredRepo.java index f7e04ba..df1a82f 100644 --- a/fluent-apps/qaserver/src/main/java/io/fluentqa/github/model/GithubStarredRepo.java +++ b/fluent-apps/qaserver/src/main/java/io/fluentqa/github/model/GithubStarredRepo.java @@ -3,6 +3,7 @@ import lombok.Data; import xyz.erupt.annotation.Erupt; import xyz.erupt.annotation.EruptField; +import xyz.erupt.annotation.sub_erupt.Layout; import xyz.erupt.annotation.sub_erupt.Power; import xyz.erupt.annotation.sub_field.Edit; import xyz.erupt.annotation.sub_field.EditType; @@ -15,7 +16,10 @@ @Data @Entity -@Erupt(name = "starred Github Repos", power = @Power(importable = true, export = true)) +@Erupt(name = "starred Github Repos", + power = @Power(importable = true, export = true), layout = @Layout( + tableLeftFixed = 3, + pageSize = 30)) public class GithubStarredRepo extends MetaModelVo { @EruptField(views = @View(title = "名称"), edit = @Edit(title = "名称", type = EditType.INPUT, search = @Search, notNull = true, inputType = @InputType)) private String name; diff --git a/fluent-apps/qaserver/src/main/java/io/fluentqa/jobs/github/GithubJobFetchParameters.java b/fluent-apps/qaserver/src/main/java/io/fluentqa/jobs/github/GithubJobFetchParameters.java index 2c57794..0cfd142 100644 --- a/fluent-apps/qaserver/src/main/java/io/fluentqa/jobs/github/GithubJobFetchParameters.java +++ b/fluent-apps/qaserver/src/main/java/io/fluentqa/jobs/github/GithubJobFetchParameters.java @@ -2,6 +2,7 @@ import lombok.Data; //https://olakit.cn/box/quartz_cron_build_check +//0 0 23 ? * * * @Data public class GithubJobFetchParameters { private String userNames="qdriven"; diff --git a/fluent-apps/qaserver/src/main/resources/application-dev.yaml b/fluent-apps/qaserver/src/main/resources/application-dev.yaml index d30cabc..90320f3 100644 --- a/fluent-apps/qaserver/src/main/resources/application-dev.yaml +++ b/fluent-apps/qaserver/src/main/resources/application-dev.yaml @@ -23,7 +23,7 @@ erupt: spring: datasource: - url: jdbc:postgresql://supabase_db_dev-stacks.orb.local:5432/workspace + url: jdbc:postgresql://db.supabase.orb.local:5432/workspace username: postgres password: postgres jpa: diff --git a/fluent-erupts/fluent-erupts-base/src/main/java/io/fluentqa/base/handlers/SqlTagFetchHandler.java b/fluent-erupts/fluent-erupts-base/src/main/java/io/fluentqa/base/handlers/SqlTagFetchHandler.java index b7a4af8..044f686 100644 --- a/fluent-erupts/fluent-erupts-base/src/main/java/io/fluentqa/base/handlers/SqlTagFetchHandler.java +++ b/fluent-erupts/fluent-erupts-base/src/main/java/io/fluentqa/base/handlers/SqlTagFetchHandler.java @@ -1,5 +1,8 @@ package io.fluentqa.base.handlers; +import java.util.List; +import java.util.function.Supplier; +import javax.annotation.Resource; import org.springframework.jdbc.core.JdbcTemplate; import org.springframework.stereotype.Component; import xyz.erupt.annotation.fun.TagsFetchHandler; @@ -7,30 +10,26 @@ import xyz.erupt.core.cache.EruptCacheLRU; import xyz.erupt.core.util.EruptAssert; -import javax.annotation.Resource; -import java.util.List; -import java.util.function.Supplier; - - @Component public class SqlTagFetchHandler implements TagsFetchHandler { - @Resource - private JdbcTemplate jdbcTemplate; + @Resource private JdbcTemplate jdbcTemplate; private final EruptCache> tagsCache = new EruptCacheLRU<>(100); - public SqlTagFetchHandler() { - } + public SqlTagFetchHandler() {} @Override public List fetchTags(String[] params) { EruptAssert.notNull(params, SqlTagFetchHandler.class.getSimpleName() + " → params not found"); - String key = SqlTagFetchHandler.class.getName() + ":" + params[0]; - return this.tagsCache.getAndSet(key, 3000L, new Supplier>() { - @Override - public List get() { - System.out.println("get tags"); - return jdbcTemplate.query(params[0], (rs, i) -> rs.getString(1)); - } - }); + String key = SqlTagFetchHandler.class.getName() + ":" + params[0]; + return this.tagsCache.getAndSet( + key, + 3000L, + new Supplier>() { + @Override + public List get() { + System.out.println("get tags"); + return jdbcTemplate.query(params[0], (rs, i) -> rs.getString(1)); + } + }); } } diff --git a/fluent-erupts/fluent-erupts-base/src/main/java/io/fluentqa/base/model/ModelWithValidFlag.java b/fluent-erupts/fluent-erupts-base/src/main/java/io/fluentqa/base/model/ModelWithValidFlag.java index f0d5f1d..4f6e8b7 100644 --- a/fluent-erupts/fluent-erupts-base/src/main/java/io/fluentqa/base/model/ModelWithValidFlag.java +++ b/fluent-erupts/fluent-erupts-base/src/main/java/io/fluentqa/base/model/ModelWithValidFlag.java @@ -1,6 +1,6 @@ package io.fluentqa.base.model; - +import javax.persistence.MappedSuperclass; import xyz.erupt.annotation.EruptField; import xyz.erupt.annotation.sub_field.Edit; import xyz.erupt.annotation.sub_field.EditType; @@ -9,24 +9,18 @@ import xyz.erupt.annotation.sub_field.sub_edit.Search; import xyz.erupt.jpa.model.MetaModel; -import javax.persistence.MappedSuperclass; - @MappedSuperclass -/** - * Do not display Creator/Updater - */ +/** Do not display Creator/Updater */ public class ModelWithValidFlag extends MetaModel { - @EruptField( - views = @View( - title = "是否有效" - ), - edit = @Edit( - title = "是否有效", - type = EditType.BOOLEAN, search = @Search, notNull = true, - boolType = @BoolType - ) - ) - private final Boolean valid = true; - + @EruptField( + views = @View(title = "是否有效"), + edit = + @Edit( + title = "是否有效", + type = EditType.BOOLEAN, + search = @Search, + notNull = true, + boolType = @BoolType)) + private final Boolean valid = true; } diff --git a/fluent-erupts/fluent-erupts-base/src/main/java/io/fluentqa/base/model/ModelWithValidFlagVo.java b/fluent-erupts/fluent-erupts-base/src/main/java/io/fluentqa/base/model/ModelWithValidFlagVo.java index 71c7615..e93ded9 100644 --- a/fluent-erupts/fluent-erupts-base/src/main/java/io/fluentqa/base/model/ModelWithValidFlagVo.java +++ b/fluent-erupts/fluent-erupts-base/src/main/java/io/fluentqa/base/model/ModelWithValidFlagVo.java @@ -1,6 +1,6 @@ package io.fluentqa.base.model; - +import javax.persistence.MappedSuperclass; import org.hibernate.annotations.DynamicInsert; import org.hibernate.annotations.DynamicUpdate; import org.hibernate.annotations.Where; @@ -12,31 +12,28 @@ import xyz.erupt.annotation.sub_field.sub_edit.Search; import xyz.erupt.jpa.model.MetaModelVo; -import javax.persistence.MappedSuperclass; - @MappedSuperclass @DynamicUpdate @DynamicInsert @Where(clause = "valid=true") public class ModelWithValidFlagVo extends MetaModelVo { - @EruptField( - views = @View( - title = "是否有效" - ), - edit = @Edit( - title = "是否有效", - type = EditType.BOOLEAN, search = @Search, notNull = true, - boolType = @BoolType - ) - ) - private Boolean valid = true; + @EruptField( + views = @View(title = "是否有效"), + edit = + @Edit( + title = "是否有效", + type = EditType.BOOLEAN, + search = @Search, + notNull = true, + boolType = @BoolType)) + private Boolean valid = true; - public Boolean getValid() { - return valid; - } + public Boolean getValid() { + return valid; + } - public void setValid(Boolean valid) { - this.valid = valid; - } + public void setValid(Boolean valid) { + this.valid = valid; + } } diff --git a/fluent-erupts/fluent-erupts-base/src/main/java/io/fluentqa/base/model/NamedModelVO.java b/fluent-erupts/fluent-erupts-base/src/main/java/io/fluentqa/base/model/NamedModelVO.java index 8c816d9..89e28ec 100644 --- a/fluent-erupts/fluent-erupts-base/src/main/java/io/fluentqa/base/model/NamedModelVO.java +++ b/fluent-erupts/fluent-erupts-base/src/main/java/io/fluentqa/base/model/NamedModelVO.java @@ -1,6 +1,6 @@ package io.fluentqa.base.model; - +import javax.persistence.MappedSuperclass; import org.hibernate.annotations.DynamicInsert; import org.hibernate.annotations.DynamicUpdate; import org.hibernate.annotations.Where; @@ -11,50 +11,40 @@ import xyz.erupt.annotation.sub_field.sub_edit.InputType; import xyz.erupt.annotation.sub_field.sub_edit.Search; -import javax.persistence.MappedSuperclass; - @MappedSuperclass @DynamicUpdate @DynamicInsert @Where(clause = "valid=true") public class NamedModelVO extends ModelWithValidFlagVo { - @EruptField( - views = @View( - title = "名称", sortable = true - ), - edit = @Edit( - title = "名称", - type = EditType.INPUT, search = @Search, notNull = true, - inputType = @InputType - ) - ) - private String name; - - @EruptField( - views = @View( - title = "详细描述", sortable = true - ), - edit = @Edit( - title = "详细描述", - type = EditType.INPUT, - inputType = @InputType - ) - ) - private String description; - - public String getName() { - return name; - } - - public void setName(String name) { - this.name = name; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } + @EruptField( + views = @View(title = "名称", sortable = true), + edit = + @Edit( + title = "名称", + type = EditType.INPUT, + search = @Search, + notNull = true, + inputType = @InputType)) + private String name; + + @EruptField( + views = @View(title = "详细描述", sortable = true), + edit = @Edit(title = "详细描述", type = EditType.INPUT, inputType = @InputType)) + private String description; + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getDescription() { + return description; + } + + public void setDescription(String description) { + this.description = description; + } } diff --git a/fluent-erupts/fluent-erupts-base/src/main/java/io/fluentqa/base/model/NamedTimeStatusModel.java b/fluent-erupts/fluent-erupts-base/src/main/java/io/fluentqa/base/model/NamedTimeStatusModel.java index dc5495b..d29d492 100644 --- a/fluent-erupts/fluent-erupts-base/src/main/java/io/fluentqa/base/model/NamedTimeStatusModel.java +++ b/fluent-erupts/fluent-erupts-base/src/main/java/io/fluentqa/base/model/NamedTimeStatusModel.java @@ -1,6 +1,7 @@ package io.fluentqa.base.model; - +import java.time.LocalDate; +import javax.persistence.MappedSuperclass; import lombok.Data; import xyz.erupt.annotation.EruptField; import xyz.erupt.annotation.sub_field.Edit; @@ -9,75 +10,60 @@ import xyz.erupt.annotation.sub_field.sub_edit.BoolType; import xyz.erupt.annotation.sub_field.sub_edit.Search; -import javax.persistence.MappedSuperclass; -import java.time.LocalDate; - - @MappedSuperclass @Data public class NamedTimeStatusModel extends ModelWithValidFlagVo { - @EruptField( - views = @View( - title = "名称" - ), - edit = @Edit( - title = "名称", - type = EditType.INPUT, search = @Search, notNull = true - ) - ) - private String name; - @EruptField( - views = @View( - title = "详细" - ), - edit = @Edit( - title = "详细", - type = EditType.INPUT, search = @Search, notNull = true - ) - ) - private String detail; - @EruptField( - views = @View( - title = "开始时间" - ), - edit = @Edit( - title = "开始时间", - type = EditType.DATE, search = @Search, notNull = true, - boolType = @BoolType - ) - ) - private LocalDate startDate; - @EruptField( - views = @View( - title = "预计完成时间" - ), - edit = @Edit( - title = "预计完成时间", - type = EditType.DATE, search = @Search, notNull = true, - boolType = @BoolType - ) - ) - private LocalDate estimatedCompletedDate; - @EruptField( - views = @View( - title = "完成时间" - ), - edit = @Edit( - title = "完成时间", - type = EditType.DATE, search = @Search, notNull = true, - boolType = @BoolType - ) - ) - private LocalDate completedDate; - @EruptField( - views = @View( - title = "当前状态" - ), - edit = @Edit( - title = "当前状态", - type = EditType.INPUT, search = @Search, notNull = true, - boolType = @BoolType - ) - ) - private String status; + @EruptField( + views = @View(title = "名称"), + edit = @Edit(title = "名称", type = EditType.INPUT, search = @Search, notNull = true)) + private String name; + + @EruptField( + views = @View(title = "详细"), + edit = @Edit(title = "详细", type = EditType.INPUT, search = @Search, notNull = true)) + private String detail; + + @EruptField( + views = @View(title = "开始时间"), + edit = + @Edit( + title = "开始时间", + type = EditType.DATE, + search = @Search, + notNull = true, + boolType = @BoolType)) + private LocalDate startDate; + + @EruptField( + views = @View(title = "预计完成时间"), + edit = + @Edit( + title = "预计完成时间", + type = EditType.DATE, + search = @Search, + notNull = true, + boolType = @BoolType)) + private LocalDate estimatedCompletedDate; + + @EruptField( + views = @View(title = "完成时间"), + edit = + @Edit( + title = "完成时间", + type = EditType.DATE, + search = @Search, + notNull = true, + boolType = @BoolType)) + private LocalDate completedDate; + + @EruptField( + views = @View(title = "当前状态"), + edit = + @Edit( + title = "当前状态", + type = EditType.INPUT, + search = @Search, + notNull = true, + boolType = @BoolType)) + private String status; } diff --git a/fluent-erupts/fluent-erupts-base/src/main/java/io/fluentqa/base/package-info.java b/fluent-erupts/fluent-erupts-base/src/main/java/io/fluentqa/base/package-info.java index 3130485..3bce169 100644 --- a/fluent-erupts/fluent-erupts-base/src/main/java/io/fluentqa/base/package-info.java +++ b/fluent-erupts/fluent-erupts-base/src/main/java/io/fluentqa/base/package-info.java @@ -1 +1 @@ -package io.fluentqa.base; \ No newline at end of file +package io.fluentqa.base; diff --git a/fluent-erupts/fluent-erupts-base/src/main/java/io/fluentqa/base/proxies/AuditDataEnhancerProxy.java b/fluent-erupts/fluent-erupts-base/src/main/java/io/fluentqa/base/proxies/AuditDataEnhancerProxy.java index 78d99b0..2ede92d 100644 --- a/fluent-erupts/fluent-erupts-base/src/main/java/io/fluentqa/base/proxies/AuditDataEnhancerProxy.java +++ b/fluent-erupts/fluent-erupts-base/src/main/java/io/fluentqa/base/proxies/AuditDataEnhancerProxy.java @@ -1,13 +1,10 @@ package io.fluentqa.base.proxies; -import io.fluent.builtin.StringUtils; +import java.time.LocalDateTime; import org.springframework.stereotype.Component; -import xyz.erupt.core.context.MetaContext; import xyz.erupt.jpa.model.MetaDataProxy; import xyz.erupt.jpa.model.MetaModel; -import java.time.LocalDateTime; - @Component public class AuditDataEnhancerProxy extends MetaDataProxy { diff --git a/fluent-erupts/fluent-generator/src/main/java/io/fluentqa/generator/FluentEruptApiAutoConfiguration.java b/fluent-erupts/fluent-generator/src/main/java/io/fluentqa/generator/FluentEruptApiAutoConfiguration.java index 099069a..8e5268d 100644 --- a/fluent-erupts/fluent-generator/src/main/java/io/fluentqa/generator/FluentEruptApiAutoConfiguration.java +++ b/fluent-erupts/fluent-generator/src/main/java/io/fluentqa/generator/FluentEruptApiAutoConfiguration.java @@ -1,6 +1,11 @@ package io.fluentqa.generator; import io.fluentqa.generator.api.action.MagicApiTpl; +import java.util.ArrayList; +import java.util.LinkedHashMap; +import java.util.List; +import java.util.Map; +import java.util.concurrent.atomic.AtomicInteger; import org.springframework.context.annotation.ComponentScan; import org.springframework.context.annotation.Configuration; import org.ssssssss.magicapi.core.interceptor.Authorization; @@ -12,55 +17,69 @@ import xyz.erupt.core.module.ModuleInfo; import xyz.erupt.tpl.service.EruptTplService; -import java.util.ArrayList; -import java.util.LinkedHashMap; -import java.util.List; -import java.util.Map; -import java.util.concurrent.atomic.AtomicInteger; - @Configuration @ComponentScan @EruptScan public class FluentEruptApiAutoConfiguration implements EruptModule { - public static final String MAGIC_API_MENU_PREFIX = "ERUPT_MAGIC_"; + public static final String MAGIC_API_MENU_PREFIX = "ERUPT_MAGIC_"; - public static final String DATASOURCE = "DATASOURCE"; + public static final String DATASOURCE = "DATASOURCE"; - public static final String FUNCTION = "FUNCTION"; + public static final String FUNCTION = "FUNCTION"; - static { - EruptModuleInvoke.addEruptModule(FluentEruptApiAutoConfiguration.class); - } + static { + EruptModuleInvoke.addEruptModule(FluentEruptApiAutoConfiguration.class); + } - @Override - public ModuleInfo info() { - return ModuleInfo.builder().name("erupt-magic-api").build(); - } + @Override + public ModuleInfo info() { + return ModuleInfo.builder().name("erupt-magic-api").build(); + } - @Override - public List initMenus() { - String menuKey = "magic-api"; - Map menus = new LinkedHashMap<>(); - menus.put(Authorization.SAVE, "保存"); - menus.put(Authorization.VIEW, "查看"); - menus.put(Authorization.DELETE, "删除"); - menus.put(Authorization.DOWNLOAD, "导出"); - menus.put(Authorization.UPLOAD, "上传"); - menus.put(Authorization.PUSH, "远程推送"); - menus.put(Authorization.LOCK, "锁定"); - menus.put(Authorization.UNLOCK, "解锁"); - AtomicInteger sort = new AtomicInteger(); - List metaMenus = new ArrayList<>(); - metaMenus.add(MetaMenu.createSimpleMenu(menuKey, "接口配置", MagicApiTpl.MAGIC_API_PERMISSION, null, 50, EruptTplService.TPL)); - metaMenus.add(MetaMenu.createSimpleMenu(menuKey + "-" + FUNCTION.toLowerCase(), "函数", MAGIC_API_MENU_PREFIX + FUNCTION.toUpperCase(), metaMenus.get(0), sort.addAndGet(10), MenuTypeEnum.BUTTON.getCode())); - metaMenus.add(MetaMenu.createSimpleMenu(menuKey + "-" + DATASOURCE.toLowerCase(), "数据源", MAGIC_API_MENU_PREFIX + DATASOURCE.toUpperCase(), metaMenus.get(0), sort.addAndGet(10), MenuTypeEnum.BUTTON.getCode())); - menus.forEach((key, value) -> metaMenus.add(MetaMenu.createSimpleMenu( - menuKey + "-" + key.name().toLowerCase(), value, - MAGIC_API_MENU_PREFIX + key.name(), - metaMenus.get(0), sort.addAndGet(10), - MenuTypeEnum.BUTTON.getCode() - ))); - return metaMenus; - } + @Override + public List initMenus() { + String menuKey = "magic-api"; + Map menus = new LinkedHashMap<>(); + menus.put(Authorization.SAVE, "保存"); + menus.put(Authorization.VIEW, "查看"); + menus.put(Authorization.DELETE, "删除"); + menus.put(Authorization.DOWNLOAD, "导出"); + menus.put(Authorization.UPLOAD, "上传"); + menus.put(Authorization.PUSH, "远程推送"); + menus.put(Authorization.LOCK, "锁定"); + menus.put(Authorization.UNLOCK, "解锁"); + AtomicInteger sort = new AtomicInteger(); + List metaMenus = new ArrayList<>(); + metaMenus.add( + MetaMenu.createSimpleMenu( + menuKey, "接口配置", MagicApiTpl.MAGIC_API_PERMISSION, null, 50, EruptTplService.TPL)); + metaMenus.add( + MetaMenu.createSimpleMenu( + menuKey + "-" + FUNCTION.toLowerCase(), + "函数", + MAGIC_API_MENU_PREFIX + FUNCTION.toUpperCase(), + metaMenus.get(0), + sort.addAndGet(10), + MenuTypeEnum.BUTTON.getCode())); + metaMenus.add( + MetaMenu.createSimpleMenu( + menuKey + "-" + DATASOURCE.toLowerCase(), + "数据源", + MAGIC_API_MENU_PREFIX + DATASOURCE.toUpperCase(), + metaMenus.get(0), + sort.addAndGet(10), + MenuTypeEnum.BUTTON.getCode())); + menus.forEach( + (key, value) -> + metaMenus.add( + MetaMenu.createSimpleMenu( + menuKey + "-" + key.name().toLowerCase(), + value, + MAGIC_API_MENU_PREFIX + key.name(), + metaMenus.get(0), + sort.addAndGet(10), + MenuTypeEnum.BUTTON.getCode()))); + return metaMenus; + } } diff --git a/fluent-erupts/fluent-generator/src/main/java/io/fluentqa/generator/api/action/MagicApiTpl.java b/fluent-erupts/fluent-generator/src/main/java/io/fluentqa/generator/api/action/MagicApiTpl.java index fb45595..db82b1e 100644 --- a/fluent-erupts/fluent-generator/src/main/java/io/fluentqa/generator/api/action/MagicApiTpl.java +++ b/fluent-erupts/fluent-generator/src/main/java/io/fluentqa/generator/api/action/MagicApiTpl.java @@ -1,5 +1,8 @@ package io.fluentqa.generator.api.action; +import java.util.HashMap; +import java.util.Map; +import javax.annotation.Resource; import org.springframework.stereotype.Component; import org.ssssssss.magicapi.core.config.MagicAPIProperties; import xyz.erupt.core.util.EruptInformation; @@ -7,30 +10,23 @@ import xyz.erupt.tpl.annotation.TplAction; import xyz.erupt.upms.service.EruptContextService; -import javax.annotation.Resource; -import java.util.HashMap; -import java.util.Map; - @EruptTpl @Component public class MagicApiTpl { - public static final String MAGIC_API_PERMISSION = "magic-api.ftl"; - - @Resource - private MagicAPIProperties magicAPIProperties; + public static final String MAGIC_API_PERMISSION = "magic-api.ftl"; - @Resource - private EruptContextService eruptContextService; + @Resource private MagicAPIProperties magicAPIProperties; - @TplAction(MAGIC_API_PERMISSION) - public Map magicApiAction() { - Map map = new HashMap<>(); - map.put("web", magicAPIProperties.getWeb()); - map.put("token", eruptContextService.getCurrentToken()); - map.put("v", EruptInformation.getEruptVersion()); - map.put("hash", this.hashCode()); - return map; - } + @Resource private EruptContextService eruptContextService; + @TplAction(MAGIC_API_PERMISSION) + public Map magicApiAction() { + Map map = new HashMap<>(); + map.put("web", magicAPIProperties.getWeb()); + map.put("token", eruptContextService.getCurrentToken()); + map.put("v", EruptInformation.getEruptVersion()); + map.put("hash", this.hashCode()); + return map; + } } diff --git a/fluent-erupts/fluent-generator/src/main/java/io/fluentqa/generator/api/package-info.java b/fluent-erupts/fluent-generator/src/main/java/io/fluentqa/generator/api/package-info.java index 70bbc75..e782537 100644 --- a/fluent-erupts/fluent-generator/src/main/java/io/fluentqa/generator/api/package-info.java +++ b/fluent-erupts/fluent-generator/src/main/java/io/fluentqa/generator/api/package-info.java @@ -1 +1 @@ -package io.fluentqa.generator.api; \ No newline at end of file +package io.fluentqa.generator.api; diff --git a/fluent-erupts/fluent-generator/src/main/java/io/fluentqa/generator/interceptor/EruptMagicAPIRequestInterceptor.java b/fluent-erupts/fluent-generator/src/main/java/io/fluentqa/generator/interceptor/EruptMagicAPIRequestInterceptor.java index b66099a..48fe714 100644 --- a/fluent-erupts/fluent-generator/src/main/java/io/fluentqa/generator/interceptor/EruptMagicAPIRequestInterceptor.java +++ b/fluent-erupts/fluent-generator/src/main/java/io/fluentqa/generator/interceptor/EruptMagicAPIRequestInterceptor.java @@ -1,6 +1,7 @@ package io.fluentqa.generator.interceptor; import io.fluentqa.generator.FluentEruptApiAutoConfiguration; +import java.util.Objects; import lombok.AllArgsConstructor; import lombok.SneakyThrows; import org.apache.commons.lang3.StringUtils; @@ -19,117 +20,125 @@ import xyz.erupt.core.module.MetaUserinfo; import xyz.erupt.upms.service.EruptUserService; -import java.util.Objects; - -/** - * magic-api UI鉴权、接口鉴权 - */ +/** magic-api UI鉴权、接口鉴权 */ @Component @AllArgsConstructor -public class EruptMagicAPIRequestInterceptor implements RequestInterceptor, AuthorizationInterceptor { +public class EruptMagicAPIRequestInterceptor + implements RequestInterceptor, AuthorizationInterceptor { - private final EruptUserService eruptUserService; + private final EruptUserService eruptUserService; - private static final String NO_PERMISSION = "权限不足!"; + private static final String NO_PERMISSION = "权限不足!"; - private static final String LOGIN_EXPIRE = "登录凭证失效!"; + private static final String LOGIN_EXPIRE = "登录凭证失效!"; - /** - * 配置接口权限 - */ - @Override - public Object preHandle(RequestEntity requestEntity) { - ApiInfo info = requestEntity.getApiInfo(); - String permission = Objects.toString(info.getOptionValue(Options.PERMISSION), ""); - String role = Objects.toString(info.getOptionValue(Options.ROLE), ""); - String login = Objects.toString(info.getOptionValue(Options.REQUIRE_LOGIN), ""); - boolean isLogin = eruptUserService.getCurrentUid() != null; - if (StringUtils.isNotBlank(login) && !isLogin) return new JsonBean<>(401, LOGIN_EXPIRE); - if (StringUtils.isNotBlank(role) || StringUtils.isNotBlank(permission)) { - // 未登录 - if (!isLogin) { - return new JsonBean(401, LOGIN_EXPIRE); - } else { - MetaUserinfo metaUserInfo = eruptUserService.getSimpleUserInfo(); - if (!metaUserInfo.isSuperAdmin()) { - // 权限判断 - if (StringUtils.isNotBlank(permission) && eruptUserService.getEruptMenuByValue(permission) == null) { - return new JsonBean(403, NO_PERMISSION); - } - // 角色判断 - if (StringUtils.isNotBlank(role) && metaUserInfo.getRoles().stream().noneMatch(role::equals)) { - return new JsonBean(403, NO_PERMISSION); - } - } - } + /** 配置接口权限 */ + @Override + public Object preHandle(RequestEntity requestEntity) { + ApiInfo info = requestEntity.getApiInfo(); + String permission = Objects.toString(info.getOptionValue(Options.PERMISSION), ""); + String role = Objects.toString(info.getOptionValue(Options.ROLE), ""); + String login = Objects.toString(info.getOptionValue(Options.REQUIRE_LOGIN), ""); + boolean isLogin = eruptUserService.getCurrentUid() != null; + if (StringUtils.isNotBlank(login) && !isLogin) return new JsonBean<>(401, LOGIN_EXPIRE); + if (StringUtils.isNotBlank(role) || StringUtils.isNotBlank(permission)) { + // 未登录 + if (!isLogin) { + return new JsonBean(401, LOGIN_EXPIRE); + } else { + MetaUserinfo metaUserInfo = eruptUserService.getSimpleUserInfo(); + if (!metaUserInfo.isSuperAdmin()) { + // 权限判断 + if (StringUtils.isNotBlank(permission) + && eruptUserService.getEruptMenuByValue(permission) == null) { + return new JsonBean(403, NO_PERMISSION); + } + // 角色判断 + if (StringUtils.isNotBlank(role) + && metaUserInfo.getRoles().stream().noneMatch(role::equals)) { + return new JsonBean(403, NO_PERMISSION); + } } - return null; + } } + return null; + } - /** - * 配置UI界面不需要登录框 - */ - @Override - public boolean requireLogin() { - return false; - } - - @Override - @SneakyThrows - public MagicUser getUserByToken(String token) { - MetaUserinfo metaUserinfo = eruptUserService.getSimpleUserInfoByToken(token); - if (null == metaUserinfo) throw new MagicLoginException(LOGIN_EXPIRE); - return new MagicUser(metaUserinfo.getAccount(), metaUserinfo.getUsername(), token); - } + /** 配置UI界面不需要登录框 */ + @Override + public boolean requireLogin() { + return false; + } + @Override + @SneakyThrows + public MagicUser getUserByToken(String token) { + MetaUserinfo metaUserinfo = eruptUserService.getSimpleUserInfoByToken(token); + if (null == metaUserinfo) throw new MagicLoginException(LOGIN_EXPIRE); + return new MagicUser(metaUserinfo.getAccount(), metaUserinfo.getUsername(), token); + } - - /** - * 配置UI鉴权 - */ - @Override - public boolean allowVisit(MagicUser magicUser, MagicHttpServletRequest request, Authorization authorization) { - if (Authorization.RELOAD == authorization) return true; - if (eruptUserService.getCurrentUid() == null) { - throw new EruptWebApiRuntimeException(LOGIN_EXPIRE); - } else if (null == eruptUserService.getEruptMenuByValue(FluentEruptApiAutoConfiguration.MAGIC_API_MENU_PREFIX + authorization.name())) { - throw new EruptWebApiRuntimeException(NO_PERMISSION); - } - return true; + /** 配置UI鉴权 */ + @Override + public boolean allowVisit( + MagicUser magicUser, MagicHttpServletRequest request, Authorization authorization) { + if (Authorization.RELOAD == authorization) return true; + if (eruptUserService.getCurrentUid() == null) { + throw new EruptWebApiRuntimeException(LOGIN_EXPIRE); + } else if (null + == eruptUserService.getEruptMenuByValue( + FluentEruptApiAutoConfiguration.MAGIC_API_MENU_PREFIX + authorization.name())) { + throw new EruptWebApiRuntimeException(NO_PERMISSION); } + return true; + } - @Override - public boolean allowVisit(MagicUser magicUser, MagicHttpServletRequest request, Authorization authorization, Group group) { - if (null == eruptUserService.getCurrentUid()) throw new EruptWebApiRuntimeException(LOGIN_EXPIRE); - MetaUserinfo metaUserinfo = eruptUserService.getSimpleUserInfo(); - if (!metaUserinfo.isSuperAdmin()) { - if (group.getOptions().size() > 0) { - for (BaseDefinition option : group.getOptions()) { - if (null != option.getValue() && StringUtils.isNotBlank(option.getValue().toString())) { - if (Options.ROLE.getValue().equals(option.getName())) { - return metaUserinfo.getRoles().stream().anyMatch(it -> it.equals(option.getValue())); - } else if (Options.PERMISSION.getValue().equals(option.getName())) { - return null != eruptUserService.getEruptMenuByValue(option.getValue().toString()); - } - } - } + @Override + public boolean allowVisit( + MagicUser magicUser, + MagicHttpServletRequest request, + Authorization authorization, + Group group) { + if (null == eruptUserService.getCurrentUid()) + throw new EruptWebApiRuntimeException(LOGIN_EXPIRE); + MetaUserinfo metaUserinfo = eruptUserService.getSimpleUserInfo(); + if (!metaUserinfo.isSuperAdmin()) { + if (group.getOptions().size() > 0) { + for (BaseDefinition option : group.getOptions()) { + if (null != option.getValue() && StringUtils.isNotBlank(option.getValue().toString())) { + if (Options.ROLE.getValue().equals(option.getName())) { + return metaUserinfo.getRoles().stream().anyMatch(it -> it.equals(option.getValue())); + } else if (Options.PERMISSION.getValue().equals(option.getName())) { + return null != eruptUserService.getEruptMenuByValue(option.getValue().toString()); } + } } - return true; + } } + return true; + } - @Override - public boolean allowVisit(MagicUser magicUser, MagicHttpServletRequest request, Authorization authorization, MagicEntity entity) { - if (entity instanceof FunctionInfo) { - if (Authorization.SAVE == authorization || Authorization.DELETE == authorization) { - return eruptUserService.getEruptMenuByValue(FluentEruptApiAutoConfiguration.MAGIC_API_MENU_PREFIX + FluentEruptApiAutoConfiguration.FUNCTION) != null; - } - } else if (entity instanceof DataSourceInfo) { - if (Authorization.SAVE == authorization || Authorization.DELETE == authorization) { - return eruptUserService.getEruptMenuByValue(FluentEruptApiAutoConfiguration.MAGIC_API_MENU_PREFIX + FluentEruptApiAutoConfiguration.DATASOURCE) != null; - } - } - return AuthorizationInterceptor.super.allowVisit(magicUser, request, authorization, entity); + @Override + public boolean allowVisit( + MagicUser magicUser, + MagicHttpServletRequest request, + Authorization authorization, + MagicEntity entity) { + if (entity instanceof FunctionInfo) { + if (Authorization.SAVE == authorization || Authorization.DELETE == authorization) { + return eruptUserService.getEruptMenuByValue( + FluentEruptApiAutoConfiguration.MAGIC_API_MENU_PREFIX + + FluentEruptApiAutoConfiguration.FUNCTION) + != null; + } + } else if (entity instanceof DataSourceInfo) { + if (Authorization.SAVE == authorization || Authorization.DELETE == authorization) { + return eruptUserService.getEruptMenuByValue( + FluentEruptApiAutoConfiguration.MAGIC_API_MENU_PREFIX + + FluentEruptApiAutoConfiguration.DATASOURCE) + != null; + } } - + return AuthorizationInterceptor.super.allowVisit(magicUser, request, authorization, entity); + } } diff --git a/fluent-erupts/fluent-generator/src/main/java/io/fluentqa/generator/package-info.java b/fluent-erupts/fluent-generator/src/main/java/io/fluentqa/generator/package-info.java index 59dadb6..fd8bb89 100644 --- a/fluent-erupts/fluent-generator/src/main/java/io/fluentqa/generator/package-info.java +++ b/fluent-erupts/fluent-generator/src/main/java/io/fluentqa/generator/package-info.java @@ -1 +1 @@ -package io.fluentqa.generator; \ No newline at end of file +package io.fluentqa.generator; diff --git a/fluent-erupts/fluent-generator/src/main/java/io/fluentqa/generator/service/JsonToPojoGenerateService.java b/fluent-erupts/fluent-generator/src/main/java/io/fluentqa/generator/service/JsonToPojoGenerateService.java index 72fd3e3..0873572 100644 --- a/fluent-erupts/fluent-generator/src/main/java/io/fluentqa/generator/service/JsonToPojoGenerateService.java +++ b/fluent-erupts/fluent-generator/src/main/java/io/fluentqa/generator/service/JsonToPojoGenerateService.java @@ -1,53 +1,49 @@ package io.fluentqa.generator.service; import com.beust.jcommander.internal.Lists; -import org.jsonschema2pojo.Jsonschema2Pojo; -import org.jsonschema2pojo.SourceType; -import org.jsonschema2pojo.cli.Arguments; -import org.jsonschema2pojo.cli.CommandLineLogger; - import java.io.File; import java.io.IOException; import java.net.URL; import java.util.Iterator; +import org.jsonschema2pojo.Jsonschema2Pojo; +import org.jsonschema2pojo.SourceType; +import org.jsonschema2pojo.cli.Arguments; +import org.jsonschema2pojo.cli.CommandLineLogger; public class JsonToPojoGenerateService { - public void generate(String schemaFile, - String packageName, String className, - String outputDir) throws IOException { - URL source = JsonToPojoGenerateService.class.getResource("/schema/" + schemaFile); - Arguments config = new Arguments() { - - @Override - public Iterator getSource() { - return Lists.newArrayList( - source - ).iterator(); - } - - @Override - public File getTargetDirectory() { - return new File(outputDir); - } - - @Override - public boolean isIncludeToString() { - return false; - } - - @Override - public boolean isIncludeHashcodeAndEquals() { - return false; - } - - @Override - public SourceType getSourceType() { - return SourceType.JSON; - } + public void generate(String schemaFile, String packageName, String className, String outputDir) + throws IOException { + URL source = JsonToPojoGenerateService.class.getResource("/schema/" + schemaFile); + Arguments config = + new Arguments() { + + @Override + public Iterator getSource() { + return Lists.newArrayList(source).iterator(); + } + + @Override + public File getTargetDirectory() { + return new File(outputDir); + } + + @Override + public boolean isIncludeToString() { + return false; + } + + @Override + public boolean isIncludeHashcodeAndEquals() { + return false; + } + + @Override + public SourceType getSourceType() { + return SourceType.JSON; + } }; - Jsonschema2Pojo.generate(config, - new CommandLineLogger("info")); - } + Jsonschema2Pojo.generate(config, new CommandLineLogger("info")); + } } diff --git a/fluent-erupts/fluent-generator/src/test/java/io/fluentqa/generator/pojo/PojoGeneratorTest.java b/fluent-erupts/fluent-generator/src/test/java/io/fluentqa/generator/pojo/PojoGeneratorTest.java index 643e043..365d544 100644 --- a/fluent-erupts/fluent-generator/src/test/java/io/fluentqa/generator/pojo/PojoGeneratorTest.java +++ b/fluent-erupts/fluent-generator/src/test/java/io/fluentqa/generator/pojo/PojoGeneratorTest.java @@ -1,15 +1,14 @@ package io.fluentqa.generator.pojo; import io.fluentqa.generator.service.JsonToPojoGenerateService; -import org.junit.jupiter.api.Test; - import java.io.IOException; - +import org.junit.jupiter.api.Test; class PojoGeneratorTest { - JsonToPojoGenerateService generator = new JsonToPojoGenerateService(); - @Test - public void testGenerate() throws IOException { - generator.generate("github-repo.json","io.fluent","GithubRepository","models"); - } -} \ No newline at end of file + JsonToPojoGenerateService generator = new JsonToPojoGenerateService(); + + @Test + public void testGenerate() throws IOException { + generator.generate("github-repo.json", "io.fluent", "GithubRepository", "models"); + } +} diff --git a/fluent-wrappers/fluent-ai/src/main/java/io/fluent/ai/package-info.java b/fluent-wrappers/fluent-ai/src/main/java/io/fluent/ai/package-info.java deleted file mode 100644 index ea44520..0000000 --- a/fluent-wrappers/fluent-ai/src/main/java/io/fluent/ai/package-info.java +++ /dev/null @@ -1 +0,0 @@ -package io.fluent.ai; \ No newline at end of file diff --git a/fluent-wrappers/fluent-feishu/src/main/java/io/fluent/wrappers/feishu/BitTableApis.java b/fluent-wrappers/fluent-feishu/src/main/java/io/fluent/wrappers/feishu/BitTableApis.java index 78aa037..9318477 100644 --- a/fluent-wrappers/fluent-feishu/src/main/java/io/fluent/wrappers/feishu/BitTableApis.java +++ b/fluent-wrappers/fluent-feishu/src/main/java/io/fluent/wrappers/feishu/BitTableApis.java @@ -6,102 +6,108 @@ import com.lark.oapi.service.bitable.v1.enums.BatchCreateAppTableRecordUserIdTypeEnum; import com.lark.oapi.service.bitable.v1.enums.CreateAppTableRecordUserIdTypeEnum; import com.lark.oapi.service.bitable.v1.model.*; - import java.util.HashMap; import java.util.Map; public class BitTableApis { - - public static void createTableRecord(Client client) throws Exception { - - Map fields = new HashMap<>(); - fields.put("name", "zlx"); - fields.put("sex", "male"); - fields.put("Date", 1612108800000L); - fields.put("number", 1234L); - fields.put("url", Url.newBuilder() - .link("https://bytedance.feishu.cn/drive/home/") - .text("我是加多") - .build()); -// fields.put("Attachment", -// new Attachment[]{Attachment.newBuilder().fileToken("boxcnnIpo5luPZtLWjuyJpuo9yf").build()}); - - CreateAppTableRecordReq req = CreateAppTableRecordReq.newBuilder() - .userIdType(CreateAppTableRecordUserIdTypeEnum.USER_ID) - .tableId("tbl9a6pWtNVFsSrQ") - .appToken("bascnpApISZqKuO0uEbcOzGcH6b") - .appTableRecord(AppTableRecord.newBuilder() - .fields(fields) - .build()) - .build(); - - // 发起请求 - CreateAppTableRecordResp resp = client.bitable().appTableRecord() - .create(req, RequestOptions.newBuilder() - .userAccessToken("u-2Q0ERNI7F6FaiEU3HzuqR90glhox4leHPi005gO025Qz") - .build()); - - // 处理服务端错误 - if (resp.getCode() != 0) { - System.out.println(String.format("code:%d,msg:%s,err:%s" - , resp.getCode(), resp.getMsg(), resp.getRequestId())); - return; - } - - // 业务处理结果 - System.out.println(Jsons.DEFAULT.toJson(resp)); + public static void createTableRecord(Client client) throws Exception { + + Map fields = new HashMap<>(); + fields.put("name", "zlx"); + fields.put("sex", "male"); + fields.put("Date", 1612108800000L); + fields.put("number", 1234L); + fields.put( + "url", + Url.newBuilder().link("https://bytedance.feishu.cn/drive/home/").text("我是加多").build()); + // fields.put("Attachment", + // new + // Attachment[]{Attachment.newBuilder().fileToken("boxcnnIpo5luPZtLWjuyJpuo9yf").build()}); + + CreateAppTableRecordReq req = + CreateAppTableRecordReq.newBuilder() + .userIdType(CreateAppTableRecordUserIdTypeEnum.USER_ID) + .tableId("tbl9a6pWtNVFsSrQ") + .appToken("bascnpApISZqKuO0uEbcOzGcH6b") + .appTableRecord(AppTableRecord.newBuilder().fields(fields).build()) + .build(); + + // 发起请求 + CreateAppTableRecordResp resp = + client + .bitable() + .appTableRecord() + .create( + req, + RequestOptions.newBuilder() + .userAccessToken("u-2Q0ERNI7F6FaiEU3HzuqR90glhox4leHPi005gO025Qz") + .build()); + + // 处理服务端错误 + if (resp.getCode() != 0) { + System.out.println( + String.format( + "code:%d,msg:%s,err:%s", resp.getCode(), resp.getMsg(), resp.getRequestId())); + return; } - - public static void batchCreateTableRecord(Client client) throws Exception { - Map fields = new HashMap<>(); -// fields.put("name", "zlx"); -// fields.put("sex", "male"); -// fields.put("Date", 1612108800000L); - fields.put("aid", 121212); - fields.put("tag", Url.newBuilder() - .link("https://bytedance.feishu.cn/drive/home/") - .text("我是加多") - .build()); - AppTableRecord record = AppTableRecord.newBuilder() - .fields(fields) - .build(); - - BatchCreateAppTableRecordReq req = BatchCreateAppTableRecordReq.newBuilder() - .userIdType(BatchCreateAppTableRecordUserIdTypeEnum.USER_ID) - .tableId("tbl2CfTdOZ2cuTMD") - .appToken("bascnXiAbRDW2azUWZECiBc2Hrd") - .batchCreateAppTableRecordReqBody(BatchCreateAppTableRecordReqBody.newBuilder() - .records(new AppTableRecord[]{record, record}) - .build()) - .build(); - - // 发起请求 - BatchCreateAppTableRecordResp resp = client.bitable().appTableRecord() - .batchCreate(req, RequestOptions.newBuilder() - .userAccessToken("u-2Q0ERNI7F6FaiEU3HzuqR90glhox4leHPi005gO025Qz") - .build()); - - // 处理服务端错误 - if (resp.getCode() != 0) { - System.out.println(String.format("code:%d,msg:%s,err:%s" - , resp.getCode(), resp.getMsg(), resp.getRequestId())); - return; - } - - // 业务处理结果 - System.out.println(Jsons.DEFAULT.toJson(resp)); + // 业务处理结果 + System.out.println(Jsons.DEFAULT.toJson(resp)); + } + + public static void batchCreateTableRecord(Client client) throws Exception { + Map fields = new HashMap<>(); + // fields.put("name", "zlx"); + // fields.put("sex", "male"); + // fields.put("Date", 1612108800000L); + fields.put("aid", 121212); + fields.put( + "tag", + Url.newBuilder().link("https://bytedance.feishu.cn/drive/home/").text("我是加多").build()); + AppTableRecord record = AppTableRecord.newBuilder().fields(fields).build(); + + BatchCreateAppTableRecordReq req = + BatchCreateAppTableRecordReq.newBuilder() + .userIdType(BatchCreateAppTableRecordUserIdTypeEnum.USER_ID) + .tableId("tbl2CfTdOZ2cuTMD") + .appToken("bascnXiAbRDW2azUWZECiBc2Hrd") + .batchCreateAppTableRecordReqBody( + BatchCreateAppTableRecordReqBody.newBuilder() + .records(new AppTableRecord[] {record, record}) + .build()) + .build(); + + // 发起请求 + BatchCreateAppTableRecordResp resp = + client + .bitable() + .appTableRecord() + .batchCreate( + req, + RequestOptions.newBuilder() + .userAccessToken("u-2Q0ERNI7F6FaiEU3HzuqR90glhox4leHPi005gO025Qz") + .build()); + + // 处理服务端错误 + if (resp.getCode() != 0) { + System.out.println( + String.format( + "code:%d,msg:%s,err:%s", resp.getCode(), resp.getMsg(), resp.getRequestId())); + return; } -// public static void main(String arg[]) throws Exception { -// // 构建client -// String appId = System.getenv().get("APP_ID"); -// String appSecret = System.getenv().get("APP_SECRET"); -// -// Client client = Client.newBuilder(appId, appSecret).build(); -// createTableRecord(client); -// } + // 业务处理结果 + System.out.println(Jsons.DEFAULT.toJson(resp)); + } + // public static void main(String arg[]) throws Exception { + // // 构建client + // String appId = System.getenv().get("APP_ID"); + // String appSecret = System.getenv().get("APP_SECRET"); + // + // Client client = Client.newBuilder(appId, appSecret).build(); + // createTableRecord(client); + // } -} \ No newline at end of file +} diff --git a/fluent-wrappers/fluent-feishu/src/main/java/io/fluent/wrappers/feishu/RawApiCall.java b/fluent-wrappers/fluent-feishu/src/main/java/io/fluent/wrappers/feishu/RawApiCall.java index 21aca30..177fbf4 100644 --- a/fluent-wrappers/fluent-feishu/src/main/java/io/fluent/wrappers/feishu/RawApiCall.java +++ b/fluent-wrappers/fluent-feishu/src/main/java/io/fluent/wrappers/feishu/RawApiCall.java @@ -12,101 +12,102 @@ import com.lark.oapi.service.ext.model.CreateFileResp; import com.lark.oapi.service.im.v1.enums.MsgTypeEnum; import com.lark.oapi.service.im.v1.model.ext.MessageText; - import java.util.HashMap; import java.util.Map; -/** - * 原生http 调用方式 - */ +/** 原生http 调用方式 */ public class RawApiCall { - public static void sendMsg() throws Exception { - String appId = System.getenv().get("APP_ID"); - String appSecret = System.getenv().get("APP_SECRET"); - - // 构建client - Client client = Client.newBuilder(appId, appSecret) - .appType(AppType.SELF_BUILT) // 设置app类型,默认为自建 - .logReqAtDebug(true) - .build(); - - // 构建http body - Map body = new HashMap<>(); - body.put("receive_id", "ou_c245b0a7dff2725cfa2fb104f8b48b9d"); - body.put("content", MessageText.newBuilder() - .atUser("ou_155184d1e73cbfb8973e5a9e698e74f2", "Tom") - .text("test content") - .build()); - body.put("msg_type", MsgTypeEnum.MSG_TYPE_TEXT); - - // 发起请求 - RawResponse resp = client.post( - "https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=open_id" - , body - , AccessTokenType.Tenant); - - // 处理结果 - System.out.println(resp.getStatusCode()); - System.out.println(Jsons.DEFAULT.toJson(resp.getHeaders())); - System.out.println(new String(resp.getBody())); - System.out.println(resp.getRequestID()); - } - - - public static void getTenantToken() throws Exception { - String appId = System.getenv().get("APP_ID"); - String appSecret = System.getenv().get("APP_SECRET"); - - // 构建client - Client client = Client.newBuilder(appId, appSecret) - .appType(AppType.SELF_BUILT) // 设置app类型,默认为自建 - .logReqAtDebug(true) - .build(); - - // 发起请求 - Map body = new HashMap<>(); - body.put("app_id", appId); - body.put("app_secret", appSecret); - RawResponse resp = client.post( - "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal" - , body - , AccessTokenType.None); - - // 处理结果 - System.out.println(resp.getStatusCode()); - System.out.println(Jsons.DEFAULT.toJson(resp.getHeaders())); - System.out.println(new String(resp.getBody())); - System.out.println(resp.getRequestID()); - } - - public static void createFile() throws Exception { - String appId = System.getenv().get("APP_ID"); - String appSecret = System.getenv().get("APP_SECRET"); - - // 构建client - Client client = Client.newBuilder(appId, appSecret) - .logReqAtDebug(true) - .build(); - - CreateFileResp resp = client.ext() - .createFile(CreateFileReq.newBuilder() - .folderToken("fldcniHf40Vcv1DoEc8SXeuA0Zd") - .body(CreateFileReqBody.newBuilder() - .title("测试哎") - .type(FileTypeEnum.DOC) - .build()) - .build(), RequestOptions.newBuilder() - .userAccessToken("u-3hVKsQTwR5H9j_tQbO2GoElg0Rggl543io00glM0277v") - .build()); - // 处理结果 - if (!resp.success()) { - System.out.println( - String.format("%s,%s,%s", resp.getRequestId(), resp.getMsg(), resp.getCode())); - return; - } - System.out.println(Jsons.DEFAULT.toJson(resp.getData())); - System.out.println(resp.getRequestId()); + public static void sendMsg() throws Exception { + String appId = System.getenv().get("APP_ID"); + String appSecret = System.getenv().get("APP_SECRET"); + + // 构建client + Client client = + Client.newBuilder(appId, appSecret) + .appType(AppType.SELF_BUILT) // 设置app类型,默认为自建 + .logReqAtDebug(true) + .build(); + + // 构建http body + Map body = new HashMap<>(); + body.put("receive_id", "ou_c245b0a7dff2725cfa2fb104f8b48b9d"); + body.put( + "content", + MessageText.newBuilder() + .atUser("ou_155184d1e73cbfb8973e5a9e698e74f2", "Tom") + .text("test content") + .build()); + body.put("msg_type", MsgTypeEnum.MSG_TYPE_TEXT); + + // 发起请求 + RawResponse resp = + client.post( + "https://open.feishu.cn/open-apis/im/v1/messages?receive_id_type=open_id", + body, + AccessTokenType.Tenant); + + // 处理结果 + System.out.println(resp.getStatusCode()); + System.out.println(Jsons.DEFAULT.toJson(resp.getHeaders())); + System.out.println(new String(resp.getBody())); + System.out.println(resp.getRequestID()); + } + + public static void getTenantToken() throws Exception { + String appId = System.getenv().get("APP_ID"); + String appSecret = System.getenv().get("APP_SECRET"); + + // 构建client + Client client = + Client.newBuilder(appId, appSecret) + .appType(AppType.SELF_BUILT) // 设置app类型,默认为自建 + .logReqAtDebug(true) + .build(); + + // 发起请求 + Map body = new HashMap<>(); + body.put("app_id", appId); + body.put("app_secret", appSecret); + RawResponse resp = + client.post( + "https://open.feishu.cn/open-apis/auth/v3/tenant_access_token/internal", + body, + AccessTokenType.None); + + // 处理结果 + System.out.println(resp.getStatusCode()); + System.out.println(Jsons.DEFAULT.toJson(resp.getHeaders())); + System.out.println(new String(resp.getBody())); + System.out.println(resp.getRequestID()); + } + + public static void createFile() throws Exception { + String appId = System.getenv().get("APP_ID"); + String appSecret = System.getenv().get("APP_SECRET"); + + // 构建client + Client client = Client.newBuilder(appId, appSecret).logReqAtDebug(true).build(); + + CreateFileResp resp = + client + .ext() + .createFile( + CreateFileReq.newBuilder() + .folderToken("fldcniHf40Vcv1DoEc8SXeuA0Zd") + .body( + CreateFileReqBody.newBuilder().title("测试哎").type(FileTypeEnum.DOC).build()) + .build(), + RequestOptions.newBuilder() + .userAccessToken("u-3hVKsQTwR5H9j_tQbO2GoElg0Rggl543io00glM0277v") + .build()); + // 处理结果 + if (!resp.success()) { + System.out.println( + String.format("%s,%s,%s", resp.getRequestId(), resp.getMsg(), resp.getCode())); + return; } - -} \ No newline at end of file + System.out.println(Jsons.DEFAULT.toJson(resp.getData())); + System.out.println(resp.getRequestId()); + } +} diff --git a/fluent-wrappers/fluent-feishu/src/main/java/io/fluent/wrappers/feishu/auth/dto/req/TenantAccessTokenGetReqDTO.java b/fluent-wrappers/fluent-feishu/src/main/java/io/fluent/wrappers/feishu/auth/dto/req/TenantAccessTokenGetReqDTO.java index 909c16c..0f64039 100644 --- a/fluent-wrappers/fluent-feishu/src/main/java/io/fluent/wrappers/feishu/auth/dto/req/TenantAccessTokenGetReqDTO.java +++ b/fluent-wrappers/fluent-feishu/src/main/java/io/fluent/wrappers/feishu/auth/dto/req/TenantAccessTokenGetReqDTO.java @@ -6,24 +6,16 @@ import lombok.Data; import lombok.NoArgsConstructor; -/** - * 企业自建应用token获取请求参数 - - */ +/** 企业自建应用token获取请求参数 */ @Data @NoArgsConstructor @AllArgsConstructor @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) public class TenantAccessTokenGetReqDTO { - /** - * 应用ID - */ - private String appId; - - /** - * 密钥 - */ - private String appSecret; + /** 应用ID */ + private String appId; + /** 密钥 */ + private String appSecret; } diff --git a/fluent-wrappers/fluent-feishu/src/main/java/io/fluent/wrappers/feishu/auth/dto/resp/TenantAccessTokenGetRespDTO.java b/fluent-wrappers/fluent-feishu/src/main/java/io/fluent/wrappers/feishu/auth/dto/resp/TenantAccessTokenGetRespDTO.java index 682cce4..5bf16b9 100644 --- a/fluent-wrappers/fluent-feishu/src/main/java/io/fluent/wrappers/feishu/auth/dto/resp/TenantAccessTokenGetRespDTO.java +++ b/fluent-wrappers/fluent-feishu/src/main/java/io/fluent/wrappers/feishu/auth/dto/resp/TenantAccessTokenGetRespDTO.java @@ -4,33 +4,20 @@ import com.fasterxml.jackson.databind.annotation.JsonNaming; import lombok.Data; -/** - * 企业自建应用token获取请求参数 - * - */ +/** 企业自建应用token获取请求参数 */ @Data @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) public class TenantAccessTokenGetRespDTO { - /** - * 响应码 - */ - private Integer code; + /** 响应码 */ + private Integer code; - /** - * 消息 - */ - private String msg; - - /** - * token - */ - private String tenantAccessToken; - - /** - * 过期时间 - */ - private Integer expire; + /** 消息 */ + private String msg; + /** token */ + private String tenantAccessToken; + /** 过期时间 */ + private Integer expire; } diff --git a/fluent-wrappers/fluent-feishu/src/main/java/io/fluent/wrappers/feishu/auth/service/AuthApiService.java b/fluent-wrappers/fluent-feishu/src/main/java/io/fluent/wrappers/feishu/auth/service/AuthApiService.java index 5effccb..17f6165 100644 --- a/fluent-wrappers/fluent-feishu/src/main/java/io/fluent/wrappers/feishu/auth/service/AuthApiService.java +++ b/fluent-wrappers/fluent-feishu/src/main/java/io/fluent/wrappers/feishu/auth/service/AuthApiService.java @@ -1,22 +1,22 @@ -//package io.fluent.wrappers.feishu.auth.service; +// package io.fluent.wrappers.feishu.auth.service; // -//import cn.hutool.core.util.StrUtil; -//import cn.hutool.http.HttpUtil; -//import io.fluent.wrappers.feishu.auth.dto.req.TenantAccessTokenGetReqDTO; -//import io.fluent.wrappers.feishu.auth.dto.resp.TenantAccessTokenGetRespDTO; -//import lombok.Data; +// import cn.hutool.core.util.StrUtil; +// import cn.hutool.http.HttpUtil; +// import io.fluent.wrappers.feishu.auth.dto.req.TenantAccessTokenGetReqDTO; +// import io.fluent.wrappers.feishu.auth.dto.resp.TenantAccessTokenGetRespDTO; +// import lombok.Data; // -//import java.util.concurrent.TimeUnit; -//import java.util.concurrent.atomic.AtomicLong; +// import java.util.concurrent.TimeUnit; +// import java.util.concurrent.atomic.AtomicLong; // -///** +/// ** // * 飞书认证api接口 // * // * @author Tao.Liu // * @date 2022/6/29 13:55 // */ -//@Data -//public class AuthApiService { +// @Data +// public class AuthApiService { // // public final static String BASE_URL = "https://open.feishu.cn/open-apis/auth"; // @@ -55,13 +55,16 @@ // * @return // */ // public String getTenantAccessToken() { -// if (StrUtil.isNotBlank(tenantAccessToken) && System.currentTimeMillis() < EXPIRE_TIMES.get()) { +// if (StrUtil.isNotBlank(tenantAccessToken) && System.currentTimeMillis() < +// EXPIRE_TIMES.get()) { // return this.tenantAccessToken; // } // // synchronized (this) { -// final TenantAccessTokenGetReqDTO tokenGetReqDTO = new TenantAccessTokenGetReqDTO(appId, appSecret); -// final TenantAccessTokenGetRespDTO tokenRespDTO = HttpUtil.post(BASE_URL + "/v3/tenant_access_token/internal", +// final TenantAccessTokenGetReqDTO tokenGetReqDTO = new +// TenantAccessTokenGetReqDTO(appId, appSecret); +// final TenantAccessTokenGetRespDTO tokenRespDTO = HttpUtil.post(BASE_URL + +// "/v3/tenant_access_token/internal", // tokenGetReqDTO, TenantAccessTokenGetRespDTO.class); // if (tokenGetReqDTO == null && Strings.isBlank(tokenRespDTO.getTenantAccessToken())) { // throw new FeishuException(FeishuErrorCodeEnum.TABLE_ERROR, "获取飞书token出错"); @@ -75,4 +78,4 @@ // } // } // -//} +// } diff --git a/fluent-wrappers/fluent-feishu/src/main/java/io/fluent/wrappers/feishu/bitable/dto/FieldProperty.java b/fluent-wrappers/fluent-feishu/src/main/java/io/fluent/wrappers/feishu/bitable/dto/FieldProperty.java index eb48cc8..a464667 100644 --- a/fluent-wrappers/fluent-feishu/src/main/java/io/fluent/wrappers/feishu/bitable/dto/FieldProperty.java +++ b/fluent-wrappers/fluent-feishu/src/main/java/io/fluent/wrappers/feishu/bitable/dto/FieldProperty.java @@ -3,12 +3,11 @@ import com.fasterxml.jackson.annotation.JsonInclude; import com.fasterxml.jackson.databind.PropertyNamingStrategy; import com.fasterxml.jackson.databind.annotation.JsonNaming; -import lombok.Data; -import lombok.NoArgsConstructor; - import java.util.Arrays; import java.util.List; import java.util.stream.Collectors; +import lombok.Data; +import lombok.NoArgsConstructor; /** * 数据表字段属性 @@ -22,79 +21,52 @@ @JsonNaming(PropertyNamingStrategy.SnakeCaseStrategy.class) public class FieldProperty { - public FieldProperty(final String... optionNames) { - this.options = Arrays.stream(optionNames).map(e -> new Option(e)).collect(Collectors.toList()); - } + public FieldProperty(final String... optionNames) { + this.options = Arrays.stream(optionNames).map(e -> new Option(e)).collect(Collectors.toList()); + } - /** - * 单选、多选字段的选项信息 - */ - private List