Skip to content

Commit

Permalink
add typehandler
Browse files Browse the repository at this point in the history
  • Loading branch information
Zzm0809 committed Oct 13, 2023
1 parent 9fcae42 commit 29857a5
Show file tree
Hide file tree
Showing 2 changed files with 84 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.dinky.data.typehandler.flink;

import org.apache.flink.runtime.rest.messages.checkpoints.CheckpointConfigInfo;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;

import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler;

import cn.hutool.json.JSONUtil;

@MappedTypes({CheckpointConfigInfo.class})
@MappedJdbcTypes({JdbcType.VARCHAR})
public class CheckpointConfigTypeHandler extends AbstractJsonTypeHandler<CheckpointConfigInfo> {
protected CheckpointConfigInfo parse(String json) {
return JSONUtil.toBean(json, CheckpointConfigInfo.class);
}

@Override
protected String toJson(CheckpointConfigInfo obj) {
return JSONUtil.toJsonStr(obj);
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
/*
*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
* The ASF licenses this file to You under the Apache License, Version 2.0
* (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*
*/

package org.dinky.data.typehandler.flink;

import org.apache.flink.runtime.rest.messages.checkpoints.CheckpointingStatistics;
import org.apache.ibatis.type.JdbcType;
import org.apache.ibatis.type.MappedJdbcTypes;
import org.apache.ibatis.type.MappedTypes;

import com.baomidou.mybatisplus.extension.handlers.AbstractJsonTypeHandler;

import cn.hutool.json.JSONUtil;

@MappedTypes({CheckpointingStatistics.class})
@MappedJdbcTypes({JdbcType.VARCHAR})
public class CheckpointingStatisticsTypeHandler extends AbstractJsonTypeHandler<CheckpointingStatistics> {
protected CheckpointingStatistics parse(String json) {
return JSONUtil.toBean(json, CheckpointingStatistics.class);
}

@Override
protected String toJson(CheckpointingStatistics obj) {
return JSONUtil.toJsonStr(obj);
}
}

0 comments on commit 29857a5

Please sign in to comment.