blob: aadcf829e268e23263c2d36c03942fd9c2b48bbb [file] [log] [blame]
/*
* 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.camel.quarkus.maven.model;
import java.nio.file.Path;
import org.apache.camel.quarkus.maven.StringHelper;
import static org.apache.camel.quarkus.maven.StringHelper.cutLastZeroDigit;
public abstract class AbstractModel {
private String kind;
private String name;
private String modelName;
private String title;
private String description;
private String firstVersion;
private String label;
private String deprecated;
private String deprecationNote;
private String javaType;
private String groupId;
private String artifactId;
private String version;
private Path extensionsDocPath;
public String getKind() {
return kind;
}
public void setKind(String kind) {
this.kind = kind;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public String getModelName() {
return modelName;
}
public void setModelName(String modelName) {
this.modelName = modelName;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
public String getDescription() {
return description;
}
public void setDescription(String description) {
this.description = description;
}
public String getFirstVersion() {
return firstVersion;
}
public void setFirstVersion(String firstVersion) {
this.firstVersion = firstVersion;
}
public String getLabel() {
return label;
}
public void setLabel(String label) {
this.label = label;
}
public String getDeprecated() {
return deprecated;
}
public void setDeprecated(String deprecated) {
this.deprecated = deprecated;
}
public String getDeprecationNote() {
return deprecationNote;
}
public void setDeprecationNote(String deprecationNote) {
this.deprecationNote = deprecationNote;
}
public String getJavaType() {
return javaType;
}
public void setJavaType(String javaType) {
this.javaType = javaType;
}
public String getGroupId() {
return groupId;
}
public void setGroupId(String groupId) {
this.groupId = groupId;
}
public String getArtifactId() {
return artifactId;
}
public void setArtifactId(String artifactId) {
this.artifactId = artifactId;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getShortJavaType() {
return StringHelper.getClassShortName(javaType);
}
public boolean localDocExists() {
Path path = extensionsDocPath.resolve(getExtensionDocName());
return path.toFile().exists();
}
public Path getExtensionsDocPath() {
return extensionsDocPath;
}
public void setExtensionsDocPath(Path extensionsDocPath) {
this.extensionsDocPath = extensionsDocPath;
}
public String getLocalDocLink() {
return "xref:extensions/" + getExtensionDocName();
}
public String getExtensionDocName() {
return StringHelper.after(artifactId, "camel-quarkus-") + ".adoc";
}
public String getDocLink() {
if (localDocExists()) {
return getLocalDocLink();
}
return String.format("link:https://camel.apache.org/%s/latest/%s", getDocLinkSection(), getDocLinkDocument());
}
public String getFirstVersionShort() {
return cutLastZeroDigit(firstVersion);
}
abstract String getDocLinkSection();
abstract String getDocLinkDocument();
}