proj_name stringclasses 131
values | relative_path stringlengths 30 228 | class_name stringlengths 1 68 | func_name stringlengths 1 48 | masked_class stringlengths 78 9.82k | func_body stringlengths 46 9.61k | len_input int64 29 2.01k | len_output int64 14 1.94k | total int64 55 2.05k | relevant_context stringlengths 0 38.4k |
|---|---|---|---|---|---|---|---|---|---|
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-api/src/main/java/org/hswebframework/web/api/crud/entity/PagerResult.java | PagerResult | of | class PagerResult<E> implements Serializable {
private static final long serialVersionUID = -6171751136953308027L;
/**
* 创建一个空结果
*
* @param <E> 结果类型
* @return PagerResult
*/
public static <E> PagerResult<E> empty() {
return of(0, new ArrayList<>());
}
/**
* 创建... |
PagerResult<E> pagerResult = of(total, list);
pagerResult.setPageIndex(entity.getThinkPageIndex());
pagerResult.setPageSize(entity.getPageSize());
return pagerResult;
| 535 | 61 | 596 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-api/src/main/java/org/hswebframework/web/api/crud/entity/QueryParamEntity.java | QueryParamEntity | setWhere | class QueryParamEntity extends QueryParam {
private static final long serialVersionUID = 8097500947924037523L;
@Schema(description = "where条件表达式,与terms参数不能共存.语法: name = 张三 and age > 16")
private String where;
@Schema(description = "orderBy条件表达式,与sorts参数不能共存.语法: age asc,createTime desc")
private S... |
this.where = where;
if (!StringUtils.hasText(where)) {
return;
}
setTerms(TermExpressionParser.parse(where));
| 1,820 | 45 | 1,865 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-api/src/main/java/org/hswebframework/web/api/crud/entity/TreeUtils.java | TreeUtils | list2tree | class TreeUtils {
/**
* 树结构转为List
*
* @param nodeList List
* @param children 子节点获取函数
* @param <N> 节点类型
* @return List
*/
public static <N> List<N> treeToList(Collection<N> nodeList,
Function<N, Collection<N>> children) {
L... |
Objects.requireNonNull(dataList, "source list can not be null");
Objects.requireNonNull(childConsumer, "child consumer can not be null");
Objects.requireNonNull(predicateFunction, "root predicate function can not be null");
// id,node
Map<PK, N> cache = Maps.newHashMapWithExpec... | 892 | 365 | 1,257 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/configuration/AutoDDLProcessor.java | AutoDDLProcessor | afterPropertiesSet | class AutoDDLProcessor implements InitializingBean {
private Set<EntityInfo> entities = new HashSet<>();
@Autowired
private DatabaseOperator operator;
@Autowired
private EasyormProperties properties;
@Autowired
private EntityTableMetadataResolver resolver;
@Autowired
private Ent... |
List<Class<?>> readyToDDL = new ArrayList<>(this.entities.size());
List<Class<?>> nonDDL = new ArrayList<>();
for (EntityInfo entity : this.entities) {
Class<?> type = entityFactory.getInstanceType(entity.getRealType(), true);
DDL ddl = AnnotatedElementUtils.findMerged... | 152 | 652 | 804 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/configuration/CompositeEntityTableMetadataResolver.java | CompositeEntityTableMetadataResolver | doResolve | class CompositeEntityTableMetadataResolver implements EntityTableMetadataResolver {
private final List<EntityTableMetadataParser> resolvers = new ArrayList<>();
private final Map<Class<?>, AtomicReference<RDBTableMetadata>> cache = new ConcurrentHashMap<>();
public void addParser(EntityTableMetadataParse... |
return resolvers.stream()
.map(resolver -> resolver.parseTableMetadata(entityClass))
.filter(Optional::isPresent)
.map(Optional::get)
.reduce((t1, t2) -> {
t2.merge(t1);
return t2;
}).orElse(... | 184 | 90 | 274 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/configuration/DialectProviders.java | DialectProviders | lookup | class DialectProviders {
private static final Map<String, DialectProvider> allSupportedDialect = new HashMap<>();
static {
for (EasyormProperties.DialectEnum value : EasyormProperties.DialectEnum.values()) {
allSupportedDialect.put(value.name(), value);
}
for (DialectProvid... |
DialectProvider provider = allSupportedDialect.get(dialect);
if (provider == null) {
if (dialect.contains(".")) {
provider = (DialectProvider) Class.forName(dialect).newInstance();
allSupportedDialect.put(dialect, provider);
} else {
... | 175 | 135 | 310 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/configuration/EasyormConfiguration.java | EasyormConfiguration | postProcessAfterInitialization | class EasyormConfiguration {
static {
}
@Bean
@ConditionalOnMissingBean
public EntityFactory entityFactory(ObjectProvider<EntityMappingCustomizer> customizers) {
MapperEntityFactory factory = new MapperEntityFactory();
for (EntityMappingCustomizer customizer : customizers) {
... |
if (bean instanceof EventListener) {
eventListener.addListener(((EventListener) bean));
} else if (bean instanceof Feature) {
metadata.addFeature(((Feature) bean));
}
return bean;
| 1,584 | 59 | 1,643 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/configuration/EasyormProperties.java | EasyormProperties | createDatabaseMetadata | class EasyormProperties {
private String defaultSchema = "PUBLIC";
private String[] schemas = {};
private boolean autoDdl = true;
private boolean allowAlter = false;
private boolean allowTypeAlter = true;
/**
* @see DialectProvider
*/
private DialectProvider dialect = Dialect... |
RDBDatabaseMetadata metadata = new RDBDatabaseMetadata(createDialect());
Set<String> schemaSet = new HashSet<>(Arrays.asList(schemas));
if (defaultSchema != null) {
schemaSet.add(defaultSchema);
}
schemaSet.stream()
.map(this::createSchema)
... | 630 | 125 | 755 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/configuration/EasyormRepositoryRegistrar.java | EasyormRepositoryRegistrar | findIdType | class EasyormRepositoryRegistrar implements ImportBeanDefinitionRegistrar {
private final ResourcePatternResolver resourcePatternResolver = new PathMatchingResourcePatternResolver();
private final MetadataReaderFactory metadataReaderFactory = new CachingMetadataReaderFactory();
private String getResource... |
Class<?> idType;
try {
if (GenericEntity.class.isAssignableFrom(entityType)) {
return GenericTypeResolver.resolveTypeArgument(entityType, GenericEntity.class);
}
Class<?>[] ref = new Class[1];
ReflectionUtils.doWithFields(entityType, fiel... | 1,504 | 236 | 1,740 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/configuration/R2dbcSqlExecutorConfiguration.java | R2dbcSqlExecutorConfiguration | reactiveSqlExecutor | class R2dbcSqlExecutorConfiguration {
@Bean
@ConditionalOnMissingBean
public ReactiveSqlExecutor reactiveSqlExecutor(EasyormProperties properties) {<FILL_FUNCTION_BODY>}
@Bean
@ConditionalOnMissingBean
public SyncSqlExecutor syncSqlExecutor(ReactiveSqlExecutor reactiveSqlExecutor) {
ret... |
DefaultR2dbcExecutor executor = new DefaultR2dbcExecutor();
executor.setBindSymbol(properties.getDialect().getBindSymbol());
executor.setBindCustomSymbol(!executor.getBindSymbol().equals("?"));
return executor;
| 107 | 67 | 174 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/events/CompositeEventListener.java | CompositeEventListener | addListener | class CompositeEventListener implements EventListener {
private List<EventListener> eventListeners = new CopyOnWriteArrayList<>();
@Override
public void onEvent(EventType type, EventContext context) {
for (EventListener eventListener : eventListeners) {
eventListener.onEvent(type, cont... |
eventListeners.add(eventListener);
eventListeners.sort(Comparator.comparingLong(e -> e instanceof Ordered ? ((Ordered) e).getOrder() : Ordered.LOWEST_PRECEDENCE));
| 107 | 60 | 167 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/events/CreatorEventListener.java | CreatorEventListener | applyCreator | class CreatorEventListener implements EventListener, Ordered {
@Override
public String getId() {
return "creator-listener";
}
@Override
public String getName() {
return "创建者监听器";
}
@Override
public void onEvent(EventType type, EventContext context) {
Optional<R... |
long now = System.currentTimeMillis();
if (updateCreator) {
if (entity instanceof RecordCreationEntity) {
RecordCreationEntity e = (RecordCreationEntity) entity;
if (ObjectUtils.isEmpty(e.getCreatorId())) {
e.setCreatorId(auth.getUser().ge... | 584 | 451 | 1,035 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/events/DefaultEntityEventListenerConfigure.java | DefaultEntityEventListenerConfigure | initByEntity | class DefaultEntityEventListenerConfigure implements EntityEventListenerConfigure {
private final Map<Class<? extends Entity>, Map<EntityEventType, Set<EntityEventPhase>>> enabledFeatures = new ConcurrentHashMap<>();
private final Map<Class<? extends Entity>, Map<EntityEventType, Set<EntityEventPhase>>> disabl... |
EnableEntityEvent annotation = AnnotatedElementUtils.findMergedAnnotation(type, EnableEntityEvent.class);
EntityEventType[] types = annotation != null ? annotation.value() : all ? EntityEventType.values() : new EntityEventType[0];
for (EntityEventType entityEventType : types) {
Set... | 1,097 | 131 | 1,228 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/events/EntityBeforeModifyEvent.java | EntityBeforeModifyEvent | toString | class EntityBeforeModifyEvent<E> extends DefaultAsyncEvent implements Serializable {
private static final long serialVersionUID = -7158901204884303777L;
private final List<E> before;
private final List<E> after;
private final Class<E> entityType;
@Override
public String toString() {<FILL_FU... |
return "EntityBeforeModifyEvent<" + entityType.getSimpleName() + ">\n{\nbefore:" + before + "\nafter: " + after + "\n}";
| 113 | 46 | 159 | <methods>public non-sealed void <init>() ,public synchronized void async(Publisher<?>) ,public synchronized void first(Publisher<?>) ,public Mono<java.lang.Void> getAsync() ,public boolean hasListener() ,public Mono<java.lang.Void> publish(ApplicationEventPublisher) ,public void transform(Function<Mono<?>,Publisher<?>>... |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/events/EntityEventHelper.java | EntityEventHelper | publishCreatedEvent | class EntityEventHelper {
private static final String doEventContextKey = EntityEventHelper.class.getName() + "_doEvent";
/**
* 判断当前是否设置了事件
*
* @param defaultIfEmpty 如果未设置时的默认值
* @return 是否设置了事件
*/
public static Mono<Boolean> isDoFireEvent(boolean defaultIfEmpty) {
return ... |
return publishEvent(source, entityType, () -> new EntityCreatedEvent<>(entities, entityType), publisher);
| 1,223 | 32 | 1,255 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/events/EntityModifyEvent.java | EntityModifyEvent | toString | class EntityModifyEvent<E> extends DefaultAsyncEvent implements Serializable{
private static final long serialVersionUID = -7158901204884303777L;
private final List<E> before;
private final List<E> after;
private final Class<E> entityType;
@Override
public String toString() {<FILL_FUNCTION_... |
return "EntityModifyEvent<" + entityType.getSimpleName() + ">\n{\nbefore:" + before + "\nafter: " + after + "\n}";
| 112 | 45 | 157 | <methods>public non-sealed void <init>() ,public synchronized void async(Publisher<?>) ,public synchronized void first(Publisher<?>) ,public Mono<java.lang.Void> getAsync() ,public boolean hasListener() ,public Mono<java.lang.Void> publish(ApplicationEventPublisher) ,public void transform(Function<Mono<?>,Publisher<?>>... |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/events/EntityPrepareModifyEvent.java | EntityPrepareModifyEvent | toString | class EntityPrepareModifyEvent<E> extends DefaultAsyncEvent implements Serializable{
private static final long serialVersionUID = -7158901204884303777L;
private final List<E> before;
private final List<E> after;
private final Class<E> entityType;
@Override
public String toString() {<FILL_FU... |
return "EntityPrepareModifyEvent<" + entityType.getSimpleName() + ">\n{\nbefore:" + before + "\nafter: " + after + "\n}";
| 115 | 48 | 163 | <methods>public non-sealed void <init>() ,public synchronized void async(Publisher<?>) ,public synchronized void first(Publisher<?>) ,public Mono<java.lang.Void> getAsync() ,public boolean hasListener() ,public Mono<java.lang.Void> publish(ApplicationEventPublisher) ,public void transform(Function<Mono<?>,Publisher<?>>... |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/events/ValidateEventListener.java | ValidateEventListener | onEvent | class ValidateEventListener implements EventListener, Ordered {
@Override
public String getId() {
return "validate-listener";
}
@Override
public String getName() {
return "验证器监听器";
}
@Override
public void onEvent(EventType type, EventContext context) {<FILL_FUNCTION_B... |
Optional<ReactiveResultHolder> resultHolder = context.get(MappingContextKeys.reactiveResultHolder);
if (resultHolder.isPresent()) {
resultHolder
.ifPresent(holder -> holder
.invoke(LocaleUtils
.doIn... | 470 | 113 | 583 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/events/expr/SpelSqlExpressionInvoker.java | SqlFunctions | spelError | class SqlFunctions extends HashMap<String, Object> {
private final EntityColumnMapping mapping;
public SqlFunctions(EntityColumnMapping mapping, Map<String, Object> map) {
super(map);
this.mapping = mapping;
}
@Override
public Object get(Object key) {
... |
log.warn("create sql expression [{}] parser error", sql, error);
return (mapping, args, data) -> null;
| 1,293 | 36 | 1,329 | <methods>public non-sealed void <init>() ,public java.lang.Object invoke(NativeSql, EntityColumnMapping, Map<java.lang.String,java.lang.Object>) <variables>private final Map<java.lang.String,Function3<EntityColumnMapping,java.lang.Object[],Map<java.lang.String,java.lang.Object>,java.lang.Object>> compiled |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/generator/CurrentTimeGenerator.java | CurrentTimeGenerator | generic | class CurrentTimeGenerator implements DefaultValueGenerator<RDBColumnMetadata> {
@Override
public String getSortId() {
return Generators.CURRENT_TIME;
}
@Override
public DefaultValue generate(RDBColumnMetadata metadata) {
return (RuntimeDefaultValue) () -> generic(metadata.getJavaTy... |
if (type == Date.class) {
return new Date();
}
if (type == java.sql.Date.class) {
return new java.sql.Date(System.currentTimeMillis());
}
if (type == LocalDateTime.class) {
return LocalDateTime.now();
}
return System.currentTim... | 133 | 91 | 224 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/generator/DefaultIdGenerator.java | DefaultIdGenerator | generate | class DefaultIdGenerator implements DefaultValueGenerator<RDBColumnMetadata> {
@Getter
@Setter
private String defaultId = Generators.SNOW_FLAKE;
@Getter
@Setter
private Map<String, String> mappings = new HashMap<>();
@Override
public String getSortId() {
return Generators.DEFA... |
String genId = mappings.getOrDefault(metadata.getOwner().getName(), defaultId);
DefaultValueGenerator<RDBColumnMetadata> generator = metadata.findFeatureNow(DefaultValueGenerator.createId(genId));
log.debug("use default id generator : {} for column : {}", generator.getSortId(), metadata.getFull... | 171 | 93 | 264 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/query/DefaultQueryHelper.java | Joiner | prepare | class Joiner {
private final List<Term> terms;
private final List<Term> joinTerms = new ArrayList<>();
public Joiner(List<Term> terms) {
this.terms = terms;
prepare(terms);
}
public void prepare(List<Term> terms) {<FILL_FUNCT... |
for (Term term : terms) {
if (Objects.equals(TermType.eq, term.getTermType())
&& term.getValue() instanceof JoinConditionalSpecImpl.ColumnRef) {
joinTerms.add(term);
}
if (term.getTerms() != null... | 920 | 94 | 1,014 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/query/QueryHelperUtils.java | QueryHelperUtils | toHump | class QueryHelperUtils {
static final FastThreadLocal<StringBuilder> SHARE = new FastThreadLocal<StringBuilder>() {
@Override
protected StringBuilder initialValue() throws Exception {
return new StringBuilder();
}
};
public static String toSnake(String col) {
St... |
StringBuilder builder = SHARE.get();
builder.setLength(0);
boolean hasUpper = false, hasLower = false;
for (int i = 0, len = col.length(); i < len; i++) {
char c = col.charAt(i);
if (Character.isLowerCase(c)) {
hasLower = true;
}
... | 234 | 231 | 465 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/query/ToHumpMap.java | ToHumpMap | put | class ToHumpMap<V> extends LinkedHashMap<String, V> {
@Override
public V put(String key, V value) {<FILL_FUNCTION_BODY>}
} |
V val = super.put(key, value);
String humpKey = QueryHelperUtils.toHump(key);
if (!humpKey.equals(key)) {
super.put(humpKey, value);
}
return val;
| 52 | 67 | 119 | <methods>public void <init>() ,public void <init>(int) ,public void <init>(Map<? extends java.lang.String,? extends V>) ,public void <init>(int, float) ,public void <init>(int, float, boolean) ,public void clear() ,public boolean containsValue(java.lang.Object) ,public Set<Entry<java.lang.String,V>> entrySet() ,public ... |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/service/GenericReactiveCacheSupportCrudService.java | GenericReactiveCacheSupportCrudService | getCache | class GenericReactiveCacheSupportCrudService<E, K> implements EnableCacheReactiveCrudService<E, K> {
@Autowired
private ReactiveRepository<E, K> repository;
@Override
public ReactiveRepository<E, K> getRepository() {
return repository;
}
@Autowired(required = false)
private Reacti... |
if (cache != null) {
return cache;
}
if (cacheManager == null) {
return cache = UnSupportedReactiveCache.getInstance();
}
return cache = cacheManager.getCache(getCacheName());
| 221 | 64 | 285 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/sql/DefaultJdbcExecutor.java | DefaultJdbcExecutor | getConnection | class DefaultJdbcExecutor extends JdbcSyncSqlExecutor {
@Autowired
private DataSource dataSource;
protected String getDatasourceId() {
return DataSourceHolder.switcher().datasource().current().orElse("default");
}
@Override
public Connection getConnection(SqlRequest sqlRequest) {<FILL... |
DataSource dataSource = DataSourceHolder.isDynamicDataSourceReady() ?
DataSourceHolder.currentDataSource().getNative() :
this.dataSource;
Connection connection = DataSourceUtils.getConnection(dataSource);
boolean isConnectionTransactional = DataSourceUtils.isCon... | 470 | 144 | 614 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/sql/DefaultJdbcReactiveExecutor.java | DefaultJdbcReactiveExecutor | getDataSourceAndConnection | class DefaultJdbcReactiveExecutor extends JdbcReactiveSqlExecutor {
@Autowired
private DataSource dataSource;
protected String getDatasourceId() {
return DataSourceHolder.switcher().datasource().current().orElse("default");
}
private Tuple2<DataSource, Connection> getDataSourceAndConnectio... |
DataSource dataSource = DataSourceHolder.isDynamicDataSourceReady() ?
DataSourceHolder.currentDataSource().getNative() :
this.dataSource;
Connection connection = DataSourceUtils.getConnection(dataSource);
boolean isConnectionTransactional = DataSourceUtils.isConn... | 586 | 152 | 738 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/sql/DefaultR2dbcExecutor.java | DefaultR2dbcExecutor | bind | class DefaultR2dbcExecutor extends R2dbcReactiveSqlExecutor {
@Autowired
private ConnectionFactory defaultFactory;
@Setter
private boolean bindCustomSymbol = false;
@Setter
private String bindSymbol = "$";
@Override
public String getBindSymbol() {
return bindSymbol;
}
... |
if (value instanceof Date) {
value = ((Date) value)
.toInstant()
.atZone(ZoneOffset.systemDefault())
.toLocalDateTime();
}
if (bindCustomSymbol) {
statement.bind(getBindSymbol() + (index + getBindFirstIndex()), ... | 975 | 97 | 1,072 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/sql/terms/TreeChildTermBuilder.java | TreeChildTermBuilder | createFragments | class TreeChildTermBuilder extends AbstractTermFragmentBuilder {
public TreeChildTermBuilder(String termType, String name) {
super(termType, name);
}
protected abstract String tableName();
@Override
public SqlFragments createFragments(String columnFullName, RDBColumnMetadata column, Term t... |
List<Object> id = convertList(column, term);
String tableName = getTableName(tableName(), column);
String[] args = new String[id.size()];
Arrays.fill(args, "?");
RDBColumnMetadata pathColumn = column
.getOwner()
.getSchema()
.ge... | 95 | 377 | 472 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/utils/TransactionUtils.java | TransactionUtils | registerSynchronization | class TransactionUtils {
public static Mono<Void> registerSynchronization(TransactionSynchronization synchronization,
Function<TransactionSynchronization, Mono<Void>> whenNoTransaction) {<FILL_FUNCTION_BODY>}
} |
return TransactionSynchronizationManager
.forCurrentTransaction()
.flatMap(manager -> {
if (manager.isSynchronizationActive()) {
try {
manager.registerSynchronization(synchronization);
} catch (Throwable err... | 64 | 191 | 255 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/web/R2dbcErrorControllerAdvice.java | R2dbcErrorControllerAdvice | handleException | class R2dbcErrorControllerAdvice {
@ExceptionHandler
@ResponseStatus(HttpStatus.INTERNAL_SERVER_ERROR)
public Mono<ResponseMessage<Object>> handleException(R2dbcException e) {<FILL_FUNCTION_BODY>}
} |
log.error(e.getLocalizedMessage(), e);
return LocaleUtils
.resolveMessageReactive("error.internal_server_error")
.map(msg -> ResponseMessage.error(500, "error." + e.getClass().getSimpleName(), msg));
| 69 | 72 | 141 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/web/ResponseMessage.java | ResponseMessage | of | class ResponseMessage<T> implements Serializable {
private static final long serialVersionUID = 8992436576262574064L;
@Schema(description = "消息提示")
private String message;
@Schema(description = "数据内容")
private T result;
@Schema(description = "状态码")
private int status;
@Schema(descri... |
@SuppressWarnings("all")
ResponseMessage<T> msg = EntityFactoryHolder.newInstance(ResponseMessage.class, ResponseMessage::new);
msg.setMessage(message);
msg.setResult(result);
msg.setStatus(status);
msg.setCode(code);
msg.setTimestamp(timestamp);
return m... | 439 | 91 | 530 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/web/ResponseMessageWrapper.java | ResponseMessageWrapper | supports | class ResponseMessageWrapper extends ResponseBodyResultHandler {
public ResponseMessageWrapper(List<HttpMessageWriter<?>> writers,
RequestedContentTypeResolver resolver,
ReactiveAdapterRegistry registry) {
super(writers, resolver, registry... |
if (!CollectionUtils.isEmpty(excludes) && result.getHandler() instanceof HandlerMethod) {
HandlerMethod method = (HandlerMethod) result.getHandler();
String typeName = method.getMethod().getDeclaringClass().getName() + "." + method.getMethod().getName();
for (String exclud... | 489 | 348 | 837 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-commons/hsweb-commons-crud/src/main/java/org/hswebframework/web/crud/web/ResponseMessageWrapperAdvice.java | ResponseMessageWrapperAdvice | supports | class ResponseMessageWrapperAdvice implements ResponseBodyAdvice<Object> {
@Setter
@Getter
private Set<String> excludes = new HashSet<>();
@Override
public boolean supports(@Nonnull MethodParameter methodParameter, @Nonnull Class<? extends HttpMessageConverter<?>> aClass) {<FILL_FUNCTION_BODY>}
... |
if (methodParameter.getMethod() == null) {
return true;
}
RequestMapping mapping = methodParameter.getMethodAnnotation(RequestMapping.class);
if (mapping == null) {
return false;
}
for (String produce : mapping.produces()) {
MimeType... | 354 | 369 | 723 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-concurrent/hsweb-concurrent-cache/src/main/java/org/hswebframework/web/cache/configuration/ReactiveCacheProperties.java | ReactiveCacheProperties | createCacheManager | class ReactiveCacheProperties {
private Type type = Type.none;
private GuavaProperties guava = new GuavaProperties();
private CaffeineProperties caffeine = new CaffeineProperties();
private RedisProperties redis = new RedisProperties();
public boolean anyProviderPresent() {
return Cla... |
if (!anyProviderPresent()) {
return new ReactiveCacheManager() {
@Override
public <E> ReactiveCache<E> getCache(String name) {
return UnSupportedReactiveCache.getInstance();
}
};
}
if (type == Type.redi... | 1,008 | 233 | 1,241 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-concurrent/hsweb-concurrent-cache/src/main/java/org/hswebframework/web/cache/supports/AbstractReactiveCache.java | CacheLoader | getFlux | class CacheLoader extends MonoOperator<Object, Object> {
private final AbstractReactiveCache<?> parent;
private final Object key;
private Mono<? extends Object> defaultValue;
private final Sinks.One<Object> holder = Sinks.one();
private volatile Disposable loading;
p... |
return Flux.deferContextual(ctx -> {
CacheLoader cacheLoader = cacheLoading.compute(key, (_key, old) -> {
CacheLoader cl = new CacheLoader(this, _key, getNow(_key));
cl.defaultValue(loader.get().collectList(), ctx);
return cl;
});
... | 866 | 109 | 975 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-concurrent/hsweb-concurrent-cache/src/main/java/org/hswebframework/web/cache/supports/CaffeineReactiveCache.java | CaffeineReactiveCache | getAll | class CaffeineReactiveCache<E> extends AbstractReactiveCache<E> {
private Cache<Object, Object> cache;
@Override
public Mono<Void> evictAll(Iterable<?> key) {
return Mono.fromRunnable(() -> cache.invalidateAll(key));
}
@Override
public Flux<E> getAll(Object... keys) {<FILL_FUNCTION_BO... |
return Flux.<E>defer(() -> {
if (keys == null || keys.length == 0) {
return Flux.fromIterable(cache.asMap().values())
.map(e -> (E) e);
}
return Flux.fromIterable(cache.getAllPresent(Arrays.asList(keys)).values())
... | 286 | 108 | 394 | <methods>public non-sealed void <init>() ,public abstract Mono<java.lang.Void> clear() ,public abstract Mono<java.lang.Void> evict(java.lang.Object) ,public abstract Mono<java.lang.Void> evictAll(Iterable<?>) ,public transient Flux<E> getAll(java.lang.Object[]) ,public final Flux<E> getFlux(java.lang.Object) ,public fi... |
hs-web_hsweb-framework | hsweb-framework/hsweb-concurrent/hsweb-concurrent-cache/src/main/java/org/hswebframework/web/cache/supports/GuavaReactiveCache.java | GuavaReactiveCache | getAll | class GuavaReactiveCache<E> extends AbstractReactiveCache<E> {
private Cache<Object, Object> cache;
@Override
public Mono<Void> evictAll(Iterable<?> key) {
return Mono.fromRunnable(() -> cache.invalidateAll(key));
}
@Override
protected Mono<Object> getNow(Object key) {
return... |
return Flux.<E>defer(() -> {
if (keys == null || keys.length == 0) {
return Flux
.fromIterable(cache.asMap().values())
.map(e -> (E) e);
}
return Flux.fromIterable(cache.getAllPresent(Arrays.asList(keys)).values... | 287 | 110 | 397 | <methods>public non-sealed void <init>() ,public abstract Mono<java.lang.Void> clear() ,public abstract Mono<java.lang.Void> evict(java.lang.Object) ,public abstract Mono<java.lang.Void> evictAll(Iterable<?>) ,public transient Flux<E> getAll(java.lang.Object[]) ,public final Flux<E> getFlux(java.lang.Object) ,public fi... |
hs-web_hsweb-framework | hsweb-framework/hsweb-concurrent/hsweb-concurrent-cache/src/main/java/org/hswebframework/web/cache/supports/RedisReactiveCache.java | RedisReactiveCache | putNow | class RedisReactiveCache<E> extends AbstractReactiveCache<E> {
private ReactiveRedisOperations<Object, Object> operations;
private String redisKey;
private ReactiveCache<E> localCache;
private String topicName;
public RedisReactiveCache(String redisKey, ReactiveRedisOperations<Object, Object> o... |
return operations
.opsForHash()
.put(redisKey, key, value)
.then(localCache.evict(key))
.then(operations.convertAndSend(topicName, key))
.then();
| 868 | 62 | 930 | <methods>public non-sealed void <init>() ,public abstract Mono<java.lang.Void> clear() ,public abstract Mono<java.lang.Void> evict(java.lang.Object) ,public abstract Mono<java.lang.Void> evictAll(Iterable<?>) ,public transient Flux<E> getAll(java.lang.Object[]) ,public final Flux<E> getFlux(java.lang.Object) ,public fi... |
hs-web_hsweb-framework | hsweb-framework/hsweb-core/src/main/java/org/hswebframework/web/aop/MethodInterceptorHolder.java | MethodInterceptorHolder | getArgument | class MethodInterceptorHolder {
/**
* 参数名称获取器,用于获取方法参数的名称
*/
public static final ParameterNameDiscoverer nameDiscoverer = new DefaultParameterNameDiscoverer();
public static MethodInterceptorHolder create(MethodInvocation invocation) {
String[] argNames = nameDiscoverer.getParameterNames(... |
if (namedArguments == null) {
return Optional.empty();
}
return Optional.ofNullable((T) namedArguments.get(name));
| 1,136 | 40 | 1,176 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-core/src/main/java/org/hswebframework/web/bean/CompareUtils.java | CompareUtils | compare | class CompareUtils {
public static boolean compare(Object source, Object target) {<FILL_FUNCTION_BODY>}
public static boolean compare(Map<?, ?> map, Object target) {
if (map == target) {
return true;
}
if (map == null || target == null) {
return false;
... |
if (source == target) {
return true;
}
if (source == null || target == null) {
return false;
}
if (source.equals(target)) {
return true;
}
if (source instanceof Boolean) {
return compare(((Boolean) source), targe... | 1,443 | 502 | 1,945 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-core/src/main/java/org/hswebframework/web/bean/Diff.java | Diff | of | class Diff {
private String property;
private Object before;
private Object after;
public static List<Diff> of(Object before, Object after, String... ignoreProperty) {<FILL_FUNCTION_BODY>}
@Override
public String toString() {
return JSON.toJSONString(this);
}
} |
List<Diff> diffs = new ArrayList<>();
Set<String> ignores = Sets.newHashSet(ignoreProperty);
Map<String, Object> beforeMap = FastBeanCopier.copy(before, HashMap::new);
Map<String, Object> afterMap = FastBeanCopier.copy(after, HashMap::new);
for (Map.Entry<String, Object> entry... | 90 | 211 | 301 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-core/src/main/java/org/hswebframework/web/bean/FastBeanCopier.java | ClassProperty | createGetterFunction | class ClassProperty {
@Getter
protected String name;
@Getter
protected String readMethodName;
@Getter
protected String writeMethodName;
@Getter
protected BiFunction<Class<?>, Class<?>, String> getter;
@Getter
protected BiFunction<Class... |
return (targetBeanType, targetType) -> {
String getterCode = "$$__source." + getReadMethod();
String generic = "org.hswebframework.web.bean.FastBeanCopier.EMPTY_CLASS_ARRAY";
Field field = ReflectionUtils.findField(targetBeanType, name);
boo... | 701 | 967 | 1,668 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-core/src/main/java/org/hswebframework/web/bean/SingleValueMap.java | SingleValueMap | remove | class SingleValueMap<K, V> implements Map<K, V> {
private K key;
private V value;
@Override
public int size() {
return value == null ? 0 : 1;
}
@Override
public boolean isEmpty() {
return size() == 0;
}
@Override
public boolean containsKey(Object key) {
... |
if (Objects.equals(key, this.key)) {
V old = this.value;
this.value = null;
return old;
}
return null;
| 650 | 48 | 698 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-core/src/main/java/org/hswebframework/web/bean/ToString.java | ToString | createFeatures | class ToString {
public static long DEFAULT_FEATURE = Feature.createFeatures(
Feature.coverIgnoreProperty
, Feature.nullPropertyToEmpty
// , Feature.jsonFormat
);
public static final Map<Class, ToStringOperator> cache = new ConcurrentHashMap<>();
@SuppressWarnings("... |
if (features == null) {
return 0L;
}
long value = 0L;
for (Feature feature : features) {
value |= feature.getMask();
}
return value;
| 869 | 58 | 927 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-core/src/main/java/org/hswebframework/web/context/ContextUtils.java | ContextUtils | acceptContext | class ContextUtils {
private static final ThreadLocal<Context> contextThreadLocal = ThreadLocal.withInitial(MapContext::new);
public static Context currentContext() {
return contextThreadLocal.get();
}
@Deprecated
public static Mono<Context> reactiveContext() {
return Mono
... |
return context -> {
if (!context.hasKey(Context.class)) {
context = context.put(Context.class, new MapContext());
}
contextConsumer.accept(context.get(Context.class));
return context;
};
| 186 | 66 | 252 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-core/src/main/java/org/hswebframework/web/dict/defaults/DefaultDictDefineRepository.java | DefaultDictDefineRepository | registerDefine | class DefaultDictDefineRepository implements DictDefineRepository {
protected static final Map<String, DictDefine> parsedDict = new HashMap<>();
public static void registerDefine(DictDefine define) {<FILL_FUNCTION_BODY>}
@SuppressWarnings("all")
public static DictDefine parseEnumDict(Class<?> type) {
... |
if (define == null) {
return;
}
parsedDict.put(define.getId(), define);
| 594 | 33 | 627 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-core/src/main/java/org/hswebframework/web/event/AsyncEventHooks.java | AsyncEventHooks | hookFirst | class AsyncEventHooks {
private static final FastThreadLocal<LinkedList<AsyncEventHook>> hooks = new FastThreadLocal<LinkedList<AsyncEventHook>>() {
@Override
protected LinkedList<AsyncEventHook> initialValue() {
return new LinkedList<>();
}
};
public static AutoUnbinda... |
LinkedList<AsyncEventHook> hooksList = hooks.getIfExists();
if (hooksList == null) {
return publisher;
}
for (AsyncEventHook asyncEventHook : hooksList) {
publisher = asyncEventHook.hookFirst(event, publisher);
}
return publisher;
| 383 | 81 | 464 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-core/src/main/java/org/hswebframework/web/exception/I18nSupportException.java | I18nSupportException | tryGetLocalizedMessage | class I18nSupportException extends TraceSourceException {
/**
* 消息code,在message.properties文件中定义的key
*/
private String i18nCode;
/**
* 消息参数
*/
private Object[] args;
protected I18nSupportException() {
}
public I18nSupportException(String code, Object... args) {
... |
if (error instanceof I18nSupportException) {
return ((I18nSupportException) error).getLocalizedMessage(locale);
}
String msg = error.getMessage();
if (!StringUtils.hasText(msg)) {
msg = "error." + error.getClass().getSimpleName();
}
if (msg.conta... | 510 | 118 | 628 | <methods>public void <init>() ,public void <init>(java.lang.String) ,public void <init>(java.lang.Throwable) ,public void <init>(java.lang.String, java.lang.Throwable) ,public static Context deepTraceContext() ,public java.lang.String getOperation() ,public java.lang.Object getSource() ,public static Function<java.lang... |
hs-web_hsweb-framework | hsweb-framework/hsweb-core/src/main/java/org/hswebframework/web/exception/TraceSourceException.java | TraceSourceException | tryGetOperation | class TraceSourceException extends RuntimeException {
private static final String deepTraceKey = TraceSourceException.class.getName() + "_deep";
private static final Context deepTraceContext = Context.of(deepTraceKey, true);
private String operation;
private Object source;
public TraceSourceExce... |
if (err instanceof TraceSourceException) {
return ((TraceSourceException) err).getOperation();
}
return null;
| 1,176 | 36 | 1,212 | <methods>public void <init>() ,public void <init>(java.lang.String) ,public void <init>(java.lang.Throwable) ,public void <init>(java.lang.String, java.lang.Throwable) <variables>static final long serialVersionUID |
hs-web_hsweb-framework | hsweb-framework/hsweb-core/src/main/java/org/hswebframework/web/exception/ValidationException.java | ValidationException | getLocalizedMessage | class ValidationException extends I18nSupportException {
private static final boolean propertyI18nEnabled = Boolean.getBoolean("i18n.validation.property.enabled");
private List<Detail> details;
public ValidationException(String message) {
super(message);
}
public ValidationException(Stri... |
if (propertyI18nEnabled && "validation.property_validate_failed".equals(getI18nCode()) && getArgs().length > 0) {
Object[] args = getArgs().clone();
args[0] = LocaleUtils.resolveMessage(String.valueOf(args[0]), locale, String.valueOf(args[0]));
return LocaleUtils.resolveMess... | 712 | 128 | 840 | <methods>public transient void <init>(java.lang.String, java.lang.Object[]) ,public transient void <init>(java.lang.String, java.lang.Throwable, java.lang.Object[]) ,public final java.lang.String getLocalizedMessage() ,public java.lang.String getLocalizedMessage(java.util.Locale) ,public final Mono<java.lang.String> ge... |
hs-web_hsweb-framework | hsweb-framework/hsweb-core/src/main/java/org/hswebframework/web/i18n/MessageSourceInitializer.java | MessageSourceInitializer | init | class MessageSourceInitializer {
public static void init(MessageSource messageSource) {<FILL_FUNCTION_BODY>}
} |
if (LocaleUtils.messageSource == null || LocaleUtils.messageSource instanceof UnsupportedMessageSource) {
LocaleUtils.messageSource = messageSource;
}
| 35 | 44 | 79 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-core/src/main/java/org/hswebframework/web/i18n/WebFluxLocaleFilter.java | WebFluxLocaleFilter | getLocaleContext | class WebFluxLocaleFilter implements WebFilter {
@Override
@NonNull
public Mono<Void> filter(@NonNull ServerWebExchange exchange, WebFilterChain chain) {
return chain
.filter(exchange)
.as(LocaleUtils::transform)
.contextWrite(LocaleUtils.useLocale(get... |
String lang = exchange.getRequest()
.getQueryParams()
.getFirst(":lang");
if (StringUtils.hasText(lang)) {
return Locale.forLanguageTag(lang);
}
Locale locale = exchange.getLocaleContext().getLocale();
if (l... | 126 | 100 | 226 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-core/src/main/java/org/hswebframework/web/id/RandomIdGenerator.java | RandomIdGenerator | timestampRangeOf | class RandomIdGenerator implements IDGenerator<String> {
// java -Dgenerator.random.instance-id=8
static final RandomIdGenerator GLOBAL = new RandomIdGenerator(
Integer.getInteger("generator.random.instance-id", ThreadLocalRandom.current().nextInt(1, 127)).byteValue()
);
static final Base6... |
try {
if (!isRandomId(id)) {
return false;
}
long now = System.currentTimeMillis();
long ts = getTimestampInId(id);
return Math.abs(now - ts) <= duration.toMillis();
} catch (IllegalArgumentException e) {
return fal... | 828 | 87 | 915 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-core/src/main/java/org/hswebframework/web/id/SnowflakeIdGenerator.java | SnowflakeIdGenerator | nextId | class SnowflakeIdGenerator {
private final long workerId;
private final long dataCenterId;
private long sequence = 0L;
private final long twepoch = 1288834974657L;
private final long workerIdBits = 5L;
private final long datacenterIdBits = 5L;
private final long maxWorkerId = ~(-1L << wor... |
long timestamp = timeGen();
if (timestamp < lastTimestamp) {
log.error("clock is moving backwards. Rejecting requests until {}.", lastTimestamp);
throw new UnsupportedOperationException(String.format("Clock moved backwards. Refusing to generate id for %d milliseconds", lastTi... | 754 | 195 | 949 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-core/src/main/java/org/hswebframework/web/logger/ReactiveLogger.java | ReactiveLogger | log | class ReactiveLogger {
private static final String CONTEXT_KEY = ReactiveLogger.class.getName();
public static Function<Context, Context> start(String key, String value) {
return start(Collections.singletonMap(key, value));
}
public static Function<Context, Context> start(String... keyAndValu... |
Optional<Map<String, String>> maybeContextMap = context.getOrEmpty(CONTEXT_KEY);
if (!maybeContextMap.isPresent()) {
logger.accept(new HashMap<>());
} else {
Map<String, String> ctx = maybeContextMap.get();
MDC.setContextMap(ctx);
try {
... | 998 | 113 | 1,111 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-core/src/main/java/org/hswebframework/web/utils/AnnotationUtils.java | AnnotationUtils | findMethodAnnotation | class AnnotationUtils {
private AnnotationUtils() {
}
public static <T extends Annotation> T findMethodAnnotation(Class targetClass, Method method, Class<T> annClass) {<FILL_FUNCTION_BODY>}
public static <T extends Annotation> T findAnnotation(Class targetClass, Class<T> annClass) {
return or... |
Method m = method;
T a = org.springframework.core.annotation.AnnotationUtils.findAnnotation(m, annClass);
if (a != null) {
return a;
}
m = ClassUtils.getMostSpecificMethod(m, targetClass);
a = org.springframework.core.annotation.AnnotationUtils.findAnnotation... | 579 | 333 | 912 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-core/src/main/java/org/hswebframework/web/utils/CollectionUtils.java | CollectionUtils | pairingArray | class CollectionUtils {
@SafeVarargs
public static <A> Map<A, A> pairingArrayMap(A... array) {
return pairingArray(array, LinkedHashMap::new, Map::put);
}
public static <A, T> T pairingArray(A[] array,
Supplier<T> supplier,
... |
T container = supplier.get();
for (int i = 0, len = array.length / 2; i < len; i++) {
mapping.accept(container, array[i * 2], array[i * 2 + 1]);
}
return container;
| 114 | 70 | 184 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-core/src/main/java/org/hswebframework/web/utils/ExpressionUtils.java | ExpressionUtils | analytical | class ExpressionUtils {
//表达式提取正则 ${.+?}
private static final Pattern PATTERN = Pattern.compile("(?<=\\$\\{)(.+?)(?=})");
/**
* 获取默认的表达式变量
*
* @return 变量集合
*/
public static Map<String, Object> getDefaultVar() {
return new HashMap<>();
}
/**
* 获取默认的表达式变量并将制定的变量... |
if (!expression.contains("${")) {
return expression;
}
DynamicScriptEngine engine = DynamicScriptEngineFactory.getEngine(language);
if (engine == null) {
return expression;
}
return TemplateParser.parse(expression, var -> {
if (String... | 582 | 361 | 943 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-core/src/main/java/org/hswebframework/web/utils/FluxCache.java | FluxCache | cache | class FluxCache {
public static <T> Flux<T> cache(Flux<T> source, Function<Flux<T>, Publisher<?>> handler) {<FILL_FUNCTION_BODY>}
} |
Disposable[] ref = new Disposable[1];
Flux<T> cache = source
.doFinally((s) -> ref[0] = null)
.replay()
.autoConnect(1, dis -> ref[0] = dis);
return Mono
.from(handler.apply(cache))
.thenMany(cache)
... | 60 | 133 | 193 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-core/src/main/java/org/hswebframework/web/utils/HttpParameterConverter.java | HttpParameterConverter | doConvert | class HttpParameterConverter {
private Map<String, Object> beanMap;
private Map<String, String> parameter = new HashMap<>();
private String prefix = "";
private static final Map<Class, Function<Object, String>> convertMap = new HashMap<>();
private static Function<Object, String> defaultConvert... |
if (value == null) {
return;
}
if(value instanceof Class){
return;
}
Class type = org.springframework.util.ClassUtils.getUserClass(value);
if (basicClass.contains(type) || value instanceof Number || value instanceof Enum) {
parameter.... | 629 | 240 | 869 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-core/src/main/java/org/hswebframework/web/utils/ModuleUtils.java | ModuleInfo | getId | class ModuleInfo {
private String classPath;
private String id;
private String groupId;
private String path;
private String artifactId;
private String gitCommitHash;
private String gitRepository;
private String comment;
private String vers... |
if (StringUtils.isEmpty(id)) {
id = groupId + "/" + artifactId;
}
return id;
| 377 | 36 | 413 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-core/src/main/java/org/hswebframework/web/utils/ReactiveWebUtils.java | ReactiveWebUtils | getIpAddr | class ReactiveWebUtils {
static final String[] ipHeaders = {
"X-Forwarded-For",
"X-Real-IP",
"Proxy-Client-IP",
"WL-Proxy-Client-IP"
};
/**
* 获取请求客户端的真实ip地址
*
* @param request 请求对象
* @return ip地址
*/
public static String getIpAddr... |
for (String ipHeader : ipHeaders) {
String ip = request.getHeaders().getFirst(ipHeader);
if (!StringUtils.isEmpty(ip) && !ip.contains("unknown")) {
return ip;
}
}
return Optional.ofNullable(request.getRemoteAddress())
.map(addr... | 131 | 102 | 233 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-core/src/main/java/org/hswebframework/web/utils/TemplateParser.java | TemplateParser | isPrepareEnd | class TemplateParser {
private static final char[] DEFAULT_PREPARE_START_SYMBOL = "${".toCharArray();
private static final char[] DEFAULT_PREPARE_END_SYMBOL = "}".toCharArray();
@Getter
@Setter
private char[] prepareStartSymbol = DEFAULT_PREPARE_START_SYMBOL;
@Getter
@Setter
private c... |
for (char c : prepareEndSymbol) {
if (c == symbol) {
return true;
}
}
return false;
| 991 | 40 | 1,031 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-core/src/main/java/org/hswebframework/web/utils/WebUtils.java | WebUtils | queryStringToMap | class WebUtils {
/**
* 将对象转为http请求参数:
* <pre>
* {name:"test",org:[1,2,3]} => {"name":"test","org[0]":1,"org[1]":2,"org[2]":3}
* </pre>
*
* @param object
* @return
*/
public static Map<String, String> objectToHttpParameters(Object object) {
return new HttpPara... |
try {
Map<String,String> map = new HashMap<>();
String[] decode = URLDecoder.decode(queryString,charset).split("&");
for (String keyValue : decode) {
String[] kv = keyValue.split("[=]",2);
map.put(kv[0],kv.length>1?kv[1]:"");
}
... | 755 | 135 | 890 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-core/src/main/java/org/hswebframework/web/validator/ValidatorUtils.java | ValidatorUtils | getValidator | class ValidatorUtils {
private ValidatorUtils() {
}
static volatile Validator validator;
public static Validator getValidator() {<FILL_FUNCTION_BODY>}
public static <T> T tryValidate(T bean, Class<?>... group) {
Set<ConstraintViolation<T>> violations = getValidator().validate(bean, group... |
if (validator == null) {
synchronized (ValidatorUtils.class) {
if (validator != null) {
return validator;
}
Configuration<?> configuration = Validation
.byDefaultProvider()
.configure... | 329 | 158 | 487 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-datasource/hsweb-datasource-api/src/main/java/org/hswebframework/web/datasource/AopDataSourceSwitcherAutoConfiguration.java | AopDataSourceSwitcherAutoConfiguration | alwaysNoMatchStrategyMatcher | class AopDataSourceSwitcherAutoConfiguration {
@Bean
@ConfigurationProperties(prefix = "hsweb.datasource")
public ExpressionDataSourceSwitchStrategyMatcher expressionDataSourceSwitchStrategyMatcher() {
return new ExpressionDataSourceSwitchStrategyMatcher();
}
@Bean
public AnnotationDat... |
return new TableSwitchStrategyMatcher() {
@Override
public boolean match(Class target, Method method) {
return false;
}
@Override
public Strategy getStrategy(MethodInterceptorContext context) {
return null;
... | 1,700 | 71 | 1,771 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-datasource/hsweb-datasource-api/src/main/java/org/hswebframework/web/datasource/DataSourceHolder.java | DataSourceHolder | existing | class DataSourceHolder {
/**
* 动态数据源服务
*/
static volatile DynamicDataSourceService dynamicDataSourceService;
static volatile JdbcSwitcher jdbcSwitcher = new DefaultJdbcSwitcher();
static volatile R2dbcSwitcher r2dbcSwitcher = new DefaultR2dbcSwicher();
public static boolean isDynamicDa... |
try {
checkDynamicDataSourceReady();
return dynamicDataSourceService.getDataSource(id) != null;
} catch (DataSourceNotFoundException e) {
return false;
}
| 884 | 53 | 937 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-datasource/hsweb-datasource-api/src/main/java/org/hswebframework/web/datasource/DynamicDataSourceAutoConfiguration.java | DynamicDataSourceAutoConfiguration | switcherInitProcessor | class DynamicDataSourceAutoConfiguration {
@Bean
@ConfigurationProperties(prefix = "spring.datasource")
public HswebDataSourceProperties hswebDataSouceProperties() {
return new HswebDataSourceProperties();
}
@Bean
public BeanPostProcessor switcherInitProcessor() {<FILL_FUNCTION_BODY>}
... |
return new BeanPostProcessor() {
@Override
public Object postProcessBeforeInitialization(Object bean, String beanName) throws BeansException {
return bean;
}
@Override
public Object postProcessAfterInitialization(Object bean, String b... | 96 | 121 | 217 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-datasource/hsweb-datasource-api/src/main/java/org/hswebframework/web/datasource/DynamicDataSourceProxy.java | DynamicDataSourceProxy | getType | class DynamicDataSourceProxy implements DynamicDataSource {
private String id;
@Setter
private volatile DatabaseType databaseType;
private DataSource proxy;
private Lock lock = new ReentrantLock();
public DynamicDataSourceProxy(String id, DatabaseType databaseType, DataSource proxy) {
... |
if (databaseType == null) {
lock.lock();
try {
if (databaseType != null) {
return databaseType;
}
try (Connection connection = proxy.getConnection()) {
databaseType = DatabaseType.fromJdbcUrl(connect... | 225 | 104 | 329 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-datasource/hsweb-datasource-api/src/main/java/org/hswebframework/web/datasource/strategy/AnnotationDataSourceSwitchStrategyMatcher.java | AnnotationDataSourceSwitchStrategyMatcher | createStrategyIfMatch | class AnnotationDataSourceSwitchStrategyMatcher extends CachedDataSourceSwitchStrategyMatcher {
static final Set<String> ignoreMethod = new HashSet<>(Arrays.asList("toString", "clone", "equals"));
@Override
public Strategy createStrategyIfMatch(Class target, Method method) {<FILL_FUNCTION_BODY>}
} |
if (ignoreMethod.contains(method.getName())) {
return null;
}
UseDataSource useDataSource = AnnotationUtils.findAnnotation(target, method, UseDataSource.class);
UseDefaultDataSource useDefaultDataSource = AnnotationUtils.findAnnotation(target, method, UseDefaultDataSource.cl... | 88 | 320 | 408 | <methods>public non-sealed void <init>() ,public abstract org.hswebframework.web.datasource.strategy.DataSourceSwitchStrategyMatcher.Strategy createStrategyIfMatch(Class#RAW, java.lang.reflect.Method) ,public org.hswebframework.web.datasource.strategy.DataSourceSwitchStrategyMatcher.Strategy getStrategy(org.hswebframew... |
hs-web_hsweb-framework | hsweb-framework/hsweb-datasource/hsweb-datasource-api/src/main/java/org/hswebframework/web/datasource/strategy/CachedDataSourceSwitchStrategyMatcher.java | CachedDataSourceSwitchStrategyMatcher | match | class CachedDataSourceSwitchStrategyMatcher implements DataSourceSwitchStrategyMatcher {
static Map<CacheKey, Strategy> cache = new ConcurrentHashMap<>();
public abstract Strategy createStrategyIfMatch(Class target, Method method);
@Override
public boolean match(Class target, Method method) {<FILL_FU... |
Strategy strategy = createStrategyIfMatch(target, method);
if (null != strategy) {
if (log.isDebugEnabled()) {
log.debug("create data source switcher strategy:{} for method:{}", strategy, method);
}
CacheKey cacheKey = new CacheKey(target, method);
... | 372 | 104 | 476 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-datasource/hsweb-datasource-api/src/main/java/org/hswebframework/web/datasource/strategy/CachedTableSwitchStrategyMatcher.java | CacheKey | hashCode | class CacheKey {
private Class target;
private Method method;
@Override
public boolean equals(Object obj) {
if (!(obj instanceof CacheKey)) {
return false;
}
CacheKey target = ((CacheKey) obj);
return target.target == thi... |
int result = this.target != null ? this.target.hashCode() : 0;
result = 31 * result + (this.method != null ? this.method.hashCode() : 0);
return result;
| 109 | 59 | 168 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-datasource/hsweb-datasource-api/src/main/java/org/hswebframework/web/datasource/strategy/ExpressionDataSourceSwitchStrategyMatcher.java | ExpressionDataSourceSwitchStrategyMatcher | createStrategyIfMatch | class ExpressionDataSourceSwitchStrategyMatcher extends CachedDataSourceSwitchStrategyMatcher {
@Getter
@Setter
private Map<String, ExpressionStrategy> switcher = new HashMap<>();
private static AntPathMatcher antPathMatcher = new AntPathMatcher(".");
@Override
public Strategy createStrategyI... |
if (switcher.isEmpty()) {
return null;
}
String text = target.getName().concat(".").concat(method.getName());
return switcher.entrySet().stream()
.filter(entry -> antPathMatcher.match(entry.getValue().getExpression(), text))
.peek(entry -> en... | 267 | 123 | 390 | <methods>public non-sealed void <init>() ,public abstract org.hswebframework.web.datasource.strategy.DataSourceSwitchStrategyMatcher.Strategy createStrategyIfMatch(Class#RAW, java.lang.reflect.Method) ,public org.hswebframework.web.datasource.strategy.DataSourceSwitchStrategyMatcher.Strategy getStrategy(org.hswebframew... |
hs-web_hsweb-framework | hsweb-framework/hsweb-datasource/hsweb-datasource-api/src/main/java/org/hswebframework/web/datasource/switcher/DefaultReactiveSwitcher.java | DefaultReactiveSwitcher | doInContext | class DefaultReactiveSwitcher implements ReactiveSwitcher {
private String name;
private String defaultId;
private String type;
public DefaultReactiveSwitcher(String name,String type) {
this.name = "ReactiveSwitcher.".concat(name);
this.defaultId = name.concat(".").concat("_default")... |
if (publisher instanceof Mono) {
return (R)((Mono<?>) publisher)
.contextWrite(ContextUtils.acceptContext(ctx -> {
consumer.accept(ctx.getOrDefault(ContextKey.<Deque<String>>of(this.name), LinkedList::new));
}));
} else if (pub... | 579 | 171 | 750 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-datasource/hsweb-datasource-api/src/main/java/org/hswebframework/web/datasource/switcher/DefaultSwitcher.java | DefaultSwitcher | useLast | class DefaultSwitcher implements Switcher {
private String name;
private String defaultId;
private String type;
public DefaultSwitcher(String name, String type) {
this.name = "DefaultSwitcher.".concat(name);
this.defaultId = name.concat(".").concat("_default");
this.type = ty... |
// 没有上一次了
if (getUsedHistoryQueue().isEmpty()) {
return;
}
//移除队尾,则当前的队尾则为上一次的数据源
getUsedHistoryQueue().removeLast();
if (log.isDebugEnabled()) {
String current = current().orElse(null);
if (null != current) {
log.debug... | 445 | 136 | 581 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-datasource/hsweb-datasource-jta/src/main/java/org/hswebframework/web/datasource/jta/AtomikosDataSourceConfig.java | AtomikosDataSourceConfig | putProperties | class AtomikosDataSourceConfig extends DynamicDataSourceConfig {
private static final long serialVersionUID = 5588085000663972571L;
private int minPoolSize = 5;
private int maxPoolSize = 200;
private int bor... |
if (null != xaProperties) {
xaProperties.entrySet().forEach(entry -> entry.setValue(String.valueOf(entry.getValue())));
}
//fix #87
XADataSource dataSource = (XADataSource) ClassUtils.forName(getXaDataSourceClassName(),null).newInstance();
FastBeanCopier.copy(xaProp... | 277 | 405 | 682 | <methods>public non-sealed void <init>() <variables>private org.hswebframework.web.datasource.DatabaseType databaseType,private java.lang.String describe,private java.lang.String id,private java.lang.String name,private static final long serialVersionUID |
hs-web_hsweb-framework | hsweb-framework/hsweb-datasource/hsweb-datasource-jta/src/main/java/org/hswebframework/web/datasource/jta/InMemoryAtomikosDataSourceRepository.java | InMemoryAtomikosDataSourceRepository | init | class InMemoryAtomikosDataSourceRepository implements JtaDataSourceRepository {
@Getter
@Setter
private Map<String, AtomikosDataSourceConfig> jta = new HashMap<>();
@PostConstruct
public void init() {<FILL_FUNCTION_BODY>}
@Override
public List<AtomikosDataSourceConfig> findAll() {
... |
jta.forEach((id, config) -> {
if (config.getId() == null) {
config.setId(id);
} else if (!config.getId().equals(id)) {
jta.put(config.getId(), config);
}
});
| 238 | 72 | 310 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-logging/hsweb-access-logging-aop/src/main/java/org/hswebframework/web/logging/aop/AopAccessLoggerSupport.java | AopAccessLoggerSupport | createLogger | class AopAccessLoggerSupport extends StaticMethodMatcherPointcutAdvisor {
@Autowired(required = false)
private final List<AccessLoggerParser> loggerParsers = new ArrayList<>();
@Autowired
private ApplicationEventPublisher eventPublisher;
public AopAccessLoggerSupport() {
setAdvice((Metho... |
AccessLoggerInfo info = new AccessLoggerInfo();
info.setId(IDGenerator.MD5.generate());
info.setRequestTime(System.currentTimeMillis());
LoggerDefine define = loggerParsers
.stream()
.filter(parser -> parser.support(ClassUtils.getUserClass(holder.getTarg... | 489 | 297 | 786 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-logging/hsweb-access-logging-aop/src/main/java/org/hswebframework/web/logging/aop/DefaultAccessLoggerParser.java | DefaultAccessLoggerParser | ignoreParameter | class DefaultAccessLoggerParser implements AccessLoggerParser {
@Override
public boolean support(Class<?> clazz, Method method) {
AccessLogger ann = AnnotationUtils.findAnnotation(method, AccessLogger.class);
//注解了并且未取消
return null != ann && !ann.ignore();
}
@Override
public... |
AccessLogger methodAnn = holder.findMethodAnnotation(AccessLogger.class);
AccessLogger classAnn = holder.findClassAnnotation(AccessLogger.class);
Set<String> ignoreParameter = new HashSet<>();
if (methodAnn != null) {
ignoreParameter.addAll(Arrays.asList(methodAnn.ignorePar... | 332 | 143 | 475 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-logging/hsweb-access-logging-aop/src/main/java/org/hswebframework/web/logging/aop/ResourceAccessLoggerParser.java | ResourceAccessLoggerParser | support | class ResourceAccessLoggerParser implements AccessLoggerParser {
Set<Class<? extends Annotation>> annotations = new HashSet<>(Arrays.asList(
Resource.class, ResourceAction.class
));
@Override
public boolean support(Class<?> clazz, Method method) {<FILL_FUNCTION_BODY>}
@Override
pu... |
Set<Annotation> a1 = AnnotatedElementUtils.findAllMergedAnnotations(method, annotations);
Set<Annotation> a2 = AnnotatedElementUtils.findAllMergedAnnotations(clazz, annotations);
return !a1.isEmpty() || !a2.isEmpty();
| 287 | 78 | 365 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-logging/hsweb-access-logging-aop/src/main/java/org/hswebframework/web/logging/aop/Swagger3AccessLoggerParser.java | Swagger3AccessLoggerParser | parse | class Swagger3AccessLoggerParser implements AccessLoggerParser {
@Override
public boolean support(Class<?> clazz, Method method) {
Tag api = AnnotationUtils.findAnnotation(clazz, Tag.class);
Operation operation = AnnotationUtils.findAnnotation(method, Operation.class);
return api != nu... |
Tag api = holder.findAnnotation(Tag.class);
Operation operation = AnnotatedElementUtils.findMergedAnnotation(holder.getMethod(),Operation.class);
String action = "";
if (api != null) {
action = action.concat(api.name());
}
if (null != operation) {
... | 125 | 126 | 251 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-logging/hsweb-access-logging-aop/src/main/java/org/hswebframework/web/logging/aop/SwaggerAccessLoggerParser.java | SwaggerAccessLoggerParser | support | class SwaggerAccessLoggerParser implements AccessLoggerParser {
@Override
public boolean support(Class<?> clazz, Method method) {<FILL_FUNCTION_BODY>}
@Override
public LoggerDefine parse(MethodInterceptorHolder holder) {
Api api = holder.findAnnotation(Api.class);
ApiOperation operation... |
Api api = AnnotationUtils.findAnnotation(clazz, Api.class);
ApiOperation operation = AnnotationUtils.findAnnotation(method, ApiOperation.class);
return api != null || operation != null;
| 187 | 61 | 248 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-logging/hsweb-access-logging-api/src/main/java/org/hswebframework/web/logging/AccessLoggerInfo.java | AccessLoggerInfo | toSimpleMap | class AccessLoggerInfo {
/**
* 日志id
*/
private String id;
/**
* 访问的操作
*
* @see AccessLogger#value()
*/
private String action;
/**
* 描述
*
* @see AccessLogger#describe()
*/
private String describe;
/**
* 访问对应的java方法
*/
private... |
map.put("action", action);
map.put("describe", describe);
if (method != null) {
StringJoiner methodAppender = new StringJoiner(",", method.getName().concat("("), ")");
String[] parameterNames = parameters.keySet().toArray(new String[0]);
Class<?>[] parameterT... | 681 | 452 | 1,133 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-starter/src/main/java/org/hswebframework/web/starter/CorsAutoConfiguration.java | WebMvcCorsConfiguration | corsFilter | class WebMvcCorsConfiguration {
@Bean
public org.springframework.web.filter.CorsFilter corsFilter(CorsProperties corsProperties) {<FILL_FUNCTION_BODY>}
} |
UrlBasedCorsConfigurationSource corsConfigurationSource = new UrlBasedCorsConfigurationSource();
Optional.ofNullable(corsProperties.getConfigs())
.orElseGet(()->Collections.singletonList(new CorsProperties.CorsConfiguration().applyPermitDefaultValues()))
... | 54 | 129 | 183 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-starter/src/main/java/org/hswebframework/web/starter/CorsProperties.java | CorsConfiguration | addAllowedHeader | class CorsConfiguration {
/**
* Wildcard representing <em>all</em> origins, methods, or headers.
*/
public static final String ALL = "*";
private String path = "/**";
private List<String> allowedOrigins;
private List<String> allowedMethods;
private ... |
if (this.allowedHeaders == null) {
this.allowedHeaders = new ArrayList<>(4);
}
this.allowedHeaders.add(CorsConfiguration.ALL);
| 678 | 46 | 724 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-starter/src/main/java/org/hswebframework/web/starter/HswebAutoConfiguration.java | HswebAutoConfiguration | systemInit | class HswebAutoConfiguration {
private List<DynamicScriptEngine> engines;
@Autowired
private ApplicationContext applicationContext;
@PostConstruct
public void init() {
engines = Stream.of("js", "groovy")
.map(DynamicScriptEngineFactory::getEngine)
... |
addGlobalVariable("database", database);
addGlobalVariable("sqlExecutor", database
.getMetadata()
.getFeature(SyncSqlExecutor.ID)
.orElseGet(() -> database
.getMetadata()
.getFeature(ReactiveSqlExecutor.ID)... | 248 | 168 | 416 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-starter/src/main/java/org/hswebframework/web/starter/i18n/CompositeMessageSource.java | CompositeMessageSource | getMessage | class CompositeMessageSource implements MessageSource {
private final List<MessageSource> messageSources = new CopyOnWriteArrayList<>();
public void addMessageSources(Collection<MessageSource> source) {
messageSources.addAll(source);
}
public void addMessageSource(MessageSource source) {
... |
for (MessageSource messageSource : messageSources) {
try {
String result = messageSource.getMessage(resolvable, locale);
if (StringUtils.hasText(result)) {
return result;
}
} catch (NoSuchMessageException ignore) {
... | 370 | 121 | 491 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-starter/src/main/java/org/hswebframework/web/starter/i18n/I18nConfiguration.java | I18nConfiguration | autoResolveI18nMessageSource | class I18nConfiguration {
@Bean
@SneakyThrows
public MessageSource autoResolveI18nMessageSource() {<FILL_FUNCTION_BODY>}
@Bean
@Primary
public MessageSource compositeMessageSource(ObjectProvider<MessageSource> objectProvider) {
CompositeMessageSource messageSource = new CompositeMessag... |
ResourceBundleMessageSource messageSource = new ResourceBundleMessageSource();
messageSource.setDefaultEncoding("UTF-8");
Resource[] resources = new PathMatchingResourcePatternResolver().getResources("classpath*:i18n/**");
for (Resource resource : resources) {
String path ... | 140 | 257 | 397 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-starter/src/main/java/org/hswebframework/web/starter/initialize/AppProperties.java | AppProperties | build | class AppProperties {
private boolean autoInit = true;
private List<String> initTableExcludes;
private String name = "default";
private String comment;
private String website;
private String version;
public SystemVersion build() {<FILL_FUNCTION_BODY>}
} |
SystemVersion systemVersion = new SystemVersion();
systemVersion.setName(name);
systemVersion.setComment(comment);
systemVersion.setWebsite(website);
systemVersion.setVersion(version);
return systemVersion;
| 78 | 62 | 140 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-starter/src/main/java/org/hswebframework/web/starter/initialize/DefaultDependencyUpgrader.java | DefaultDependencyUpgrader | filter | class DefaultDependencyUpgrader implements DependencyUpgrader {
private Logger logger = LoggerFactory.getLogger(this.getClass());
Dependency installed;
Dependency dependency;
List<Map<String, Object>> shouldUpdateVersionList;
private Map<String, Object> context;
private boolean firs... |
shouldUpdateVersionList = versions.stream()
.filter(map -> {
String ver = (String) map.get("version");
if (null == ver) {
return false;
}
//首次安装
if (firstInstall) {
... | 341 | 169 | 510 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-starter/src/main/java/org/hswebframework/web/starter/initialize/Dependency.java | Dependency | fromMap | class Dependency extends Version {
protected String groupId;
protected String artifactId;
protected String author;
public String getGroupId() {
return groupId;
}
public void setGroupId(String groupId) {
this.groupId = groupId;
}
... |
Dependency dependency = new Dependency();
dependency.setGroupId((String) map.get("groupId"));
dependency.setArtifactId((String) map.get("artifactId"));
dependency.setName((String) map.getOrDefault(SystemVersion.Property.name, dependency.getArtifactId()));
dep... | 314 | 134 | 448 | <methods>public non-sealed void <init>() ,public int compareTo(org.hswebframework.web.starter.initialize.Version) ,public java.lang.String getComment() ,public int getMajorVersion() ,public int getMinorVersion() ,public java.lang.String getName() ,public int getRevisionVersion() ,public java.lang.String getWebsite() ,p... |
hs-web_hsweb-framework | hsweb-framework/hsweb-starter/src/main/java/org/hswebframework/web/starter/initialize/SimpleDependencyInstaller.java | SimpleDependencyInstaller | doInitialize | class SimpleDependencyInstaller implements DependencyInstaller {
Dependency dependency;
CallBack installer;
CallBack upgrader;
CallBack unInstaller;
CallBack initializer;
private Logger logger = LoggerFactory.getLogger(this.getClass());
public SimpleDependencyInstaller() {
}
public... |
if (initializer != null) {
if (logger.isInfoEnabled()) {
logger.info("initialize [{}/{}]", dependency.getGroupId(), dependency.getArtifactId());
}
initializer.execute(context);
}
| 554 | 66 | 620 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-starter/src/main/java/org/hswebframework/web/starter/initialize/SystemInitialize.java | SystemInitialize | init | class SystemInitialize {
private final Logger logger = LoggerFactory.getLogger(SystemInitialize.class);
private final DatabaseOperator database;
//将要安装的信息
private final SystemVersion targetVersion;
//已安装的信息
private SystemVersion installed;
private List<SimpleDependencyInstaller> readyToIn... |
if (initialized) {
return;
}
// if (!CollectionUtils.isEmpty(excludeTables)) {
// this.database = new SkipCreateOrAlterRDBDatabase(database, excludeTables, sqlExecutor);
// }
scriptContext.put("database", database);
scriptContext.put("logger", logge... | 1,787 | 94 | 1,881 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-starter/src/main/java/org/hswebframework/web/starter/initialize/SystemVersion.java | SystemVersion | initDepCache | class SystemVersion extends Version {
public SystemVersion() {
}
public SystemVersion(String version) {
this.setVersion(version);
}
private FrameworkVersion frameworkVersion = new FrameworkVersion();
private List<Dependency> dependencies = new ArrayList<>();
public FrameworkVer... |
depCache = new HashMap<>();
dependencies.forEach(dependency -> depCache.put(getDepKey(dependency.groupId, dependency.artifactId), dependency));
| 641 | 41 | 682 | <methods>public non-sealed void <init>() ,public int compareTo(org.hswebframework.web.starter.initialize.Version) ,public java.lang.String getComment() ,public int getMajorVersion() ,public int getMinorVersion() ,public java.lang.String getName() ,public int getRevisionVersion() ,public java.lang.String getWebsite() ,p... |
hs-web_hsweb-framework | hsweb-framework/hsweb-starter/src/main/java/org/hswebframework/web/starter/initialize/Version.java | Version | setVersion | class Version implements Comparable<Version>, Serializable {
protected String name;
protected String comment;
protected String website;
protected int majorVersion = 1;
protected int minorVersion = 0;
protected int revisionVersion = 0;
protected boolean snapshot = false;
public void setV... |
this.majorVersion = major;
this.minorVersion = minor;
this.revisionVersion = revision;
this.snapshot = snapshot;
| 999 | 41 | 1,040 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-starter/src/main/java/org/hswebframework/web/starter/jackson/CustomCodecsAutoConfiguration.java | JacksonDecoderConfiguration | jacksonDecoderCustomizer | class JacksonDecoderConfiguration {
@Bean
SimpleModule entityAndEnumDictModule(EntityFactory entityFactory) {
SimpleModule module = new SimpleModule();
module.setDeserializers(new CustomDeserializers(entityFactory));
return module;
}
@Bean
@... |
return (configurer) -> {
CodecConfigurer.DefaultCodecs defaults = configurer.defaultCodecs();
defaults.jackson2JsonDecoder(new CustomJackson2JsonDecoder(entityFactory, objectMapper));
defaults.jackson2JsonEncoder(new CustomJackson2jsonEncoder(objectMapper));
... | 198 | 85 | 283 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-starter/src/main/java/org/hswebframework/web/starter/jackson/CustomDeserializers.java | CustomDeserializers | findEnumDeserializer | class CustomDeserializers extends SimpleDeserializers {
private final EntityFactory entityFactory;
@Override
public JsonDeserializer<?> findBeanDeserializer(JavaType type,
DeserializationConfig config,
Be... |
JsonDeserializer<?> deser = null;
if (type.isEnum() && EnumDict.class.isAssignableFrom(type)) {
deser = new EnumDict.EnumDictJSONDeserializer(val -> EnumDict
.find((Class) type, val)
.orElse(null));
}
return deser;
| 318 | 98 | 416 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-starter/src/main/java/org/hswebframework/web/starter/jackson/CustomJackson2JsonDecoder.java | CustomJackson2JsonDecoder | processException | class CustomJackson2JsonDecoder extends Jackson2CodecSupport implements HttpMessageDecoder<Object> {
private final EntityFactory entityFactory;
/**
* Constructor with a Jackson {@link ObjectMapper} to use.
*/
public CustomJackson2JsonDecoder(EntityFactory entityFactory, ObjectMapper mapper, Mime... |
if (ex instanceof InvalidDefinitionException) {
JavaType type = ((InvalidDefinitionException) ex).getType();
return new CodecException("Type definition error: " + type, ex);
}
if (ex instanceof JsonProcessingException) {
String originalMessage = ((JsonProcess... | 1,567 | 124 | 1,691 | <no_super_class> |
hs-web_hsweb-framework | hsweb-framework/hsweb-starter/src/main/java/org/hswebframework/web/starter/jackson/CustomMappingJackson2HttpMessageConverter.java | CustomMappingJackson2HttpMessageConverter | read | class CustomMappingJackson2HttpMessageConverter extends MappingJackson2HttpMessageConverter {
private final EntityFactory entityFactory;
public CustomMappingJackson2HttpMessageConverter(ObjectMapper objectMapper,
EntityFactory entityFactory) {
supe... |
if (type instanceof ParameterizedType) {
ResolvableType resolvableType = ResolvableType.forType(GenericTypeResolver.resolveType(type, contextClass));
Class<?> clazz = resolvableType.toClass();
//适配响应式的参数
if (Publisher.class.isAssignableFrom(clazz)) {
... | 249 | 266 | 515 | <no_super_class> |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.