Initial commit

This commit is contained in:
github-classroom[bot]
2023-11-15 07:02:37 +00:00
committed by GitHub
commit 0e8d7b5d31
23 changed files with 1452 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
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();
}