-
Notifications
You must be signed in to change notification settings - Fork 6.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
159 additions
and
63 deletions.
There are no files selected for viewing
48 changes: 48 additions & 0 deletions
48
.../src/main/java/org/apache/shardingsphere/infra/yaml/schema/swapper/YamlColumnSwapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
/* | ||
* 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.apache.shardingsphere.infra.yaml.schema.swapper; | ||
|
||
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereColumn; | ||
import org.apache.shardingsphere.infra.util.yaml.swapper.YamlConfigurationSwapper; | ||
import org.apache.shardingsphere.infra.yaml.schema.pojo.YamlShardingSphereColumn; | ||
|
||
/** | ||
* YAML column swapper. | ||
*/ | ||
public final class YamlColumnSwapper implements YamlConfigurationSwapper<YamlShardingSphereColumn, ShardingSphereColumn> { | ||
|
||
@Override | ||
public YamlShardingSphereColumn swapToYamlConfiguration(final ShardingSphereColumn data) { | ||
YamlShardingSphereColumn result = new YamlShardingSphereColumn(); | ||
result.setName(data.getName()); | ||
result.setDataType(data.getDataType()); | ||
result.setPrimaryKey(data.isPrimaryKey()); | ||
result.setGenerated(data.isGenerated()); | ||
result.setCaseSensitive(data.isCaseSensitive()); | ||
result.setVisible(data.isVisible()); | ||
result.setUnsigned(data.isUnsigned()); | ||
result.setNullable(data.isNullable()); | ||
return result; | ||
} | ||
|
||
@Override | ||
public ShardingSphereColumn swapToObject(final YamlShardingSphereColumn yamlConfig) { | ||
return new ShardingSphereColumn(yamlConfig.getName(), yamlConfig.getDataType(), | ||
yamlConfig.isPrimaryKey(), yamlConfig.isGenerated(), yamlConfig.isCaseSensitive(), yamlConfig.isVisible(), yamlConfig.isUnsigned(), yamlConfig.isNullable()); | ||
} | ||
} |
41 changes: 41 additions & 0 deletions
41
.../main/java/org/apache/shardingsphere/infra/yaml/schema/swapper/YamlConstraintSwapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
/* | ||
* 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.apache.shardingsphere.infra.yaml.schema.swapper; | ||
|
||
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereConstraint; | ||
import org.apache.shardingsphere.infra.util.yaml.swapper.YamlConfigurationSwapper; | ||
import org.apache.shardingsphere.infra.yaml.schema.pojo.YamlShardingSphereConstraint; | ||
|
||
/** | ||
* YAML constraint swapper. | ||
*/ | ||
public final class YamlConstraintSwapper implements YamlConfigurationSwapper<YamlShardingSphereConstraint, ShardingSphereConstraint> { | ||
|
||
@Override | ||
public YamlShardingSphereConstraint swapToYamlConfiguration(final ShardingSphereConstraint data) { | ||
YamlShardingSphereConstraint result = new YamlShardingSphereConstraint(); | ||
result.setName(data.getName()); | ||
result.setReferencedTableName(data.getReferencedTableName()); | ||
return result; | ||
} | ||
|
||
@Override | ||
public ShardingSphereConstraint swapToObject(final YamlShardingSphereConstraint yamlConfig) { | ||
return new ShardingSphereConstraint(yamlConfig.getName(), yamlConfig.getReferencedTableName()); | ||
} | ||
} |
45 changes: 45 additions & 0 deletions
45
...n/src/main/java/org/apache/shardingsphere/infra/yaml/schema/swapper/YamlIndexSwapper.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
/* | ||
* 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.apache.shardingsphere.infra.yaml.schema.swapper; | ||
|
||
import org.apache.shardingsphere.infra.metadata.database.schema.model.ShardingSphereIndex; | ||
import org.apache.shardingsphere.infra.util.yaml.swapper.YamlConfigurationSwapper; | ||
import org.apache.shardingsphere.infra.yaml.schema.pojo.YamlShardingSphereIndex; | ||
|
||
/** | ||
* YAML index swapper. | ||
*/ | ||
public final class YamlIndexSwapper implements YamlConfigurationSwapper<YamlShardingSphereIndex, ShardingSphereIndex> { | ||
|
||
@Override | ||
public YamlShardingSphereIndex swapToYamlConfiguration(final ShardingSphereIndex data) { | ||
YamlShardingSphereIndex result = new YamlShardingSphereIndex(); | ||
result.setName(data.getName()); | ||
result.getColumns().addAll(data.getColumns()); | ||
result.setUnique(data.isUnique()); | ||
return result; | ||
} | ||
|
||
@Override | ||
public ShardingSphereIndex swapToObject(final YamlShardingSphereIndex yamlConfig) { | ||
ShardingSphereIndex result = new ShardingSphereIndex(yamlConfig.getName()); | ||
result.getColumns().addAll(yamlConfig.getColumns()); | ||
result.setUnique(yamlConfig.isUnique()); | ||
return result; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters