/** * Returns the input kind for a given path. * * @param path The relative endpoint path (the path that follows * data/inputs). * @return A member of {@code InputKind}, indicating the type of input. */ protected InputKind itemKind(String path) { String relpathWithInputName = Util.substringAfter(path, "/data/inputs/", null); for (InputKind kind : inputKinds) { if (relpathWithInputName.startsWith(kind.getRelativePath())) { return kind; } } // Not good. This means that there is an input of an unknown kind. return InputKind.Unknown; }
/** * Returns an {@code InputKind} representing this input's type. * * The input kind is inferred from the input's path. */ public InputKind getKind() { String[] pathComponents = Util.substringAfter(this.path, "/data/inputs/", null).split("/"); String kindPath; if (pathComponents[0].equals("tcp")) { kindPath = "tcp/" + pathComponents[1]; } else { kindPath = pathComponents[0]; } return InputKind.create(kindPath); } }