sdedic commented on code in PR #7614:
URL: https://github.com/apache/netbeans/pull/7614#discussion_r1710036029


##########
enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/assets/ApplicationPropertiesGenerator.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * 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.netbeans.modules.cloud.oracle.assets;
+
+import java.util.Date;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ *
+ * @author Dusan Petrovic
+ */
+public class ApplicationPropertiesGenerator {
+
+    final PropertiesGenerator propertiesGenerator;
+
+    public ApplicationPropertiesGenerator(PropertiesGenerator 
propertiesGenerator) {
+        this.propertiesGenerator = propertiesGenerator;
+    }
+
+    public String getApplicationPropertiesString() {
+        StringBuilder sb = new StringBuilder();
+        appendApplicationProperties(sb);
+        appendBootstrapProperties(sb);
+        return sb.toString();
+    }
+
+    private void appendApplicationProperties(StringBuilder sb) {
+        appendComments(sb,
+                "Generated application.properties\n", //NOI18N
+                "Uncomment following line when running inside Oracle Cloud\n", 
//NOI18N
+                "oci.config.instance-principal.enabled=true\n" //NOI18N
+                );
+        appendDateComment(sb);
+        appendProperties(sb, new 
TreeMap<>(this.propertiesGenerator.getApplication()));
+    }
+
+    private void appendBootstrapProperties(StringBuilder sb) {
+        if (!this.propertiesGenerator.getApplication().isEmpty()) {
+            sb.append("\n"); //NOI18N
+        }
+        appendComments(sb, "Generated bootstrap.properties\n"); //NOI18N
+        appendProperties(sb, new 
TreeMap<>(this.propertiesGenerator.getBootstrap()));
+    }
+
+    private void appendComments(StringBuilder sb, String ...comments) {
+        for (String comment : comments) {
+            sb.append("#").append(comment); //NOI18N

Review Comment:
   I'd add a space after "#", it better follows usual conventions and is more 
readable.



##########
enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/assets/ApplicationPropertiesGenerator.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * 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.netbeans.modules.cloud.oracle.assets;
+
+import java.util.Date;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ *
+ * @author Dusan Petrovic
+ */
+public class ApplicationPropertiesGenerator {
+
+    final PropertiesGenerator propertiesGenerator;
+
+    public ApplicationPropertiesGenerator(PropertiesGenerator 
propertiesGenerator) {
+        this.propertiesGenerator = propertiesGenerator;
+    }
+
+    public String getApplicationPropertiesString() {
+        StringBuilder sb = new StringBuilder();
+        appendApplicationProperties(sb);
+        appendBootstrapProperties(sb);
+        return sb.toString();
+    }
+
+    private void appendApplicationProperties(StringBuilder sb) {
+        appendComments(sb,
+                "Generated application.properties\n", //NOI18N

Review Comment:
   Nitpick: as appendComments appends whole lines, it could make ending 
newlines automatically.



##########
enterprise/cloud.oracle/src/org/netbeans/modules/cloud/oracle/assets/ApplicationPropertiesGenerator.java:
##########
@@ -0,0 +1,96 @@
+/*
+ * 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.netbeans.modules.cloud.oracle.assets;
+
+import java.util.Date;
+import java.util.Map;
+import java.util.TreeMap;
+
+/**
+ *
+ * @author Dusan Petrovic
+ */
+public class ApplicationPropertiesGenerator {
+
+    final PropertiesGenerator propertiesGenerator;
+
+    public ApplicationPropertiesGenerator(PropertiesGenerator 
propertiesGenerator) {
+        this.propertiesGenerator = propertiesGenerator;
+    }
+
+    public String getApplicationPropertiesString() {
+        StringBuilder sb = new StringBuilder();
+        appendApplicationProperties(sb);
+        appendBootstrapProperties(sb);
+        return sb.toString();
+    }
+
+    private void appendApplicationProperties(StringBuilder sb) {
+        appendComments(sb,
+                "Generated application.properties\n", //NOI18N
+                "Uncomment following line when running inside Oracle Cloud\n", 
//NOI18N
+                "oci.config.instance-principal.enabled=true\n" //NOI18N
+                );
+        appendDateComment(sb);
+        appendProperties(sb, new 
TreeMap<>(this.propertiesGenerator.getApplication()));
+    }
+
+    private void appendBootstrapProperties(StringBuilder sb) {
+        if (!this.propertiesGenerator.getApplication().isEmpty()) {

Review Comment:
   Nitpick: I'd move this to `getApplicationPropertiesString`: the code assumes 
a specific order of invocations - and that other function defines that order.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

For further information about the NetBeans mailing lists, visit:
https://cwiki.apache.org/confluence/display/NETBEANS/Mailing+lists

Reply via email to