You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2015/11/12 09:18:30 UTC

[19/33] camel git commit: Camel component docs. Add group as a way of combining the options in a number of coheret groups based on their labels.

http://git-wip-us.apache.org/repos/asf/camel/blob/259553c3/tooling/apt/src/main/java/org/apache/camel/tools/apt/model/ComponentOption.java
----------------------------------------------------------------------
diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/model/ComponentOption.java b/tooling/apt/src/main/java/org/apache/camel/tools/apt/model/ComponentOption.java
new file mode 100644
index 0000000..fd8562b
--- /dev/null
+++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/model/ComponentOption.java
@@ -0,0 +1,137 @@
+/**
+ * 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.tools.apt.model;
+
+import java.util.Set;
+
+import org.apache.camel.tools.apt.helper.CollectionStringBuffer;
+
+import static org.apache.camel.tools.apt.helper.Strings.isNullOrEmpty;
+
+public final class ComponentOption {
+
+    private String name;
+    private String type;
+    private String required;
+    private String defaultValue;
+    private String defaultValueNote;
+    private String documentation;
+    private boolean deprecated;
+    private String group;
+    private String label;
+    private boolean enumType;
+    private Set<String> enums;
+
+    public ComponentOption(String name, String type, String required, String defaultValue, String defaultValueNote,
+                           String documentation, boolean deprecated, String group, String label, boolean enumType, Set<String> enums) {
+        this.name = name;
+        this.type = type;
+        this.required = required;
+        this.defaultValue = defaultValue;
+        this.defaultValueNote = defaultValueNote;
+        this.documentation = documentation;
+        this.deprecated = deprecated;
+        this.label = group;
+        this.label = label;
+        this.enumType = enumType;
+        this.enums = enums;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public String getRequired() {
+        return required;
+    }
+
+    public String getDefaultValue() {
+        return defaultValue;
+    }
+
+    public String getDocumentation() {
+        return documentation;
+    }
+
+    public boolean isDeprecated() {
+        return deprecated;
+    }
+
+    public String getEnumValuesAsHtml() {
+        CollectionStringBuffer csb = new CollectionStringBuffer("<br/>");
+        if (enums != null && enums.size() > 0) {
+            for (String e : enums) {
+                csb.append(e);
+            }
+        }
+        return csb.toString();
+    }
+
+    public String getDocumentationWithNotes() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(documentation);
+
+        if (!isNullOrEmpty(defaultValueNote)) {
+            sb.append(". Default value notice: ").append(defaultValueNote);
+        }
+
+        return sb.toString();
+    }
+
+    public boolean isEnumType() {
+        return enumType;
+    }
+
+    public Set<String> getEnums() {
+        return enums;
+    }
+
+    public String getGroup() {
+        return group;
+    }
+
+    public String getLabel() {
+        return label;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+
+        ComponentOption that = (ComponentOption) o;
+
+        if (!name.equals(that.name)) {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        return name.hashCode();
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/259553c3/tooling/apt/src/main/java/org/apache/camel/tools/apt/model/EndpointOption.java
----------------------------------------------------------------------
diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/model/EndpointOption.java b/tooling/apt/src/main/java/org/apache/camel/tools/apt/model/EndpointOption.java
new file mode 100644
index 0000000..2755167
--- /dev/null
+++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/model/EndpointOption.java
@@ -0,0 +1,137 @@
+/**
+ * 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.tools.apt.model;
+
+import java.util.Set;
+
+import org.apache.camel.tools.apt.helper.CollectionStringBuffer;
+
+import static org.apache.camel.tools.apt.helper.Strings.isNullOrEmpty;
+
+public final class EndpointOption {
+
+    private String name;
+    private String type;
+    private String required;
+    private String defaultValue;
+    private String defaultValueNote;
+    private String documentation;
+    private boolean deprecated;
+    private String group;
+    private String label;
+    private boolean enumType;
+    private Set<String> enums;
+
+    public EndpointOption(String name, String type, String required, String defaultValue, String defaultValueNote,
+                          String documentation, boolean deprecated,  String group, String label, boolean enumType, Set<String> enums) {
+        this.name = name;
+        this.type = type;
+        this.required = required;
+        this.defaultValue = defaultValue;
+        this.defaultValueNote = defaultValueNote;
+        this.documentation = documentation;
+        this.deprecated = deprecated;
+        this.group = group;
+        this.label = label;
+        this.enumType = enumType;
+        this.enums = enums;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public String getRequired() {
+        return required;
+    }
+
+    public String getDefaultValue() {
+        return defaultValue;
+    }
+
+    public String getDocumentation() {
+        return documentation;
+    }
+
+    public boolean isDeprecated() {
+        return deprecated;
+    }
+
+    public String getEnumValuesAsHtml() {
+        CollectionStringBuffer csb = new CollectionStringBuffer("<br/>");
+        if (enums != null && enums.size() > 0) {
+            for (String e : enums) {
+                csb.append(e);
+            }
+        }
+        return csb.toString();
+    }
+
+    public String getDocumentationWithNotes() {
+        StringBuilder sb = new StringBuilder();
+        sb.append(documentation);
+
+        if (!isNullOrEmpty(defaultValueNote)) {
+            sb.append(". Default value notice: ").append(defaultValueNote);
+        }
+
+        return sb.toString();
+    }
+
+    public boolean isEnumType() {
+        return enumType;
+    }
+
+    public Set<String> getEnums() {
+        return enums;
+    }
+
+    public String getGroup() {
+        return group;
+    }
+
+    public String getLabel() {
+        return label;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+
+        EndpointOption that = (EndpointOption) o;
+
+        if (!name.equals(that.name)) {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        return name.hashCode();
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/259553c3/tooling/apt/src/main/java/org/apache/camel/tools/apt/model/EndpointPath.java
----------------------------------------------------------------------
diff --git a/tooling/apt/src/main/java/org/apache/camel/tools/apt/model/EndpointPath.java b/tooling/apt/src/main/java/org/apache/camel/tools/apt/model/EndpointPath.java
new file mode 100644
index 0000000..5088814
--- /dev/null
+++ b/tooling/apt/src/main/java/org/apache/camel/tools/apt/model/EndpointPath.java
@@ -0,0 +1,122 @@
+/**
+ * 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.tools.apt.model;
+
+import java.util.Set;
+
+import org.apache.camel.tools.apt.helper.CollectionStringBuffer;
+
+public final class EndpointPath {
+
+    private String name;
+    private String type;
+    private String required;
+    private String defaultValue;
+    private String documentation;
+    private boolean deprecated;
+    private String group;
+    private String label;
+    private boolean enumType;
+    private Set<String> enums;
+
+    public EndpointPath(String name, String type, String required, String defaultValue, String documentation, boolean deprecated,
+                        String group, String label, boolean enumType, Set<String> enums) {
+        this.name = name;
+        this.type = type;
+        this.required = required;
+        this.defaultValue = defaultValue;
+        this.documentation = documentation;
+        this.deprecated = deprecated;
+        this.group = group;
+        this.label = label;
+        this.enumType = enumType;
+        this.enums = enums;
+    }
+
+    public String getName() {
+        return name;
+    }
+
+    public String getType() {
+        return type;
+    }
+
+    public String getRequired() {
+        return required;
+    }
+
+    public String getDefaultValue() {
+        return defaultValue;
+    }
+
+    public String getDocumentation() {
+        return documentation;
+    }
+
+    public boolean isDeprecated() {
+        return deprecated;
+    }
+
+    public String getEnumValuesAsHtml() {
+        CollectionStringBuffer csb = new CollectionStringBuffer("<br/>");
+        if (enums != null && enums.size() > 0) {
+            for (String e : enums) {
+                csb.append(e);
+            }
+        }
+        return csb.toString();
+    }
+
+    public boolean isEnumType() {
+        return enumType;
+    }
+
+    public Set<String> getEnums() {
+        return enums;
+    }
+
+    public String getGroup() {
+        return group;
+    }
+
+    public String getLabel() {
+        return label;
+    }
+
+    @Override
+    public boolean equals(Object o) {
+        if (this == o) {
+            return true;
+        }
+        if (o == null || getClass() != o.getClass()) {
+            return false;
+        }
+
+        EndpointPath that = (EndpointPath) o;
+
+        if (!name.equals(that.name)) {
+            return false;
+        }
+
+        return true;
+    }
+
+    @Override
+    public int hashCode() {
+        return name.hashCode();
+    }
+}

http://git-wip-us.apache.org/repos/asf/camel/blob/259553c3/tooling/apt/src/test/java/org/apache/camel/tools/apt/EndpointOptionComparatorTest.java
----------------------------------------------------------------------
diff --git a/tooling/apt/src/test/java/org/apache/camel/tools/apt/EndpointOptionComparatorTest.java b/tooling/apt/src/test/java/org/apache/camel/tools/apt/EndpointOptionComparatorTest.java
new file mode 100644
index 0000000..85bfaa5
--- /dev/null
+++ b/tooling/apt/src/test/java/org/apache/camel/tools/apt/EndpointOptionComparatorTest.java
@@ -0,0 +1,61 @@
+/**
+ * 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.tools.apt;
+
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.List;
+
+import org.apache.camel.tools.apt.helper.EndpointHelper;
+import org.apache.camel.tools.apt.model.EndpointOption;
+import org.junit.Test;
+
+import static org.junit.Assert.assertEquals;
+
+public class EndpointOptionComparatorTest {
+
+    @Test
+    public void testComparator() {
+        String label1 = "common";
+        String label2 = "advanced";
+        String label3 = "common";
+        String label4 = "filter";
+        String group1 = EndpointHelper.labelAsGroupName(label1, false, false);
+        String group2 = EndpointHelper.labelAsGroupName(label2, false, false);
+        String group3 = EndpointHelper.labelAsGroupName(label3, false, false);
+        String group4 = EndpointHelper.labelAsGroupName(label4, false, false);
+
+        EndpointOption op1 = new EndpointOption("aaa", "string", "true", "", "", "blah", false, group1, label1, false, null);
+        EndpointOption op2 = new EndpointOption("ccc", "string", "true", "", "", "blah", false, group2, label2, false, null);
+        EndpointOption op3 = new EndpointOption("ddd", "string", "true", "", "", "blah", false, group3, label3, false, null);
+        EndpointOption op4 = new EndpointOption("bbb", "string", "true", "", "", "blah", false, group4, label4, false, null);
+
+        List<EndpointOption> list = new ArrayList<EndpointOption>();
+        list.add(op1);
+        list.add(op2);
+        list.add(op3);
+        list.add(op4);
+
+        // then by label into the groups
+        Collections.sort(list, EndpointHelper.createGroupAndLabelComparator());
+
+        assertEquals("aaa", list.get(0).getName());
+        assertEquals("ddd", list.get(1).getName());
+        assertEquals("bbb", list.get(2).getName());
+        assertEquals("ccc", list.get(3).getName());
+    }
+}