Initial commit
This commit is contained in:
38
src/main/java/things/IO.java
Normal file
38
src/main/java/things/IO.java
Normal 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();
|
||||
}
|
||||
Reference in New Issue
Block a user