Skip to content

Commit

Permalink
cleanup/modernize code a bit + add special handling for the "name"
Browse files Browse the repository at this point in the history
attribute reported by some subsystems
  • Loading branch information
tomf committed May 10, 2024
1 parent 44e85f7 commit 9347a54
Show file tree
Hide file tree
Showing 9 changed files with 294 additions and 256 deletions.
20 changes: 20 additions & 0 deletions nb-configuration.xml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,26 @@ You can copy and paste the single properties, into the pom.xml file and the IDE
That way multiple projects can share the same settings (useful for formatting rules for example).
Any value defined here will override the pom.xml file value but is only applicable to the current project.
-->
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignJavadocExceptionDescriptions>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignJavadocExceptionDescriptions>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignJavadocParameterDescriptions>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignJavadocParameterDescriptions>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignJavadocReturnDescription>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignJavadocReturnDescription>

<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAnnotationArgs>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineAnnotationArgs>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineCallArgs>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineCallArgs>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineImplements>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineImplements>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineMethodParams>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineMethodParams>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineThrows>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.alignMultilineThrows>

<!-- <org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLineAfterJavadocParameterDescriptions>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLineAfterJavadocParameterDescriptions>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLineAfterJavadocReturnTag>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.blankLineAfterJavadocReturnTag>-->
<!--<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.preserveNewLinesInComments>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.preserveNewLinesInComments>-->

<!-- <org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.enable-indent>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.enable-indent>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.generateParagraphTagOnBlankLines>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.generateParagraphTagOnBlankLines>-->

<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapMethodParams>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapMethodParams>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapThrowsKeyword>true</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.wrapThrowsKeyword>

<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.text-line-wrap>none</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.text-line-wrap>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.continuationIndentSize>4</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.continuationIndentSize>
<org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indent-shift-width>4</org-netbeans-modules-editor-indent.text.x-java.CodeStyle.project.indent-shift-width>
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<modelVersion>4.0.0</modelVersion>
<groupId>org.jboss.tfonteyne.profilecloner</groupId>
<artifactId>profilecloner</artifactId>
<version>2024-05-08</version>
<version>2024-05-10</version>
<packaging>jar</packaging>
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
Expand Down
23 changes: 9 additions & 14 deletions src/main/java/org/jboss/tfonteyne/profilecloner/Address.java
Original file line number Diff line number Diff line change
Expand Up @@ -16,33 +16,28 @@
*/
package org.jboss.tfonteyne.profilecloner;

/**
*
* @author Tom Fonteyne
*/
public class Address {

public Address(String name, String value) {
final String name;
final String value;

public Address(final String name,
final String value) {
this.name = name;
this.value = value;
}

public Address(String pair) {
String[] nv = pair.split("=");
try
{
public Address(final String pair) {
final String[] nv = pair.split("=");
try {
this.name = nv[0];
this.value = nv[1];
}
catch (ArrayIndexOutOfBoundsException oob)
{
catch (ArrayIndexOutOfBoundsException oob) {
throw new ArrayIndexOutOfBoundsException("Invalid address pair: " + pair);
}
}

String name;
String value;

@Override
public String toString() {
return "/" + name + "=\"" + value + "\"";
Expand Down
21 changes: 9 additions & 12 deletions src/main/java/org/jboss/tfonteyne/profilecloner/AddressStack.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,30 +20,27 @@
import org.jboss.as.controller.client.helpers.ClientConstants;
import org.jboss.dmr.ModelNode;

/**
*
* @author Tom Fonteyne
*/
public class AddressStack {

private final Stack<Address> adresses = new Stack<>();

public AddressStack(String root, String source) {
public AddressStack(final String root,
final String source) {
adresses.push(new Address(root, source));
}

public AddressStack(String source) {
String[] nvPairs = source.split("/");
for (int i=1; i<nvPairs.length; i++) {
public AddressStack(final String source) {
final String[] nvPairs = source.split("/");
for (int i = 1; i < nvPairs.length; i++) {
adresses.push(new Address(nvPairs[i]));
}
}

public void push(Address address) {
public void push(final Address address) {
adresses.push(address);
}

public void push(String nvString) {
public void push(final String nvString) {
adresses.push(new Address(nvString));
}

Expand All @@ -57,14 +54,14 @@ public String toString() {
}

public StringBuilder toStringBuilder() {
StringBuilder adressString = new StringBuilder();
final StringBuilder adressString = new StringBuilder();
for (Address address : adresses) {
adressString.append(address.toString());
}
return adressString;
}

public void setAddress(ModelNode node) {
public void setAddress(final ModelNode node) {
for (Address address : adresses) {
node.get(ClientConstants.OP_ADDR).add(address.name, address.value);
}
Expand Down
8 changes: 3 additions & 5 deletions src/main/java/org/jboss/tfonteyne/profilecloner/Cloner.java
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@
import java.util.List;
import org.jboss.as.cli.CommandLineException;

/**
*
* @author Tom Fonteyne
*/
public interface Cloner {
public List<String> copy() throws IOException, CommandLineException;
List<String> copy()
throws IOException,
CommandLineException;
}
36 changes: 36 additions & 0 deletions src/main/java/org/jboss/tfonteyne/profilecloner/Element.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* This is free software; you can redistribute it and/or modify it
* under the terms of the GNU Lesser General Public License as
* published by the Free Software Foundation; either version 2.1 of
* the License, or (at your option) any later version.
*
* This software is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* You should have received a copy of the GNU Lesser General Public
* License along with this software; if not, write to the Free
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
*/
package org.jboss.tfonteyne.profilecloner;

/**
* Used to keep a list of the elements to be cloned
*/
public class Element {
final String source;
final String destination;

public Element(final String source) {
this.source = source;
this.destination = null;
}

public Element(final String from,
final String destination) {
this.source = from;
this.destination = destination;
}
}
Loading

0 comments on commit 9347a54

Please sign in to comment.