This repository has been archived on 2024-01-25. You can view files and clone it, but cannot push or open issues or pull requests.

39 lines
833 B
Java
Raw Normal View History

2023-11-15 07:02:37 +00:00
package things;
import com.fasterxml.jackson.core.JsonProcessingException;
/**
* Base class for inputs or outputs.
*
* @see Resource
*/
public abstract class IO extends NamedResource {
private final Thing parent;
protected IO(Thing parent, String name) {
super(name);
this.parent = parent;
}
protected Thing getParent() {
return parent;
}
@Override
public String getURI() {
return parent.getURI() + "/" + getName();
}
@Override
public String getJSON() throws JsonProcessingException {
return Things.sharedObjectMapper().writerWithView(JSONViews.IODetail.class).writeValueAsString(this);
}
/**
* Returns the current value of the input or output.
*
* @return Current value.
*/
abstract public int getValue();
}