Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

75: countdown timeouts review and removals #90

Merged
merged 15 commits into from
Dec 19, 2024
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@
<maven.resource.plugin.version>3.3.1</maven.resource.plugin.version>
<maven.build.helper.plugin.version>3.6.0</maven.build.helper.plugin.version>
<maven.shade.plugin.version>3.6.0</maven.shade.plugin.version>
<pi4j.version>2.7.0-SNAPSHOT</pi4j.version>
<pi4j.version>2.7.0</pi4j.version>
<slf4j.version>2.0.16</slf4j.version>
<nexus.staging.version>1.6.7</nexus.staging.version>

Expand Down
4 changes: 2 additions & 2 deletions robo4j-core/src/main/java/com/robo4j/AttributeDescriptor.java
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,12 @@ public interface AttributeDescriptor<T> {
*
* @return the attribute type.
*/
Class<T> getAttributeType();
Class<T> attributeType();

/**
* Returns the name of the attribute.
*
* @return the attribute name.
*/
String getAttributeName();
String attributeName();
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
*/
package com.robo4j;

import java.io.Serial;

/**
* Exception thrown when a problem occurs configuring a RoboUnit.
*
* @author Marcus Hirt (@hirt)
* @author Miroslav Wengner (@miragemiko)
*/
public class ConfigurationException extends Exception {
@Serial
private static final long serialVersionUID = 1L;

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,52 +16,37 @@
*/
package com.robo4j;

import java.io.Serial;
import java.io.Serializable;

/**
* Default implementation of an attribute descriptor.
*
*
* @author Marcus Hirt (@hirt)
* @author Miroslav Wengner (@miragemiko)
*/
public class DefaultAttributeDescriptor<T> implements AttributeDescriptor<T>, Serializable {
public record DefaultAttributeDescriptor<T>(Class<T> attributeType,
String attributeName) implements AttributeDescriptor<T>, Serializable {
@Serial
private static final long serialVersionUID = 1L;
private final Class<T> attributeType;
private final String attributeName;

/**
* Constructor.
*
* @param attributeType
* the type of the attribute. Needed since the generic type is
* erased.
* @param attributeName
* the name of the attribute.
*
* @param attributeType the type of the attribute. Needed since the generic type is
* erased.
* @param attributeName the name of the attribute.
*/
public DefaultAttributeDescriptor(Class<T> attributeType, String attributeName) {
this.attributeType = attributeType;
this.attributeName = attributeName;
}

@Override
public Class<T> getAttributeType() {
return attributeType;
public DefaultAttributeDescriptor {
}

@Override
public String getAttributeName() {
return attributeName;
}

/**
* Factory method for creating attribute descriptors.
*
* @param attributeType
* the type of the attribute.
* @param attributeName
* the name of the attribute.
* @param <T>
* attribute type class
*
* @param attributeType the type of the attribute.
* @param attributeName the name of the attribute.
* @param <T> attribute type class
* @return created attribute
*/
public static <T> DefaultAttributeDescriptor<T> create(Class<T> attributeType, String attributeName) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,12 +16,12 @@
*/
package com.robo4j;

import com.robo4j.configuration.Configuration;

import java.util.Collection;
import java.util.Map;
import java.util.concurrent.Future;

import com.robo4j.configuration.Configuration;

/**
* This is a useful adapter to hand off a RoboReference to a unit which will
* only use it as a callback. Note that this has several serious limits. First,
Expand Down Expand Up @@ -56,7 +56,7 @@ public Configuration getConfiguration() {
}

@Override
public String getId() {
public String id() {
return null;
}

Expand Down
128 changes: 0 additions & 128 deletions robo4j-core/src/main/java/com/robo4j/RoboApplication.java

This file was deleted.

34 changes: 0 additions & 34 deletions robo4j-core/src/main/java/com/robo4j/RoboApplicationException.java

This file was deleted.

40 changes: 12 additions & 28 deletions robo4j-core/src/main/java/com/robo4j/RoboBuilder.java
Original file line number Diff line number Diff line change
Expand Up @@ -92,18 +92,14 @@ private class RoboXMLHandler extends DefaultHandler {
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
switch (qName) {
case ELEMENT_ROBO_UNIT:
currentId = attributes.getValue("id");
break;
case SystemXMLHandler.ELEMENT_SYSTEM:
inSystemElement = true;
break;
case XmlConfigurationFactory.ELEMENT_CONFIG:
case ELEMENT_ROBO_UNIT -> currentId = attributes.getValue("id");
case SystemXMLHandler.ELEMENT_SYSTEM -> inSystemElement = true;
case XmlConfigurationFactory.ELEMENT_CONFIG -> {
if (!configState && !inSystemElement) {
currentConfiguration = StringConstants.EMPTY;
configState = true;
break;
}
}
}
lastElement = qName;
if (configState) {
Expand Down Expand Up @@ -147,14 +143,8 @@ public void characters(char[] ch, int start, int length) throws SAXException {
// NOTE(Marcus/Jan 22, 2017): Seems these can be called repeatedly
// for a single text() node.
switch (lastElement) {
case XmlConfigurationFactory.ELEMENT_CONFIG:
currentConfiguration += toString(ch, start, length);
break;
case "class":
currentClassName += toString(ch, start, length);
break;
default:
break;
case XmlConfigurationFactory.ELEMENT_CONFIG -> currentConfiguration += toString(ch, start, length);
case XmlConfigurationFactory.ELEMENT_CLASS -> currentClassName += toString(ch, start, length);
}
}

Expand Down Expand Up @@ -202,15 +192,13 @@ private static class SystemXMLHandler extends DefaultHandler {
@Override
public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException {
switch (qName) {
case ELEMENT_SYSTEM:
currentId = attributes.getValue("id");
break;
case XmlConfigurationFactory.ELEMENT_CONFIG:
case ELEMENT_SYSTEM -> currentId = attributes.getValue("id");
case XmlConfigurationFactory.ELEMENT_CONFIG -> {
if (!configState) {
currentConfiguration = StringConstants.EMPTY;
configState = true;
break;
}
}
}
lastElement = qName;
if (configState) {
Expand Down Expand Up @@ -249,12 +237,8 @@ public void characters(char[] ch, int start, int length) throws SAXException {
}
// NOTE(Marcus/Jan 22, 2017): Seems these can be called repeatedly
// for a single text() node.
switch (lastElement) {
case XmlConfigurationFactory.ELEMENT_CONFIG:
currentConfiguration += toString(ch, start, length);
break;
default:
break;
if (lastElement.equals(XmlConfigurationFactory.ELEMENT_CONFIG)) {
currentConfiguration += toString(ch, start, length);
}
}

Expand Down Expand Up @@ -443,7 +427,7 @@ private void internalAddUnit(RoboUnit<?> unit) throws RoboBuilderException {
throw new RoboBuilderException("Cannot add the null unit! Skipping");
} else if (units.contains(unit)) {
throw new RoboBuilderException(
"Only one unit with the id " + unit.getId() + " can be active at a time. Skipping " + unit.toString());
"Only one unit with the id " + unit.id() + " can be active at a time. Skipping " + unit.toString());
}
units.add(unit);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,16 @@
*/
package com.robo4j;

import java.io.Serial;

/**
* Exception thrown from the RoboBuilder.
*
* @author Marcus Hirt (@hirt)
* @author Miroslav Wengner (@miragemiko)
*/
public class RoboBuilderException extends Exception {
@Serial
private static final long serialVersionUID = 1L;

/**
Expand Down
Loading
Loading