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(); }