Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
59 changes: 59 additions & 0 deletions flink-cdc-common-2.x/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
<?xml version="1.0" encoding="UTF-8"?>
<!--
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.
-->
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<parent>
<artifactId>flink-cdc-parent</artifactId>
<groupId>org.apache.flink</groupId>
<version>${revision}</version>
</parent>
<modelVersion>4.0.0</modelVersion>

<artifactId>flink-cdc-common-2.x</artifactId>

<properties>
<flink.version>${flink.2.x.version}</flink.version>
<shaded.guava.version>${flink.2.x.shaded.guava.version}</shaded.guava.version>
</properties>

<dependencies>
<dependency>
<groupId>org.apache.flink</groupId>
<artifactId>flink-cdc-common</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>

<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<id>test-jar</id>
<goals>
<goal>test-jar</goal>
</goals>
</execution>
</executions>
</plugin>
</plugins>
</build>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/*
* 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.flink.cdc.common.configuration.description;

import org.apache.flink.cdc.common.annotation.PublicEvolving;

import org.apache.flink.shaded.guava33.com.google.common.base.Strings;

import java.util.Arrays;
import java.util.Collections;
import java.util.EnumSet;
import java.util.List;

/** Represents a text block in the {@link Description}. */
@PublicEvolving
public class TextElement implements BlockElement, InlineElement {
private final String format;
private final List<InlineElement> elements;
private final EnumSet<TextStyle> textStyles = EnumSet.noneOf(TextStyle.class);

/**
* Creates a block of text with placeholders ("%s") that will be replaced with proper string
* representation of given {@link InlineElement}. For example:
*
* <p>{@code text("This is a text with a link %s", link("https://somepage", "to here"))}
*
* @param format text with placeholders for elements
* @param elements elements to be put in the text
* @return block of text
*/
public static TextElement text(String format, InlineElement... elements) {
return new TextElement(format, Arrays.asList(elements));
}

/**
* Creates a simple block of text.
*
* @param text a simple block of text
* @return block of text
*/
public static TextElement text(String text) {
return new TextElement(text, Collections.emptyList());
}

/** Wraps a list of {@link InlineElement}s into a single {@link TextElement}. */
public static InlineElement wrap(InlineElement... elements) {
return text(Strings.repeat("%s", elements.length), elements);
}

/**
* Creates a block of text formatted as code.
*
* @param text a block of text that will be formatted as code
* @return block of text formatted as code
*/
public static TextElement code(String text) {
TextElement element = text(text);
element.textStyles.add(TextStyle.CODE);
return element;
}

public String getFormat() {
return format;
}

public List<InlineElement> getElements() {
return elements;
}

public EnumSet<TextStyle> getStyles() {
return textStyles;
}

private TextElement(String format, List<InlineElement> elements) {
this.format = format;
this.elements = elements;
}

@Override
public void format(Formatter formatter) {
formatter.format(this);
}

/** Styles that can be applied to {@link TextElement} e.g. code, bold etc. */
@PublicEvolving
public enum TextStyle {
CODE
}
}
Loading
Loading